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.impl.BasePersistenceImpl;
051    
052    import com.liferay.portlet.blogs.NoSuchEntryException;
053    import com.liferay.portlet.blogs.model.BlogsEntry;
054    import com.liferay.portlet.blogs.model.impl.BlogsEntryImpl;
055    import com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl;
056    import com.liferay.portlet.blogs.service.persistence.BlogsEntryPersistence;
057    
058    import java.io.Serializable;
059    
060    import java.sql.Timestamp;
061    
062    import java.util.Collections;
063    import java.util.Date;
064    import java.util.HashMap;
065    import java.util.HashSet;
066    import java.util.Iterator;
067    import java.util.List;
068    import java.util.Map;
069    import java.util.Set;
070    
071    /**
072     * The persistence implementation for the blogs entry service.
073     *
074     * <p>
075     * Caching information and settings can be found in <code>portal.properties</code>
076     * </p>
077     *
078     * @author Brian Wing Shun Chan
079     * @see BlogsEntryPersistence
080     * @see com.liferay.portlet.blogs.service.persistence.BlogsEntryUtil
081     * @generated
082     */
083    @ProviderType
084    public class BlogsEntryPersistenceImpl extends BasePersistenceImpl<BlogsEntry>
085            implements BlogsEntryPersistence {
086            /*
087             * NOTE FOR DEVELOPERS:
088             *
089             * 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.
090             */
091            public static final String FINDER_CLASS_NAME_ENTITY = BlogsEntryImpl.class.getName();
092            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
093                    ".List1";
094            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
095                    ".List2";
096            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
097                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
098                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
099            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
100                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
101                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
102            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
103                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
104                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
105            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
106                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
107                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
108                            new String[] {
109                                    String.class.getName(),
110                                    
111                            Integer.class.getName(), Integer.class.getName(),
112                                    OrderByComparator.class.getName()
113                            });
114            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
115                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
116                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
117                            new String[] { String.class.getName() },
118                            BlogsEntryModelImpl.UUID_COLUMN_BITMASK |
119                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
120                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
121            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
122                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
123                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
124                            new String[] { String.class.getName() });
125    
126            /**
127             * Returns all the blogs entries where uuid = &#63;.
128             *
129             * @param uuid the uuid
130             * @return the matching blogs entries
131             */
132            @Override
133            public List<BlogsEntry> findByUuid(String uuid) {
134                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
135            }
136    
137            /**
138             * Returns a range of all the blogs entries where uuid = &#63;.
139             *
140             * <p>
141             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
142             * </p>
143             *
144             * @param uuid the uuid
145             * @param start the lower bound of the range of blogs entries
146             * @param end the upper bound of the range of blogs entries (not inclusive)
147             * @return the range of matching blogs entries
148             */
149            @Override
150            public List<BlogsEntry> findByUuid(String uuid, int start, int end) {
151                    return findByUuid(uuid, start, end, null);
152            }
153    
154            /**
155             * Returns an ordered range of all the blogs entries where uuid = &#63;.
156             *
157             * <p>
158             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
159             * </p>
160             *
161             * @param uuid the uuid
162             * @param start the lower bound of the range of blogs entries
163             * @param end the upper bound of the range of blogs entries (not inclusive)
164             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
165             * @return the ordered range of matching blogs entries
166             */
167            @Override
168            public List<BlogsEntry> findByUuid(String uuid, int start, int end,
169                    OrderByComparator<BlogsEntry> orderByComparator) {
170                    return findByUuid(uuid, start, end, orderByComparator, true);
171            }
172    
173            /**
174             * Returns an ordered range of all the blogs entries where uuid = &#63;.
175             *
176             * <p>
177             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
178             * </p>
179             *
180             * @param uuid the uuid
181             * @param start the lower bound of the range of blogs entries
182             * @param end the upper bound of the range of blogs entries (not inclusive)
183             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
184             * @param retrieveFromCache whether to retrieve from the finder cache
185             * @return the ordered range of matching blogs entries
186             */
187            @Override
188            public List<BlogsEntry> findByUuid(String uuid, int start, int end,
189                    OrderByComparator<BlogsEntry> orderByComparator,
190                    boolean retrieveFromCache) {
191                    boolean pagination = true;
192                    FinderPath finderPath = null;
193                    Object[] finderArgs = null;
194    
195                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
196                                    (orderByComparator == null)) {
197                            pagination = false;
198                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
199                            finderArgs = new Object[] { uuid };
200                    }
201                    else {
202                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
203                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
204                    }
205    
206                    List<BlogsEntry> list = null;
207    
208                    if (retrieveFromCache) {
209                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
210                                            finderArgs, this);
211    
212                            if ((list != null) && !list.isEmpty()) {
213                                    for (BlogsEntry blogsEntry : list) {
214                                            if (!Validator.equals(uuid, blogsEntry.getUuid())) {
215                                                    list = null;
216    
217                                                    break;
218                                            }
219                                    }
220                            }
221                    }
222    
223                    if (list == null) {
224                            StringBundler query = null;
225    
226                            if (orderByComparator != null) {
227                                    query = new StringBundler(3 +
228                                                    (orderByComparator.getOrderByFields().length * 3));
229                            }
230                            else {
231                                    query = new StringBundler(3);
232                            }
233    
234                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
235    
236                            boolean bindUuid = false;
237    
238                            if (uuid == null) {
239                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
240                            }
241                            else if (uuid.equals(StringPool.BLANK)) {
242                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
243                            }
244                            else {
245                                    bindUuid = true;
246    
247                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
248                            }
249    
250                            if (orderByComparator != null) {
251                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
252                                            orderByComparator);
253                            }
254                            else
255                             if (pagination) {
256                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
257                            }
258    
259                            String sql = query.toString();
260    
261                            Session session = null;
262    
263                            try {
264                                    session = openSession();
265    
266                                    Query q = session.createQuery(sql);
267    
268                                    QueryPos qPos = QueryPos.getInstance(q);
269    
270                                    if (bindUuid) {
271                                            qPos.add(uuid);
272                                    }
273    
274                                    if (!pagination) {
275                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
276                                                            start, end, false);
277    
278                                            Collections.sort(list);
279    
280                                            list = Collections.unmodifiableList(list);
281                                    }
282                                    else {
283                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
284                                                            start, end);
285                                    }
286    
287                                    cacheResult(list);
288    
289                                    finderCache.putResult(finderPath, finderArgs, list);
290                            }
291                            catch (Exception e) {
292                                    finderCache.removeResult(finderPath, finderArgs);
293    
294                                    throw processException(e);
295                            }
296                            finally {
297                                    closeSession(session);
298                            }
299                    }
300    
301                    return list;
302            }
303    
304            /**
305             * Returns the first blogs entry in the ordered set where uuid = &#63;.
306             *
307             * @param uuid the uuid
308             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
309             * @return the first matching blogs entry
310             * @throws NoSuchEntryException if a matching blogs entry could not be found
311             */
312            @Override
313            public BlogsEntry findByUuid_First(String uuid,
314                    OrderByComparator<BlogsEntry> orderByComparator)
315                    throws NoSuchEntryException {
316                    BlogsEntry blogsEntry = fetchByUuid_First(uuid, orderByComparator);
317    
318                    if (blogsEntry != null) {
319                            return blogsEntry;
320                    }
321    
322                    StringBundler msg = new StringBundler(4);
323    
324                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
325    
326                    msg.append("uuid=");
327                    msg.append(uuid);
328    
329                    msg.append(StringPool.CLOSE_CURLY_BRACE);
330    
331                    throw new NoSuchEntryException(msg.toString());
332            }
333    
334            /**
335             * Returns the first blogs entry in the ordered set where uuid = &#63;.
336             *
337             * @param uuid the uuid
338             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
339             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
340             */
341            @Override
342            public BlogsEntry fetchByUuid_First(String uuid,
343                    OrderByComparator<BlogsEntry> orderByComparator) {
344                    List<BlogsEntry> list = findByUuid(uuid, 0, 1, orderByComparator);
345    
346                    if (!list.isEmpty()) {
347                            return list.get(0);
348                    }
349    
350                    return null;
351            }
352    
353            /**
354             * Returns the last blogs entry in the ordered set where uuid = &#63;.
355             *
356             * @param uuid the uuid
357             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
358             * @return the last matching blogs entry
359             * @throws NoSuchEntryException if a matching blogs entry could not be found
360             */
361            @Override
362            public BlogsEntry findByUuid_Last(String uuid,
363                    OrderByComparator<BlogsEntry> orderByComparator)
364                    throws NoSuchEntryException {
365                    BlogsEntry blogsEntry = fetchByUuid_Last(uuid, orderByComparator);
366    
367                    if (blogsEntry != null) {
368                            return blogsEntry;
369                    }
370    
371                    StringBundler msg = new StringBundler(4);
372    
373                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
374    
375                    msg.append("uuid=");
376                    msg.append(uuid);
377    
378                    msg.append(StringPool.CLOSE_CURLY_BRACE);
379    
380                    throw new NoSuchEntryException(msg.toString());
381            }
382    
383            /**
384             * Returns the last blogs entry in the ordered set where uuid = &#63;.
385             *
386             * @param uuid the uuid
387             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
388             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
389             */
390            @Override
391            public BlogsEntry fetchByUuid_Last(String uuid,
392                    OrderByComparator<BlogsEntry> orderByComparator) {
393                    int count = countByUuid(uuid);
394    
395                    if (count == 0) {
396                            return null;
397                    }
398    
399                    List<BlogsEntry> list = findByUuid(uuid, count - 1, count,
400                                    orderByComparator);
401    
402                    if (!list.isEmpty()) {
403                            return list.get(0);
404                    }
405    
406                    return null;
407            }
408    
409            /**
410             * Returns the blogs entries before and after the current blogs entry in the ordered set where uuid = &#63;.
411             *
412             * @param entryId the primary key of the current blogs entry
413             * @param uuid the uuid
414             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
415             * @return the previous, current, and next blogs entry
416             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
417             */
418            @Override
419            public BlogsEntry[] findByUuid_PrevAndNext(long entryId, String uuid,
420                    OrderByComparator<BlogsEntry> orderByComparator)
421                    throws NoSuchEntryException {
422                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
423    
424                    Session session = null;
425    
426                    try {
427                            session = openSession();
428    
429                            BlogsEntry[] array = new BlogsEntryImpl[3];
430    
431                            array[0] = getByUuid_PrevAndNext(session, blogsEntry, uuid,
432                                            orderByComparator, true);
433    
434                            array[1] = blogsEntry;
435    
436                            array[2] = getByUuid_PrevAndNext(session, blogsEntry, uuid,
437                                            orderByComparator, false);
438    
439                            return array;
440                    }
441                    catch (Exception e) {
442                            throw processException(e);
443                    }
444                    finally {
445                            closeSession(session);
446                    }
447            }
448    
449            protected BlogsEntry getByUuid_PrevAndNext(Session session,
450                    BlogsEntry blogsEntry, String uuid,
451                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
452                    StringBundler query = null;
453    
454                    if (orderByComparator != null) {
455                            query = new StringBundler(6 +
456                                            (orderByComparator.getOrderByFields().length * 6));
457                    }
458                    else {
459                            query = new StringBundler(3);
460                    }
461    
462                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
463    
464                    boolean bindUuid = false;
465    
466                    if (uuid == null) {
467                            query.append(_FINDER_COLUMN_UUID_UUID_1);
468                    }
469                    else if (uuid.equals(StringPool.BLANK)) {
470                            query.append(_FINDER_COLUMN_UUID_UUID_3);
471                    }
472                    else {
473                            bindUuid = true;
474    
475                            query.append(_FINDER_COLUMN_UUID_UUID_2);
476                    }
477    
478                    if (orderByComparator != null) {
479                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
480    
481                            if (orderByConditionFields.length > 0) {
482                                    query.append(WHERE_AND);
483                            }
484    
485                            for (int i = 0; i < orderByConditionFields.length; i++) {
486                                    query.append(_ORDER_BY_ENTITY_ALIAS);
487                                    query.append(orderByConditionFields[i]);
488    
489                                    if ((i + 1) < orderByConditionFields.length) {
490                                            if (orderByComparator.isAscending() ^ previous) {
491                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
492                                            }
493                                            else {
494                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
495                                            }
496                                    }
497                                    else {
498                                            if (orderByComparator.isAscending() ^ previous) {
499                                                    query.append(WHERE_GREATER_THAN);
500                                            }
501                                            else {
502                                                    query.append(WHERE_LESSER_THAN);
503                                            }
504                                    }
505                            }
506    
507                            query.append(ORDER_BY_CLAUSE);
508    
509                            String[] orderByFields = orderByComparator.getOrderByFields();
510    
511                            for (int i = 0; i < orderByFields.length; i++) {
512                                    query.append(_ORDER_BY_ENTITY_ALIAS);
513                                    query.append(orderByFields[i]);
514    
515                                    if ((i + 1) < orderByFields.length) {
516                                            if (orderByComparator.isAscending() ^ previous) {
517                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
518                                            }
519                                            else {
520                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
521                                            }
522                                    }
523                                    else {
524                                            if (orderByComparator.isAscending() ^ previous) {
525                                                    query.append(ORDER_BY_ASC);
526                                            }
527                                            else {
528                                                    query.append(ORDER_BY_DESC);
529                                            }
530                                    }
531                            }
532                    }
533                    else {
534                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
535                    }
536    
537                    String sql = query.toString();
538    
539                    Query q = session.createQuery(sql);
540    
541                    q.setFirstResult(0);
542                    q.setMaxResults(2);
543    
544                    QueryPos qPos = QueryPos.getInstance(q);
545    
546                    if (bindUuid) {
547                            qPos.add(uuid);
548                    }
549    
550                    if (orderByComparator != null) {
551                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
552    
553                            for (Object value : values) {
554                                    qPos.add(value);
555                            }
556                    }
557    
558                    List<BlogsEntry> list = q.list();
559    
560                    if (list.size() == 2) {
561                            return list.get(1);
562                    }
563                    else {
564                            return null;
565                    }
566            }
567    
568            /**
569             * Removes all the blogs entries where uuid = &#63; from the database.
570             *
571             * @param uuid the uuid
572             */
573            @Override
574            public void removeByUuid(String uuid) {
575                    for (BlogsEntry blogsEntry : findByUuid(uuid, QueryUtil.ALL_POS,
576                                    QueryUtil.ALL_POS, null)) {
577                            remove(blogsEntry);
578                    }
579            }
580    
581            /**
582             * Returns the number of blogs entries where uuid = &#63;.
583             *
584             * @param uuid the uuid
585             * @return the number of matching blogs entries
586             */
587            @Override
588            public int countByUuid(String uuid) {
589                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
590    
591                    Object[] finderArgs = new Object[] { uuid };
592    
593                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
594    
595                    if (count == null) {
596                            StringBundler query = new StringBundler(2);
597    
598                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
599    
600                            boolean bindUuid = false;
601    
602                            if (uuid == null) {
603                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
604                            }
605                            else if (uuid.equals(StringPool.BLANK)) {
606                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
607                            }
608                            else {
609                                    bindUuid = true;
610    
611                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
612                            }
613    
614                            String sql = query.toString();
615    
616                            Session session = null;
617    
618                            try {
619                                    session = openSession();
620    
621                                    Query q = session.createQuery(sql);
622    
623                                    QueryPos qPos = QueryPos.getInstance(q);
624    
625                                    if (bindUuid) {
626                                            qPos.add(uuid);
627                                    }
628    
629                                    count = (Long)q.uniqueResult();
630    
631                                    finderCache.putResult(finderPath, finderArgs, count);
632                            }
633                            catch (Exception e) {
634                                    finderCache.removeResult(finderPath, finderArgs);
635    
636                                    throw processException(e);
637                            }
638                            finally {
639                                    closeSession(session);
640                            }
641                    }
642    
643                    return count.intValue();
644            }
645    
646            private static final String _FINDER_COLUMN_UUID_UUID_1 = "blogsEntry.uuid IS NULL";
647            private static final String _FINDER_COLUMN_UUID_UUID_2 = "blogsEntry.uuid = ?";
648            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(blogsEntry.uuid IS NULL OR blogsEntry.uuid = '')";
649            public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
650                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
651                            FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
652                            new String[] { String.class.getName(), Long.class.getName() },
653                            BlogsEntryModelImpl.UUID_COLUMN_BITMASK |
654                            BlogsEntryModelImpl.GROUPID_COLUMN_BITMASK);
655            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
656                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
657                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
658                            new String[] { String.class.getName(), Long.class.getName() });
659    
660            /**
661             * Returns the blogs entry where uuid = &#63; and groupId = &#63; or throws a {@link NoSuchEntryException} if it could not be found.
662             *
663             * @param uuid the uuid
664             * @param groupId the group ID
665             * @return the matching blogs entry
666             * @throws NoSuchEntryException if a matching blogs entry could not be found
667             */
668            @Override
669            public BlogsEntry findByUUID_G(String uuid, long groupId)
670                    throws NoSuchEntryException {
671                    BlogsEntry blogsEntry = fetchByUUID_G(uuid, groupId);
672    
673                    if (blogsEntry == null) {
674                            StringBundler msg = new StringBundler(6);
675    
676                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
677    
678                            msg.append("uuid=");
679                            msg.append(uuid);
680    
681                            msg.append(", groupId=");
682                            msg.append(groupId);
683    
684                            msg.append(StringPool.CLOSE_CURLY_BRACE);
685    
686                            if (_log.isWarnEnabled()) {
687                                    _log.warn(msg.toString());
688                            }
689    
690                            throw new NoSuchEntryException(msg.toString());
691                    }
692    
693                    return blogsEntry;
694            }
695    
696            /**
697             * 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.
698             *
699             * @param uuid the uuid
700             * @param groupId the group ID
701             * @return the matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
702             */
703            @Override
704            public BlogsEntry fetchByUUID_G(String uuid, long groupId) {
705                    return fetchByUUID_G(uuid, groupId, true);
706            }
707    
708            /**
709             * 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.
710             *
711             * @param uuid the uuid
712             * @param groupId the group ID
713             * @param retrieveFromCache whether to retrieve from the finder cache
714             * @return the matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
715             */
716            @Override
717            public BlogsEntry fetchByUUID_G(String uuid, long groupId,
718                    boolean retrieveFromCache) {
719                    Object[] finderArgs = new Object[] { uuid, groupId };
720    
721                    Object result = null;
722    
723                    if (retrieveFromCache) {
724                            result = finderCache.getResult(FINDER_PATH_FETCH_BY_UUID_G,
725                                            finderArgs, this);
726                    }
727    
728                    if (result instanceof BlogsEntry) {
729                            BlogsEntry blogsEntry = (BlogsEntry)result;
730    
731                            if (!Validator.equals(uuid, blogsEntry.getUuid()) ||
732                                            (groupId != blogsEntry.getGroupId())) {
733                                    result = null;
734                            }
735                    }
736    
737                    if (result == null) {
738                            StringBundler query = new StringBundler(4);
739    
740                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
741    
742                            boolean bindUuid = false;
743    
744                            if (uuid == null) {
745                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
746                            }
747                            else if (uuid.equals(StringPool.BLANK)) {
748                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
749                            }
750                            else {
751                                    bindUuid = true;
752    
753                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
754                            }
755    
756                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
757    
758                            String sql = query.toString();
759    
760                            Session session = null;
761    
762                            try {
763                                    session = openSession();
764    
765                                    Query q = session.createQuery(sql);
766    
767                                    QueryPos qPos = QueryPos.getInstance(q);
768    
769                                    if (bindUuid) {
770                                            qPos.add(uuid);
771                                    }
772    
773                                    qPos.add(groupId);
774    
775                                    List<BlogsEntry> list = q.list();
776    
777                                    if (list.isEmpty()) {
778                                            finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G,
779                                                    finderArgs, list);
780                                    }
781                                    else {
782                                            BlogsEntry blogsEntry = list.get(0);
783    
784                                            result = blogsEntry;
785    
786                                            cacheResult(blogsEntry);
787    
788                                            if ((blogsEntry.getUuid() == null) ||
789                                                            !blogsEntry.getUuid().equals(uuid) ||
790                                                            (blogsEntry.getGroupId() != groupId)) {
791                                                    finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G,
792                                                            finderArgs, blogsEntry);
793                                            }
794                                    }
795                            }
796                            catch (Exception e) {
797                                    finderCache.removeResult(FINDER_PATH_FETCH_BY_UUID_G, finderArgs);
798    
799                                    throw processException(e);
800                            }
801                            finally {
802                                    closeSession(session);
803                            }
804                    }
805    
806                    if (result instanceof List<?>) {
807                            return null;
808                    }
809                    else {
810                            return (BlogsEntry)result;
811                    }
812            }
813    
814            /**
815             * Removes the blogs entry where uuid = &#63; and groupId = &#63; from the database.
816             *
817             * @param uuid the uuid
818             * @param groupId the group ID
819             * @return the blogs entry that was removed
820             */
821            @Override
822            public BlogsEntry removeByUUID_G(String uuid, long groupId)
823                    throws NoSuchEntryException {
824                    BlogsEntry blogsEntry = findByUUID_G(uuid, groupId);
825    
826                    return remove(blogsEntry);
827            }
828    
829            /**
830             * Returns the number of blogs entries where uuid = &#63; and groupId = &#63;.
831             *
832             * @param uuid the uuid
833             * @param groupId the group ID
834             * @return the number of matching blogs entries
835             */
836            @Override
837            public int countByUUID_G(String uuid, long groupId) {
838                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_G;
839    
840                    Object[] finderArgs = new Object[] { uuid, groupId };
841    
842                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
843    
844                    if (count == null) {
845                            StringBundler query = new StringBundler(3);
846    
847                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
848    
849                            boolean bindUuid = false;
850    
851                            if (uuid == null) {
852                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
853                            }
854                            else if (uuid.equals(StringPool.BLANK)) {
855                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
856                            }
857                            else {
858                                    bindUuid = true;
859    
860                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
861                            }
862    
863                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
864    
865                            String sql = query.toString();
866    
867                            Session session = null;
868    
869                            try {
870                                    session = openSession();
871    
872                                    Query q = session.createQuery(sql);
873    
874                                    QueryPos qPos = QueryPos.getInstance(q);
875    
876                                    if (bindUuid) {
877                                            qPos.add(uuid);
878                                    }
879    
880                                    qPos.add(groupId);
881    
882                                    count = (Long)q.uniqueResult();
883    
884                                    finderCache.putResult(finderPath, finderArgs, count);
885                            }
886                            catch (Exception e) {
887                                    finderCache.removeResult(finderPath, finderArgs);
888    
889                                    throw processException(e);
890                            }
891                            finally {
892                                    closeSession(session);
893                            }
894                    }
895    
896                    return count.intValue();
897            }
898    
899            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "blogsEntry.uuid IS NULL AND ";
900            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "blogsEntry.uuid = ? AND ";
901            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(blogsEntry.uuid IS NULL OR blogsEntry.uuid = '') AND ";
902            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "blogsEntry.groupId = ?";
903            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
904                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
905                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C",
906                            new String[] {
907                                    String.class.getName(), Long.class.getName(),
908                                    
909                            Integer.class.getName(), Integer.class.getName(),
910                                    OrderByComparator.class.getName()
911                            });
912            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
913                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
914                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
915                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
916                            new String[] { String.class.getName(), Long.class.getName() },
917                            BlogsEntryModelImpl.UUID_COLUMN_BITMASK |
918                            BlogsEntryModelImpl.COMPANYID_COLUMN_BITMASK |
919                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
920                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
921            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
922                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
923                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
924                            new String[] { String.class.getName(), Long.class.getName() });
925    
926            /**
927             * Returns all the blogs entries where uuid = &#63; and companyId = &#63;.
928             *
929             * @param uuid the uuid
930             * @param companyId the company ID
931             * @return the matching blogs entries
932             */
933            @Override
934            public List<BlogsEntry> findByUuid_C(String uuid, long companyId) {
935                    return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
936                            QueryUtil.ALL_POS, null);
937            }
938    
939            /**
940             * Returns a range of all the blogs entries where uuid = &#63; and companyId = &#63;.
941             *
942             * <p>
943             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
944             * </p>
945             *
946             * @param uuid the uuid
947             * @param companyId the company ID
948             * @param start the lower bound of the range of blogs entries
949             * @param end the upper bound of the range of blogs entries (not inclusive)
950             * @return the range of matching blogs entries
951             */
952            @Override
953            public List<BlogsEntry> findByUuid_C(String uuid, long companyId,
954                    int start, int end) {
955                    return findByUuid_C(uuid, companyId, start, end, null);
956            }
957    
958            /**
959             * Returns an ordered range of all the blogs entries where uuid = &#63; and companyId = &#63;.
960             *
961             * <p>
962             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
963             * </p>
964             *
965             * @param uuid the uuid
966             * @param companyId the company ID
967             * @param start the lower bound of the range of blogs entries
968             * @param end the upper bound of the range of blogs entries (not inclusive)
969             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
970             * @return the ordered range of matching blogs entries
971             */
972            @Override
973            public List<BlogsEntry> findByUuid_C(String uuid, long companyId,
974                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator) {
975                    return findByUuid_C(uuid, companyId, start, end, orderByComparator, true);
976            }
977    
978            /**
979             * Returns an ordered range of all the blogs entries where uuid = &#63; and companyId = &#63;.
980             *
981             * <p>
982             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
983             * </p>
984             *
985             * @param uuid the uuid
986             * @param companyId the company ID
987             * @param start the lower bound of the range of blogs entries
988             * @param end the upper bound of the range of blogs entries (not inclusive)
989             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
990             * @param retrieveFromCache whether to retrieve from the finder cache
991             * @return the ordered range of matching blogs entries
992             */
993            @Override
994            public List<BlogsEntry> findByUuid_C(String uuid, long companyId,
995                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator,
996                    boolean retrieveFromCache) {
997                    boolean pagination = true;
998                    FinderPath finderPath = null;
999                    Object[] finderArgs = null;
1000    
1001                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1002                                    (orderByComparator == null)) {
1003                            pagination = false;
1004                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
1005                            finderArgs = new Object[] { uuid, companyId };
1006                    }
1007                    else {
1008                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
1009                            finderArgs = new Object[] {
1010                                            uuid, companyId,
1011                                            
1012                                            start, end, orderByComparator
1013                                    };
1014                    }
1015    
1016                    List<BlogsEntry> list = null;
1017    
1018                    if (retrieveFromCache) {
1019                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
1020                                            finderArgs, this);
1021    
1022                            if ((list != null) && !list.isEmpty()) {
1023                                    for (BlogsEntry blogsEntry : list) {
1024                                            if (!Validator.equals(uuid, blogsEntry.getUuid()) ||
1025                                                            (companyId != blogsEntry.getCompanyId())) {
1026                                                    list = null;
1027    
1028                                                    break;
1029                                            }
1030                                    }
1031                            }
1032                    }
1033    
1034                    if (list == null) {
1035                            StringBundler query = null;
1036    
1037                            if (orderByComparator != null) {
1038                                    query = new StringBundler(4 +
1039                                                    (orderByComparator.getOrderByFields().length * 3));
1040                            }
1041                            else {
1042                                    query = new StringBundler(4);
1043                            }
1044    
1045                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
1046    
1047                            boolean bindUuid = false;
1048    
1049                            if (uuid == null) {
1050                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1051                            }
1052                            else if (uuid.equals(StringPool.BLANK)) {
1053                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1054                            }
1055                            else {
1056                                    bindUuid = true;
1057    
1058                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1059                            }
1060    
1061                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1062    
1063                            if (orderByComparator != null) {
1064                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1065                                            orderByComparator);
1066                            }
1067                            else
1068                             if (pagination) {
1069                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
1070                            }
1071    
1072                            String sql = query.toString();
1073    
1074                            Session session = null;
1075    
1076                            try {
1077                                    session = openSession();
1078    
1079                                    Query q = session.createQuery(sql);
1080    
1081                                    QueryPos qPos = QueryPos.getInstance(q);
1082    
1083                                    if (bindUuid) {
1084                                            qPos.add(uuid);
1085                                    }
1086    
1087                                    qPos.add(companyId);
1088    
1089                                    if (!pagination) {
1090                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
1091                                                            start, end, false);
1092    
1093                                            Collections.sort(list);
1094    
1095                                            list = Collections.unmodifiableList(list);
1096                                    }
1097                                    else {
1098                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
1099                                                            start, end);
1100                                    }
1101    
1102                                    cacheResult(list);
1103    
1104                                    finderCache.putResult(finderPath, finderArgs, list);
1105                            }
1106                            catch (Exception e) {
1107                                    finderCache.removeResult(finderPath, finderArgs);
1108    
1109                                    throw processException(e);
1110                            }
1111                            finally {
1112                                    closeSession(session);
1113                            }
1114                    }
1115    
1116                    return list;
1117            }
1118    
1119            /**
1120             * Returns the first blogs entry in the ordered set where uuid = &#63; and companyId = &#63;.
1121             *
1122             * @param uuid the uuid
1123             * @param companyId the company ID
1124             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1125             * @return the first matching blogs entry
1126             * @throws NoSuchEntryException if a matching blogs entry could not be found
1127             */
1128            @Override
1129            public BlogsEntry findByUuid_C_First(String uuid, long companyId,
1130                    OrderByComparator<BlogsEntry> orderByComparator)
1131                    throws NoSuchEntryException {
1132                    BlogsEntry blogsEntry = fetchByUuid_C_First(uuid, companyId,
1133                                    orderByComparator);
1134    
1135                    if (blogsEntry != null) {
1136                            return blogsEntry;
1137                    }
1138    
1139                    StringBundler msg = new StringBundler(6);
1140    
1141                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1142    
1143                    msg.append("uuid=");
1144                    msg.append(uuid);
1145    
1146                    msg.append(", companyId=");
1147                    msg.append(companyId);
1148    
1149                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1150    
1151                    throw new NoSuchEntryException(msg.toString());
1152            }
1153    
1154            /**
1155             * Returns the first blogs entry in the ordered set where uuid = &#63; and companyId = &#63;.
1156             *
1157             * @param uuid the uuid
1158             * @param companyId the company ID
1159             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1160             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
1161             */
1162            @Override
1163            public BlogsEntry fetchByUuid_C_First(String uuid, long companyId,
1164                    OrderByComparator<BlogsEntry> orderByComparator) {
1165                    List<BlogsEntry> list = findByUuid_C(uuid, companyId, 0, 1,
1166                                    orderByComparator);
1167    
1168                    if (!list.isEmpty()) {
1169                            return list.get(0);
1170                    }
1171    
1172                    return null;
1173            }
1174    
1175            /**
1176             * Returns the last blogs entry in the ordered set where uuid = &#63; and companyId = &#63;.
1177             *
1178             * @param uuid the uuid
1179             * @param companyId the company ID
1180             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1181             * @return the last matching blogs entry
1182             * @throws NoSuchEntryException if a matching blogs entry could not be found
1183             */
1184            @Override
1185            public BlogsEntry findByUuid_C_Last(String uuid, long companyId,
1186                    OrderByComparator<BlogsEntry> orderByComparator)
1187                    throws NoSuchEntryException {
1188                    BlogsEntry blogsEntry = fetchByUuid_C_Last(uuid, companyId,
1189                                    orderByComparator);
1190    
1191                    if (blogsEntry != null) {
1192                            return blogsEntry;
1193                    }
1194    
1195                    StringBundler msg = new StringBundler(6);
1196    
1197                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1198    
1199                    msg.append("uuid=");
1200                    msg.append(uuid);
1201    
1202                    msg.append(", companyId=");
1203                    msg.append(companyId);
1204    
1205                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1206    
1207                    throw new NoSuchEntryException(msg.toString());
1208            }
1209    
1210            /**
1211             * Returns the last blogs entry in the ordered set where uuid = &#63; and companyId = &#63;.
1212             *
1213             * @param uuid the uuid
1214             * @param companyId the company ID
1215             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1216             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
1217             */
1218            @Override
1219            public BlogsEntry fetchByUuid_C_Last(String uuid, long companyId,
1220                    OrderByComparator<BlogsEntry> orderByComparator) {
1221                    int count = countByUuid_C(uuid, companyId);
1222    
1223                    if (count == 0) {
1224                            return null;
1225                    }
1226    
1227                    List<BlogsEntry> list = findByUuid_C(uuid, companyId, count - 1, count,
1228                                    orderByComparator);
1229    
1230                    if (!list.isEmpty()) {
1231                            return list.get(0);
1232                    }
1233    
1234                    return null;
1235            }
1236    
1237            /**
1238             * Returns the blogs entries before and after the current blogs entry in the ordered set where uuid = &#63; and companyId = &#63;.
1239             *
1240             * @param entryId the primary key of the current blogs entry
1241             * @param uuid the uuid
1242             * @param companyId the company ID
1243             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1244             * @return the previous, current, and next blogs entry
1245             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
1246             */
1247            @Override
1248            public BlogsEntry[] findByUuid_C_PrevAndNext(long entryId, String uuid,
1249                    long companyId, OrderByComparator<BlogsEntry> orderByComparator)
1250                    throws NoSuchEntryException {
1251                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
1252    
1253                    Session session = null;
1254    
1255                    try {
1256                            session = openSession();
1257    
1258                            BlogsEntry[] array = new BlogsEntryImpl[3];
1259    
1260                            array[0] = getByUuid_C_PrevAndNext(session, blogsEntry, uuid,
1261                                            companyId, orderByComparator, true);
1262    
1263                            array[1] = blogsEntry;
1264    
1265                            array[2] = getByUuid_C_PrevAndNext(session, blogsEntry, uuid,
1266                                            companyId, orderByComparator, false);
1267    
1268                            return array;
1269                    }
1270                    catch (Exception e) {
1271                            throw processException(e);
1272                    }
1273                    finally {
1274                            closeSession(session);
1275                    }
1276            }
1277    
1278            protected BlogsEntry getByUuid_C_PrevAndNext(Session session,
1279                    BlogsEntry blogsEntry, String uuid, long companyId,
1280                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
1281                    StringBundler query = null;
1282    
1283                    if (orderByComparator != null) {
1284                            query = new StringBundler(6 +
1285                                            (orderByComparator.getOrderByFields().length * 6));
1286                    }
1287                    else {
1288                            query = new StringBundler(3);
1289                    }
1290    
1291                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
1292    
1293                    boolean bindUuid = false;
1294    
1295                    if (uuid == null) {
1296                            query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1297                    }
1298                    else if (uuid.equals(StringPool.BLANK)) {
1299                            query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1300                    }
1301                    else {
1302                            bindUuid = true;
1303    
1304                            query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1305                    }
1306    
1307                    query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1308    
1309                    if (orderByComparator != null) {
1310                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1311    
1312                            if (orderByConditionFields.length > 0) {
1313                                    query.append(WHERE_AND);
1314                            }
1315    
1316                            for (int i = 0; i < orderByConditionFields.length; i++) {
1317                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1318                                    query.append(orderByConditionFields[i]);
1319    
1320                                    if ((i + 1) < orderByConditionFields.length) {
1321                                            if (orderByComparator.isAscending() ^ previous) {
1322                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1323                                            }
1324                                            else {
1325                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1326                                            }
1327                                    }
1328                                    else {
1329                                            if (orderByComparator.isAscending() ^ previous) {
1330                                                    query.append(WHERE_GREATER_THAN);
1331                                            }
1332                                            else {
1333                                                    query.append(WHERE_LESSER_THAN);
1334                                            }
1335                                    }
1336                            }
1337    
1338                            query.append(ORDER_BY_CLAUSE);
1339    
1340                            String[] orderByFields = orderByComparator.getOrderByFields();
1341    
1342                            for (int i = 0; i < orderByFields.length; i++) {
1343                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1344                                    query.append(orderByFields[i]);
1345    
1346                                    if ((i + 1) < orderByFields.length) {
1347                                            if (orderByComparator.isAscending() ^ previous) {
1348                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1349                                            }
1350                                            else {
1351                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1352                                            }
1353                                    }
1354                                    else {
1355                                            if (orderByComparator.isAscending() ^ previous) {
1356                                                    query.append(ORDER_BY_ASC);
1357                                            }
1358                                            else {
1359                                                    query.append(ORDER_BY_DESC);
1360                                            }
1361                                    }
1362                            }
1363                    }
1364                    else {
1365                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
1366                    }
1367    
1368                    String sql = query.toString();
1369    
1370                    Query q = session.createQuery(sql);
1371    
1372                    q.setFirstResult(0);
1373                    q.setMaxResults(2);
1374    
1375                    QueryPos qPos = QueryPos.getInstance(q);
1376    
1377                    if (bindUuid) {
1378                            qPos.add(uuid);
1379                    }
1380    
1381                    qPos.add(companyId);
1382    
1383                    if (orderByComparator != null) {
1384                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
1385    
1386                            for (Object value : values) {
1387                                    qPos.add(value);
1388                            }
1389                    }
1390    
1391                    List<BlogsEntry> list = q.list();
1392    
1393                    if (list.size() == 2) {
1394                            return list.get(1);
1395                    }
1396                    else {
1397                            return null;
1398                    }
1399            }
1400    
1401            /**
1402             * Removes all the blogs entries where uuid = &#63; and companyId = &#63; from the database.
1403             *
1404             * @param uuid the uuid
1405             * @param companyId the company ID
1406             */
1407            @Override
1408            public void removeByUuid_C(String uuid, long companyId) {
1409                    for (BlogsEntry blogsEntry : findByUuid_C(uuid, companyId,
1410                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1411                            remove(blogsEntry);
1412                    }
1413            }
1414    
1415            /**
1416             * Returns the number of blogs entries where uuid = &#63; and companyId = &#63;.
1417             *
1418             * @param uuid the uuid
1419             * @param companyId the company ID
1420             * @return the number of matching blogs entries
1421             */
1422            @Override
1423            public int countByUuid_C(String uuid, long companyId) {
1424                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1425    
1426                    Object[] finderArgs = new Object[] { uuid, companyId };
1427    
1428                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
1429    
1430                    if (count == null) {
1431                            StringBundler query = new StringBundler(3);
1432    
1433                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
1434    
1435                            boolean bindUuid = false;
1436    
1437                            if (uuid == null) {
1438                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1439                            }
1440                            else if (uuid.equals(StringPool.BLANK)) {
1441                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1442                            }
1443                            else {
1444                                    bindUuid = true;
1445    
1446                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1447                            }
1448    
1449                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1450    
1451                            String sql = query.toString();
1452    
1453                            Session session = null;
1454    
1455                            try {
1456                                    session = openSession();
1457    
1458                                    Query q = session.createQuery(sql);
1459    
1460                                    QueryPos qPos = QueryPos.getInstance(q);
1461    
1462                                    if (bindUuid) {
1463                                            qPos.add(uuid);
1464                                    }
1465    
1466                                    qPos.add(companyId);
1467    
1468                                    count = (Long)q.uniqueResult();
1469    
1470                                    finderCache.putResult(finderPath, finderArgs, count);
1471                            }
1472                            catch (Exception e) {
1473                                    finderCache.removeResult(finderPath, finderArgs);
1474    
1475                                    throw processException(e);
1476                            }
1477                            finally {
1478                                    closeSession(session);
1479                            }
1480                    }
1481    
1482                    return count.intValue();
1483            }
1484    
1485            private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "blogsEntry.uuid IS NULL AND ";
1486            private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "blogsEntry.uuid = ? AND ";
1487            private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(blogsEntry.uuid IS NULL OR blogsEntry.uuid = '') AND ";
1488            private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "blogsEntry.companyId = ?";
1489            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
1490                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
1491                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId",
1492                            new String[] {
1493                                    Long.class.getName(),
1494                                    
1495                            Integer.class.getName(), Integer.class.getName(),
1496                                    OrderByComparator.class.getName()
1497                            });
1498            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
1499                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
1500                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
1501                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
1502                            new String[] { Long.class.getName() },
1503                            BlogsEntryModelImpl.GROUPID_COLUMN_BITMASK |
1504                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
1505                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
1506            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
1507                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
1508                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
1509                            new String[] { Long.class.getName() });
1510    
1511            /**
1512             * Returns all the blogs entries where groupId = &#63;.
1513             *
1514             * @param groupId the group ID
1515             * @return the matching blogs entries
1516             */
1517            @Override
1518            public List<BlogsEntry> findByGroupId(long groupId) {
1519                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1520            }
1521    
1522            /**
1523             * Returns a range of all the blogs entries where groupId = &#63;.
1524             *
1525             * <p>
1526             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
1527             * </p>
1528             *
1529             * @param groupId the group ID
1530             * @param start the lower bound of the range of blogs entries
1531             * @param end the upper bound of the range of blogs entries (not inclusive)
1532             * @return the range of matching blogs entries
1533             */
1534            @Override
1535            public List<BlogsEntry> findByGroupId(long groupId, int start, int end) {
1536                    return findByGroupId(groupId, start, end, null);
1537            }
1538    
1539            /**
1540             * Returns an ordered range of all the blogs entries where groupId = &#63;.
1541             *
1542             * <p>
1543             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
1544             * </p>
1545             *
1546             * @param groupId the group ID
1547             * @param start the lower bound of the range of blogs entries
1548             * @param end the upper bound of the range of blogs entries (not inclusive)
1549             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1550             * @return the ordered range of matching blogs entries
1551             */
1552            @Override
1553            public List<BlogsEntry> findByGroupId(long groupId, int start, int end,
1554                    OrderByComparator<BlogsEntry> orderByComparator) {
1555                    return findByGroupId(groupId, start, end, orderByComparator, true);
1556            }
1557    
1558            /**
1559             * Returns an ordered range of all the blogs entries where groupId = &#63;.
1560             *
1561             * <p>
1562             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
1563             * </p>
1564             *
1565             * @param groupId the group ID
1566             * @param start the lower bound of the range of blogs entries
1567             * @param end the upper bound of the range of blogs entries (not inclusive)
1568             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1569             * @param retrieveFromCache whether to retrieve from the finder cache
1570             * @return the ordered range of matching blogs entries
1571             */
1572            @Override
1573            public List<BlogsEntry> findByGroupId(long groupId, int start, int end,
1574                    OrderByComparator<BlogsEntry> orderByComparator,
1575                    boolean retrieveFromCache) {
1576                    boolean pagination = true;
1577                    FinderPath finderPath = null;
1578                    Object[] finderArgs = null;
1579    
1580                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1581                                    (orderByComparator == null)) {
1582                            pagination = false;
1583                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1584                            finderArgs = new Object[] { groupId };
1585                    }
1586                    else {
1587                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1588                            finderArgs = new Object[] { groupId, start, end, orderByComparator };
1589                    }
1590    
1591                    List<BlogsEntry> list = null;
1592    
1593                    if (retrieveFromCache) {
1594                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
1595                                            finderArgs, this);
1596    
1597                            if ((list != null) && !list.isEmpty()) {
1598                                    for (BlogsEntry blogsEntry : list) {
1599                                            if ((groupId != blogsEntry.getGroupId())) {
1600                                                    list = null;
1601    
1602                                                    break;
1603                                            }
1604                                    }
1605                            }
1606                    }
1607    
1608                    if (list == null) {
1609                            StringBundler query = null;
1610    
1611                            if (orderByComparator != null) {
1612                                    query = new StringBundler(3 +
1613                                                    (orderByComparator.getOrderByFields().length * 3));
1614                            }
1615                            else {
1616                                    query = new StringBundler(3);
1617                            }
1618    
1619                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
1620    
1621                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1622    
1623                            if (orderByComparator != null) {
1624                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1625                                            orderByComparator);
1626                            }
1627                            else
1628                             if (pagination) {
1629                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
1630                            }
1631    
1632                            String sql = query.toString();
1633    
1634                            Session session = null;
1635    
1636                            try {
1637                                    session = openSession();
1638    
1639                                    Query q = session.createQuery(sql);
1640    
1641                                    QueryPos qPos = QueryPos.getInstance(q);
1642    
1643                                    qPos.add(groupId);
1644    
1645                                    if (!pagination) {
1646                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
1647                                                            start, end, false);
1648    
1649                                            Collections.sort(list);
1650    
1651                                            list = Collections.unmodifiableList(list);
1652                                    }
1653                                    else {
1654                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
1655                                                            start, end);
1656                                    }
1657    
1658                                    cacheResult(list);
1659    
1660                                    finderCache.putResult(finderPath, finderArgs, list);
1661                            }
1662                            catch (Exception e) {
1663                                    finderCache.removeResult(finderPath, finderArgs);
1664    
1665                                    throw processException(e);
1666                            }
1667                            finally {
1668                                    closeSession(session);
1669                            }
1670                    }
1671    
1672                    return list;
1673            }
1674    
1675            /**
1676             * Returns the first blogs entry in the ordered set where groupId = &#63;.
1677             *
1678             * @param groupId the group ID
1679             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1680             * @return the first matching blogs entry
1681             * @throws NoSuchEntryException if a matching blogs entry could not be found
1682             */
1683            @Override
1684            public BlogsEntry findByGroupId_First(long groupId,
1685                    OrderByComparator<BlogsEntry> orderByComparator)
1686                    throws NoSuchEntryException {
1687                    BlogsEntry blogsEntry = fetchByGroupId_First(groupId, orderByComparator);
1688    
1689                    if (blogsEntry != null) {
1690                            return blogsEntry;
1691                    }
1692    
1693                    StringBundler msg = new StringBundler(4);
1694    
1695                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1696    
1697                    msg.append("groupId=");
1698                    msg.append(groupId);
1699    
1700                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1701    
1702                    throw new NoSuchEntryException(msg.toString());
1703            }
1704    
1705            /**
1706             * Returns the first blogs entry in the ordered set where groupId = &#63;.
1707             *
1708             * @param groupId the group ID
1709             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1710             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
1711             */
1712            @Override
1713            public BlogsEntry fetchByGroupId_First(long groupId,
1714                    OrderByComparator<BlogsEntry> orderByComparator) {
1715                    List<BlogsEntry> list = findByGroupId(groupId, 0, 1, orderByComparator);
1716    
1717                    if (!list.isEmpty()) {
1718                            return list.get(0);
1719                    }
1720    
1721                    return null;
1722            }
1723    
1724            /**
1725             * Returns the last blogs entry in the ordered set where groupId = &#63;.
1726             *
1727             * @param groupId the group ID
1728             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1729             * @return the last matching blogs entry
1730             * @throws NoSuchEntryException if a matching blogs entry could not be found
1731             */
1732            @Override
1733            public BlogsEntry findByGroupId_Last(long groupId,
1734                    OrderByComparator<BlogsEntry> orderByComparator)
1735                    throws NoSuchEntryException {
1736                    BlogsEntry blogsEntry = fetchByGroupId_Last(groupId, orderByComparator);
1737    
1738                    if (blogsEntry != null) {
1739                            return blogsEntry;
1740                    }
1741    
1742                    StringBundler msg = new StringBundler(4);
1743    
1744                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1745    
1746                    msg.append("groupId=");
1747                    msg.append(groupId);
1748    
1749                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1750    
1751                    throw new NoSuchEntryException(msg.toString());
1752            }
1753    
1754            /**
1755             * Returns the last blogs entry in the ordered set where groupId = &#63;.
1756             *
1757             * @param groupId the group ID
1758             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1759             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
1760             */
1761            @Override
1762            public BlogsEntry fetchByGroupId_Last(long groupId,
1763                    OrderByComparator<BlogsEntry> orderByComparator) {
1764                    int count = countByGroupId(groupId);
1765    
1766                    if (count == 0) {
1767                            return null;
1768                    }
1769    
1770                    List<BlogsEntry> list = findByGroupId(groupId, count - 1, count,
1771                                    orderByComparator);
1772    
1773                    if (!list.isEmpty()) {
1774                            return list.get(0);
1775                    }
1776    
1777                    return null;
1778            }
1779    
1780            /**
1781             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63;.
1782             *
1783             * @param entryId the primary key of the current blogs entry
1784             * @param groupId the group ID
1785             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1786             * @return the previous, current, and next blogs entry
1787             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
1788             */
1789            @Override
1790            public BlogsEntry[] findByGroupId_PrevAndNext(long entryId, long groupId,
1791                    OrderByComparator<BlogsEntry> orderByComparator)
1792                    throws NoSuchEntryException {
1793                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
1794    
1795                    Session session = null;
1796    
1797                    try {
1798                            session = openSession();
1799    
1800                            BlogsEntry[] array = new BlogsEntryImpl[3];
1801    
1802                            array[0] = getByGroupId_PrevAndNext(session, blogsEntry, groupId,
1803                                            orderByComparator, true);
1804    
1805                            array[1] = blogsEntry;
1806    
1807                            array[2] = getByGroupId_PrevAndNext(session, blogsEntry, groupId,
1808                                            orderByComparator, false);
1809    
1810                            return array;
1811                    }
1812                    catch (Exception e) {
1813                            throw processException(e);
1814                    }
1815                    finally {
1816                            closeSession(session);
1817                    }
1818            }
1819    
1820            protected BlogsEntry getByGroupId_PrevAndNext(Session session,
1821                    BlogsEntry blogsEntry, long groupId,
1822                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
1823                    StringBundler query = null;
1824    
1825                    if (orderByComparator != null) {
1826                            query = new StringBundler(6 +
1827                                            (orderByComparator.getOrderByFields().length * 6));
1828                    }
1829                    else {
1830                            query = new StringBundler(3);
1831                    }
1832    
1833                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
1834    
1835                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1836    
1837                    if (orderByComparator != null) {
1838                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1839    
1840                            if (orderByConditionFields.length > 0) {
1841                                    query.append(WHERE_AND);
1842                            }
1843    
1844                            for (int i = 0; i < orderByConditionFields.length; i++) {
1845                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1846                                    query.append(orderByConditionFields[i]);
1847    
1848                                    if ((i + 1) < orderByConditionFields.length) {
1849                                            if (orderByComparator.isAscending() ^ previous) {
1850                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1851                                            }
1852                                            else {
1853                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1854                                            }
1855                                    }
1856                                    else {
1857                                            if (orderByComparator.isAscending() ^ previous) {
1858                                                    query.append(WHERE_GREATER_THAN);
1859                                            }
1860                                            else {
1861                                                    query.append(WHERE_LESSER_THAN);
1862                                            }
1863                                    }
1864                            }
1865    
1866                            query.append(ORDER_BY_CLAUSE);
1867    
1868                            String[] orderByFields = orderByComparator.getOrderByFields();
1869    
1870                            for (int i = 0; i < orderByFields.length; i++) {
1871                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1872                                    query.append(orderByFields[i]);
1873    
1874                                    if ((i + 1) < orderByFields.length) {
1875                                            if (orderByComparator.isAscending() ^ previous) {
1876                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1877                                            }
1878                                            else {
1879                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1880                                            }
1881                                    }
1882                                    else {
1883                                            if (orderByComparator.isAscending() ^ previous) {
1884                                                    query.append(ORDER_BY_ASC);
1885                                            }
1886                                            else {
1887                                                    query.append(ORDER_BY_DESC);
1888                                            }
1889                                    }
1890                            }
1891                    }
1892                    else {
1893                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
1894                    }
1895    
1896                    String sql = query.toString();
1897    
1898                    Query q = session.createQuery(sql);
1899    
1900                    q.setFirstResult(0);
1901                    q.setMaxResults(2);
1902    
1903                    QueryPos qPos = QueryPos.getInstance(q);
1904    
1905                    qPos.add(groupId);
1906    
1907                    if (orderByComparator != null) {
1908                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
1909    
1910                            for (Object value : values) {
1911                                    qPos.add(value);
1912                            }
1913                    }
1914    
1915                    List<BlogsEntry> list = q.list();
1916    
1917                    if (list.size() == 2) {
1918                            return list.get(1);
1919                    }
1920                    else {
1921                            return null;
1922                    }
1923            }
1924    
1925            /**
1926             * Returns all the blogs entries that the user has permission to view where groupId = &#63;.
1927             *
1928             * @param groupId the group ID
1929             * @return the matching blogs entries that the user has permission to view
1930             */
1931            @Override
1932            public List<BlogsEntry> filterFindByGroupId(long groupId) {
1933                    return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1934                            QueryUtil.ALL_POS, null);
1935            }
1936    
1937            /**
1938             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63;.
1939             *
1940             * <p>
1941             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
1942             * </p>
1943             *
1944             * @param groupId the group ID
1945             * @param start the lower bound of the range of blogs entries
1946             * @param end the upper bound of the range of blogs entries (not inclusive)
1947             * @return the range of matching blogs entries that the user has permission to view
1948             */
1949            @Override
1950            public List<BlogsEntry> filterFindByGroupId(long groupId, int start, int end) {
1951                    return filterFindByGroupId(groupId, start, end, null);
1952            }
1953    
1954            /**
1955             * Returns an ordered range of all the blogs entries that the user has permissions to view where groupId = &#63;.
1956             *
1957             * <p>
1958             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
1959             * </p>
1960             *
1961             * @param groupId the group ID
1962             * @param start the lower bound of the range of blogs entries
1963             * @param end the upper bound of the range of blogs entries (not inclusive)
1964             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1965             * @return the ordered range of matching blogs entries that the user has permission to view
1966             */
1967            @Override
1968            public List<BlogsEntry> filterFindByGroupId(long groupId, int start,
1969                    int end, OrderByComparator<BlogsEntry> orderByComparator) {
1970                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1971                            return findByGroupId(groupId, start, end, orderByComparator);
1972                    }
1973    
1974                    StringBundler query = null;
1975    
1976                    if (orderByComparator != null) {
1977                            query = new StringBundler(3 +
1978                                            (orderByComparator.getOrderByFields().length * 3));
1979                    }
1980                    else {
1981                            query = new StringBundler(3);
1982                    }
1983    
1984                    if (getDB().isSupportsInlineDistinct()) {
1985                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
1986                    }
1987                    else {
1988                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
1989                    }
1990    
1991                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1992    
1993                    if (!getDB().isSupportsInlineDistinct()) {
1994                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
1995                    }
1996    
1997                    if (orderByComparator != null) {
1998                            if (getDB().isSupportsInlineDistinct()) {
1999                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2000                                            orderByComparator, true);
2001                            }
2002                            else {
2003                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2004                                            orderByComparator, true);
2005                            }
2006                    }
2007                    else {
2008                            if (getDB().isSupportsInlineDistinct()) {
2009                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
2010                            }
2011                            else {
2012                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
2013                            }
2014                    }
2015    
2016                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2017                                    BlogsEntry.class.getName(),
2018                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2019    
2020                    Session session = null;
2021    
2022                    try {
2023                            session = openSession();
2024    
2025                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
2026    
2027                            if (getDB().isSupportsInlineDistinct()) {
2028                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
2029                            }
2030                            else {
2031                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
2032                            }
2033    
2034                            QueryPos qPos = QueryPos.getInstance(q);
2035    
2036                            qPos.add(groupId);
2037    
2038                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
2039                    }
2040                    catch (Exception e) {
2041                            throw processException(e);
2042                    }
2043                    finally {
2044                            closeSession(session);
2045                    }
2046            }
2047    
2048            /**
2049             * 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;.
2050             *
2051             * @param entryId the primary key of the current blogs entry
2052             * @param groupId the group ID
2053             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2054             * @return the previous, current, and next blogs entry
2055             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
2056             */
2057            @Override
2058            public BlogsEntry[] filterFindByGroupId_PrevAndNext(long entryId,
2059                    long groupId, OrderByComparator<BlogsEntry> orderByComparator)
2060                    throws NoSuchEntryException {
2061                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2062                            return findByGroupId_PrevAndNext(entryId, groupId, orderByComparator);
2063                    }
2064    
2065                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
2066    
2067                    Session session = null;
2068    
2069                    try {
2070                            session = openSession();
2071    
2072                            BlogsEntry[] array = new BlogsEntryImpl[3];
2073    
2074                            array[0] = filterGetByGroupId_PrevAndNext(session, blogsEntry,
2075                                            groupId, orderByComparator, true);
2076    
2077                            array[1] = blogsEntry;
2078    
2079                            array[2] = filterGetByGroupId_PrevAndNext(session, blogsEntry,
2080                                            groupId, orderByComparator, false);
2081    
2082                            return array;
2083                    }
2084                    catch (Exception e) {
2085                            throw processException(e);
2086                    }
2087                    finally {
2088                            closeSession(session);
2089                    }
2090            }
2091    
2092            protected BlogsEntry filterGetByGroupId_PrevAndNext(Session session,
2093                    BlogsEntry blogsEntry, long groupId,
2094                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
2095                    StringBundler query = null;
2096    
2097                    if (orderByComparator != null) {
2098                            query = new StringBundler(6 +
2099                                            (orderByComparator.getOrderByFields().length * 6));
2100                    }
2101                    else {
2102                            query = new StringBundler(3);
2103                    }
2104    
2105                    if (getDB().isSupportsInlineDistinct()) {
2106                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
2107                    }
2108                    else {
2109                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
2110                    }
2111    
2112                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2113    
2114                    if (!getDB().isSupportsInlineDistinct()) {
2115                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
2116                    }
2117    
2118                    if (orderByComparator != null) {
2119                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2120    
2121                            if (orderByConditionFields.length > 0) {
2122                                    query.append(WHERE_AND);
2123                            }
2124    
2125                            for (int i = 0; i < orderByConditionFields.length; i++) {
2126                                    if (getDB().isSupportsInlineDistinct()) {
2127                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2128                                    }
2129                                    else {
2130                                            query.append(_ORDER_BY_ENTITY_TABLE);
2131                                    }
2132    
2133                                    query.append(orderByConditionFields[i]);
2134    
2135                                    if ((i + 1) < orderByConditionFields.length) {
2136                                            if (orderByComparator.isAscending() ^ previous) {
2137                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2138                                            }
2139                                            else {
2140                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2141                                            }
2142                                    }
2143                                    else {
2144                                            if (orderByComparator.isAscending() ^ previous) {
2145                                                    query.append(WHERE_GREATER_THAN);
2146                                            }
2147                                            else {
2148                                                    query.append(WHERE_LESSER_THAN);
2149                                            }
2150                                    }
2151                            }
2152    
2153                            query.append(ORDER_BY_CLAUSE);
2154    
2155                            String[] orderByFields = orderByComparator.getOrderByFields();
2156    
2157                            for (int i = 0; i < orderByFields.length; i++) {
2158                                    if (getDB().isSupportsInlineDistinct()) {
2159                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2160                                    }
2161                                    else {
2162                                            query.append(_ORDER_BY_ENTITY_TABLE);
2163                                    }
2164    
2165                                    query.append(orderByFields[i]);
2166    
2167                                    if ((i + 1) < orderByFields.length) {
2168                                            if (orderByComparator.isAscending() ^ previous) {
2169                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2170                                            }
2171                                            else {
2172                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2173                                            }
2174                                    }
2175                                    else {
2176                                            if (orderByComparator.isAscending() ^ previous) {
2177                                                    query.append(ORDER_BY_ASC);
2178                                            }
2179                                            else {
2180                                                    query.append(ORDER_BY_DESC);
2181                                            }
2182                                    }
2183                            }
2184                    }
2185                    else {
2186                            if (getDB().isSupportsInlineDistinct()) {
2187                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
2188                            }
2189                            else {
2190                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
2191                            }
2192                    }
2193    
2194                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2195                                    BlogsEntry.class.getName(),
2196                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2197    
2198                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
2199    
2200                    q.setFirstResult(0);
2201                    q.setMaxResults(2);
2202    
2203                    if (getDB().isSupportsInlineDistinct()) {
2204                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
2205                    }
2206                    else {
2207                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
2208                    }
2209    
2210                    QueryPos qPos = QueryPos.getInstance(q);
2211    
2212                    qPos.add(groupId);
2213    
2214                    if (orderByComparator != null) {
2215                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
2216    
2217                            for (Object value : values) {
2218                                    qPos.add(value);
2219                            }
2220                    }
2221    
2222                    List<BlogsEntry> list = q.list();
2223    
2224                    if (list.size() == 2) {
2225                            return list.get(1);
2226                    }
2227                    else {
2228                            return null;
2229                    }
2230            }
2231    
2232            /**
2233             * Removes all the blogs entries where groupId = &#63; from the database.
2234             *
2235             * @param groupId the group ID
2236             */
2237            @Override
2238            public void removeByGroupId(long groupId) {
2239                    for (BlogsEntry blogsEntry : findByGroupId(groupId, QueryUtil.ALL_POS,
2240                                    QueryUtil.ALL_POS, null)) {
2241                            remove(blogsEntry);
2242                    }
2243            }
2244    
2245            /**
2246             * Returns the number of blogs entries where groupId = &#63;.
2247             *
2248             * @param groupId the group ID
2249             * @return the number of matching blogs entries
2250             */
2251            @Override
2252            public int countByGroupId(long groupId) {
2253                    FinderPath finderPath = FINDER_PATH_COUNT_BY_GROUPID;
2254    
2255                    Object[] finderArgs = new Object[] { groupId };
2256    
2257                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
2258    
2259                    if (count == null) {
2260                            StringBundler query = new StringBundler(2);
2261    
2262                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
2263    
2264                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2265    
2266                            String sql = query.toString();
2267    
2268                            Session session = null;
2269    
2270                            try {
2271                                    session = openSession();
2272    
2273                                    Query q = session.createQuery(sql);
2274    
2275                                    QueryPos qPos = QueryPos.getInstance(q);
2276    
2277                                    qPos.add(groupId);
2278    
2279                                    count = (Long)q.uniqueResult();
2280    
2281                                    finderCache.putResult(finderPath, finderArgs, count);
2282                            }
2283                            catch (Exception e) {
2284                                    finderCache.removeResult(finderPath, finderArgs);
2285    
2286                                    throw processException(e);
2287                            }
2288                            finally {
2289                                    closeSession(session);
2290                            }
2291                    }
2292    
2293                    return count.intValue();
2294            }
2295    
2296            /**
2297             * Returns the number of blogs entries that the user has permission to view where groupId = &#63;.
2298             *
2299             * @param groupId the group ID
2300             * @return the number of matching blogs entries that the user has permission to view
2301             */
2302            @Override
2303            public int filterCountByGroupId(long groupId) {
2304                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2305                            return countByGroupId(groupId);
2306                    }
2307    
2308                    StringBundler query = new StringBundler(2);
2309    
2310                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
2311    
2312                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2313    
2314                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2315                                    BlogsEntry.class.getName(),
2316                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2317    
2318                    Session session = null;
2319    
2320                    try {
2321                            session = openSession();
2322    
2323                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
2324    
2325                            q.addScalar(COUNT_COLUMN_NAME,
2326                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
2327    
2328                            QueryPos qPos = QueryPos.getInstance(q);
2329    
2330                            qPos.add(groupId);
2331    
2332                            Long count = (Long)q.uniqueResult();
2333    
2334                            return count.intValue();
2335                    }
2336                    catch (Exception e) {
2337                            throw processException(e);
2338                    }
2339                    finally {
2340                            closeSession(session);
2341                    }
2342            }
2343    
2344            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "blogsEntry.groupId = ?";
2345            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
2346                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
2347                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
2348                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId",
2349                            new String[] {
2350                                    Long.class.getName(),
2351                                    
2352                            Integer.class.getName(), Integer.class.getName(),
2353                                    OrderByComparator.class.getName()
2354                            });
2355            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
2356                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
2357                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
2358                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
2359                            new String[] { Long.class.getName() },
2360                            BlogsEntryModelImpl.COMPANYID_COLUMN_BITMASK |
2361                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
2362                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
2363            public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
2364                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
2365                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
2366                            new String[] { Long.class.getName() });
2367    
2368            /**
2369             * Returns all the blogs entries where companyId = &#63;.
2370             *
2371             * @param companyId the company ID
2372             * @return the matching blogs entries
2373             */
2374            @Override
2375            public List<BlogsEntry> findByCompanyId(long companyId) {
2376                    return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2377                            null);
2378            }
2379    
2380            /**
2381             * Returns a range of all the blogs entries where companyId = &#63;.
2382             *
2383             * <p>
2384             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
2385             * </p>
2386             *
2387             * @param companyId the company ID
2388             * @param start the lower bound of the range of blogs entries
2389             * @param end the upper bound of the range of blogs entries (not inclusive)
2390             * @return the range of matching blogs entries
2391             */
2392            @Override
2393            public List<BlogsEntry> findByCompanyId(long companyId, int start, int end) {
2394                    return findByCompanyId(companyId, start, end, null);
2395            }
2396    
2397            /**
2398             * Returns an ordered range of all the blogs entries where companyId = &#63;.
2399             *
2400             * <p>
2401             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
2402             * </p>
2403             *
2404             * @param companyId the company ID
2405             * @param start the lower bound of the range of blogs entries
2406             * @param end the upper bound of the range of blogs entries (not inclusive)
2407             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2408             * @return the ordered range of matching blogs entries
2409             */
2410            @Override
2411            public List<BlogsEntry> findByCompanyId(long companyId, int start, int end,
2412                    OrderByComparator<BlogsEntry> orderByComparator) {
2413                    return findByCompanyId(companyId, start, end, orderByComparator, true);
2414            }
2415    
2416            /**
2417             * Returns an ordered range of all the blogs entries where companyId = &#63;.
2418             *
2419             * <p>
2420             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
2421             * </p>
2422             *
2423             * @param companyId the company ID
2424             * @param start the lower bound of the range of blogs entries
2425             * @param end the upper bound of the range of blogs entries (not inclusive)
2426             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2427             * @param retrieveFromCache whether to retrieve from the finder cache
2428             * @return the ordered range of matching blogs entries
2429             */
2430            @Override
2431            public List<BlogsEntry> findByCompanyId(long companyId, int start, int end,
2432                    OrderByComparator<BlogsEntry> orderByComparator,
2433                    boolean retrieveFromCache) {
2434                    boolean pagination = true;
2435                    FinderPath finderPath = null;
2436                    Object[] finderArgs = null;
2437    
2438                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2439                                    (orderByComparator == null)) {
2440                            pagination = false;
2441                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
2442                            finderArgs = new Object[] { companyId };
2443                    }
2444                    else {
2445                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
2446                            finderArgs = new Object[] { companyId, start, end, orderByComparator };
2447                    }
2448    
2449                    List<BlogsEntry> list = null;
2450    
2451                    if (retrieveFromCache) {
2452                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
2453                                            finderArgs, this);
2454    
2455                            if ((list != null) && !list.isEmpty()) {
2456                                    for (BlogsEntry blogsEntry : list) {
2457                                            if ((companyId != blogsEntry.getCompanyId())) {
2458                                                    list = null;
2459    
2460                                                    break;
2461                                            }
2462                                    }
2463                            }
2464                    }
2465    
2466                    if (list == null) {
2467                            StringBundler query = null;
2468    
2469                            if (orderByComparator != null) {
2470                                    query = new StringBundler(3 +
2471                                                    (orderByComparator.getOrderByFields().length * 3));
2472                            }
2473                            else {
2474                                    query = new StringBundler(3);
2475                            }
2476    
2477                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
2478    
2479                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2480    
2481                            if (orderByComparator != null) {
2482                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2483                                            orderByComparator);
2484                            }
2485                            else
2486                             if (pagination) {
2487                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
2488                            }
2489    
2490                            String sql = query.toString();
2491    
2492                            Session session = null;
2493    
2494                            try {
2495                                    session = openSession();
2496    
2497                                    Query q = session.createQuery(sql);
2498    
2499                                    QueryPos qPos = QueryPos.getInstance(q);
2500    
2501                                    qPos.add(companyId);
2502    
2503                                    if (!pagination) {
2504                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
2505                                                            start, end, false);
2506    
2507                                            Collections.sort(list);
2508    
2509                                            list = Collections.unmodifiableList(list);
2510                                    }
2511                                    else {
2512                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
2513                                                            start, end);
2514                                    }
2515    
2516                                    cacheResult(list);
2517    
2518                                    finderCache.putResult(finderPath, finderArgs, list);
2519                            }
2520                            catch (Exception e) {
2521                                    finderCache.removeResult(finderPath, finderArgs);
2522    
2523                                    throw processException(e);
2524                            }
2525                            finally {
2526                                    closeSession(session);
2527                            }
2528                    }
2529    
2530                    return list;
2531            }
2532    
2533            /**
2534             * Returns the first blogs entry in the ordered set where companyId = &#63;.
2535             *
2536             * @param companyId the company ID
2537             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2538             * @return the first matching blogs entry
2539             * @throws NoSuchEntryException if a matching blogs entry could not be found
2540             */
2541            @Override
2542            public BlogsEntry findByCompanyId_First(long companyId,
2543                    OrderByComparator<BlogsEntry> orderByComparator)
2544                    throws NoSuchEntryException {
2545                    BlogsEntry blogsEntry = fetchByCompanyId_First(companyId,
2546                                    orderByComparator);
2547    
2548                    if (blogsEntry != null) {
2549                            return blogsEntry;
2550                    }
2551    
2552                    StringBundler msg = new StringBundler(4);
2553    
2554                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2555    
2556                    msg.append("companyId=");
2557                    msg.append(companyId);
2558    
2559                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2560    
2561                    throw new NoSuchEntryException(msg.toString());
2562            }
2563    
2564            /**
2565             * Returns the first blogs entry in the ordered set where companyId = &#63;.
2566             *
2567             * @param companyId the company ID
2568             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2569             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
2570             */
2571            @Override
2572            public BlogsEntry fetchByCompanyId_First(long companyId,
2573                    OrderByComparator<BlogsEntry> orderByComparator) {
2574                    List<BlogsEntry> list = findByCompanyId(companyId, 0, 1,
2575                                    orderByComparator);
2576    
2577                    if (!list.isEmpty()) {
2578                            return list.get(0);
2579                    }
2580    
2581                    return null;
2582            }
2583    
2584            /**
2585             * Returns the last blogs entry in the ordered set where companyId = &#63;.
2586             *
2587             * @param companyId the company ID
2588             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2589             * @return the last matching blogs entry
2590             * @throws NoSuchEntryException if a matching blogs entry could not be found
2591             */
2592            @Override
2593            public BlogsEntry findByCompanyId_Last(long companyId,
2594                    OrderByComparator<BlogsEntry> orderByComparator)
2595                    throws NoSuchEntryException {
2596                    BlogsEntry blogsEntry = fetchByCompanyId_Last(companyId,
2597                                    orderByComparator);
2598    
2599                    if (blogsEntry != null) {
2600                            return blogsEntry;
2601                    }
2602    
2603                    StringBundler msg = new StringBundler(4);
2604    
2605                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2606    
2607                    msg.append("companyId=");
2608                    msg.append(companyId);
2609    
2610                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2611    
2612                    throw new NoSuchEntryException(msg.toString());
2613            }
2614    
2615            /**
2616             * Returns the last blogs entry in the ordered set where companyId = &#63;.
2617             *
2618             * @param companyId the company ID
2619             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2620             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
2621             */
2622            @Override
2623            public BlogsEntry fetchByCompanyId_Last(long companyId,
2624                    OrderByComparator<BlogsEntry> orderByComparator) {
2625                    int count = countByCompanyId(companyId);
2626    
2627                    if (count == 0) {
2628                            return null;
2629                    }
2630    
2631                    List<BlogsEntry> list = findByCompanyId(companyId, count - 1, count,
2632                                    orderByComparator);
2633    
2634                    if (!list.isEmpty()) {
2635                            return list.get(0);
2636                    }
2637    
2638                    return null;
2639            }
2640    
2641            /**
2642             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63;.
2643             *
2644             * @param entryId the primary key of the current blogs entry
2645             * @param companyId the company ID
2646             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2647             * @return the previous, current, and next blogs entry
2648             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
2649             */
2650            @Override
2651            public BlogsEntry[] findByCompanyId_PrevAndNext(long entryId,
2652                    long companyId, OrderByComparator<BlogsEntry> orderByComparator)
2653                    throws NoSuchEntryException {
2654                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
2655    
2656                    Session session = null;
2657    
2658                    try {
2659                            session = openSession();
2660    
2661                            BlogsEntry[] array = new BlogsEntryImpl[3];
2662    
2663                            array[0] = getByCompanyId_PrevAndNext(session, blogsEntry,
2664                                            companyId, orderByComparator, true);
2665    
2666                            array[1] = blogsEntry;
2667    
2668                            array[2] = getByCompanyId_PrevAndNext(session, blogsEntry,
2669                                            companyId, orderByComparator, false);
2670    
2671                            return array;
2672                    }
2673                    catch (Exception e) {
2674                            throw processException(e);
2675                    }
2676                    finally {
2677                            closeSession(session);
2678                    }
2679            }
2680    
2681            protected BlogsEntry getByCompanyId_PrevAndNext(Session session,
2682                    BlogsEntry blogsEntry, long companyId,
2683                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
2684                    StringBundler query = null;
2685    
2686                    if (orderByComparator != null) {
2687                            query = new StringBundler(6 +
2688                                            (orderByComparator.getOrderByFields().length * 6));
2689                    }
2690                    else {
2691                            query = new StringBundler(3);
2692                    }
2693    
2694                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
2695    
2696                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2697    
2698                    if (orderByComparator != null) {
2699                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2700    
2701                            if (orderByConditionFields.length > 0) {
2702                                    query.append(WHERE_AND);
2703                            }
2704    
2705                            for (int i = 0; i < orderByConditionFields.length; i++) {
2706                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2707                                    query.append(orderByConditionFields[i]);
2708    
2709                                    if ((i + 1) < orderByConditionFields.length) {
2710                                            if (orderByComparator.isAscending() ^ previous) {
2711                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2712                                            }
2713                                            else {
2714                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2715                                            }
2716                                    }
2717                                    else {
2718                                            if (orderByComparator.isAscending() ^ previous) {
2719                                                    query.append(WHERE_GREATER_THAN);
2720                                            }
2721                                            else {
2722                                                    query.append(WHERE_LESSER_THAN);
2723                                            }
2724                                    }
2725                            }
2726    
2727                            query.append(ORDER_BY_CLAUSE);
2728    
2729                            String[] orderByFields = orderByComparator.getOrderByFields();
2730    
2731                            for (int i = 0; i < orderByFields.length; i++) {
2732                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2733                                    query.append(orderByFields[i]);
2734    
2735                                    if ((i + 1) < orderByFields.length) {
2736                                            if (orderByComparator.isAscending() ^ previous) {
2737                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2738                                            }
2739                                            else {
2740                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2741                                            }
2742                                    }
2743                                    else {
2744                                            if (orderByComparator.isAscending() ^ previous) {
2745                                                    query.append(ORDER_BY_ASC);
2746                                            }
2747                                            else {
2748                                                    query.append(ORDER_BY_DESC);
2749                                            }
2750                                    }
2751                            }
2752                    }
2753                    else {
2754                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
2755                    }
2756    
2757                    String sql = query.toString();
2758    
2759                    Query q = session.createQuery(sql);
2760    
2761                    q.setFirstResult(0);
2762                    q.setMaxResults(2);
2763    
2764                    QueryPos qPos = QueryPos.getInstance(q);
2765    
2766                    qPos.add(companyId);
2767    
2768                    if (orderByComparator != null) {
2769                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
2770    
2771                            for (Object value : values) {
2772                                    qPos.add(value);
2773                            }
2774                    }
2775    
2776                    List<BlogsEntry> list = q.list();
2777    
2778                    if (list.size() == 2) {
2779                            return list.get(1);
2780                    }
2781                    else {
2782                            return null;
2783                    }
2784            }
2785    
2786            /**
2787             * Removes all the blogs entries where companyId = &#63; from the database.
2788             *
2789             * @param companyId the company ID
2790             */
2791            @Override
2792            public void removeByCompanyId(long companyId) {
2793                    for (BlogsEntry blogsEntry : findByCompanyId(companyId,
2794                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2795                            remove(blogsEntry);
2796                    }
2797            }
2798    
2799            /**
2800             * Returns the number of blogs entries where companyId = &#63;.
2801             *
2802             * @param companyId the company ID
2803             * @return the number of matching blogs entries
2804             */
2805            @Override
2806            public int countByCompanyId(long companyId) {
2807                    FinderPath finderPath = FINDER_PATH_COUNT_BY_COMPANYID;
2808    
2809                    Object[] finderArgs = new Object[] { companyId };
2810    
2811                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
2812    
2813                    if (count == null) {
2814                            StringBundler query = new StringBundler(2);
2815    
2816                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
2817    
2818                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2819    
2820                            String sql = query.toString();
2821    
2822                            Session session = null;
2823    
2824                            try {
2825                                    session = openSession();
2826    
2827                                    Query q = session.createQuery(sql);
2828    
2829                                    QueryPos qPos = QueryPos.getInstance(q);
2830    
2831                                    qPos.add(companyId);
2832    
2833                                    count = (Long)q.uniqueResult();
2834    
2835                                    finderCache.putResult(finderPath, finderArgs, count);
2836                            }
2837                            catch (Exception e) {
2838                                    finderCache.removeResult(finderPath, finderArgs);
2839    
2840                                    throw processException(e);
2841                            }
2842                            finally {
2843                                    closeSession(session);
2844                            }
2845                    }
2846    
2847                    return count.intValue();
2848            }
2849    
2850            private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "blogsEntry.companyId = ?";
2851            public static final FinderPath FINDER_PATH_FETCH_BY_G_UT = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
2852                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
2853                            FINDER_CLASS_NAME_ENTITY, "fetchByG_UT",
2854                            new String[] { Long.class.getName(), String.class.getName() },
2855                            BlogsEntryModelImpl.GROUPID_COLUMN_BITMASK |
2856                            BlogsEntryModelImpl.URLTITLE_COLUMN_BITMASK);
2857            public static final FinderPath FINDER_PATH_COUNT_BY_G_UT = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
2858                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
2859                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_UT",
2860                            new String[] { Long.class.getName(), String.class.getName() });
2861    
2862            /**
2863             * Returns the blogs entry where groupId = &#63; and urlTitle = &#63; or throws a {@link NoSuchEntryException} if it could not be found.
2864             *
2865             * @param groupId the group ID
2866             * @param urlTitle the url title
2867             * @return the matching blogs entry
2868             * @throws NoSuchEntryException if a matching blogs entry could not be found
2869             */
2870            @Override
2871            public BlogsEntry findByG_UT(long groupId, String urlTitle)
2872                    throws NoSuchEntryException {
2873                    BlogsEntry blogsEntry = fetchByG_UT(groupId, urlTitle);
2874    
2875                    if (blogsEntry == null) {
2876                            StringBundler msg = new StringBundler(6);
2877    
2878                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2879    
2880                            msg.append("groupId=");
2881                            msg.append(groupId);
2882    
2883                            msg.append(", urlTitle=");
2884                            msg.append(urlTitle);
2885    
2886                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2887    
2888                            if (_log.isWarnEnabled()) {
2889                                    _log.warn(msg.toString());
2890                            }
2891    
2892                            throw new NoSuchEntryException(msg.toString());
2893                    }
2894    
2895                    return blogsEntry;
2896            }
2897    
2898            /**
2899             * 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.
2900             *
2901             * @param groupId the group ID
2902             * @param urlTitle the url title
2903             * @return the matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
2904             */
2905            @Override
2906            public BlogsEntry fetchByG_UT(long groupId, String urlTitle) {
2907                    return fetchByG_UT(groupId, urlTitle, true);
2908            }
2909    
2910            /**
2911             * 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.
2912             *
2913             * @param groupId the group ID
2914             * @param urlTitle the url title
2915             * @param retrieveFromCache whether to retrieve from the finder cache
2916             * @return the matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
2917             */
2918            @Override
2919            public BlogsEntry fetchByG_UT(long groupId, String urlTitle,
2920                    boolean retrieveFromCache) {
2921                    Object[] finderArgs = new Object[] { groupId, urlTitle };
2922    
2923                    Object result = null;
2924    
2925                    if (retrieveFromCache) {
2926                            result = finderCache.getResult(FINDER_PATH_FETCH_BY_G_UT,
2927                                            finderArgs, this);
2928                    }
2929    
2930                    if (result instanceof BlogsEntry) {
2931                            BlogsEntry blogsEntry = (BlogsEntry)result;
2932    
2933                            if ((groupId != blogsEntry.getGroupId()) ||
2934                                            !Validator.equals(urlTitle, blogsEntry.getUrlTitle())) {
2935                                    result = null;
2936                            }
2937                    }
2938    
2939                    if (result == null) {
2940                            StringBundler query = new StringBundler(4);
2941    
2942                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
2943    
2944                            query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
2945    
2946                            boolean bindUrlTitle = false;
2947    
2948                            if (urlTitle == null) {
2949                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
2950                            }
2951                            else if (urlTitle.equals(StringPool.BLANK)) {
2952                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
2953                            }
2954                            else {
2955                                    bindUrlTitle = true;
2956    
2957                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
2958                            }
2959    
2960                            String sql = query.toString();
2961    
2962                            Session session = null;
2963    
2964                            try {
2965                                    session = openSession();
2966    
2967                                    Query q = session.createQuery(sql);
2968    
2969                                    QueryPos qPos = QueryPos.getInstance(q);
2970    
2971                                    qPos.add(groupId);
2972    
2973                                    if (bindUrlTitle) {
2974                                            qPos.add(urlTitle);
2975                                    }
2976    
2977                                    List<BlogsEntry> list = q.list();
2978    
2979                                    if (list.isEmpty()) {
2980                                            finderCache.putResult(FINDER_PATH_FETCH_BY_G_UT,
2981                                                    finderArgs, list);
2982                                    }
2983                                    else {
2984                                            BlogsEntry blogsEntry = list.get(0);
2985    
2986                                            result = blogsEntry;
2987    
2988                                            cacheResult(blogsEntry);
2989    
2990                                            if ((blogsEntry.getGroupId() != groupId) ||
2991                                                            (blogsEntry.getUrlTitle() == null) ||
2992                                                            !blogsEntry.getUrlTitle().equals(urlTitle)) {
2993                                                    finderCache.putResult(FINDER_PATH_FETCH_BY_G_UT,
2994                                                            finderArgs, blogsEntry);
2995                                            }
2996                                    }
2997                            }
2998                            catch (Exception e) {
2999                                    finderCache.removeResult(FINDER_PATH_FETCH_BY_G_UT, finderArgs);
3000    
3001                                    throw processException(e);
3002                            }
3003                            finally {
3004                                    closeSession(session);
3005                            }
3006                    }
3007    
3008                    if (result instanceof List<?>) {
3009                            return null;
3010                    }
3011                    else {
3012                            return (BlogsEntry)result;
3013                    }
3014            }
3015    
3016            /**
3017             * Removes the blogs entry where groupId = &#63; and urlTitle = &#63; from the database.
3018             *
3019             * @param groupId the group ID
3020             * @param urlTitle the url title
3021             * @return the blogs entry that was removed
3022             */
3023            @Override
3024            public BlogsEntry removeByG_UT(long groupId, String urlTitle)
3025                    throws NoSuchEntryException {
3026                    BlogsEntry blogsEntry = findByG_UT(groupId, urlTitle);
3027    
3028                    return remove(blogsEntry);
3029            }
3030    
3031            /**
3032             * Returns the number of blogs entries where groupId = &#63; and urlTitle = &#63;.
3033             *
3034             * @param groupId the group ID
3035             * @param urlTitle the url title
3036             * @return the number of matching blogs entries
3037             */
3038            @Override
3039            public int countByG_UT(long groupId, String urlTitle) {
3040                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_UT;
3041    
3042                    Object[] finderArgs = new Object[] { groupId, urlTitle };
3043    
3044                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
3045    
3046                    if (count == null) {
3047                            StringBundler query = new StringBundler(3);
3048    
3049                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
3050    
3051                            query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
3052    
3053                            boolean bindUrlTitle = false;
3054    
3055                            if (urlTitle == null) {
3056                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
3057                            }
3058                            else if (urlTitle.equals(StringPool.BLANK)) {
3059                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
3060                            }
3061                            else {
3062                                    bindUrlTitle = true;
3063    
3064                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
3065                            }
3066    
3067                            String sql = query.toString();
3068    
3069                            Session session = null;
3070    
3071                            try {
3072                                    session = openSession();
3073    
3074                                    Query q = session.createQuery(sql);
3075    
3076                                    QueryPos qPos = QueryPos.getInstance(q);
3077    
3078                                    qPos.add(groupId);
3079    
3080                                    if (bindUrlTitle) {
3081                                            qPos.add(urlTitle);
3082                                    }
3083    
3084                                    count = (Long)q.uniqueResult();
3085    
3086                                    finderCache.putResult(finderPath, finderArgs, count);
3087                            }
3088                            catch (Exception e) {
3089                                    finderCache.removeResult(finderPath, finderArgs);
3090    
3091                                    throw processException(e);
3092                            }
3093                            finally {
3094                                    closeSession(session);
3095                            }
3096                    }
3097    
3098                    return count.intValue();
3099            }
3100    
3101            private static final String _FINDER_COLUMN_G_UT_GROUPID_2 = "blogsEntry.groupId = ? AND ";
3102            private static final String _FINDER_COLUMN_G_UT_URLTITLE_1 = "blogsEntry.urlTitle IS NULL";
3103            private static final String _FINDER_COLUMN_G_UT_URLTITLE_2 = "blogsEntry.urlTitle = ?";
3104            private static final String _FINDER_COLUMN_G_UT_URLTITLE_3 = "(blogsEntry.urlTitle IS NULL OR blogsEntry.urlTitle = '')";
3105            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
3106                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
3107                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_LtD",
3108                            new String[] {
3109                                    Long.class.getName(), Date.class.getName(),
3110                                    
3111                            Integer.class.getName(), Integer.class.getName(),
3112                                    OrderByComparator.class.getName()
3113                            });
3114            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
3115                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
3116                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_LtD",
3117                            new String[] { Long.class.getName(), Date.class.getName() });
3118    
3119            /**
3120             * Returns all the blogs entries where groupId = &#63; and displayDate &lt; &#63;.
3121             *
3122             * @param groupId the group ID
3123             * @param displayDate the display date
3124             * @return the matching blogs entries
3125             */
3126            @Override
3127            public List<BlogsEntry> findByG_LtD(long groupId, Date displayDate) {
3128                    return findByG_LtD(groupId, displayDate, QueryUtil.ALL_POS,
3129                            QueryUtil.ALL_POS, null);
3130            }
3131    
3132            /**
3133             * Returns a range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63;.
3134             *
3135             * <p>
3136             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
3137             * </p>
3138             *
3139             * @param groupId the group ID
3140             * @param displayDate the display date
3141             * @param start the lower bound of the range of blogs entries
3142             * @param end the upper bound of the range of blogs entries (not inclusive)
3143             * @return the range of matching blogs entries
3144             */
3145            @Override
3146            public List<BlogsEntry> findByG_LtD(long groupId, Date displayDate,
3147                    int start, int end) {
3148                    return findByG_LtD(groupId, displayDate, start, end, null);
3149            }
3150    
3151            /**
3152             * Returns an ordered range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63;.
3153             *
3154             * <p>
3155             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
3156             * </p>
3157             *
3158             * @param groupId the group ID
3159             * @param displayDate the display date
3160             * @param start the lower bound of the range of blogs entries
3161             * @param end the upper bound of the range of blogs entries (not inclusive)
3162             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3163             * @return the ordered range of matching blogs entries
3164             */
3165            @Override
3166            public List<BlogsEntry> findByG_LtD(long groupId, Date displayDate,
3167                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator) {
3168                    return findByG_LtD(groupId, displayDate, start, end, orderByComparator,
3169                            true);
3170            }
3171    
3172            /**
3173             * Returns an ordered range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63;.
3174             *
3175             * <p>
3176             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
3177             * </p>
3178             *
3179             * @param groupId the group ID
3180             * @param displayDate the display date
3181             * @param start the lower bound of the range of blogs entries
3182             * @param end the upper bound of the range of blogs entries (not inclusive)
3183             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3184             * @param retrieveFromCache whether to retrieve from the finder cache
3185             * @return the ordered range of matching blogs entries
3186             */
3187            @Override
3188            public List<BlogsEntry> findByG_LtD(long groupId, Date displayDate,
3189                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator,
3190                    boolean retrieveFromCache) {
3191                    boolean pagination = true;
3192                    FinderPath finderPath = null;
3193                    Object[] finderArgs = null;
3194    
3195                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD;
3196                    finderArgs = new Object[] {
3197                                    groupId, displayDate,
3198                                    
3199                                    start, end, orderByComparator
3200                            };
3201    
3202                    List<BlogsEntry> list = null;
3203    
3204                    if (retrieveFromCache) {
3205                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
3206                                            finderArgs, this);
3207    
3208                            if ((list != null) && !list.isEmpty()) {
3209                                    for (BlogsEntry blogsEntry : list) {
3210                                            if ((groupId != blogsEntry.getGroupId()) ||
3211                                                            (displayDate.getTime() <= blogsEntry.getDisplayDate()
3212                                                                                                                                            .getTime())) {
3213                                                    list = null;
3214    
3215                                                    break;
3216                                            }
3217                                    }
3218                            }
3219                    }
3220    
3221                    if (list == null) {
3222                            StringBundler query = null;
3223    
3224                            if (orderByComparator != null) {
3225                                    query = new StringBundler(4 +
3226                                                    (orderByComparator.getOrderByFields().length * 3));
3227                            }
3228                            else {
3229                                    query = new StringBundler(4);
3230                            }
3231    
3232                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
3233    
3234                            query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
3235    
3236                            boolean bindDisplayDate = false;
3237    
3238                            if (displayDate == null) {
3239                                    query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
3240                            }
3241                            else {
3242                                    bindDisplayDate = true;
3243    
3244                                    query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
3245                            }
3246    
3247                            if (orderByComparator != null) {
3248                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3249                                            orderByComparator);
3250                            }
3251                            else
3252                             if (pagination) {
3253                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
3254                            }
3255    
3256                            String sql = query.toString();
3257    
3258                            Session session = null;
3259    
3260                            try {
3261                                    session = openSession();
3262    
3263                                    Query q = session.createQuery(sql);
3264    
3265                                    QueryPos qPos = QueryPos.getInstance(q);
3266    
3267                                    qPos.add(groupId);
3268    
3269                                    if (bindDisplayDate) {
3270                                            qPos.add(new Timestamp(displayDate.getTime()));
3271                                    }
3272    
3273                                    if (!pagination) {
3274                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
3275                                                            start, end, false);
3276    
3277                                            Collections.sort(list);
3278    
3279                                            list = Collections.unmodifiableList(list);
3280                                    }
3281                                    else {
3282                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
3283                                                            start, end);
3284                                    }
3285    
3286                                    cacheResult(list);
3287    
3288                                    finderCache.putResult(finderPath, finderArgs, list);
3289                            }
3290                            catch (Exception e) {
3291                                    finderCache.removeResult(finderPath, finderArgs);
3292    
3293                                    throw processException(e);
3294                            }
3295                            finally {
3296                                    closeSession(session);
3297                            }
3298                    }
3299    
3300                    return list;
3301            }
3302    
3303            /**
3304             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63;.
3305             *
3306             * @param groupId the group ID
3307             * @param displayDate the display date
3308             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3309             * @return the first matching blogs entry
3310             * @throws NoSuchEntryException if a matching blogs entry could not be found
3311             */
3312            @Override
3313            public BlogsEntry findByG_LtD_First(long groupId, Date displayDate,
3314                    OrderByComparator<BlogsEntry> orderByComparator)
3315                    throws NoSuchEntryException {
3316                    BlogsEntry blogsEntry = fetchByG_LtD_First(groupId, displayDate,
3317                                    orderByComparator);
3318    
3319                    if (blogsEntry != null) {
3320                            return blogsEntry;
3321                    }
3322    
3323                    StringBundler msg = new StringBundler(6);
3324    
3325                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3326    
3327                    msg.append("groupId=");
3328                    msg.append(groupId);
3329    
3330                    msg.append(", displayDate=");
3331                    msg.append(displayDate);
3332    
3333                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3334    
3335                    throw new NoSuchEntryException(msg.toString());
3336            }
3337    
3338            /**
3339             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63;.
3340             *
3341             * @param groupId the group ID
3342             * @param displayDate the display date
3343             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3344             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
3345             */
3346            @Override
3347            public BlogsEntry fetchByG_LtD_First(long groupId, Date displayDate,
3348                    OrderByComparator<BlogsEntry> orderByComparator) {
3349                    List<BlogsEntry> list = findByG_LtD(groupId, displayDate, 0, 1,
3350                                    orderByComparator);
3351    
3352                    if (!list.isEmpty()) {
3353                            return list.get(0);
3354                    }
3355    
3356                    return null;
3357            }
3358    
3359            /**
3360             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63;.
3361             *
3362             * @param groupId the group ID
3363             * @param displayDate the display date
3364             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3365             * @return the last matching blogs entry
3366             * @throws NoSuchEntryException if a matching blogs entry could not be found
3367             */
3368            @Override
3369            public BlogsEntry findByG_LtD_Last(long groupId, Date displayDate,
3370                    OrderByComparator<BlogsEntry> orderByComparator)
3371                    throws NoSuchEntryException {
3372                    BlogsEntry blogsEntry = fetchByG_LtD_Last(groupId, displayDate,
3373                                    orderByComparator);
3374    
3375                    if (blogsEntry != null) {
3376                            return blogsEntry;
3377                    }
3378    
3379                    StringBundler msg = new StringBundler(6);
3380    
3381                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3382    
3383                    msg.append("groupId=");
3384                    msg.append(groupId);
3385    
3386                    msg.append(", displayDate=");
3387                    msg.append(displayDate);
3388    
3389                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3390    
3391                    throw new NoSuchEntryException(msg.toString());
3392            }
3393    
3394            /**
3395             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63;.
3396             *
3397             * @param groupId the group ID
3398             * @param displayDate the display date
3399             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3400             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
3401             */
3402            @Override
3403            public BlogsEntry fetchByG_LtD_Last(long groupId, Date displayDate,
3404                    OrderByComparator<BlogsEntry> orderByComparator) {
3405                    int count = countByG_LtD(groupId, displayDate);
3406    
3407                    if (count == 0) {
3408                            return null;
3409                    }
3410    
3411                    List<BlogsEntry> list = findByG_LtD(groupId, displayDate, count - 1,
3412                                    count, orderByComparator);
3413    
3414                    if (!list.isEmpty()) {
3415                            return list.get(0);
3416                    }
3417    
3418                    return null;
3419            }
3420    
3421            /**
3422             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63;.
3423             *
3424             * @param entryId the primary key of the current blogs entry
3425             * @param groupId the group ID
3426             * @param displayDate the display date
3427             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3428             * @return the previous, current, and next blogs entry
3429             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
3430             */
3431            @Override
3432            public BlogsEntry[] findByG_LtD_PrevAndNext(long entryId, long groupId,
3433                    Date displayDate, OrderByComparator<BlogsEntry> orderByComparator)
3434                    throws NoSuchEntryException {
3435                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
3436    
3437                    Session session = null;
3438    
3439                    try {
3440                            session = openSession();
3441    
3442                            BlogsEntry[] array = new BlogsEntryImpl[3];
3443    
3444                            array[0] = getByG_LtD_PrevAndNext(session, blogsEntry, groupId,
3445                                            displayDate, orderByComparator, true);
3446    
3447                            array[1] = blogsEntry;
3448    
3449                            array[2] = getByG_LtD_PrevAndNext(session, blogsEntry, groupId,
3450                                            displayDate, orderByComparator, false);
3451    
3452                            return array;
3453                    }
3454                    catch (Exception e) {
3455                            throw processException(e);
3456                    }
3457                    finally {
3458                            closeSession(session);
3459                    }
3460            }
3461    
3462            protected BlogsEntry getByG_LtD_PrevAndNext(Session session,
3463                    BlogsEntry blogsEntry, long groupId, Date displayDate,
3464                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
3465                    StringBundler query = null;
3466    
3467                    if (orderByComparator != null) {
3468                            query = new StringBundler(6 +
3469                                            (orderByComparator.getOrderByFields().length * 6));
3470                    }
3471                    else {
3472                            query = new StringBundler(3);
3473                    }
3474    
3475                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
3476    
3477                    query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
3478    
3479                    boolean bindDisplayDate = false;
3480    
3481                    if (displayDate == null) {
3482                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
3483                    }
3484                    else {
3485                            bindDisplayDate = true;
3486    
3487                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
3488                    }
3489    
3490                    if (orderByComparator != null) {
3491                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3492    
3493                            if (orderByConditionFields.length > 0) {
3494                                    query.append(WHERE_AND);
3495                            }
3496    
3497                            for (int i = 0; i < orderByConditionFields.length; i++) {
3498                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3499                                    query.append(orderByConditionFields[i]);
3500    
3501                                    if ((i + 1) < orderByConditionFields.length) {
3502                                            if (orderByComparator.isAscending() ^ previous) {
3503                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3504                                            }
3505                                            else {
3506                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3507                                            }
3508                                    }
3509                                    else {
3510                                            if (orderByComparator.isAscending() ^ previous) {
3511                                                    query.append(WHERE_GREATER_THAN);
3512                                            }
3513                                            else {
3514                                                    query.append(WHERE_LESSER_THAN);
3515                                            }
3516                                    }
3517                            }
3518    
3519                            query.append(ORDER_BY_CLAUSE);
3520    
3521                            String[] orderByFields = orderByComparator.getOrderByFields();
3522    
3523                            for (int i = 0; i < orderByFields.length; i++) {
3524                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3525                                    query.append(orderByFields[i]);
3526    
3527                                    if ((i + 1) < orderByFields.length) {
3528                                            if (orderByComparator.isAscending() ^ previous) {
3529                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3530                                            }
3531                                            else {
3532                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3533                                            }
3534                                    }
3535                                    else {
3536                                            if (orderByComparator.isAscending() ^ previous) {
3537                                                    query.append(ORDER_BY_ASC);
3538                                            }
3539                                            else {
3540                                                    query.append(ORDER_BY_DESC);
3541                                            }
3542                                    }
3543                            }
3544                    }
3545                    else {
3546                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
3547                    }
3548    
3549                    String sql = query.toString();
3550    
3551                    Query q = session.createQuery(sql);
3552    
3553                    q.setFirstResult(0);
3554                    q.setMaxResults(2);
3555    
3556                    QueryPos qPos = QueryPos.getInstance(q);
3557    
3558                    qPos.add(groupId);
3559    
3560                    if (bindDisplayDate) {
3561                            qPos.add(new Timestamp(displayDate.getTime()));
3562                    }
3563    
3564                    if (orderByComparator != null) {
3565                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
3566    
3567                            for (Object value : values) {
3568                                    qPos.add(value);
3569                            }
3570                    }
3571    
3572                    List<BlogsEntry> list = q.list();
3573    
3574                    if (list.size() == 2) {
3575                            return list.get(1);
3576                    }
3577                    else {
3578                            return null;
3579                    }
3580            }
3581    
3582            /**
3583             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63;.
3584             *
3585             * @param groupId the group ID
3586             * @param displayDate the display date
3587             * @return the matching blogs entries that the user has permission to view
3588             */
3589            @Override
3590            public List<BlogsEntry> filterFindByG_LtD(long groupId, Date displayDate) {
3591                    return filterFindByG_LtD(groupId, displayDate, QueryUtil.ALL_POS,
3592                            QueryUtil.ALL_POS, null);
3593            }
3594    
3595            /**
3596             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63;.
3597             *
3598             * <p>
3599             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
3600             * </p>
3601             *
3602             * @param groupId the group ID
3603             * @param displayDate the display date
3604             * @param start the lower bound of the range of blogs entries
3605             * @param end the upper bound of the range of blogs entries (not inclusive)
3606             * @return the range of matching blogs entries that the user has permission to view
3607             */
3608            @Override
3609            public List<BlogsEntry> filterFindByG_LtD(long groupId, Date displayDate,
3610                    int start, int end) {
3611                    return filterFindByG_LtD(groupId, displayDate, start, end, null);
3612            }
3613    
3614            /**
3615             * Returns an ordered range of all the blogs entries that the user has permissions to view where groupId = &#63; and displayDate &lt; &#63;.
3616             *
3617             * <p>
3618             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
3619             * </p>
3620             *
3621             * @param groupId the group ID
3622             * @param displayDate the display date
3623             * @param start the lower bound of the range of blogs entries
3624             * @param end the upper bound of the range of blogs entries (not inclusive)
3625             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3626             * @return the ordered range of matching blogs entries that the user has permission to view
3627             */
3628            @Override
3629            public List<BlogsEntry> filterFindByG_LtD(long groupId, Date displayDate,
3630                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator) {
3631                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3632                            return findByG_LtD(groupId, displayDate, start, end,
3633                                    orderByComparator);
3634                    }
3635    
3636                    StringBundler query = null;
3637    
3638                    if (orderByComparator != null) {
3639                            query = new StringBundler(4 +
3640                                            (orderByComparator.getOrderByFields().length * 3));
3641                    }
3642                    else {
3643                            query = new StringBundler(4);
3644                    }
3645    
3646                    if (getDB().isSupportsInlineDistinct()) {
3647                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
3648                    }
3649                    else {
3650                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
3651                    }
3652    
3653                    query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
3654    
3655                    boolean bindDisplayDate = false;
3656    
3657                    if (displayDate == null) {
3658                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
3659                    }
3660                    else {
3661                            bindDisplayDate = true;
3662    
3663                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
3664                    }
3665    
3666                    if (!getDB().isSupportsInlineDistinct()) {
3667                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
3668                    }
3669    
3670                    if (orderByComparator != null) {
3671                            if (getDB().isSupportsInlineDistinct()) {
3672                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3673                                            orderByComparator, true);
3674                            }
3675                            else {
3676                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
3677                                            orderByComparator, true);
3678                            }
3679                    }
3680                    else {
3681                            if (getDB().isSupportsInlineDistinct()) {
3682                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
3683                            }
3684                            else {
3685                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
3686                            }
3687                    }
3688    
3689                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3690                                    BlogsEntry.class.getName(),
3691                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3692    
3693                    Session session = null;
3694    
3695                    try {
3696                            session = openSession();
3697    
3698                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
3699    
3700                            if (getDB().isSupportsInlineDistinct()) {
3701                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
3702                            }
3703                            else {
3704                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
3705                            }
3706    
3707                            QueryPos qPos = QueryPos.getInstance(q);
3708    
3709                            qPos.add(groupId);
3710    
3711                            if (bindDisplayDate) {
3712                                    qPos.add(new Timestamp(displayDate.getTime()));
3713                            }
3714    
3715                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
3716                    }
3717                    catch (Exception e) {
3718                            throw processException(e);
3719                    }
3720                    finally {
3721                            closeSession(session);
3722                    }
3723            }
3724    
3725            /**
3726             * 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;.
3727             *
3728             * @param entryId the primary key of the current blogs entry
3729             * @param groupId the group ID
3730             * @param displayDate the display date
3731             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3732             * @return the previous, current, and next blogs entry
3733             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
3734             */
3735            @Override
3736            public BlogsEntry[] filterFindByG_LtD_PrevAndNext(long entryId,
3737                    long groupId, Date displayDate,
3738                    OrderByComparator<BlogsEntry> orderByComparator)
3739                    throws NoSuchEntryException {
3740                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3741                            return findByG_LtD_PrevAndNext(entryId, groupId, displayDate,
3742                                    orderByComparator);
3743                    }
3744    
3745                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
3746    
3747                    Session session = null;
3748    
3749                    try {
3750                            session = openSession();
3751    
3752                            BlogsEntry[] array = new BlogsEntryImpl[3];
3753    
3754                            array[0] = filterGetByG_LtD_PrevAndNext(session, blogsEntry,
3755                                            groupId, displayDate, orderByComparator, true);
3756    
3757                            array[1] = blogsEntry;
3758    
3759                            array[2] = filterGetByG_LtD_PrevAndNext(session, blogsEntry,
3760                                            groupId, displayDate, orderByComparator, false);
3761    
3762                            return array;
3763                    }
3764                    catch (Exception e) {
3765                            throw processException(e);
3766                    }
3767                    finally {
3768                            closeSession(session);
3769                    }
3770            }
3771    
3772            protected BlogsEntry filterGetByG_LtD_PrevAndNext(Session session,
3773                    BlogsEntry blogsEntry, long groupId, Date displayDate,
3774                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
3775                    StringBundler query = null;
3776    
3777                    if (orderByComparator != null) {
3778                            query = new StringBundler(6 +
3779                                            (orderByComparator.getOrderByFields().length * 6));
3780                    }
3781                    else {
3782                            query = new StringBundler(3);
3783                    }
3784    
3785                    if (getDB().isSupportsInlineDistinct()) {
3786                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
3787                    }
3788                    else {
3789                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
3790                    }
3791    
3792                    query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
3793    
3794                    boolean bindDisplayDate = false;
3795    
3796                    if (displayDate == null) {
3797                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
3798                    }
3799                    else {
3800                            bindDisplayDate = true;
3801    
3802                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
3803                    }
3804    
3805                    if (!getDB().isSupportsInlineDistinct()) {
3806                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
3807                    }
3808    
3809                    if (orderByComparator != null) {
3810                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3811    
3812                            if (orderByConditionFields.length > 0) {
3813                                    query.append(WHERE_AND);
3814                            }
3815    
3816                            for (int i = 0; i < orderByConditionFields.length; i++) {
3817                                    if (getDB().isSupportsInlineDistinct()) {
3818                                            query.append(_ORDER_BY_ENTITY_ALIAS);
3819                                    }
3820                                    else {
3821                                            query.append(_ORDER_BY_ENTITY_TABLE);
3822                                    }
3823    
3824                                    query.append(orderByConditionFields[i]);
3825    
3826                                    if ((i + 1) < orderByConditionFields.length) {
3827                                            if (orderByComparator.isAscending() ^ previous) {
3828                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3829                                            }
3830                                            else {
3831                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3832                                            }
3833                                    }
3834                                    else {
3835                                            if (orderByComparator.isAscending() ^ previous) {
3836                                                    query.append(WHERE_GREATER_THAN);
3837                                            }
3838                                            else {
3839                                                    query.append(WHERE_LESSER_THAN);
3840                                            }
3841                                    }
3842                            }
3843    
3844                            query.append(ORDER_BY_CLAUSE);
3845    
3846                            String[] orderByFields = orderByComparator.getOrderByFields();
3847    
3848                            for (int i = 0; i < orderByFields.length; i++) {
3849                                    if (getDB().isSupportsInlineDistinct()) {
3850                                            query.append(_ORDER_BY_ENTITY_ALIAS);
3851                                    }
3852                                    else {
3853                                            query.append(_ORDER_BY_ENTITY_TABLE);
3854                                    }
3855    
3856                                    query.append(orderByFields[i]);
3857    
3858                                    if ((i + 1) < orderByFields.length) {
3859                                            if (orderByComparator.isAscending() ^ previous) {
3860                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3861                                            }
3862                                            else {
3863                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3864                                            }
3865                                    }
3866                                    else {
3867                                            if (orderByComparator.isAscending() ^ previous) {
3868                                                    query.append(ORDER_BY_ASC);
3869                                            }
3870                                            else {
3871                                                    query.append(ORDER_BY_DESC);
3872                                            }
3873                                    }
3874                            }
3875                    }
3876                    else {
3877                            if (getDB().isSupportsInlineDistinct()) {
3878                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
3879                            }
3880                            else {
3881                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
3882                            }
3883                    }
3884    
3885                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3886                                    BlogsEntry.class.getName(),
3887                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3888    
3889                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
3890    
3891                    q.setFirstResult(0);
3892                    q.setMaxResults(2);
3893    
3894                    if (getDB().isSupportsInlineDistinct()) {
3895                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
3896                    }
3897                    else {
3898                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
3899                    }
3900    
3901                    QueryPos qPos = QueryPos.getInstance(q);
3902    
3903                    qPos.add(groupId);
3904    
3905                    if (bindDisplayDate) {
3906                            qPos.add(new Timestamp(displayDate.getTime()));
3907                    }
3908    
3909                    if (orderByComparator != null) {
3910                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
3911    
3912                            for (Object value : values) {
3913                                    qPos.add(value);
3914                            }
3915                    }
3916    
3917                    List<BlogsEntry> list = q.list();
3918    
3919                    if (list.size() == 2) {
3920                            return list.get(1);
3921                    }
3922                    else {
3923                            return null;
3924                    }
3925            }
3926    
3927            /**
3928             * Removes all the blogs entries where groupId = &#63; and displayDate &lt; &#63; from the database.
3929             *
3930             * @param groupId the group ID
3931             * @param displayDate the display date
3932             */
3933            @Override
3934            public void removeByG_LtD(long groupId, Date displayDate) {
3935                    for (BlogsEntry blogsEntry : findByG_LtD(groupId, displayDate,
3936                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3937                            remove(blogsEntry);
3938                    }
3939            }
3940    
3941            /**
3942             * Returns the number of blogs entries where groupId = &#63; and displayDate &lt; &#63;.
3943             *
3944             * @param groupId the group ID
3945             * @param displayDate the display date
3946             * @return the number of matching blogs entries
3947             */
3948            @Override
3949            public int countByG_LtD(long groupId, Date displayDate) {
3950                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD;
3951    
3952                    Object[] finderArgs = new Object[] { groupId, displayDate };
3953    
3954                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
3955    
3956                    if (count == null) {
3957                            StringBundler query = new StringBundler(3);
3958    
3959                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
3960    
3961                            query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
3962    
3963                            boolean bindDisplayDate = false;
3964    
3965                            if (displayDate == null) {
3966                                    query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
3967                            }
3968                            else {
3969                                    bindDisplayDate = true;
3970    
3971                                    query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
3972                            }
3973    
3974                            String sql = query.toString();
3975    
3976                            Session session = null;
3977    
3978                            try {
3979                                    session = openSession();
3980    
3981                                    Query q = session.createQuery(sql);
3982    
3983                                    QueryPos qPos = QueryPos.getInstance(q);
3984    
3985                                    qPos.add(groupId);
3986    
3987                                    if (bindDisplayDate) {
3988                                            qPos.add(new Timestamp(displayDate.getTime()));
3989                                    }
3990    
3991                                    count = (Long)q.uniqueResult();
3992    
3993                                    finderCache.putResult(finderPath, finderArgs, count);
3994                            }
3995                            catch (Exception e) {
3996                                    finderCache.removeResult(finderPath, finderArgs);
3997    
3998                                    throw processException(e);
3999                            }
4000                            finally {
4001                                    closeSession(session);
4002                            }
4003                    }
4004    
4005                    return count.intValue();
4006            }
4007    
4008            /**
4009             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63;.
4010             *
4011             * @param groupId the group ID
4012             * @param displayDate the display date
4013             * @return the number of matching blogs entries that the user has permission to view
4014             */
4015            @Override
4016            public int filterCountByG_LtD(long groupId, Date displayDate) {
4017                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4018                            return countByG_LtD(groupId, displayDate);
4019                    }
4020    
4021                    StringBundler query = new StringBundler(3);
4022    
4023                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
4024    
4025                    query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
4026    
4027                    boolean bindDisplayDate = false;
4028    
4029                    if (displayDate == null) {
4030                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
4031                    }
4032                    else {
4033                            bindDisplayDate = true;
4034    
4035                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
4036                    }
4037    
4038                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4039                                    BlogsEntry.class.getName(),
4040                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4041    
4042                    Session session = null;
4043    
4044                    try {
4045                            session = openSession();
4046    
4047                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
4048    
4049                            q.addScalar(COUNT_COLUMN_NAME,
4050                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
4051    
4052                            QueryPos qPos = QueryPos.getInstance(q);
4053    
4054                            qPos.add(groupId);
4055    
4056                            if (bindDisplayDate) {
4057                                    qPos.add(new Timestamp(displayDate.getTime()));
4058                            }
4059    
4060                            Long count = (Long)q.uniqueResult();
4061    
4062                            return count.intValue();
4063                    }
4064                    catch (Exception e) {
4065                            throw processException(e);
4066                    }
4067                    finally {
4068                            closeSession(session);
4069                    }
4070            }
4071    
4072            private static final String _FINDER_COLUMN_G_LTD_GROUPID_2 = "blogsEntry.groupId = ? AND ";
4073            private static final String _FINDER_COLUMN_G_LTD_DISPLAYDATE_1 = "blogsEntry.displayDate IS NULL";
4074            private static final String _FINDER_COLUMN_G_LTD_DISPLAYDATE_2 = "blogsEntry.displayDate < ?";
4075            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
4076                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
4077                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_S",
4078                            new String[] {
4079                                    Long.class.getName(), Integer.class.getName(),
4080                                    
4081                            Integer.class.getName(), Integer.class.getName(),
4082                                    OrderByComparator.class.getName()
4083                            });
4084            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
4085                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
4086                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_S",
4087                            new String[] { Long.class.getName(), Integer.class.getName() },
4088                            BlogsEntryModelImpl.GROUPID_COLUMN_BITMASK |
4089                            BlogsEntryModelImpl.STATUS_COLUMN_BITMASK |
4090                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
4091                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
4092            public static final FinderPath FINDER_PATH_COUNT_BY_G_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
4093                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
4094                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_S",
4095                            new String[] { Long.class.getName(), Integer.class.getName() });
4096    
4097            /**
4098             * Returns all the blogs entries where groupId = &#63; and status = &#63;.
4099             *
4100             * @param groupId the group ID
4101             * @param status the status
4102             * @return the matching blogs entries
4103             */
4104            @Override
4105            public List<BlogsEntry> findByG_S(long groupId, int status) {
4106                    return findByG_S(groupId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
4107                            null);
4108            }
4109    
4110            /**
4111             * Returns a range of all the blogs entries where groupId = &#63; and status = &#63;.
4112             *
4113             * <p>
4114             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
4115             * </p>
4116             *
4117             * @param groupId the group ID
4118             * @param status the status
4119             * @param start the lower bound of the range of blogs entries
4120             * @param end the upper bound of the range of blogs entries (not inclusive)
4121             * @return the range of matching blogs entries
4122             */
4123            @Override
4124            public List<BlogsEntry> findByG_S(long groupId, int status, int start,
4125                    int end) {
4126                    return findByG_S(groupId, status, start, end, null);
4127            }
4128    
4129            /**
4130             * Returns an ordered range of all the blogs entries where groupId = &#63; and status = &#63;.
4131             *
4132             * <p>
4133             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
4134             * </p>
4135             *
4136             * @param groupId the group ID
4137             * @param status the status
4138             * @param start the lower bound of the range of blogs entries
4139             * @param end the upper bound of the range of blogs entries (not inclusive)
4140             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4141             * @return the ordered range of matching blogs entries
4142             */
4143            @Override
4144            public List<BlogsEntry> findByG_S(long groupId, int status, int start,
4145                    int end, OrderByComparator<BlogsEntry> orderByComparator) {
4146                    return findByG_S(groupId, status, start, end, orderByComparator, true);
4147            }
4148    
4149            /**
4150             * Returns an ordered range of all the blogs entries where groupId = &#63; and status = &#63;.
4151             *
4152             * <p>
4153             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
4154             * </p>
4155             *
4156             * @param groupId the group ID
4157             * @param status the status
4158             * @param start the lower bound of the range of blogs entries
4159             * @param end the upper bound of the range of blogs entries (not inclusive)
4160             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4161             * @param retrieveFromCache whether to retrieve from the finder cache
4162             * @return the ordered range of matching blogs entries
4163             */
4164            @Override
4165            public List<BlogsEntry> findByG_S(long groupId, int status, int start,
4166                    int end, OrderByComparator<BlogsEntry> orderByComparator,
4167                    boolean retrieveFromCache) {
4168                    boolean pagination = true;
4169                    FinderPath finderPath = null;
4170                    Object[] finderArgs = null;
4171    
4172                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4173                                    (orderByComparator == null)) {
4174                            pagination = false;
4175                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S;
4176                            finderArgs = new Object[] { groupId, status };
4177                    }
4178                    else {
4179                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S;
4180                            finderArgs = new Object[] {
4181                                            groupId, status,
4182                                            
4183                                            start, end, orderByComparator
4184                                    };
4185                    }
4186    
4187                    List<BlogsEntry> list = null;
4188    
4189                    if (retrieveFromCache) {
4190                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
4191                                            finderArgs, this);
4192    
4193                            if ((list != null) && !list.isEmpty()) {
4194                                    for (BlogsEntry blogsEntry : list) {
4195                                            if ((groupId != blogsEntry.getGroupId()) ||
4196                                                            (status != blogsEntry.getStatus())) {
4197                                                    list = null;
4198    
4199                                                    break;
4200                                            }
4201                                    }
4202                            }
4203                    }
4204    
4205                    if (list == null) {
4206                            StringBundler query = null;
4207    
4208                            if (orderByComparator != null) {
4209                                    query = new StringBundler(4 +
4210                                                    (orderByComparator.getOrderByFields().length * 3));
4211                            }
4212                            else {
4213                                    query = new StringBundler(4);
4214                            }
4215    
4216                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
4217    
4218                            query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4219    
4220                            query.append(_FINDER_COLUMN_G_S_STATUS_2);
4221    
4222                            if (orderByComparator != null) {
4223                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4224                                            orderByComparator);
4225                            }
4226                            else
4227                             if (pagination) {
4228                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
4229                            }
4230    
4231                            String sql = query.toString();
4232    
4233                            Session session = null;
4234    
4235                            try {
4236                                    session = openSession();
4237    
4238                                    Query q = session.createQuery(sql);
4239    
4240                                    QueryPos qPos = QueryPos.getInstance(q);
4241    
4242                                    qPos.add(groupId);
4243    
4244                                    qPos.add(status);
4245    
4246                                    if (!pagination) {
4247                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
4248                                                            start, end, false);
4249    
4250                                            Collections.sort(list);
4251    
4252                                            list = Collections.unmodifiableList(list);
4253                                    }
4254                                    else {
4255                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
4256                                                            start, end);
4257                                    }
4258    
4259                                    cacheResult(list);
4260    
4261                                    finderCache.putResult(finderPath, finderArgs, list);
4262                            }
4263                            catch (Exception e) {
4264                                    finderCache.removeResult(finderPath, finderArgs);
4265    
4266                                    throw processException(e);
4267                            }
4268                            finally {
4269                                    closeSession(session);
4270                            }
4271                    }
4272    
4273                    return list;
4274            }
4275    
4276            /**
4277             * Returns the first blogs entry in the ordered set where groupId = &#63; and status = &#63;.
4278             *
4279             * @param groupId the group ID
4280             * @param status the status
4281             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4282             * @return the first matching blogs entry
4283             * @throws NoSuchEntryException if a matching blogs entry could not be found
4284             */
4285            @Override
4286            public BlogsEntry findByG_S_First(long groupId, int status,
4287                    OrderByComparator<BlogsEntry> orderByComparator)
4288                    throws NoSuchEntryException {
4289                    BlogsEntry blogsEntry = fetchByG_S_First(groupId, status,
4290                                    orderByComparator);
4291    
4292                    if (blogsEntry != null) {
4293                            return blogsEntry;
4294                    }
4295    
4296                    StringBundler msg = new StringBundler(6);
4297    
4298                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4299    
4300                    msg.append("groupId=");
4301                    msg.append(groupId);
4302    
4303                    msg.append(", status=");
4304                    msg.append(status);
4305    
4306                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4307    
4308                    throw new NoSuchEntryException(msg.toString());
4309            }
4310    
4311            /**
4312             * Returns the first blogs entry in the ordered set where groupId = &#63; and status = &#63;.
4313             *
4314             * @param groupId the group ID
4315             * @param status the status
4316             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4317             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
4318             */
4319            @Override
4320            public BlogsEntry fetchByG_S_First(long groupId, int status,
4321                    OrderByComparator<BlogsEntry> orderByComparator) {
4322                    List<BlogsEntry> list = findByG_S(groupId, status, 0, 1,
4323                                    orderByComparator);
4324    
4325                    if (!list.isEmpty()) {
4326                            return list.get(0);
4327                    }
4328    
4329                    return null;
4330            }
4331    
4332            /**
4333             * Returns the last blogs entry in the ordered set where groupId = &#63; and status = &#63;.
4334             *
4335             * @param groupId the group ID
4336             * @param status the status
4337             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4338             * @return the last matching blogs entry
4339             * @throws NoSuchEntryException if a matching blogs entry could not be found
4340             */
4341            @Override
4342            public BlogsEntry findByG_S_Last(long groupId, int status,
4343                    OrderByComparator<BlogsEntry> orderByComparator)
4344                    throws NoSuchEntryException {
4345                    BlogsEntry blogsEntry = fetchByG_S_Last(groupId, status,
4346                                    orderByComparator);
4347    
4348                    if (blogsEntry != null) {
4349                            return blogsEntry;
4350                    }
4351    
4352                    StringBundler msg = new StringBundler(6);
4353    
4354                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4355    
4356                    msg.append("groupId=");
4357                    msg.append(groupId);
4358    
4359                    msg.append(", status=");
4360                    msg.append(status);
4361    
4362                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4363    
4364                    throw new NoSuchEntryException(msg.toString());
4365            }
4366    
4367            /**
4368             * Returns the last blogs entry in the ordered set where groupId = &#63; and status = &#63;.
4369             *
4370             * @param groupId the group ID
4371             * @param status the status
4372             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4373             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
4374             */
4375            @Override
4376            public BlogsEntry fetchByG_S_Last(long groupId, int status,
4377                    OrderByComparator<BlogsEntry> orderByComparator) {
4378                    int count = countByG_S(groupId, status);
4379    
4380                    if (count == 0) {
4381                            return null;
4382                    }
4383    
4384                    List<BlogsEntry> list = findByG_S(groupId, status, count - 1, count,
4385                                    orderByComparator);
4386    
4387                    if (!list.isEmpty()) {
4388                            return list.get(0);
4389                    }
4390    
4391                    return null;
4392            }
4393    
4394            /**
4395             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63; and status = &#63;.
4396             *
4397             * @param entryId the primary key of the current blogs entry
4398             * @param groupId the group ID
4399             * @param status the status
4400             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4401             * @return the previous, current, and next blogs entry
4402             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
4403             */
4404            @Override
4405            public BlogsEntry[] findByG_S_PrevAndNext(long entryId, long groupId,
4406                    int status, OrderByComparator<BlogsEntry> orderByComparator)
4407                    throws NoSuchEntryException {
4408                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
4409    
4410                    Session session = null;
4411    
4412                    try {
4413                            session = openSession();
4414    
4415                            BlogsEntry[] array = new BlogsEntryImpl[3];
4416    
4417                            array[0] = getByG_S_PrevAndNext(session, blogsEntry, groupId,
4418                                            status, orderByComparator, true);
4419    
4420                            array[1] = blogsEntry;
4421    
4422                            array[2] = getByG_S_PrevAndNext(session, blogsEntry, groupId,
4423                                            status, orderByComparator, false);
4424    
4425                            return array;
4426                    }
4427                    catch (Exception e) {
4428                            throw processException(e);
4429                    }
4430                    finally {
4431                            closeSession(session);
4432                    }
4433            }
4434    
4435            protected BlogsEntry getByG_S_PrevAndNext(Session session,
4436                    BlogsEntry blogsEntry, long groupId, int status,
4437                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
4438                    StringBundler query = null;
4439    
4440                    if (orderByComparator != null) {
4441                            query = new StringBundler(6 +
4442                                            (orderByComparator.getOrderByFields().length * 6));
4443                    }
4444                    else {
4445                            query = new StringBundler(3);
4446                    }
4447    
4448                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
4449    
4450                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4451    
4452                    query.append(_FINDER_COLUMN_G_S_STATUS_2);
4453    
4454                    if (orderByComparator != null) {
4455                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4456    
4457                            if (orderByConditionFields.length > 0) {
4458                                    query.append(WHERE_AND);
4459                            }
4460    
4461                            for (int i = 0; i < orderByConditionFields.length; i++) {
4462                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4463                                    query.append(orderByConditionFields[i]);
4464    
4465                                    if ((i + 1) < orderByConditionFields.length) {
4466                                            if (orderByComparator.isAscending() ^ previous) {
4467                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4468                                            }
4469                                            else {
4470                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4471                                            }
4472                                    }
4473                                    else {
4474                                            if (orderByComparator.isAscending() ^ previous) {
4475                                                    query.append(WHERE_GREATER_THAN);
4476                                            }
4477                                            else {
4478                                                    query.append(WHERE_LESSER_THAN);
4479                                            }
4480                                    }
4481                            }
4482    
4483                            query.append(ORDER_BY_CLAUSE);
4484    
4485                            String[] orderByFields = orderByComparator.getOrderByFields();
4486    
4487                            for (int i = 0; i < orderByFields.length; i++) {
4488                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4489                                    query.append(orderByFields[i]);
4490    
4491                                    if ((i + 1) < orderByFields.length) {
4492                                            if (orderByComparator.isAscending() ^ previous) {
4493                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4494                                            }
4495                                            else {
4496                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4497                                            }
4498                                    }
4499                                    else {
4500                                            if (orderByComparator.isAscending() ^ previous) {
4501                                                    query.append(ORDER_BY_ASC);
4502                                            }
4503                                            else {
4504                                                    query.append(ORDER_BY_DESC);
4505                                            }
4506                                    }
4507                            }
4508                    }
4509                    else {
4510                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
4511                    }
4512    
4513                    String sql = query.toString();
4514    
4515                    Query q = session.createQuery(sql);
4516    
4517                    q.setFirstResult(0);
4518                    q.setMaxResults(2);
4519    
4520                    QueryPos qPos = QueryPos.getInstance(q);
4521    
4522                    qPos.add(groupId);
4523    
4524                    qPos.add(status);
4525    
4526                    if (orderByComparator != null) {
4527                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
4528    
4529                            for (Object value : values) {
4530                                    qPos.add(value);
4531                            }
4532                    }
4533    
4534                    List<BlogsEntry> list = q.list();
4535    
4536                    if (list.size() == 2) {
4537                            return list.get(1);
4538                    }
4539                    else {
4540                            return null;
4541                    }
4542            }
4543    
4544            /**
4545             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and status = &#63;.
4546             *
4547             * @param groupId the group ID
4548             * @param status the status
4549             * @return the matching blogs entries that the user has permission to view
4550             */
4551            @Override
4552            public List<BlogsEntry> filterFindByG_S(long groupId, int status) {
4553                    return filterFindByG_S(groupId, status, QueryUtil.ALL_POS,
4554                            QueryUtil.ALL_POS, null);
4555            }
4556    
4557            /**
4558             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63; and status = &#63;.
4559             *
4560             * <p>
4561             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
4562             * </p>
4563             *
4564             * @param groupId the group ID
4565             * @param status the status
4566             * @param start the lower bound of the range of blogs entries
4567             * @param end the upper bound of the range of blogs entries (not inclusive)
4568             * @return the range of matching blogs entries that the user has permission to view
4569             */
4570            @Override
4571            public List<BlogsEntry> filterFindByG_S(long groupId, int status,
4572                    int start, int end) {
4573                    return filterFindByG_S(groupId, status, start, end, null);
4574            }
4575    
4576            /**
4577             * Returns an ordered range of all the blogs entries that the user has permissions to view where groupId = &#63; and status = &#63;.
4578             *
4579             * <p>
4580             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
4581             * </p>
4582             *
4583             * @param groupId the group ID
4584             * @param status the status
4585             * @param start the lower bound of the range of blogs entries
4586             * @param end the upper bound of the range of blogs entries (not inclusive)
4587             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4588             * @return the ordered range of matching blogs entries that the user has permission to view
4589             */
4590            @Override
4591            public List<BlogsEntry> filterFindByG_S(long groupId, int status,
4592                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator) {
4593                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4594                            return findByG_S(groupId, status, start, end, orderByComparator);
4595                    }
4596    
4597                    StringBundler query = null;
4598    
4599                    if (orderByComparator != null) {
4600                            query = new StringBundler(4 +
4601                                            (orderByComparator.getOrderByFields().length * 3));
4602                    }
4603                    else {
4604                            query = new StringBundler(4);
4605                    }
4606    
4607                    if (getDB().isSupportsInlineDistinct()) {
4608                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
4609                    }
4610                    else {
4611                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
4612                    }
4613    
4614                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4615    
4616                    query.append(_FINDER_COLUMN_G_S_STATUS_2);
4617    
4618                    if (!getDB().isSupportsInlineDistinct()) {
4619                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
4620                    }
4621    
4622                    if (orderByComparator != null) {
4623                            if (getDB().isSupportsInlineDistinct()) {
4624                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4625                                            orderByComparator, true);
4626                            }
4627                            else {
4628                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
4629                                            orderByComparator, true);
4630                            }
4631                    }
4632                    else {
4633                            if (getDB().isSupportsInlineDistinct()) {
4634                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
4635                            }
4636                            else {
4637                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
4638                            }
4639                    }
4640    
4641                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4642                                    BlogsEntry.class.getName(),
4643                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4644    
4645                    Session session = null;
4646    
4647                    try {
4648                            session = openSession();
4649    
4650                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
4651    
4652                            if (getDB().isSupportsInlineDistinct()) {
4653                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
4654                            }
4655                            else {
4656                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
4657                            }
4658    
4659                            QueryPos qPos = QueryPos.getInstance(q);
4660    
4661                            qPos.add(groupId);
4662    
4663                            qPos.add(status);
4664    
4665                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
4666                    }
4667                    catch (Exception e) {
4668                            throw processException(e);
4669                    }
4670                    finally {
4671                            closeSession(session);
4672                    }
4673            }
4674    
4675            /**
4676             * 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;.
4677             *
4678             * @param entryId the primary key of the current blogs entry
4679             * @param groupId the group ID
4680             * @param status the status
4681             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4682             * @return the previous, current, and next blogs entry
4683             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
4684             */
4685            @Override
4686            public BlogsEntry[] filterFindByG_S_PrevAndNext(long entryId, long groupId,
4687                    int status, OrderByComparator<BlogsEntry> orderByComparator)
4688                    throws NoSuchEntryException {
4689                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4690                            return findByG_S_PrevAndNext(entryId, groupId, status,
4691                                    orderByComparator);
4692                    }
4693    
4694                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
4695    
4696                    Session session = null;
4697    
4698                    try {
4699                            session = openSession();
4700    
4701                            BlogsEntry[] array = new BlogsEntryImpl[3];
4702    
4703                            array[0] = filterGetByG_S_PrevAndNext(session, blogsEntry, groupId,
4704                                            status, orderByComparator, true);
4705    
4706                            array[1] = blogsEntry;
4707    
4708                            array[2] = filterGetByG_S_PrevAndNext(session, blogsEntry, groupId,
4709                                            status, orderByComparator, false);
4710    
4711                            return array;
4712                    }
4713                    catch (Exception e) {
4714                            throw processException(e);
4715                    }
4716                    finally {
4717                            closeSession(session);
4718                    }
4719            }
4720    
4721            protected BlogsEntry filterGetByG_S_PrevAndNext(Session session,
4722                    BlogsEntry blogsEntry, long groupId, int status,
4723                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
4724                    StringBundler query = null;
4725    
4726                    if (orderByComparator != null) {
4727                            query = new StringBundler(6 +
4728                                            (orderByComparator.getOrderByFields().length * 6));
4729                    }
4730                    else {
4731                            query = new StringBundler(3);
4732                    }
4733    
4734                    if (getDB().isSupportsInlineDistinct()) {
4735                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
4736                    }
4737                    else {
4738                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
4739                    }
4740    
4741                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4742    
4743                    query.append(_FINDER_COLUMN_G_S_STATUS_2);
4744    
4745                    if (!getDB().isSupportsInlineDistinct()) {
4746                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
4747                    }
4748    
4749                    if (orderByComparator != null) {
4750                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4751    
4752                            if (orderByConditionFields.length > 0) {
4753                                    query.append(WHERE_AND);
4754                            }
4755    
4756                            for (int i = 0; i < orderByConditionFields.length; i++) {
4757                                    if (getDB().isSupportsInlineDistinct()) {
4758                                            query.append(_ORDER_BY_ENTITY_ALIAS);
4759                                    }
4760                                    else {
4761                                            query.append(_ORDER_BY_ENTITY_TABLE);
4762                                    }
4763    
4764                                    query.append(orderByConditionFields[i]);
4765    
4766                                    if ((i + 1) < orderByConditionFields.length) {
4767                                            if (orderByComparator.isAscending() ^ previous) {
4768                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4769                                            }
4770                                            else {
4771                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4772                                            }
4773                                    }
4774                                    else {
4775                                            if (orderByComparator.isAscending() ^ previous) {
4776                                                    query.append(WHERE_GREATER_THAN);
4777                                            }
4778                                            else {
4779                                                    query.append(WHERE_LESSER_THAN);
4780                                            }
4781                                    }
4782                            }
4783    
4784                            query.append(ORDER_BY_CLAUSE);
4785    
4786                            String[] orderByFields = orderByComparator.getOrderByFields();
4787    
4788                            for (int i = 0; i < orderByFields.length; i++) {
4789                                    if (getDB().isSupportsInlineDistinct()) {
4790                                            query.append(_ORDER_BY_ENTITY_ALIAS);
4791                                    }
4792                                    else {
4793                                            query.append(_ORDER_BY_ENTITY_TABLE);
4794                                    }
4795    
4796                                    query.append(orderByFields[i]);
4797    
4798                                    if ((i + 1) < orderByFields.length) {
4799                                            if (orderByComparator.isAscending() ^ previous) {
4800                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4801                                            }
4802                                            else {
4803                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4804                                            }
4805                                    }
4806                                    else {
4807                                            if (orderByComparator.isAscending() ^ previous) {
4808                                                    query.append(ORDER_BY_ASC);
4809                                            }
4810                                            else {
4811                                                    query.append(ORDER_BY_DESC);
4812                                            }
4813                                    }
4814                            }
4815                    }
4816                    else {
4817                            if (getDB().isSupportsInlineDistinct()) {
4818                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
4819                            }
4820                            else {
4821                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
4822                            }
4823                    }
4824    
4825                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4826                                    BlogsEntry.class.getName(),
4827                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4828    
4829                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
4830    
4831                    q.setFirstResult(0);
4832                    q.setMaxResults(2);
4833    
4834                    if (getDB().isSupportsInlineDistinct()) {
4835                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
4836                    }
4837                    else {
4838                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
4839                    }
4840    
4841                    QueryPos qPos = QueryPos.getInstance(q);
4842    
4843                    qPos.add(groupId);
4844    
4845                    qPos.add(status);
4846    
4847                    if (orderByComparator != null) {
4848                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
4849    
4850                            for (Object value : values) {
4851                                    qPos.add(value);
4852                            }
4853                    }
4854    
4855                    List<BlogsEntry> list = q.list();
4856    
4857                    if (list.size() == 2) {
4858                            return list.get(1);
4859                    }
4860                    else {
4861                            return null;
4862                    }
4863            }
4864    
4865            /**
4866             * Removes all the blogs entries where groupId = &#63; and status = &#63; from the database.
4867             *
4868             * @param groupId the group ID
4869             * @param status the status
4870             */
4871            @Override
4872            public void removeByG_S(long groupId, int status) {
4873                    for (BlogsEntry blogsEntry : findByG_S(groupId, status,
4874                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
4875                            remove(blogsEntry);
4876                    }
4877            }
4878    
4879            /**
4880             * Returns the number of blogs entries where groupId = &#63; and status = &#63;.
4881             *
4882             * @param groupId the group ID
4883             * @param status the status
4884             * @return the number of matching blogs entries
4885             */
4886            @Override
4887            public int countByG_S(long groupId, int status) {
4888                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_S;
4889    
4890                    Object[] finderArgs = new Object[] { groupId, status };
4891    
4892                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
4893    
4894                    if (count == null) {
4895                            StringBundler query = new StringBundler(3);
4896    
4897                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
4898    
4899                            query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4900    
4901                            query.append(_FINDER_COLUMN_G_S_STATUS_2);
4902    
4903                            String sql = query.toString();
4904    
4905                            Session session = null;
4906    
4907                            try {
4908                                    session = openSession();
4909    
4910                                    Query q = session.createQuery(sql);
4911    
4912                                    QueryPos qPos = QueryPos.getInstance(q);
4913    
4914                                    qPos.add(groupId);
4915    
4916                                    qPos.add(status);
4917    
4918                                    count = (Long)q.uniqueResult();
4919    
4920                                    finderCache.putResult(finderPath, finderArgs, count);
4921                            }
4922                            catch (Exception e) {
4923                                    finderCache.removeResult(finderPath, finderArgs);
4924    
4925                                    throw processException(e);
4926                            }
4927                            finally {
4928                                    closeSession(session);
4929                            }
4930                    }
4931    
4932                    return count.intValue();
4933            }
4934    
4935            /**
4936             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and status = &#63;.
4937             *
4938             * @param groupId the group ID
4939             * @param status the status
4940             * @return the number of matching blogs entries that the user has permission to view
4941             */
4942            @Override
4943            public int filterCountByG_S(long groupId, int status) {
4944                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4945                            return countByG_S(groupId, status);
4946                    }
4947    
4948                    StringBundler query = new StringBundler(3);
4949    
4950                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
4951    
4952                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4953    
4954                    query.append(_FINDER_COLUMN_G_S_STATUS_2);
4955    
4956                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4957                                    BlogsEntry.class.getName(),
4958                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4959    
4960                    Session session = null;
4961    
4962                    try {
4963                            session = openSession();
4964    
4965                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
4966    
4967                            q.addScalar(COUNT_COLUMN_NAME,
4968                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
4969    
4970                            QueryPos qPos = QueryPos.getInstance(q);
4971    
4972                            qPos.add(groupId);
4973    
4974                            qPos.add(status);
4975    
4976                            Long count = (Long)q.uniqueResult();
4977    
4978                            return count.intValue();
4979                    }
4980                    catch (Exception e) {
4981                            throw processException(e);
4982                    }
4983                    finally {
4984                            closeSession(session);
4985                    }
4986            }
4987    
4988            private static final String _FINDER_COLUMN_G_S_GROUPID_2 = "blogsEntry.groupId = ? AND ";
4989            private static final String _FINDER_COLUMN_G_S_STATUS_2 = "blogsEntry.status = ?";
4990            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_NOTS = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
4991                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
4992                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_NotS",
4993                            new String[] {
4994                                    Long.class.getName(), Integer.class.getName(),
4995                                    
4996                            Integer.class.getName(), Integer.class.getName(),
4997                                    OrderByComparator.class.getName()
4998                            });
4999            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_NOTS = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
5000                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
5001                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_NotS",
5002                            new String[] { Long.class.getName(), Integer.class.getName() });
5003    
5004            /**
5005             * Returns all the blogs entries where groupId = &#63; and status &ne; &#63;.
5006             *
5007             * @param groupId the group ID
5008             * @param status the status
5009             * @return the matching blogs entries
5010             */
5011            @Override
5012            public List<BlogsEntry> findByG_NotS(long groupId, int status) {
5013                    return findByG_NotS(groupId, status, QueryUtil.ALL_POS,
5014                            QueryUtil.ALL_POS, null);
5015            }
5016    
5017            /**
5018             * Returns a range of all the blogs entries where groupId = &#63; and status &ne; &#63;.
5019             *
5020             * <p>
5021             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
5022             * </p>
5023             *
5024             * @param groupId the group ID
5025             * @param status the status
5026             * @param start the lower bound of the range of blogs entries
5027             * @param end the upper bound of the range of blogs entries (not inclusive)
5028             * @return the range of matching blogs entries
5029             */
5030            @Override
5031            public List<BlogsEntry> findByG_NotS(long groupId, int status, int start,
5032                    int end) {
5033                    return findByG_NotS(groupId, status, start, end, null);
5034            }
5035    
5036            /**
5037             * Returns an ordered range of all the blogs entries where groupId = &#63; and status &ne; &#63;.
5038             *
5039             * <p>
5040             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
5041             * </p>
5042             *
5043             * @param groupId the group ID
5044             * @param status the status
5045             * @param start the lower bound of the range of blogs entries
5046             * @param end the upper bound of the range of blogs entries (not inclusive)
5047             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5048             * @return the ordered range of matching blogs entries
5049             */
5050            @Override
5051            public List<BlogsEntry> findByG_NotS(long groupId, int status, int start,
5052                    int end, OrderByComparator<BlogsEntry> orderByComparator) {
5053                    return findByG_NotS(groupId, status, start, end, orderByComparator, true);
5054            }
5055    
5056            /**
5057             * Returns an ordered range of all the blogs entries where groupId = &#63; and status &ne; &#63;.
5058             *
5059             * <p>
5060             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
5061             * </p>
5062             *
5063             * @param groupId the group ID
5064             * @param status the status
5065             * @param start the lower bound of the range of blogs entries
5066             * @param end the upper bound of the range of blogs entries (not inclusive)
5067             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5068             * @param retrieveFromCache whether to retrieve from the finder cache
5069             * @return the ordered range of matching blogs entries
5070             */
5071            @Override
5072            public List<BlogsEntry> findByG_NotS(long groupId, int status, int start,
5073                    int end, OrderByComparator<BlogsEntry> orderByComparator,
5074                    boolean retrieveFromCache) {
5075                    boolean pagination = true;
5076                    FinderPath finderPath = null;
5077                    Object[] finderArgs = null;
5078    
5079                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_NOTS;
5080                    finderArgs = new Object[] { groupId, status, start, end, orderByComparator };
5081    
5082                    List<BlogsEntry> list = null;
5083    
5084                    if (retrieveFromCache) {
5085                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
5086                                            finderArgs, this);
5087    
5088                            if ((list != null) && !list.isEmpty()) {
5089                                    for (BlogsEntry blogsEntry : list) {
5090                                            if ((groupId != blogsEntry.getGroupId()) ||
5091                                                            (status == blogsEntry.getStatus())) {
5092                                                    list = null;
5093    
5094                                                    break;
5095                                            }
5096                                    }
5097                            }
5098                    }
5099    
5100                    if (list == null) {
5101                            StringBundler query = null;
5102    
5103                            if (orderByComparator != null) {
5104                                    query = new StringBundler(4 +
5105                                                    (orderByComparator.getOrderByFields().length * 3));
5106                            }
5107                            else {
5108                                    query = new StringBundler(4);
5109                            }
5110    
5111                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
5112    
5113                            query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
5114    
5115                            query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
5116    
5117                            if (orderByComparator != null) {
5118                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5119                                            orderByComparator);
5120                            }
5121                            else
5122                             if (pagination) {
5123                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
5124                            }
5125    
5126                            String sql = query.toString();
5127    
5128                            Session session = null;
5129    
5130                            try {
5131                                    session = openSession();
5132    
5133                                    Query q = session.createQuery(sql);
5134    
5135                                    QueryPos qPos = QueryPos.getInstance(q);
5136    
5137                                    qPos.add(groupId);
5138    
5139                                    qPos.add(status);
5140    
5141                                    if (!pagination) {
5142                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
5143                                                            start, end, false);
5144    
5145                                            Collections.sort(list);
5146    
5147                                            list = Collections.unmodifiableList(list);
5148                                    }
5149                                    else {
5150                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
5151                                                            start, end);
5152                                    }
5153    
5154                                    cacheResult(list);
5155    
5156                                    finderCache.putResult(finderPath, finderArgs, list);
5157                            }
5158                            catch (Exception e) {
5159                                    finderCache.removeResult(finderPath, finderArgs);
5160    
5161                                    throw processException(e);
5162                            }
5163                            finally {
5164                                    closeSession(session);
5165                            }
5166                    }
5167    
5168                    return list;
5169            }
5170    
5171            /**
5172             * Returns the first blogs entry in the ordered set where groupId = &#63; and status &ne; &#63;.
5173             *
5174             * @param groupId the group ID
5175             * @param status the status
5176             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5177             * @return the first matching blogs entry
5178             * @throws NoSuchEntryException if a matching blogs entry could not be found
5179             */
5180            @Override
5181            public BlogsEntry findByG_NotS_First(long groupId, int status,
5182                    OrderByComparator<BlogsEntry> orderByComparator)
5183                    throws NoSuchEntryException {
5184                    BlogsEntry blogsEntry = fetchByG_NotS_First(groupId, status,
5185                                    orderByComparator);
5186    
5187                    if (blogsEntry != null) {
5188                            return blogsEntry;
5189                    }
5190    
5191                    StringBundler msg = new StringBundler(6);
5192    
5193                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5194    
5195                    msg.append("groupId=");
5196                    msg.append(groupId);
5197    
5198                    msg.append(", status=");
5199                    msg.append(status);
5200    
5201                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5202    
5203                    throw new NoSuchEntryException(msg.toString());
5204            }
5205    
5206            /**
5207             * Returns the first blogs entry in the ordered set where groupId = &#63; and status &ne; &#63;.
5208             *
5209             * @param groupId the group ID
5210             * @param status the status
5211             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5212             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
5213             */
5214            @Override
5215            public BlogsEntry fetchByG_NotS_First(long groupId, int status,
5216                    OrderByComparator<BlogsEntry> orderByComparator) {
5217                    List<BlogsEntry> list = findByG_NotS(groupId, status, 0, 1,
5218                                    orderByComparator);
5219    
5220                    if (!list.isEmpty()) {
5221                            return list.get(0);
5222                    }
5223    
5224                    return null;
5225            }
5226    
5227            /**
5228             * Returns the last blogs entry in the ordered set where groupId = &#63; and status &ne; &#63;.
5229             *
5230             * @param groupId the group ID
5231             * @param status the status
5232             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5233             * @return the last matching blogs entry
5234             * @throws NoSuchEntryException if a matching blogs entry could not be found
5235             */
5236            @Override
5237            public BlogsEntry findByG_NotS_Last(long groupId, int status,
5238                    OrderByComparator<BlogsEntry> orderByComparator)
5239                    throws NoSuchEntryException {
5240                    BlogsEntry blogsEntry = fetchByG_NotS_Last(groupId, status,
5241                                    orderByComparator);
5242    
5243                    if (blogsEntry != null) {
5244                            return blogsEntry;
5245                    }
5246    
5247                    StringBundler msg = new StringBundler(6);
5248    
5249                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5250    
5251                    msg.append("groupId=");
5252                    msg.append(groupId);
5253    
5254                    msg.append(", status=");
5255                    msg.append(status);
5256    
5257                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5258    
5259                    throw new NoSuchEntryException(msg.toString());
5260            }
5261    
5262            /**
5263             * Returns the last blogs entry in the ordered set where groupId = &#63; and status &ne; &#63;.
5264             *
5265             * @param groupId the group ID
5266             * @param status the status
5267             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5268             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
5269             */
5270            @Override
5271            public BlogsEntry fetchByG_NotS_Last(long groupId, int status,
5272                    OrderByComparator<BlogsEntry> orderByComparator) {
5273                    int count = countByG_NotS(groupId, status);
5274    
5275                    if (count == 0) {
5276                            return null;
5277                    }
5278    
5279                    List<BlogsEntry> list = findByG_NotS(groupId, status, count - 1, count,
5280                                    orderByComparator);
5281    
5282                    if (!list.isEmpty()) {
5283                            return list.get(0);
5284                    }
5285    
5286                    return null;
5287            }
5288    
5289            /**
5290             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63; and status &ne; &#63;.
5291             *
5292             * @param entryId the primary key of the current blogs entry
5293             * @param groupId the group ID
5294             * @param status the status
5295             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5296             * @return the previous, current, and next blogs entry
5297             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
5298             */
5299            @Override
5300            public BlogsEntry[] findByG_NotS_PrevAndNext(long entryId, long groupId,
5301                    int status, OrderByComparator<BlogsEntry> orderByComparator)
5302                    throws NoSuchEntryException {
5303                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
5304    
5305                    Session session = null;
5306    
5307                    try {
5308                            session = openSession();
5309    
5310                            BlogsEntry[] array = new BlogsEntryImpl[3];
5311    
5312                            array[0] = getByG_NotS_PrevAndNext(session, blogsEntry, groupId,
5313                                            status, orderByComparator, true);
5314    
5315                            array[1] = blogsEntry;
5316    
5317                            array[2] = getByG_NotS_PrevAndNext(session, blogsEntry, groupId,
5318                                            status, orderByComparator, false);
5319    
5320                            return array;
5321                    }
5322                    catch (Exception e) {
5323                            throw processException(e);
5324                    }
5325                    finally {
5326                            closeSession(session);
5327                    }
5328            }
5329    
5330            protected BlogsEntry getByG_NotS_PrevAndNext(Session session,
5331                    BlogsEntry blogsEntry, long groupId, int status,
5332                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
5333                    StringBundler query = null;
5334    
5335                    if (orderByComparator != null) {
5336                            query = new StringBundler(6 +
5337                                            (orderByComparator.getOrderByFields().length * 6));
5338                    }
5339                    else {
5340                            query = new StringBundler(3);
5341                    }
5342    
5343                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
5344    
5345                    query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
5346    
5347                    query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
5348    
5349                    if (orderByComparator != null) {
5350                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5351    
5352                            if (orderByConditionFields.length > 0) {
5353                                    query.append(WHERE_AND);
5354                            }
5355    
5356                            for (int i = 0; i < orderByConditionFields.length; i++) {
5357                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5358                                    query.append(orderByConditionFields[i]);
5359    
5360                                    if ((i + 1) < orderByConditionFields.length) {
5361                                            if (orderByComparator.isAscending() ^ previous) {
5362                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5363                                            }
5364                                            else {
5365                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5366                                            }
5367                                    }
5368                                    else {
5369                                            if (orderByComparator.isAscending() ^ previous) {
5370                                                    query.append(WHERE_GREATER_THAN);
5371                                            }
5372                                            else {
5373                                                    query.append(WHERE_LESSER_THAN);
5374                                            }
5375                                    }
5376                            }
5377    
5378                            query.append(ORDER_BY_CLAUSE);
5379    
5380                            String[] orderByFields = orderByComparator.getOrderByFields();
5381    
5382                            for (int i = 0; i < orderByFields.length; i++) {
5383                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5384                                    query.append(orderByFields[i]);
5385    
5386                                    if ((i + 1) < orderByFields.length) {
5387                                            if (orderByComparator.isAscending() ^ previous) {
5388                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5389                                            }
5390                                            else {
5391                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5392                                            }
5393                                    }
5394                                    else {
5395                                            if (orderByComparator.isAscending() ^ previous) {
5396                                                    query.append(ORDER_BY_ASC);
5397                                            }
5398                                            else {
5399                                                    query.append(ORDER_BY_DESC);
5400                                            }
5401                                    }
5402                            }
5403                    }
5404                    else {
5405                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
5406                    }
5407    
5408                    String sql = query.toString();
5409    
5410                    Query q = session.createQuery(sql);
5411    
5412                    q.setFirstResult(0);
5413                    q.setMaxResults(2);
5414    
5415                    QueryPos qPos = QueryPos.getInstance(q);
5416    
5417                    qPos.add(groupId);
5418    
5419                    qPos.add(status);
5420    
5421                    if (orderByComparator != null) {
5422                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
5423    
5424                            for (Object value : values) {
5425                                    qPos.add(value);
5426                            }
5427                    }
5428    
5429                    List<BlogsEntry> list = q.list();
5430    
5431                    if (list.size() == 2) {
5432                            return list.get(1);
5433                    }
5434                    else {
5435                            return null;
5436                    }
5437            }
5438    
5439            /**
5440             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and status &ne; &#63;.
5441             *
5442             * @param groupId the group ID
5443             * @param status the status
5444             * @return the matching blogs entries that the user has permission to view
5445             */
5446            @Override
5447            public List<BlogsEntry> filterFindByG_NotS(long groupId, int status) {
5448                    return filterFindByG_NotS(groupId, status, QueryUtil.ALL_POS,
5449                            QueryUtil.ALL_POS, null);
5450            }
5451    
5452            /**
5453             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63; and status &ne; &#63;.
5454             *
5455             * <p>
5456             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
5457             * </p>
5458             *
5459             * @param groupId the group ID
5460             * @param status the status
5461             * @param start the lower bound of the range of blogs entries
5462             * @param end the upper bound of the range of blogs entries (not inclusive)
5463             * @return the range of matching blogs entries that the user has permission to view
5464             */
5465            @Override
5466            public List<BlogsEntry> filterFindByG_NotS(long groupId, int status,
5467                    int start, int end) {
5468                    return filterFindByG_NotS(groupId, status, start, end, null);
5469            }
5470    
5471            /**
5472             * Returns an ordered range of all the blogs entries that the user has permissions to view where groupId = &#63; and status &ne; &#63;.
5473             *
5474             * <p>
5475             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
5476             * </p>
5477             *
5478             * @param groupId the group ID
5479             * @param status the status
5480             * @param start the lower bound of the range of blogs entries
5481             * @param end the upper bound of the range of blogs entries (not inclusive)
5482             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5483             * @return the ordered range of matching blogs entries that the user has permission to view
5484             */
5485            @Override
5486            public List<BlogsEntry> filterFindByG_NotS(long groupId, int status,
5487                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator) {
5488                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5489                            return findByG_NotS(groupId, status, start, end, orderByComparator);
5490                    }
5491    
5492                    StringBundler query = null;
5493    
5494                    if (orderByComparator != null) {
5495                            query = new StringBundler(4 +
5496                                            (orderByComparator.getOrderByFields().length * 3));
5497                    }
5498                    else {
5499                            query = new StringBundler(4);
5500                    }
5501    
5502                    if (getDB().isSupportsInlineDistinct()) {
5503                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
5504                    }
5505                    else {
5506                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
5507                    }
5508    
5509                    query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
5510    
5511                    query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
5512    
5513                    if (!getDB().isSupportsInlineDistinct()) {
5514                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
5515                    }
5516    
5517                    if (orderByComparator != null) {
5518                            if (getDB().isSupportsInlineDistinct()) {
5519                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5520                                            orderByComparator, true);
5521                            }
5522                            else {
5523                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
5524                                            orderByComparator, true);
5525                            }
5526                    }
5527                    else {
5528                            if (getDB().isSupportsInlineDistinct()) {
5529                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
5530                            }
5531                            else {
5532                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
5533                            }
5534                    }
5535    
5536                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5537                                    BlogsEntry.class.getName(),
5538                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5539    
5540                    Session session = null;
5541    
5542                    try {
5543                            session = openSession();
5544    
5545                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
5546    
5547                            if (getDB().isSupportsInlineDistinct()) {
5548                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
5549                            }
5550                            else {
5551                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
5552                            }
5553    
5554                            QueryPos qPos = QueryPos.getInstance(q);
5555    
5556                            qPos.add(groupId);
5557    
5558                            qPos.add(status);
5559    
5560                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
5561                    }
5562                    catch (Exception e) {
5563                            throw processException(e);
5564                    }
5565                    finally {
5566                            closeSession(session);
5567                    }
5568            }
5569    
5570            /**
5571             * 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;.
5572             *
5573             * @param entryId the primary key of the current blogs entry
5574             * @param groupId the group ID
5575             * @param status the status
5576             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5577             * @return the previous, current, and next blogs entry
5578             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
5579             */
5580            @Override
5581            public BlogsEntry[] filterFindByG_NotS_PrevAndNext(long entryId,
5582                    long groupId, int status,
5583                    OrderByComparator<BlogsEntry> orderByComparator)
5584                    throws NoSuchEntryException {
5585                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5586                            return findByG_NotS_PrevAndNext(entryId, groupId, status,
5587                                    orderByComparator);
5588                    }
5589    
5590                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
5591    
5592                    Session session = null;
5593    
5594                    try {
5595                            session = openSession();
5596    
5597                            BlogsEntry[] array = new BlogsEntryImpl[3];
5598    
5599                            array[0] = filterGetByG_NotS_PrevAndNext(session, blogsEntry,
5600                                            groupId, status, orderByComparator, true);
5601    
5602                            array[1] = blogsEntry;
5603    
5604                            array[2] = filterGetByG_NotS_PrevAndNext(session, blogsEntry,
5605                                            groupId, status, orderByComparator, false);
5606    
5607                            return array;
5608                    }
5609                    catch (Exception e) {
5610                            throw processException(e);
5611                    }
5612                    finally {
5613                            closeSession(session);
5614                    }
5615            }
5616    
5617            protected BlogsEntry filterGetByG_NotS_PrevAndNext(Session session,
5618                    BlogsEntry blogsEntry, long groupId, int status,
5619                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
5620                    StringBundler query = null;
5621    
5622                    if (orderByComparator != null) {
5623                            query = new StringBundler(6 +
5624                                            (orderByComparator.getOrderByFields().length * 6));
5625                    }
5626                    else {
5627                            query = new StringBundler(3);
5628                    }
5629    
5630                    if (getDB().isSupportsInlineDistinct()) {
5631                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
5632                    }
5633                    else {
5634                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
5635                    }
5636    
5637                    query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
5638    
5639                    query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
5640    
5641                    if (!getDB().isSupportsInlineDistinct()) {
5642                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
5643                    }
5644    
5645                    if (orderByComparator != null) {
5646                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5647    
5648                            if (orderByConditionFields.length > 0) {
5649                                    query.append(WHERE_AND);
5650                            }
5651    
5652                            for (int i = 0; i < orderByConditionFields.length; i++) {
5653                                    if (getDB().isSupportsInlineDistinct()) {
5654                                            query.append(_ORDER_BY_ENTITY_ALIAS);
5655                                    }
5656                                    else {
5657                                            query.append(_ORDER_BY_ENTITY_TABLE);
5658                                    }
5659    
5660                                    query.append(orderByConditionFields[i]);
5661    
5662                                    if ((i + 1) < orderByConditionFields.length) {
5663                                            if (orderByComparator.isAscending() ^ previous) {
5664                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5665                                            }
5666                                            else {
5667                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5668                                            }
5669                                    }
5670                                    else {
5671                                            if (orderByComparator.isAscending() ^ previous) {
5672                                                    query.append(WHERE_GREATER_THAN);
5673                                            }
5674                                            else {
5675                                                    query.append(WHERE_LESSER_THAN);
5676                                            }
5677                                    }
5678                            }
5679    
5680                            query.append(ORDER_BY_CLAUSE);
5681    
5682                            String[] orderByFields = orderByComparator.getOrderByFields();
5683    
5684                            for (int i = 0; i < orderByFields.length; i++) {
5685                                    if (getDB().isSupportsInlineDistinct()) {
5686                                            query.append(_ORDER_BY_ENTITY_ALIAS);
5687                                    }
5688                                    else {
5689                                            query.append(_ORDER_BY_ENTITY_TABLE);
5690                                    }
5691    
5692                                    query.append(orderByFields[i]);
5693    
5694                                    if ((i + 1) < orderByFields.length) {
5695                                            if (orderByComparator.isAscending() ^ previous) {
5696                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5697                                            }
5698                                            else {
5699                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5700                                            }
5701                                    }
5702                                    else {
5703                                            if (orderByComparator.isAscending() ^ previous) {
5704                                                    query.append(ORDER_BY_ASC);
5705                                            }
5706                                            else {
5707                                                    query.append(ORDER_BY_DESC);
5708                                            }
5709                                    }
5710                            }
5711                    }
5712                    else {
5713                            if (getDB().isSupportsInlineDistinct()) {
5714                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
5715                            }
5716                            else {
5717                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
5718                            }
5719                    }
5720    
5721                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5722                                    BlogsEntry.class.getName(),
5723                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5724    
5725                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
5726    
5727                    q.setFirstResult(0);
5728                    q.setMaxResults(2);
5729    
5730                    if (getDB().isSupportsInlineDistinct()) {
5731                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
5732                    }
5733                    else {
5734                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
5735                    }
5736    
5737                    QueryPos qPos = QueryPos.getInstance(q);
5738    
5739                    qPos.add(groupId);
5740    
5741                    qPos.add(status);
5742    
5743                    if (orderByComparator != null) {
5744                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
5745    
5746                            for (Object value : values) {
5747                                    qPos.add(value);
5748                            }
5749                    }
5750    
5751                    List<BlogsEntry> list = q.list();
5752    
5753                    if (list.size() == 2) {
5754                            return list.get(1);
5755                    }
5756                    else {
5757                            return null;
5758                    }
5759            }
5760    
5761            /**
5762             * Removes all the blogs entries where groupId = &#63; and status &ne; &#63; from the database.
5763             *
5764             * @param groupId the group ID
5765             * @param status the status
5766             */
5767            @Override
5768            public void removeByG_NotS(long groupId, int status) {
5769                    for (BlogsEntry blogsEntry : findByG_NotS(groupId, status,
5770                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
5771                            remove(blogsEntry);
5772                    }
5773            }
5774    
5775            /**
5776             * Returns the number of blogs entries where groupId = &#63; and status &ne; &#63;.
5777             *
5778             * @param groupId the group ID
5779             * @param status the status
5780             * @return the number of matching blogs entries
5781             */
5782            @Override
5783            public int countByG_NotS(long groupId, int status) {
5784                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_NOTS;
5785    
5786                    Object[] finderArgs = new Object[] { groupId, status };
5787    
5788                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
5789    
5790                    if (count == null) {
5791                            StringBundler query = new StringBundler(3);
5792    
5793                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
5794    
5795                            query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
5796    
5797                            query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
5798    
5799                            String sql = query.toString();
5800    
5801                            Session session = null;
5802    
5803                            try {
5804                                    session = openSession();
5805    
5806                                    Query q = session.createQuery(sql);
5807    
5808                                    QueryPos qPos = QueryPos.getInstance(q);
5809    
5810                                    qPos.add(groupId);
5811    
5812                                    qPos.add(status);
5813    
5814                                    count = (Long)q.uniqueResult();
5815    
5816                                    finderCache.putResult(finderPath, finderArgs, count);
5817                            }
5818                            catch (Exception e) {
5819                                    finderCache.removeResult(finderPath, finderArgs);
5820    
5821                                    throw processException(e);
5822                            }
5823                            finally {
5824                                    closeSession(session);
5825                            }
5826                    }
5827    
5828                    return count.intValue();
5829            }
5830    
5831            /**
5832             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and status &ne; &#63;.
5833             *
5834             * @param groupId the group ID
5835             * @param status the status
5836             * @return the number of matching blogs entries that the user has permission to view
5837             */
5838            @Override
5839            public int filterCountByG_NotS(long groupId, int status) {
5840                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5841                            return countByG_NotS(groupId, status);
5842                    }
5843    
5844                    StringBundler query = new StringBundler(3);
5845    
5846                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
5847    
5848                    query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
5849    
5850                    query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
5851    
5852                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5853                                    BlogsEntry.class.getName(),
5854                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5855    
5856                    Session session = null;
5857    
5858                    try {
5859                            session = openSession();
5860    
5861                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
5862    
5863                            q.addScalar(COUNT_COLUMN_NAME,
5864                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
5865    
5866                            QueryPos qPos = QueryPos.getInstance(q);
5867    
5868                            qPos.add(groupId);
5869    
5870                            qPos.add(status);
5871    
5872                            Long count = (Long)q.uniqueResult();
5873    
5874                            return count.intValue();
5875                    }
5876                    catch (Exception e) {
5877                            throw processException(e);
5878                    }
5879                    finally {
5880                            closeSession(session);
5881                    }
5882            }
5883    
5884            private static final String _FINDER_COLUMN_G_NOTS_GROUPID_2 = "blogsEntry.groupId = ? AND ";
5885            private static final String _FINDER_COLUMN_G_NOTS_STATUS_2 = "blogsEntry.status != ?";
5886            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
5887                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
5888                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_U",
5889                            new String[] {
5890                                    Long.class.getName(), Long.class.getName(),
5891                                    
5892                            Integer.class.getName(), Integer.class.getName(),
5893                                    OrderByComparator.class.getName()
5894                            });
5895            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
5896                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
5897                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_U",
5898                            new String[] { Long.class.getName(), Long.class.getName() },
5899                            BlogsEntryModelImpl.COMPANYID_COLUMN_BITMASK |
5900                            BlogsEntryModelImpl.USERID_COLUMN_BITMASK |
5901                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
5902                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
5903            public static final FinderPath FINDER_PATH_COUNT_BY_C_U = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
5904                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
5905                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_U",
5906                            new String[] { Long.class.getName(), Long.class.getName() });
5907    
5908            /**
5909             * Returns all the blogs entries where companyId = &#63; and userId = &#63;.
5910             *
5911             * @param companyId the company ID
5912             * @param userId the user ID
5913             * @return the matching blogs entries
5914             */
5915            @Override
5916            public List<BlogsEntry> findByC_U(long companyId, long userId) {
5917                    return findByC_U(companyId, userId, QueryUtil.ALL_POS,
5918                            QueryUtil.ALL_POS, null);
5919            }
5920    
5921            /**
5922             * Returns a range of all the blogs entries where companyId = &#63; and userId = &#63;.
5923             *
5924             * <p>
5925             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
5926             * </p>
5927             *
5928             * @param companyId the company ID
5929             * @param userId the user ID
5930             * @param start the lower bound of the range of blogs entries
5931             * @param end the upper bound of the range of blogs entries (not inclusive)
5932             * @return the range of matching blogs entries
5933             */
5934            @Override
5935            public List<BlogsEntry> findByC_U(long companyId, long userId, int start,
5936                    int end) {
5937                    return findByC_U(companyId, userId, start, end, null);
5938            }
5939    
5940            /**
5941             * Returns an ordered range of all the blogs entries where companyId = &#63; and userId = &#63;.
5942             *
5943             * <p>
5944             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
5945             * </p>
5946             *
5947             * @param companyId the company ID
5948             * @param userId the user ID
5949             * @param start the lower bound of the range of blogs entries
5950             * @param end the upper bound of the range of blogs entries (not inclusive)
5951             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5952             * @return the ordered range of matching blogs entries
5953             */
5954            @Override
5955            public List<BlogsEntry> findByC_U(long companyId, long userId, int start,
5956                    int end, OrderByComparator<BlogsEntry> orderByComparator) {
5957                    return findByC_U(companyId, userId, start, end, orderByComparator, true);
5958            }
5959    
5960            /**
5961             * Returns an ordered range of all the blogs entries where companyId = &#63; and userId = &#63;.
5962             *
5963             * <p>
5964             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
5965             * </p>
5966             *
5967             * @param companyId the company ID
5968             * @param userId the user ID
5969             * @param start the lower bound of the range of blogs entries
5970             * @param end the upper bound of the range of blogs entries (not inclusive)
5971             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5972             * @param retrieveFromCache whether to retrieve from the finder cache
5973             * @return the ordered range of matching blogs entries
5974             */
5975            @Override
5976            public List<BlogsEntry> findByC_U(long companyId, long userId, int start,
5977                    int end, OrderByComparator<BlogsEntry> orderByComparator,
5978                    boolean retrieveFromCache) {
5979                    boolean pagination = true;
5980                    FinderPath finderPath = null;
5981                    Object[] finderArgs = null;
5982    
5983                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5984                                    (orderByComparator == null)) {
5985                            pagination = false;
5986                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U;
5987                            finderArgs = new Object[] { companyId, userId };
5988                    }
5989                    else {
5990                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U;
5991                            finderArgs = new Object[] {
5992                                            companyId, userId,
5993                                            
5994                                            start, end, orderByComparator
5995                                    };
5996                    }
5997    
5998                    List<BlogsEntry> list = null;
5999    
6000                    if (retrieveFromCache) {
6001                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
6002                                            finderArgs, this);
6003    
6004                            if ((list != null) && !list.isEmpty()) {
6005                                    for (BlogsEntry blogsEntry : list) {
6006                                            if ((companyId != blogsEntry.getCompanyId()) ||
6007                                                            (userId != blogsEntry.getUserId())) {
6008                                                    list = null;
6009    
6010                                                    break;
6011                                            }
6012                                    }
6013                            }
6014                    }
6015    
6016                    if (list == null) {
6017                            StringBundler query = null;
6018    
6019                            if (orderByComparator != null) {
6020                                    query = new StringBundler(4 +
6021                                                    (orderByComparator.getOrderByFields().length * 3));
6022                            }
6023                            else {
6024                                    query = new StringBundler(4);
6025                            }
6026    
6027                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
6028    
6029                            query.append(_FINDER_COLUMN_C_U_COMPANYID_2);
6030    
6031                            query.append(_FINDER_COLUMN_C_U_USERID_2);
6032    
6033                            if (orderByComparator != null) {
6034                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6035                                            orderByComparator);
6036                            }
6037                            else
6038                             if (pagination) {
6039                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
6040                            }
6041    
6042                            String sql = query.toString();
6043    
6044                            Session session = null;
6045    
6046                            try {
6047                                    session = openSession();
6048    
6049                                    Query q = session.createQuery(sql);
6050    
6051                                    QueryPos qPos = QueryPos.getInstance(q);
6052    
6053                                    qPos.add(companyId);
6054    
6055                                    qPos.add(userId);
6056    
6057                                    if (!pagination) {
6058                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
6059                                                            start, end, false);
6060    
6061                                            Collections.sort(list);
6062    
6063                                            list = Collections.unmodifiableList(list);
6064                                    }
6065                                    else {
6066                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
6067                                                            start, end);
6068                                    }
6069    
6070                                    cacheResult(list);
6071    
6072                                    finderCache.putResult(finderPath, finderArgs, list);
6073                            }
6074                            catch (Exception e) {
6075                                    finderCache.removeResult(finderPath, finderArgs);
6076    
6077                                    throw processException(e);
6078                            }
6079                            finally {
6080                                    closeSession(session);
6081                            }
6082                    }
6083    
6084                    return list;
6085            }
6086    
6087            /**
6088             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63;.
6089             *
6090             * @param companyId the company ID
6091             * @param userId the user ID
6092             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6093             * @return the first matching blogs entry
6094             * @throws NoSuchEntryException if a matching blogs entry could not be found
6095             */
6096            @Override
6097            public BlogsEntry findByC_U_First(long companyId, long userId,
6098                    OrderByComparator<BlogsEntry> orderByComparator)
6099                    throws NoSuchEntryException {
6100                    BlogsEntry blogsEntry = fetchByC_U_First(companyId, userId,
6101                                    orderByComparator);
6102    
6103                    if (blogsEntry != null) {
6104                            return blogsEntry;
6105                    }
6106    
6107                    StringBundler msg = new StringBundler(6);
6108    
6109                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6110    
6111                    msg.append("companyId=");
6112                    msg.append(companyId);
6113    
6114                    msg.append(", userId=");
6115                    msg.append(userId);
6116    
6117                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6118    
6119                    throw new NoSuchEntryException(msg.toString());
6120            }
6121    
6122            /**
6123             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63;.
6124             *
6125             * @param companyId the company ID
6126             * @param userId the user ID
6127             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6128             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
6129             */
6130            @Override
6131            public BlogsEntry fetchByC_U_First(long companyId, long userId,
6132                    OrderByComparator<BlogsEntry> orderByComparator) {
6133                    List<BlogsEntry> list = findByC_U(companyId, userId, 0, 1,
6134                                    orderByComparator);
6135    
6136                    if (!list.isEmpty()) {
6137                            return list.get(0);
6138                    }
6139    
6140                    return null;
6141            }
6142    
6143            /**
6144             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63;.
6145             *
6146             * @param companyId the company ID
6147             * @param userId the user ID
6148             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6149             * @return the last matching blogs entry
6150             * @throws NoSuchEntryException if a matching blogs entry could not be found
6151             */
6152            @Override
6153            public BlogsEntry findByC_U_Last(long companyId, long userId,
6154                    OrderByComparator<BlogsEntry> orderByComparator)
6155                    throws NoSuchEntryException {
6156                    BlogsEntry blogsEntry = fetchByC_U_Last(companyId, userId,
6157                                    orderByComparator);
6158    
6159                    if (blogsEntry != null) {
6160                            return blogsEntry;
6161                    }
6162    
6163                    StringBundler msg = new StringBundler(6);
6164    
6165                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6166    
6167                    msg.append("companyId=");
6168                    msg.append(companyId);
6169    
6170                    msg.append(", userId=");
6171                    msg.append(userId);
6172    
6173                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6174    
6175                    throw new NoSuchEntryException(msg.toString());
6176            }
6177    
6178            /**
6179             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63;.
6180             *
6181             * @param companyId the company ID
6182             * @param userId the user ID
6183             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6184             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
6185             */
6186            @Override
6187            public BlogsEntry fetchByC_U_Last(long companyId, long userId,
6188                    OrderByComparator<BlogsEntry> orderByComparator) {
6189                    int count = countByC_U(companyId, userId);
6190    
6191                    if (count == 0) {
6192                            return null;
6193                    }
6194    
6195                    List<BlogsEntry> list = findByC_U(companyId, userId, count - 1, count,
6196                                    orderByComparator);
6197    
6198                    if (!list.isEmpty()) {
6199                            return list.get(0);
6200                    }
6201    
6202                    return null;
6203            }
6204    
6205            /**
6206             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63; and userId = &#63;.
6207             *
6208             * @param entryId the primary key of the current blogs entry
6209             * @param companyId the company ID
6210             * @param userId the user ID
6211             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6212             * @return the previous, current, and next blogs entry
6213             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
6214             */
6215            @Override
6216            public BlogsEntry[] findByC_U_PrevAndNext(long entryId, long companyId,
6217                    long userId, OrderByComparator<BlogsEntry> orderByComparator)
6218                    throws NoSuchEntryException {
6219                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
6220    
6221                    Session session = null;
6222    
6223                    try {
6224                            session = openSession();
6225    
6226                            BlogsEntry[] array = new BlogsEntryImpl[3];
6227    
6228                            array[0] = getByC_U_PrevAndNext(session, blogsEntry, companyId,
6229                                            userId, orderByComparator, true);
6230    
6231                            array[1] = blogsEntry;
6232    
6233                            array[2] = getByC_U_PrevAndNext(session, blogsEntry, companyId,
6234                                            userId, orderByComparator, false);
6235    
6236                            return array;
6237                    }
6238                    catch (Exception e) {
6239                            throw processException(e);
6240                    }
6241                    finally {
6242                            closeSession(session);
6243                    }
6244            }
6245    
6246            protected BlogsEntry getByC_U_PrevAndNext(Session session,
6247                    BlogsEntry blogsEntry, long companyId, long userId,
6248                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
6249                    StringBundler query = null;
6250    
6251                    if (orderByComparator != null) {
6252                            query = new StringBundler(6 +
6253                                            (orderByComparator.getOrderByFields().length * 6));
6254                    }
6255                    else {
6256                            query = new StringBundler(3);
6257                    }
6258    
6259                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
6260    
6261                    query.append(_FINDER_COLUMN_C_U_COMPANYID_2);
6262    
6263                    query.append(_FINDER_COLUMN_C_U_USERID_2);
6264    
6265                    if (orderByComparator != null) {
6266                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6267    
6268                            if (orderByConditionFields.length > 0) {
6269                                    query.append(WHERE_AND);
6270                            }
6271    
6272                            for (int i = 0; i < orderByConditionFields.length; i++) {
6273                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6274                                    query.append(orderByConditionFields[i]);
6275    
6276                                    if ((i + 1) < orderByConditionFields.length) {
6277                                            if (orderByComparator.isAscending() ^ previous) {
6278                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6279                                            }
6280                                            else {
6281                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6282                                            }
6283                                    }
6284                                    else {
6285                                            if (orderByComparator.isAscending() ^ previous) {
6286                                                    query.append(WHERE_GREATER_THAN);
6287                                            }
6288                                            else {
6289                                                    query.append(WHERE_LESSER_THAN);
6290                                            }
6291                                    }
6292                            }
6293    
6294                            query.append(ORDER_BY_CLAUSE);
6295    
6296                            String[] orderByFields = orderByComparator.getOrderByFields();
6297    
6298                            for (int i = 0; i < orderByFields.length; i++) {
6299                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6300                                    query.append(orderByFields[i]);
6301    
6302                                    if ((i + 1) < orderByFields.length) {
6303                                            if (orderByComparator.isAscending() ^ previous) {
6304                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6305                                            }
6306                                            else {
6307                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6308                                            }
6309                                    }
6310                                    else {
6311                                            if (orderByComparator.isAscending() ^ previous) {
6312                                                    query.append(ORDER_BY_ASC);
6313                                            }
6314                                            else {
6315                                                    query.append(ORDER_BY_DESC);
6316                                            }
6317                                    }
6318                            }
6319                    }
6320                    else {
6321                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
6322                    }
6323    
6324                    String sql = query.toString();
6325    
6326                    Query q = session.createQuery(sql);
6327    
6328                    q.setFirstResult(0);
6329                    q.setMaxResults(2);
6330    
6331                    QueryPos qPos = QueryPos.getInstance(q);
6332    
6333                    qPos.add(companyId);
6334    
6335                    qPos.add(userId);
6336    
6337                    if (orderByComparator != null) {
6338                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
6339    
6340                            for (Object value : values) {
6341                                    qPos.add(value);
6342                            }
6343                    }
6344    
6345                    List<BlogsEntry> list = q.list();
6346    
6347                    if (list.size() == 2) {
6348                            return list.get(1);
6349                    }
6350                    else {
6351                            return null;
6352                    }
6353            }
6354    
6355            /**
6356             * Removes all the blogs entries where companyId = &#63; and userId = &#63; from the database.
6357             *
6358             * @param companyId the company ID
6359             * @param userId the user ID
6360             */
6361            @Override
6362            public void removeByC_U(long companyId, long userId) {
6363                    for (BlogsEntry blogsEntry : findByC_U(companyId, userId,
6364                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
6365                            remove(blogsEntry);
6366                    }
6367            }
6368    
6369            /**
6370             * Returns the number of blogs entries where companyId = &#63; and userId = &#63;.
6371             *
6372             * @param companyId the company ID
6373             * @param userId the user ID
6374             * @return the number of matching blogs entries
6375             */
6376            @Override
6377            public int countByC_U(long companyId, long userId) {
6378                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_U;
6379    
6380                    Object[] finderArgs = new Object[] { companyId, userId };
6381    
6382                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
6383    
6384                    if (count == null) {
6385                            StringBundler query = new StringBundler(3);
6386    
6387                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
6388    
6389                            query.append(_FINDER_COLUMN_C_U_COMPANYID_2);
6390    
6391                            query.append(_FINDER_COLUMN_C_U_USERID_2);
6392    
6393                            String sql = query.toString();
6394    
6395                            Session session = null;
6396    
6397                            try {
6398                                    session = openSession();
6399    
6400                                    Query q = session.createQuery(sql);
6401    
6402                                    QueryPos qPos = QueryPos.getInstance(q);
6403    
6404                                    qPos.add(companyId);
6405    
6406                                    qPos.add(userId);
6407    
6408                                    count = (Long)q.uniqueResult();
6409    
6410                                    finderCache.putResult(finderPath, finderArgs, count);
6411                            }
6412                            catch (Exception e) {
6413                                    finderCache.removeResult(finderPath, finderArgs);
6414    
6415                                    throw processException(e);
6416                            }
6417                            finally {
6418                                    closeSession(session);
6419                            }
6420                    }
6421    
6422                    return count.intValue();
6423            }
6424    
6425            private static final String _FINDER_COLUMN_C_U_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
6426            private static final String _FINDER_COLUMN_C_U_USERID_2 = "blogsEntry.userId = ?";
6427            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
6428                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
6429                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_LtD",
6430                            new String[] {
6431                                    Long.class.getName(), Date.class.getName(),
6432                                    
6433                            Integer.class.getName(), Integer.class.getName(),
6434                                    OrderByComparator.class.getName()
6435                            });
6436            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
6437                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
6438                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_LtD",
6439                            new String[] { Long.class.getName(), Date.class.getName() });
6440    
6441            /**
6442             * Returns all the blogs entries where companyId = &#63; and displayDate &lt; &#63;.
6443             *
6444             * @param companyId the company ID
6445             * @param displayDate the display date
6446             * @return the matching blogs entries
6447             */
6448            @Override
6449            public List<BlogsEntry> findByC_LtD(long companyId, Date displayDate) {
6450                    return findByC_LtD(companyId, displayDate, QueryUtil.ALL_POS,
6451                            QueryUtil.ALL_POS, null);
6452            }
6453    
6454            /**
6455             * Returns a range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63;.
6456             *
6457             * <p>
6458             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
6459             * </p>
6460             *
6461             * @param companyId the company ID
6462             * @param displayDate the display date
6463             * @param start the lower bound of the range of blogs entries
6464             * @param end the upper bound of the range of blogs entries (not inclusive)
6465             * @return the range of matching blogs entries
6466             */
6467            @Override
6468            public List<BlogsEntry> findByC_LtD(long companyId, Date displayDate,
6469                    int start, int end) {
6470                    return findByC_LtD(companyId, displayDate, start, end, null);
6471            }
6472    
6473            /**
6474             * Returns an ordered range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63;.
6475             *
6476             * <p>
6477             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
6478             * </p>
6479             *
6480             * @param companyId the company ID
6481             * @param displayDate the display date
6482             * @param start the lower bound of the range of blogs entries
6483             * @param end the upper bound of the range of blogs entries (not inclusive)
6484             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6485             * @return the ordered range of matching blogs entries
6486             */
6487            @Override
6488            public List<BlogsEntry> findByC_LtD(long companyId, Date displayDate,
6489                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator) {
6490                    return findByC_LtD(companyId, displayDate, start, end,
6491                            orderByComparator, true);
6492            }
6493    
6494            /**
6495             * Returns an ordered range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63;.
6496             *
6497             * <p>
6498             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
6499             * </p>
6500             *
6501             * @param companyId the company ID
6502             * @param displayDate the display date
6503             * @param start the lower bound of the range of blogs entries
6504             * @param end the upper bound of the range of blogs entries (not inclusive)
6505             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6506             * @param retrieveFromCache whether to retrieve from the finder cache
6507             * @return the ordered range of matching blogs entries
6508             */
6509            @Override
6510            public List<BlogsEntry> findByC_LtD(long companyId, Date displayDate,
6511                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator,
6512                    boolean retrieveFromCache) {
6513                    boolean pagination = true;
6514                    FinderPath finderPath = null;
6515                    Object[] finderArgs = null;
6516    
6517                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD;
6518                    finderArgs = new Object[] {
6519                                    companyId, displayDate,
6520                                    
6521                                    start, end, orderByComparator
6522                            };
6523    
6524                    List<BlogsEntry> list = null;
6525    
6526                    if (retrieveFromCache) {
6527                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
6528                                            finderArgs, this);
6529    
6530                            if ((list != null) && !list.isEmpty()) {
6531                                    for (BlogsEntry blogsEntry : list) {
6532                                            if ((companyId != blogsEntry.getCompanyId()) ||
6533                                                            (displayDate.getTime() <= blogsEntry.getDisplayDate()
6534                                                                                                                                            .getTime())) {
6535                                                    list = null;
6536    
6537                                                    break;
6538                                            }
6539                                    }
6540                            }
6541                    }
6542    
6543                    if (list == null) {
6544                            StringBundler query = null;
6545    
6546                            if (orderByComparator != null) {
6547                                    query = new StringBundler(4 +
6548                                                    (orderByComparator.getOrderByFields().length * 3));
6549                            }
6550                            else {
6551                                    query = new StringBundler(4);
6552                            }
6553    
6554                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
6555    
6556                            query.append(_FINDER_COLUMN_C_LTD_COMPANYID_2);
6557    
6558                            boolean bindDisplayDate = false;
6559    
6560                            if (displayDate == null) {
6561                                    query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_1);
6562                            }
6563                            else {
6564                                    bindDisplayDate = true;
6565    
6566                                    query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_2);
6567                            }
6568    
6569                            if (orderByComparator != null) {
6570                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6571                                            orderByComparator);
6572                            }
6573                            else
6574                             if (pagination) {
6575                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
6576                            }
6577    
6578                            String sql = query.toString();
6579    
6580                            Session session = null;
6581    
6582                            try {
6583                                    session = openSession();
6584    
6585                                    Query q = session.createQuery(sql);
6586    
6587                                    QueryPos qPos = QueryPos.getInstance(q);
6588    
6589                                    qPos.add(companyId);
6590    
6591                                    if (bindDisplayDate) {
6592                                            qPos.add(new Timestamp(displayDate.getTime()));
6593                                    }
6594    
6595                                    if (!pagination) {
6596                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
6597                                                            start, end, false);
6598    
6599                                            Collections.sort(list);
6600    
6601                                            list = Collections.unmodifiableList(list);
6602                                    }
6603                                    else {
6604                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
6605                                                            start, end);
6606                                    }
6607    
6608                                    cacheResult(list);
6609    
6610                                    finderCache.putResult(finderPath, finderArgs, list);
6611                            }
6612                            catch (Exception e) {
6613                                    finderCache.removeResult(finderPath, finderArgs);
6614    
6615                                    throw processException(e);
6616                            }
6617                            finally {
6618                                    closeSession(session);
6619                            }
6620                    }
6621    
6622                    return list;
6623            }
6624    
6625            /**
6626             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63;.
6627             *
6628             * @param companyId the company ID
6629             * @param displayDate the display date
6630             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6631             * @return the first matching blogs entry
6632             * @throws NoSuchEntryException if a matching blogs entry could not be found
6633             */
6634            @Override
6635            public BlogsEntry findByC_LtD_First(long companyId, Date displayDate,
6636                    OrderByComparator<BlogsEntry> orderByComparator)
6637                    throws NoSuchEntryException {
6638                    BlogsEntry blogsEntry = fetchByC_LtD_First(companyId, displayDate,
6639                                    orderByComparator);
6640    
6641                    if (blogsEntry != null) {
6642                            return blogsEntry;
6643                    }
6644    
6645                    StringBundler msg = new StringBundler(6);
6646    
6647                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6648    
6649                    msg.append("companyId=");
6650                    msg.append(companyId);
6651    
6652                    msg.append(", displayDate=");
6653                    msg.append(displayDate);
6654    
6655                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6656    
6657                    throw new NoSuchEntryException(msg.toString());
6658            }
6659    
6660            /**
6661             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63;.
6662             *
6663             * @param companyId the company ID
6664             * @param displayDate the display date
6665             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6666             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
6667             */
6668            @Override
6669            public BlogsEntry fetchByC_LtD_First(long companyId, Date displayDate,
6670                    OrderByComparator<BlogsEntry> orderByComparator) {
6671                    List<BlogsEntry> list = findByC_LtD(companyId, displayDate, 0, 1,
6672                                    orderByComparator);
6673    
6674                    if (!list.isEmpty()) {
6675                            return list.get(0);
6676                    }
6677    
6678                    return null;
6679            }
6680    
6681            /**
6682             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63;.
6683             *
6684             * @param companyId the company ID
6685             * @param displayDate the display date
6686             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6687             * @return the last matching blogs entry
6688             * @throws NoSuchEntryException if a matching blogs entry could not be found
6689             */
6690            @Override
6691            public BlogsEntry findByC_LtD_Last(long companyId, Date displayDate,
6692                    OrderByComparator<BlogsEntry> orderByComparator)
6693                    throws NoSuchEntryException {
6694                    BlogsEntry blogsEntry = fetchByC_LtD_Last(companyId, displayDate,
6695                                    orderByComparator);
6696    
6697                    if (blogsEntry != null) {
6698                            return blogsEntry;
6699                    }
6700    
6701                    StringBundler msg = new StringBundler(6);
6702    
6703                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6704    
6705                    msg.append("companyId=");
6706                    msg.append(companyId);
6707    
6708                    msg.append(", displayDate=");
6709                    msg.append(displayDate);
6710    
6711                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6712    
6713                    throw new NoSuchEntryException(msg.toString());
6714            }
6715    
6716            /**
6717             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63;.
6718             *
6719             * @param companyId the company ID
6720             * @param displayDate the display date
6721             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6722             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
6723             */
6724            @Override
6725            public BlogsEntry fetchByC_LtD_Last(long companyId, Date displayDate,
6726                    OrderByComparator<BlogsEntry> orderByComparator) {
6727                    int count = countByC_LtD(companyId, displayDate);
6728    
6729                    if (count == 0) {
6730                            return null;
6731                    }
6732    
6733                    List<BlogsEntry> list = findByC_LtD(companyId, displayDate, count - 1,
6734                                    count, orderByComparator);
6735    
6736                    if (!list.isEmpty()) {
6737                            return list.get(0);
6738                    }
6739    
6740                    return null;
6741            }
6742    
6743            /**
6744             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63;.
6745             *
6746             * @param entryId the primary key of the current blogs entry
6747             * @param companyId the company ID
6748             * @param displayDate the display date
6749             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6750             * @return the previous, current, and next blogs entry
6751             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
6752             */
6753            @Override
6754            public BlogsEntry[] findByC_LtD_PrevAndNext(long entryId, long companyId,
6755                    Date displayDate, OrderByComparator<BlogsEntry> orderByComparator)
6756                    throws NoSuchEntryException {
6757                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
6758    
6759                    Session session = null;
6760    
6761                    try {
6762                            session = openSession();
6763    
6764                            BlogsEntry[] array = new BlogsEntryImpl[3];
6765    
6766                            array[0] = getByC_LtD_PrevAndNext(session, blogsEntry, companyId,
6767                                            displayDate, orderByComparator, true);
6768    
6769                            array[1] = blogsEntry;
6770    
6771                            array[2] = getByC_LtD_PrevAndNext(session, blogsEntry, companyId,
6772                                            displayDate, orderByComparator, false);
6773    
6774                            return array;
6775                    }
6776                    catch (Exception e) {
6777                            throw processException(e);
6778                    }
6779                    finally {
6780                            closeSession(session);
6781                    }
6782            }
6783    
6784            protected BlogsEntry getByC_LtD_PrevAndNext(Session session,
6785                    BlogsEntry blogsEntry, long companyId, Date displayDate,
6786                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
6787                    StringBundler query = null;
6788    
6789                    if (orderByComparator != null) {
6790                            query = new StringBundler(6 +
6791                                            (orderByComparator.getOrderByFields().length * 6));
6792                    }
6793                    else {
6794                            query = new StringBundler(3);
6795                    }
6796    
6797                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
6798    
6799                    query.append(_FINDER_COLUMN_C_LTD_COMPANYID_2);
6800    
6801                    boolean bindDisplayDate = false;
6802    
6803                    if (displayDate == null) {
6804                            query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_1);
6805                    }
6806                    else {
6807                            bindDisplayDate = true;
6808    
6809                            query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_2);
6810                    }
6811    
6812                    if (orderByComparator != null) {
6813                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6814    
6815                            if (orderByConditionFields.length > 0) {
6816                                    query.append(WHERE_AND);
6817                            }
6818    
6819                            for (int i = 0; i < orderByConditionFields.length; i++) {
6820                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6821                                    query.append(orderByConditionFields[i]);
6822    
6823                                    if ((i + 1) < orderByConditionFields.length) {
6824                                            if (orderByComparator.isAscending() ^ previous) {
6825                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6826                                            }
6827                                            else {
6828                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6829                                            }
6830                                    }
6831                                    else {
6832                                            if (orderByComparator.isAscending() ^ previous) {
6833                                                    query.append(WHERE_GREATER_THAN);
6834                                            }
6835                                            else {
6836                                                    query.append(WHERE_LESSER_THAN);
6837                                            }
6838                                    }
6839                            }
6840    
6841                            query.append(ORDER_BY_CLAUSE);
6842    
6843                            String[] orderByFields = orderByComparator.getOrderByFields();
6844    
6845                            for (int i = 0; i < orderByFields.length; i++) {
6846                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6847                                    query.append(orderByFields[i]);
6848    
6849                                    if ((i + 1) < orderByFields.length) {
6850                                            if (orderByComparator.isAscending() ^ previous) {
6851                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6852                                            }
6853                                            else {
6854                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6855                                            }
6856                                    }
6857                                    else {
6858                                            if (orderByComparator.isAscending() ^ previous) {
6859                                                    query.append(ORDER_BY_ASC);
6860                                            }
6861                                            else {
6862                                                    query.append(ORDER_BY_DESC);
6863                                            }
6864                                    }
6865                            }
6866                    }
6867                    else {
6868                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
6869                    }
6870    
6871                    String sql = query.toString();
6872    
6873                    Query q = session.createQuery(sql);
6874    
6875                    q.setFirstResult(0);
6876                    q.setMaxResults(2);
6877    
6878                    QueryPos qPos = QueryPos.getInstance(q);
6879    
6880                    qPos.add(companyId);
6881    
6882                    if (bindDisplayDate) {
6883                            qPos.add(new Timestamp(displayDate.getTime()));
6884                    }
6885    
6886                    if (orderByComparator != null) {
6887                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
6888    
6889                            for (Object value : values) {
6890                                    qPos.add(value);
6891                            }
6892                    }
6893    
6894                    List<BlogsEntry> list = q.list();
6895    
6896                    if (list.size() == 2) {
6897                            return list.get(1);
6898                    }
6899                    else {
6900                            return null;
6901                    }
6902            }
6903    
6904            /**
6905             * Removes all the blogs entries where companyId = &#63; and displayDate &lt; &#63; from the database.
6906             *
6907             * @param companyId the company ID
6908             * @param displayDate the display date
6909             */
6910            @Override
6911            public void removeByC_LtD(long companyId, Date displayDate) {
6912                    for (BlogsEntry blogsEntry : findByC_LtD(companyId, displayDate,
6913                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
6914                            remove(blogsEntry);
6915                    }
6916            }
6917    
6918            /**
6919             * Returns the number of blogs entries where companyId = &#63; and displayDate &lt; &#63;.
6920             *
6921             * @param companyId the company ID
6922             * @param displayDate the display date
6923             * @return the number of matching blogs entries
6924             */
6925            @Override
6926            public int countByC_LtD(long companyId, Date displayDate) {
6927                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD;
6928    
6929                    Object[] finderArgs = new Object[] { companyId, displayDate };
6930    
6931                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
6932    
6933                    if (count == null) {
6934                            StringBundler query = new StringBundler(3);
6935    
6936                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
6937    
6938                            query.append(_FINDER_COLUMN_C_LTD_COMPANYID_2);
6939    
6940                            boolean bindDisplayDate = false;
6941    
6942                            if (displayDate == null) {
6943                                    query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_1);
6944                            }
6945                            else {
6946                                    bindDisplayDate = true;
6947    
6948                                    query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_2);
6949                            }
6950    
6951                            String sql = query.toString();
6952    
6953                            Session session = null;
6954    
6955                            try {
6956                                    session = openSession();
6957    
6958                                    Query q = session.createQuery(sql);
6959    
6960                                    QueryPos qPos = QueryPos.getInstance(q);
6961    
6962                                    qPos.add(companyId);
6963    
6964                                    if (bindDisplayDate) {
6965                                            qPos.add(new Timestamp(displayDate.getTime()));
6966                                    }
6967    
6968                                    count = (Long)q.uniqueResult();
6969    
6970                                    finderCache.putResult(finderPath, finderArgs, count);
6971                            }
6972                            catch (Exception e) {
6973                                    finderCache.removeResult(finderPath, finderArgs);
6974    
6975                                    throw processException(e);
6976                            }
6977                            finally {
6978                                    closeSession(session);
6979                            }
6980                    }
6981    
6982                    return count.intValue();
6983            }
6984    
6985            private static final String _FINDER_COLUMN_C_LTD_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
6986            private static final String _FINDER_COLUMN_C_LTD_DISPLAYDATE_1 = "blogsEntry.displayDate IS NULL";
6987            private static final String _FINDER_COLUMN_C_LTD_DISPLAYDATE_2 = "blogsEntry.displayDate < ?";
6988            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
6989                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
6990                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_S",
6991                            new String[] {
6992                                    Long.class.getName(), Integer.class.getName(),
6993                                    
6994                            Integer.class.getName(), Integer.class.getName(),
6995                                    OrderByComparator.class.getName()
6996                            });
6997            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
6998                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
6999                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_S",
7000                            new String[] { Long.class.getName(), Integer.class.getName() },
7001                            BlogsEntryModelImpl.COMPANYID_COLUMN_BITMASK |
7002                            BlogsEntryModelImpl.STATUS_COLUMN_BITMASK |
7003                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
7004                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
7005            public static final FinderPath FINDER_PATH_COUNT_BY_C_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
7006                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
7007                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_S",
7008                            new String[] { Long.class.getName(), Integer.class.getName() });
7009    
7010            /**
7011             * Returns all the blogs entries where companyId = &#63; and status = &#63;.
7012             *
7013             * @param companyId the company ID
7014             * @param status the status
7015             * @return the matching blogs entries
7016             */
7017            @Override
7018            public List<BlogsEntry> findByC_S(long companyId, int status) {
7019                    return findByC_S(companyId, status, QueryUtil.ALL_POS,
7020                            QueryUtil.ALL_POS, null);
7021            }
7022    
7023            /**
7024             * Returns a range of all the blogs entries where companyId = &#63; and status = &#63;.
7025             *
7026             * <p>
7027             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
7028             * </p>
7029             *
7030             * @param companyId the company ID
7031             * @param status the status
7032             * @param start the lower bound of the range of blogs entries
7033             * @param end the upper bound of the range of blogs entries (not inclusive)
7034             * @return the range of matching blogs entries
7035             */
7036            @Override
7037            public List<BlogsEntry> findByC_S(long companyId, int status, int start,
7038                    int end) {
7039                    return findByC_S(companyId, status, start, end, null);
7040            }
7041    
7042            /**
7043             * Returns an ordered range of all the blogs entries where companyId = &#63; and status = &#63;.
7044             *
7045             * <p>
7046             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
7047             * </p>
7048             *
7049             * @param companyId the company ID
7050             * @param status the status
7051             * @param start the lower bound of the range of blogs entries
7052             * @param end the upper bound of the range of blogs entries (not inclusive)
7053             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7054             * @return the ordered range of matching blogs entries
7055             */
7056            @Override
7057            public List<BlogsEntry> findByC_S(long companyId, int status, int start,
7058                    int end, OrderByComparator<BlogsEntry> orderByComparator) {
7059                    return findByC_S(companyId, status, start, end, orderByComparator, true);
7060            }
7061    
7062            /**
7063             * Returns an ordered range of all the blogs entries where companyId = &#63; and status = &#63;.
7064             *
7065             * <p>
7066             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
7067             * </p>
7068             *
7069             * @param companyId the company ID
7070             * @param status the status
7071             * @param start the lower bound of the range of blogs entries
7072             * @param end the upper bound of the range of blogs entries (not inclusive)
7073             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7074             * @param retrieveFromCache whether to retrieve from the finder cache
7075             * @return the ordered range of matching blogs entries
7076             */
7077            @Override
7078            public List<BlogsEntry> findByC_S(long companyId, int status, int start,
7079                    int end, OrderByComparator<BlogsEntry> orderByComparator,
7080                    boolean retrieveFromCache) {
7081                    boolean pagination = true;
7082                    FinderPath finderPath = null;
7083                    Object[] finderArgs = null;
7084    
7085                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
7086                                    (orderByComparator == null)) {
7087                            pagination = false;
7088                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S;
7089                            finderArgs = new Object[] { companyId, status };
7090                    }
7091                    else {
7092                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_S;
7093                            finderArgs = new Object[] {
7094                                            companyId, status,
7095                                            
7096                                            start, end, orderByComparator
7097                                    };
7098                    }
7099    
7100                    List<BlogsEntry> list = null;
7101    
7102                    if (retrieveFromCache) {
7103                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
7104                                            finderArgs, this);
7105    
7106                            if ((list != null) && !list.isEmpty()) {
7107                                    for (BlogsEntry blogsEntry : list) {
7108                                            if ((companyId != blogsEntry.getCompanyId()) ||
7109                                                            (status != blogsEntry.getStatus())) {
7110                                                    list = null;
7111    
7112                                                    break;
7113                                            }
7114                                    }
7115                            }
7116                    }
7117    
7118                    if (list == null) {
7119                            StringBundler query = null;
7120    
7121                            if (orderByComparator != null) {
7122                                    query = new StringBundler(4 +
7123                                                    (orderByComparator.getOrderByFields().length * 3));
7124                            }
7125                            else {
7126                                    query = new StringBundler(4);
7127                            }
7128    
7129                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
7130    
7131                            query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
7132    
7133                            query.append(_FINDER_COLUMN_C_S_STATUS_2);
7134    
7135                            if (orderByComparator != null) {
7136                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7137                                            orderByComparator);
7138                            }
7139                            else
7140                             if (pagination) {
7141                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
7142                            }
7143    
7144                            String sql = query.toString();
7145    
7146                            Session session = null;
7147    
7148                            try {
7149                                    session = openSession();
7150    
7151                                    Query q = session.createQuery(sql);
7152    
7153                                    QueryPos qPos = QueryPos.getInstance(q);
7154    
7155                                    qPos.add(companyId);
7156    
7157                                    qPos.add(status);
7158    
7159                                    if (!pagination) {
7160                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
7161                                                            start, end, false);
7162    
7163                                            Collections.sort(list);
7164    
7165                                            list = Collections.unmodifiableList(list);
7166                                    }
7167                                    else {
7168                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
7169                                                            start, end);
7170                                    }
7171    
7172                                    cacheResult(list);
7173    
7174                                    finderCache.putResult(finderPath, finderArgs, list);
7175                            }
7176                            catch (Exception e) {
7177                                    finderCache.removeResult(finderPath, finderArgs);
7178    
7179                                    throw processException(e);
7180                            }
7181                            finally {
7182                                    closeSession(session);
7183                            }
7184                    }
7185    
7186                    return list;
7187            }
7188    
7189            /**
7190             * Returns the first blogs entry in the ordered set where companyId = &#63; and status = &#63;.
7191             *
7192             * @param companyId the company ID
7193             * @param status the status
7194             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7195             * @return the first matching blogs entry
7196             * @throws NoSuchEntryException if a matching blogs entry could not be found
7197             */
7198            @Override
7199            public BlogsEntry findByC_S_First(long companyId, int status,
7200                    OrderByComparator<BlogsEntry> orderByComparator)
7201                    throws NoSuchEntryException {
7202                    BlogsEntry blogsEntry = fetchByC_S_First(companyId, status,
7203                                    orderByComparator);
7204    
7205                    if (blogsEntry != null) {
7206                            return blogsEntry;
7207                    }
7208    
7209                    StringBundler msg = new StringBundler(6);
7210    
7211                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7212    
7213                    msg.append("companyId=");
7214                    msg.append(companyId);
7215    
7216                    msg.append(", status=");
7217                    msg.append(status);
7218    
7219                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7220    
7221                    throw new NoSuchEntryException(msg.toString());
7222            }
7223    
7224            /**
7225             * Returns the first blogs entry in the ordered set where companyId = &#63; and status = &#63;.
7226             *
7227             * @param companyId the company ID
7228             * @param status the status
7229             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7230             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
7231             */
7232            @Override
7233            public BlogsEntry fetchByC_S_First(long companyId, int status,
7234                    OrderByComparator<BlogsEntry> orderByComparator) {
7235                    List<BlogsEntry> list = findByC_S(companyId, status, 0, 1,
7236                                    orderByComparator);
7237    
7238                    if (!list.isEmpty()) {
7239                            return list.get(0);
7240                    }
7241    
7242                    return null;
7243            }
7244    
7245            /**
7246             * Returns the last blogs entry in the ordered set where companyId = &#63; and status = &#63;.
7247             *
7248             * @param companyId the company ID
7249             * @param status the status
7250             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7251             * @return the last matching blogs entry
7252             * @throws NoSuchEntryException if a matching blogs entry could not be found
7253             */
7254            @Override
7255            public BlogsEntry findByC_S_Last(long companyId, int status,
7256                    OrderByComparator<BlogsEntry> orderByComparator)
7257                    throws NoSuchEntryException {
7258                    BlogsEntry blogsEntry = fetchByC_S_Last(companyId, status,
7259                                    orderByComparator);
7260    
7261                    if (blogsEntry != null) {
7262                            return blogsEntry;
7263                    }
7264    
7265                    StringBundler msg = new StringBundler(6);
7266    
7267                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7268    
7269                    msg.append("companyId=");
7270                    msg.append(companyId);
7271    
7272                    msg.append(", status=");
7273                    msg.append(status);
7274    
7275                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7276    
7277                    throw new NoSuchEntryException(msg.toString());
7278            }
7279    
7280            /**
7281             * Returns the last blogs entry in the ordered set where companyId = &#63; and status = &#63;.
7282             *
7283             * @param companyId the company ID
7284             * @param status the status
7285             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7286             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
7287             */
7288            @Override
7289            public BlogsEntry fetchByC_S_Last(long companyId, int status,
7290                    OrderByComparator<BlogsEntry> orderByComparator) {
7291                    int count = countByC_S(companyId, status);
7292    
7293                    if (count == 0) {
7294                            return null;
7295                    }
7296    
7297                    List<BlogsEntry> list = findByC_S(companyId, status, count - 1, count,
7298                                    orderByComparator);
7299    
7300                    if (!list.isEmpty()) {
7301                            return list.get(0);
7302                    }
7303    
7304                    return null;
7305            }
7306    
7307            /**
7308             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63; and status = &#63;.
7309             *
7310             * @param entryId the primary key of the current blogs entry
7311             * @param companyId the company ID
7312             * @param status the status
7313             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7314             * @return the previous, current, and next blogs entry
7315             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
7316             */
7317            @Override
7318            public BlogsEntry[] findByC_S_PrevAndNext(long entryId, long companyId,
7319                    int status, OrderByComparator<BlogsEntry> orderByComparator)
7320                    throws NoSuchEntryException {
7321                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
7322    
7323                    Session session = null;
7324    
7325                    try {
7326                            session = openSession();
7327    
7328                            BlogsEntry[] array = new BlogsEntryImpl[3];
7329    
7330                            array[0] = getByC_S_PrevAndNext(session, blogsEntry, companyId,
7331                                            status, orderByComparator, true);
7332    
7333                            array[1] = blogsEntry;
7334    
7335                            array[2] = getByC_S_PrevAndNext(session, blogsEntry, companyId,
7336                                            status, orderByComparator, false);
7337    
7338                            return array;
7339                    }
7340                    catch (Exception e) {
7341                            throw processException(e);
7342                    }
7343                    finally {
7344                            closeSession(session);
7345                    }
7346            }
7347    
7348            protected BlogsEntry getByC_S_PrevAndNext(Session session,
7349                    BlogsEntry blogsEntry, long companyId, int status,
7350                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
7351                    StringBundler query = null;
7352    
7353                    if (orderByComparator != null) {
7354                            query = new StringBundler(6 +
7355                                            (orderByComparator.getOrderByFields().length * 6));
7356                    }
7357                    else {
7358                            query = new StringBundler(3);
7359                    }
7360    
7361                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
7362    
7363                    query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
7364    
7365                    query.append(_FINDER_COLUMN_C_S_STATUS_2);
7366    
7367                    if (orderByComparator != null) {
7368                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7369    
7370                            if (orderByConditionFields.length > 0) {
7371                                    query.append(WHERE_AND);
7372                            }
7373    
7374                            for (int i = 0; i < orderByConditionFields.length; i++) {
7375                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7376                                    query.append(orderByConditionFields[i]);
7377    
7378                                    if ((i + 1) < orderByConditionFields.length) {
7379                                            if (orderByComparator.isAscending() ^ previous) {
7380                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7381                                            }
7382                                            else {
7383                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7384                                            }
7385                                    }
7386                                    else {
7387                                            if (orderByComparator.isAscending() ^ previous) {
7388                                                    query.append(WHERE_GREATER_THAN);
7389                                            }
7390                                            else {
7391                                                    query.append(WHERE_LESSER_THAN);
7392                                            }
7393                                    }
7394                            }
7395    
7396                            query.append(ORDER_BY_CLAUSE);
7397    
7398                            String[] orderByFields = orderByComparator.getOrderByFields();
7399    
7400                            for (int i = 0; i < orderByFields.length; i++) {
7401                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7402                                    query.append(orderByFields[i]);
7403    
7404                                    if ((i + 1) < orderByFields.length) {
7405                                            if (orderByComparator.isAscending() ^ previous) {
7406                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7407                                            }
7408                                            else {
7409                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7410                                            }
7411                                    }
7412                                    else {
7413                                            if (orderByComparator.isAscending() ^ previous) {
7414                                                    query.append(ORDER_BY_ASC);
7415                                            }
7416                                            else {
7417                                                    query.append(ORDER_BY_DESC);
7418                                            }
7419                                    }
7420                            }
7421                    }
7422                    else {
7423                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
7424                    }
7425    
7426                    String sql = query.toString();
7427    
7428                    Query q = session.createQuery(sql);
7429    
7430                    q.setFirstResult(0);
7431                    q.setMaxResults(2);
7432    
7433                    QueryPos qPos = QueryPos.getInstance(q);
7434    
7435                    qPos.add(companyId);
7436    
7437                    qPos.add(status);
7438    
7439                    if (orderByComparator != null) {
7440                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
7441    
7442                            for (Object value : values) {
7443                                    qPos.add(value);
7444                            }
7445                    }
7446    
7447                    List<BlogsEntry> list = q.list();
7448    
7449                    if (list.size() == 2) {
7450                            return list.get(1);
7451                    }
7452                    else {
7453                            return null;
7454                    }
7455            }
7456    
7457            /**
7458             * Removes all the blogs entries where companyId = &#63; and status = &#63; from the database.
7459             *
7460             * @param companyId the company ID
7461             * @param status the status
7462             */
7463            @Override
7464            public void removeByC_S(long companyId, int status) {
7465                    for (BlogsEntry blogsEntry : findByC_S(companyId, status,
7466                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
7467                            remove(blogsEntry);
7468                    }
7469            }
7470    
7471            /**
7472             * Returns the number of blogs entries where companyId = &#63; and status = &#63;.
7473             *
7474             * @param companyId the company ID
7475             * @param status the status
7476             * @return the number of matching blogs entries
7477             */
7478            @Override
7479            public int countByC_S(long companyId, int status) {
7480                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_S;
7481    
7482                    Object[] finderArgs = new Object[] { companyId, status };
7483    
7484                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
7485    
7486                    if (count == null) {
7487                            StringBundler query = new StringBundler(3);
7488    
7489                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
7490    
7491                            query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
7492    
7493                            query.append(_FINDER_COLUMN_C_S_STATUS_2);
7494    
7495                            String sql = query.toString();
7496    
7497                            Session session = null;
7498    
7499                            try {
7500                                    session = openSession();
7501    
7502                                    Query q = session.createQuery(sql);
7503    
7504                                    QueryPos qPos = QueryPos.getInstance(q);
7505    
7506                                    qPos.add(companyId);
7507    
7508                                    qPos.add(status);
7509    
7510                                    count = (Long)q.uniqueResult();
7511    
7512                                    finderCache.putResult(finderPath, finderArgs, count);
7513                            }
7514                            catch (Exception e) {
7515                                    finderCache.removeResult(finderPath, finderArgs);
7516    
7517                                    throw processException(e);
7518                            }
7519                            finally {
7520                                    closeSession(session);
7521                            }
7522                    }
7523    
7524                    return count.intValue();
7525            }
7526    
7527            private static final String _FINDER_COLUMN_C_S_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
7528            private static final String _FINDER_COLUMN_C_S_STATUS_2 = "blogsEntry.status = ?";
7529            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_NOTS = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
7530                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
7531                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_NotS",
7532                            new String[] {
7533                                    Long.class.getName(), Integer.class.getName(),
7534                                    
7535                            Integer.class.getName(), Integer.class.getName(),
7536                                    OrderByComparator.class.getName()
7537                            });
7538            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_NOTS = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
7539                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
7540                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_NotS",
7541                            new String[] { Long.class.getName(), Integer.class.getName() });
7542    
7543            /**
7544             * Returns all the blogs entries where companyId = &#63; and status &ne; &#63;.
7545             *
7546             * @param companyId the company ID
7547             * @param status the status
7548             * @return the matching blogs entries
7549             */
7550            @Override
7551            public List<BlogsEntry> findByC_NotS(long companyId, int status) {
7552                    return findByC_NotS(companyId, status, QueryUtil.ALL_POS,
7553                            QueryUtil.ALL_POS, null);
7554            }
7555    
7556            /**
7557             * Returns a range of all the blogs entries where companyId = &#63; and status &ne; &#63;.
7558             *
7559             * <p>
7560             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
7561             * </p>
7562             *
7563             * @param companyId the company ID
7564             * @param status the status
7565             * @param start the lower bound of the range of blogs entries
7566             * @param end the upper bound of the range of blogs entries (not inclusive)
7567             * @return the range of matching blogs entries
7568             */
7569            @Override
7570            public List<BlogsEntry> findByC_NotS(long companyId, int status, int start,
7571                    int end) {
7572                    return findByC_NotS(companyId, status, start, end, null);
7573            }
7574    
7575            /**
7576             * Returns an ordered range of all the blogs entries where companyId = &#63; and status &ne; &#63;.
7577             *
7578             * <p>
7579             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
7580             * </p>
7581             *
7582             * @param companyId the company ID
7583             * @param status the status
7584             * @param start the lower bound of the range of blogs entries
7585             * @param end the upper bound of the range of blogs entries (not inclusive)
7586             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7587             * @return the ordered range of matching blogs entries
7588             */
7589            @Override
7590            public List<BlogsEntry> findByC_NotS(long companyId, int status, int start,
7591                    int end, OrderByComparator<BlogsEntry> orderByComparator) {
7592                    return findByC_NotS(companyId, status, start, end, orderByComparator,
7593                            true);
7594            }
7595    
7596            /**
7597             * Returns an ordered range of all the blogs entries where companyId = &#63; and status &ne; &#63;.
7598             *
7599             * <p>
7600             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
7601             * </p>
7602             *
7603             * @param companyId the company ID
7604             * @param status the status
7605             * @param start the lower bound of the range of blogs entries
7606             * @param end the upper bound of the range of blogs entries (not inclusive)
7607             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7608             * @param retrieveFromCache whether to retrieve from the finder cache
7609             * @return the ordered range of matching blogs entries
7610             */
7611            @Override
7612            public List<BlogsEntry> findByC_NotS(long companyId, int status, int start,
7613                    int end, OrderByComparator<BlogsEntry> orderByComparator,
7614                    boolean retrieveFromCache) {
7615                    boolean pagination = true;
7616                    FinderPath finderPath = null;
7617                    Object[] finderArgs = null;
7618    
7619                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_NOTS;
7620                    finderArgs = new Object[] {
7621                                    companyId, status,
7622                                    
7623                                    start, end, orderByComparator
7624                            };
7625    
7626                    List<BlogsEntry> list = null;
7627    
7628                    if (retrieveFromCache) {
7629                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
7630                                            finderArgs, this);
7631    
7632                            if ((list != null) && !list.isEmpty()) {
7633                                    for (BlogsEntry blogsEntry : list) {
7634                                            if ((companyId != blogsEntry.getCompanyId()) ||
7635                                                            (status == blogsEntry.getStatus())) {
7636                                                    list = null;
7637    
7638                                                    break;
7639                                            }
7640                                    }
7641                            }
7642                    }
7643    
7644                    if (list == null) {
7645                            StringBundler query = null;
7646    
7647                            if (orderByComparator != null) {
7648                                    query = new StringBundler(4 +
7649                                                    (orderByComparator.getOrderByFields().length * 3));
7650                            }
7651                            else {
7652                                    query = new StringBundler(4);
7653                            }
7654    
7655                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
7656    
7657                            query.append(_FINDER_COLUMN_C_NOTS_COMPANYID_2);
7658    
7659                            query.append(_FINDER_COLUMN_C_NOTS_STATUS_2);
7660    
7661                            if (orderByComparator != null) {
7662                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7663                                            orderByComparator);
7664                            }
7665                            else
7666                             if (pagination) {
7667                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
7668                            }
7669    
7670                            String sql = query.toString();
7671    
7672                            Session session = null;
7673    
7674                            try {
7675                                    session = openSession();
7676    
7677                                    Query q = session.createQuery(sql);
7678    
7679                                    QueryPos qPos = QueryPos.getInstance(q);
7680    
7681                                    qPos.add(companyId);
7682    
7683                                    qPos.add(status);
7684    
7685                                    if (!pagination) {
7686                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
7687                                                            start, end, false);
7688    
7689                                            Collections.sort(list);
7690    
7691                                            list = Collections.unmodifiableList(list);
7692                                    }
7693                                    else {
7694                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
7695                                                            start, end);
7696                                    }
7697    
7698                                    cacheResult(list);
7699    
7700                                    finderCache.putResult(finderPath, finderArgs, list);
7701                            }
7702                            catch (Exception e) {
7703                                    finderCache.removeResult(finderPath, finderArgs);
7704    
7705                                    throw processException(e);
7706                            }
7707                            finally {
7708                                    closeSession(session);
7709                            }
7710                    }
7711    
7712                    return list;
7713            }
7714    
7715            /**
7716             * Returns the first blogs entry in the ordered set where companyId = &#63; and status &ne; &#63;.
7717             *
7718             * @param companyId the company ID
7719             * @param status the status
7720             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7721             * @return the first matching blogs entry
7722             * @throws NoSuchEntryException if a matching blogs entry could not be found
7723             */
7724            @Override
7725            public BlogsEntry findByC_NotS_First(long companyId, int status,
7726                    OrderByComparator<BlogsEntry> orderByComparator)
7727                    throws NoSuchEntryException {
7728                    BlogsEntry blogsEntry = fetchByC_NotS_First(companyId, status,
7729                                    orderByComparator);
7730    
7731                    if (blogsEntry != null) {
7732                            return blogsEntry;
7733                    }
7734    
7735                    StringBundler msg = new StringBundler(6);
7736    
7737                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7738    
7739                    msg.append("companyId=");
7740                    msg.append(companyId);
7741    
7742                    msg.append(", status=");
7743                    msg.append(status);
7744    
7745                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7746    
7747                    throw new NoSuchEntryException(msg.toString());
7748            }
7749    
7750            /**
7751             * Returns the first blogs entry in the ordered set where companyId = &#63; and status &ne; &#63;.
7752             *
7753             * @param companyId the company ID
7754             * @param status the status
7755             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7756             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
7757             */
7758            @Override
7759            public BlogsEntry fetchByC_NotS_First(long companyId, int status,
7760                    OrderByComparator<BlogsEntry> orderByComparator) {
7761                    List<BlogsEntry> list = findByC_NotS(companyId, status, 0, 1,
7762                                    orderByComparator);
7763    
7764                    if (!list.isEmpty()) {
7765                            return list.get(0);
7766                    }
7767    
7768                    return null;
7769            }
7770    
7771            /**
7772             * Returns the last blogs entry in the ordered set where companyId = &#63; and status &ne; &#63;.
7773             *
7774             * @param companyId the company ID
7775             * @param status the status
7776             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7777             * @return the last matching blogs entry
7778             * @throws NoSuchEntryException if a matching blogs entry could not be found
7779             */
7780            @Override
7781            public BlogsEntry findByC_NotS_Last(long companyId, int status,
7782                    OrderByComparator<BlogsEntry> orderByComparator)
7783                    throws NoSuchEntryException {
7784                    BlogsEntry blogsEntry = fetchByC_NotS_Last(companyId, status,
7785                                    orderByComparator);
7786    
7787                    if (blogsEntry != null) {
7788                            return blogsEntry;
7789                    }
7790    
7791                    StringBundler msg = new StringBundler(6);
7792    
7793                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7794    
7795                    msg.append("companyId=");
7796                    msg.append(companyId);
7797    
7798                    msg.append(", status=");
7799                    msg.append(status);
7800    
7801                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7802    
7803                    throw new NoSuchEntryException(msg.toString());
7804            }
7805    
7806            /**
7807             * Returns the last blogs entry in the ordered set where companyId = &#63; and status &ne; &#63;.
7808             *
7809             * @param companyId the company ID
7810             * @param status the status
7811             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7812             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
7813             */
7814            @Override
7815            public BlogsEntry fetchByC_NotS_Last(long companyId, int status,
7816                    OrderByComparator<BlogsEntry> orderByComparator) {
7817                    int count = countByC_NotS(companyId, status);
7818    
7819                    if (count == 0) {
7820                            return null;
7821                    }
7822    
7823                    List<BlogsEntry> list = findByC_NotS(companyId, status, count - 1,
7824                                    count, orderByComparator);
7825    
7826                    if (!list.isEmpty()) {
7827                            return list.get(0);
7828                    }
7829    
7830                    return null;
7831            }
7832    
7833            /**
7834             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63; and status &ne; &#63;.
7835             *
7836             * @param entryId the primary key of the current blogs entry
7837             * @param companyId the company ID
7838             * @param status the status
7839             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7840             * @return the previous, current, and next blogs entry
7841             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
7842             */
7843            @Override
7844            public BlogsEntry[] findByC_NotS_PrevAndNext(long entryId, long companyId,
7845                    int status, OrderByComparator<BlogsEntry> orderByComparator)
7846                    throws NoSuchEntryException {
7847                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
7848    
7849                    Session session = null;
7850    
7851                    try {
7852                            session = openSession();
7853    
7854                            BlogsEntry[] array = new BlogsEntryImpl[3];
7855    
7856                            array[0] = getByC_NotS_PrevAndNext(session, blogsEntry, companyId,
7857                                            status, orderByComparator, true);
7858    
7859                            array[1] = blogsEntry;
7860    
7861                            array[2] = getByC_NotS_PrevAndNext(session, blogsEntry, companyId,
7862                                            status, orderByComparator, false);
7863    
7864                            return array;
7865                    }
7866                    catch (Exception e) {
7867                            throw processException(e);
7868                    }
7869                    finally {
7870                            closeSession(session);
7871                    }
7872            }
7873    
7874            protected BlogsEntry getByC_NotS_PrevAndNext(Session session,
7875                    BlogsEntry blogsEntry, long companyId, int status,
7876                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
7877                    StringBundler query = null;
7878    
7879                    if (orderByComparator != null) {
7880                            query = new StringBundler(6 +
7881                                            (orderByComparator.getOrderByFields().length * 6));
7882                    }
7883                    else {
7884                            query = new StringBundler(3);
7885                    }
7886    
7887                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
7888    
7889                    query.append(_FINDER_COLUMN_C_NOTS_COMPANYID_2);
7890    
7891                    query.append(_FINDER_COLUMN_C_NOTS_STATUS_2);
7892    
7893                    if (orderByComparator != null) {
7894                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7895    
7896                            if (orderByConditionFields.length > 0) {
7897                                    query.append(WHERE_AND);
7898                            }
7899    
7900                            for (int i = 0; i < orderByConditionFields.length; i++) {
7901                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7902                                    query.append(orderByConditionFields[i]);
7903    
7904                                    if ((i + 1) < orderByConditionFields.length) {
7905                                            if (orderByComparator.isAscending() ^ previous) {
7906                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7907                                            }
7908                                            else {
7909                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7910                                            }
7911                                    }
7912                                    else {
7913                                            if (orderByComparator.isAscending() ^ previous) {
7914                                                    query.append(WHERE_GREATER_THAN);
7915                                            }
7916                                            else {
7917                                                    query.append(WHERE_LESSER_THAN);
7918                                            }
7919                                    }
7920                            }
7921    
7922                            query.append(ORDER_BY_CLAUSE);
7923    
7924                            String[] orderByFields = orderByComparator.getOrderByFields();
7925    
7926                            for (int i = 0; i < orderByFields.length; i++) {
7927                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7928                                    query.append(orderByFields[i]);
7929    
7930                                    if ((i + 1) < orderByFields.length) {
7931                                            if (orderByComparator.isAscending() ^ previous) {
7932                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7933                                            }
7934                                            else {
7935                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7936                                            }
7937                                    }
7938                                    else {
7939                                            if (orderByComparator.isAscending() ^ previous) {
7940                                                    query.append(ORDER_BY_ASC);
7941                                            }
7942                                            else {
7943                                                    query.append(ORDER_BY_DESC);
7944                                            }
7945                                    }
7946                            }
7947                    }
7948                    else {
7949                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
7950                    }
7951    
7952                    String sql = query.toString();
7953    
7954                    Query q = session.createQuery(sql);
7955    
7956                    q.setFirstResult(0);
7957                    q.setMaxResults(2);
7958    
7959                    QueryPos qPos = QueryPos.getInstance(q);
7960    
7961                    qPos.add(companyId);
7962    
7963                    qPos.add(status);
7964    
7965                    if (orderByComparator != null) {
7966                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
7967    
7968                            for (Object value : values) {
7969                                    qPos.add(value);
7970                            }
7971                    }
7972    
7973                    List<BlogsEntry> list = q.list();
7974    
7975                    if (list.size() == 2) {
7976                            return list.get(1);
7977                    }
7978                    else {
7979                            return null;
7980                    }
7981            }
7982    
7983            /**
7984             * Removes all the blogs entries where companyId = &#63; and status &ne; &#63; from the database.
7985             *
7986             * @param companyId the company ID
7987             * @param status the status
7988             */
7989            @Override
7990            public void removeByC_NotS(long companyId, int status) {
7991                    for (BlogsEntry blogsEntry : findByC_NotS(companyId, status,
7992                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
7993                            remove(blogsEntry);
7994                    }
7995            }
7996    
7997            /**
7998             * Returns the number of blogs entries where companyId = &#63; and status &ne; &#63;.
7999             *
8000             * @param companyId the company ID
8001             * @param status the status
8002             * @return the number of matching blogs entries
8003             */
8004            @Override
8005            public int countByC_NotS(long companyId, int status) {
8006                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_NOTS;
8007    
8008                    Object[] finderArgs = new Object[] { companyId, status };
8009    
8010                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
8011    
8012                    if (count == null) {
8013                            StringBundler query = new StringBundler(3);
8014    
8015                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
8016    
8017                            query.append(_FINDER_COLUMN_C_NOTS_COMPANYID_2);
8018    
8019                            query.append(_FINDER_COLUMN_C_NOTS_STATUS_2);
8020    
8021                            String sql = query.toString();
8022    
8023                            Session session = null;
8024    
8025                            try {
8026                                    session = openSession();
8027    
8028                                    Query q = session.createQuery(sql);
8029    
8030                                    QueryPos qPos = QueryPos.getInstance(q);
8031    
8032                                    qPos.add(companyId);
8033    
8034                                    qPos.add(status);
8035    
8036                                    count = (Long)q.uniqueResult();
8037    
8038                                    finderCache.putResult(finderPath, finderArgs, count);
8039                            }
8040                            catch (Exception e) {
8041                                    finderCache.removeResult(finderPath, finderArgs);
8042    
8043                                    throw processException(e);
8044                            }
8045                            finally {
8046                                    closeSession(session);
8047                            }
8048                    }
8049    
8050                    return count.intValue();
8051            }
8052    
8053            private static final String _FINDER_COLUMN_C_NOTS_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
8054            private static final String _FINDER_COLUMN_C_NOTS_STATUS_2 = "blogsEntry.status != ?";
8055            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
8056                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
8057                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByLtD_S",
8058                            new String[] {
8059                                    Date.class.getName(), Integer.class.getName(),
8060                                    
8061                            Integer.class.getName(), Integer.class.getName(),
8062                                    OrderByComparator.class.getName()
8063                            });
8064            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
8065                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
8066                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByLtD_S",
8067                            new String[] { Date.class.getName(), Integer.class.getName() });
8068    
8069            /**
8070             * Returns all the blogs entries where displayDate &lt; &#63; and status = &#63;.
8071             *
8072             * @param displayDate the display date
8073             * @param status the status
8074             * @return the matching blogs entries
8075             */
8076            @Override
8077            public List<BlogsEntry> findByLtD_S(Date displayDate, int status) {
8078                    return findByLtD_S(displayDate, status, QueryUtil.ALL_POS,
8079                            QueryUtil.ALL_POS, null);
8080            }
8081    
8082            /**
8083             * Returns a range of all the blogs entries where displayDate &lt; &#63; and status = &#63;.
8084             *
8085             * <p>
8086             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
8087             * </p>
8088             *
8089             * @param displayDate the display date
8090             * @param status the status
8091             * @param start the lower bound of the range of blogs entries
8092             * @param end the upper bound of the range of blogs entries (not inclusive)
8093             * @return the range of matching blogs entries
8094             */
8095            @Override
8096            public List<BlogsEntry> findByLtD_S(Date displayDate, int status,
8097                    int start, int end) {
8098                    return findByLtD_S(displayDate, status, start, end, null);
8099            }
8100    
8101            /**
8102             * Returns an ordered range of all the blogs entries where displayDate &lt; &#63; and status = &#63;.
8103             *
8104             * <p>
8105             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
8106             * </p>
8107             *
8108             * @param displayDate the display date
8109             * @param status the status
8110             * @param start the lower bound of the range of blogs entries
8111             * @param end the upper bound of the range of blogs entries (not inclusive)
8112             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8113             * @return the ordered range of matching blogs entries
8114             */
8115            @Override
8116            public List<BlogsEntry> findByLtD_S(Date displayDate, int status,
8117                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator) {
8118                    return findByLtD_S(displayDate, status, start, end, orderByComparator,
8119                            true);
8120            }
8121    
8122            /**
8123             * Returns an ordered range of all the blogs entries where displayDate &lt; &#63; and status = &#63;.
8124             *
8125             * <p>
8126             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
8127             * </p>
8128             *
8129             * @param displayDate the display date
8130             * @param status the status
8131             * @param start the lower bound of the range of blogs entries
8132             * @param end the upper bound of the range of blogs entries (not inclusive)
8133             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8134             * @param retrieveFromCache whether to retrieve from the finder cache
8135             * @return the ordered range of matching blogs entries
8136             */
8137            @Override
8138            public List<BlogsEntry> findByLtD_S(Date displayDate, int status,
8139                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator,
8140                    boolean retrieveFromCache) {
8141                    boolean pagination = true;
8142                    FinderPath finderPath = null;
8143                    Object[] finderArgs = null;
8144    
8145                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_LTD_S;
8146                    finderArgs = new Object[] {
8147                                    displayDate, status,
8148                                    
8149                                    start, end, orderByComparator
8150                            };
8151    
8152                    List<BlogsEntry> list = null;
8153    
8154                    if (retrieveFromCache) {
8155                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
8156                                            finderArgs, this);
8157    
8158                            if ((list != null) && !list.isEmpty()) {
8159                                    for (BlogsEntry blogsEntry : list) {
8160                                            if ((displayDate.getTime() <= blogsEntry.getDisplayDate()
8161                                                                                                                                    .getTime()) ||
8162                                                            (status != blogsEntry.getStatus())) {
8163                                                    list = null;
8164    
8165                                                    break;
8166                                            }
8167                                    }
8168                            }
8169                    }
8170    
8171                    if (list == null) {
8172                            StringBundler query = null;
8173    
8174                            if (orderByComparator != null) {
8175                                    query = new StringBundler(4 +
8176                                                    (orderByComparator.getOrderByFields().length * 3));
8177                            }
8178                            else {
8179                                    query = new StringBundler(4);
8180                            }
8181    
8182                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
8183    
8184                            boolean bindDisplayDate = false;
8185    
8186                            if (displayDate == null) {
8187                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_1);
8188                            }
8189                            else {
8190                                    bindDisplayDate = true;
8191    
8192                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_2);
8193                            }
8194    
8195                            query.append(_FINDER_COLUMN_LTD_S_STATUS_2);
8196    
8197                            if (orderByComparator != null) {
8198                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8199                                            orderByComparator);
8200                            }
8201                            else
8202                             if (pagination) {
8203                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
8204                            }
8205    
8206                            String sql = query.toString();
8207    
8208                            Session session = null;
8209    
8210                            try {
8211                                    session = openSession();
8212    
8213                                    Query q = session.createQuery(sql);
8214    
8215                                    QueryPos qPos = QueryPos.getInstance(q);
8216    
8217                                    if (bindDisplayDate) {
8218                                            qPos.add(new Timestamp(displayDate.getTime()));
8219                                    }
8220    
8221                                    qPos.add(status);
8222    
8223                                    if (!pagination) {
8224                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
8225                                                            start, end, false);
8226    
8227                                            Collections.sort(list);
8228    
8229                                            list = Collections.unmodifiableList(list);
8230                                    }
8231                                    else {
8232                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
8233                                                            start, end);
8234                                    }
8235    
8236                                    cacheResult(list);
8237    
8238                                    finderCache.putResult(finderPath, finderArgs, list);
8239                            }
8240                            catch (Exception e) {
8241                                    finderCache.removeResult(finderPath, finderArgs);
8242    
8243                                    throw processException(e);
8244                            }
8245                            finally {
8246                                    closeSession(session);
8247                            }
8248                    }
8249    
8250                    return list;
8251            }
8252    
8253            /**
8254             * Returns the first blogs entry in the ordered set where displayDate &lt; &#63; and status = &#63;.
8255             *
8256             * @param displayDate the display date
8257             * @param status the status
8258             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8259             * @return the first matching blogs entry
8260             * @throws NoSuchEntryException if a matching blogs entry could not be found
8261             */
8262            @Override
8263            public BlogsEntry findByLtD_S_First(Date displayDate, int status,
8264                    OrderByComparator<BlogsEntry> orderByComparator)
8265                    throws NoSuchEntryException {
8266                    BlogsEntry blogsEntry = fetchByLtD_S_First(displayDate, status,
8267                                    orderByComparator);
8268    
8269                    if (blogsEntry != null) {
8270                            return blogsEntry;
8271                    }
8272    
8273                    StringBundler msg = new StringBundler(6);
8274    
8275                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8276    
8277                    msg.append("displayDate=");
8278                    msg.append(displayDate);
8279    
8280                    msg.append(", status=");
8281                    msg.append(status);
8282    
8283                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8284    
8285                    throw new NoSuchEntryException(msg.toString());
8286            }
8287    
8288            /**
8289             * Returns the first blogs entry in the ordered set where displayDate &lt; &#63; and status = &#63;.
8290             *
8291             * @param displayDate the display date
8292             * @param status the status
8293             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8294             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
8295             */
8296            @Override
8297            public BlogsEntry fetchByLtD_S_First(Date displayDate, int status,
8298                    OrderByComparator<BlogsEntry> orderByComparator) {
8299                    List<BlogsEntry> list = findByLtD_S(displayDate, status, 0, 1,
8300                                    orderByComparator);
8301    
8302                    if (!list.isEmpty()) {
8303                            return list.get(0);
8304                    }
8305    
8306                    return null;
8307            }
8308    
8309            /**
8310             * Returns the last blogs entry in the ordered set where displayDate &lt; &#63; and status = &#63;.
8311             *
8312             * @param displayDate the display date
8313             * @param status the status
8314             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8315             * @return the last matching blogs entry
8316             * @throws NoSuchEntryException if a matching blogs entry could not be found
8317             */
8318            @Override
8319            public BlogsEntry findByLtD_S_Last(Date displayDate, int status,
8320                    OrderByComparator<BlogsEntry> orderByComparator)
8321                    throws NoSuchEntryException {
8322                    BlogsEntry blogsEntry = fetchByLtD_S_Last(displayDate, status,
8323                                    orderByComparator);
8324    
8325                    if (blogsEntry != null) {
8326                            return blogsEntry;
8327                    }
8328    
8329                    StringBundler msg = new StringBundler(6);
8330    
8331                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8332    
8333                    msg.append("displayDate=");
8334                    msg.append(displayDate);
8335    
8336                    msg.append(", status=");
8337                    msg.append(status);
8338    
8339                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8340    
8341                    throw new NoSuchEntryException(msg.toString());
8342            }
8343    
8344            /**
8345             * Returns the last blogs entry in the ordered set where displayDate &lt; &#63; and status = &#63;.
8346             *
8347             * @param displayDate the display date
8348             * @param status the status
8349             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8350             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
8351             */
8352            @Override
8353            public BlogsEntry fetchByLtD_S_Last(Date displayDate, int status,
8354                    OrderByComparator<BlogsEntry> orderByComparator) {
8355                    int count = countByLtD_S(displayDate, status);
8356    
8357                    if (count == 0) {
8358                            return null;
8359                    }
8360    
8361                    List<BlogsEntry> list = findByLtD_S(displayDate, status, count - 1,
8362                                    count, orderByComparator);
8363    
8364                    if (!list.isEmpty()) {
8365                            return list.get(0);
8366                    }
8367    
8368                    return null;
8369            }
8370    
8371            /**
8372             * Returns the blogs entries before and after the current blogs entry in the ordered set where displayDate &lt; &#63; and status = &#63;.
8373             *
8374             * @param entryId the primary key of the current blogs entry
8375             * @param displayDate the display date
8376             * @param status the status
8377             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8378             * @return the previous, current, and next blogs entry
8379             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
8380             */
8381            @Override
8382            public BlogsEntry[] findByLtD_S_PrevAndNext(long entryId, Date displayDate,
8383                    int status, OrderByComparator<BlogsEntry> orderByComparator)
8384                    throws NoSuchEntryException {
8385                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
8386    
8387                    Session session = null;
8388    
8389                    try {
8390                            session = openSession();
8391    
8392                            BlogsEntry[] array = new BlogsEntryImpl[3];
8393    
8394                            array[0] = getByLtD_S_PrevAndNext(session, blogsEntry, displayDate,
8395                                            status, orderByComparator, true);
8396    
8397                            array[1] = blogsEntry;
8398    
8399                            array[2] = getByLtD_S_PrevAndNext(session, blogsEntry, displayDate,
8400                                            status, orderByComparator, false);
8401    
8402                            return array;
8403                    }
8404                    catch (Exception e) {
8405                            throw processException(e);
8406                    }
8407                    finally {
8408                            closeSession(session);
8409                    }
8410            }
8411    
8412            protected BlogsEntry getByLtD_S_PrevAndNext(Session session,
8413                    BlogsEntry blogsEntry, Date displayDate, int status,
8414                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
8415                    StringBundler query = null;
8416    
8417                    if (orderByComparator != null) {
8418                            query = new StringBundler(6 +
8419                                            (orderByComparator.getOrderByFields().length * 6));
8420                    }
8421                    else {
8422                            query = new StringBundler(3);
8423                    }
8424    
8425                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
8426    
8427                    boolean bindDisplayDate = false;
8428    
8429                    if (displayDate == null) {
8430                            query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_1);
8431                    }
8432                    else {
8433                            bindDisplayDate = true;
8434    
8435                            query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_2);
8436                    }
8437    
8438                    query.append(_FINDER_COLUMN_LTD_S_STATUS_2);
8439    
8440                    if (orderByComparator != null) {
8441                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8442    
8443                            if (orderByConditionFields.length > 0) {
8444                                    query.append(WHERE_AND);
8445                            }
8446    
8447                            for (int i = 0; i < orderByConditionFields.length; i++) {
8448                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8449                                    query.append(orderByConditionFields[i]);
8450    
8451                                    if ((i + 1) < orderByConditionFields.length) {
8452                                            if (orderByComparator.isAscending() ^ previous) {
8453                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8454                                            }
8455                                            else {
8456                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8457                                            }
8458                                    }
8459                                    else {
8460                                            if (orderByComparator.isAscending() ^ previous) {
8461                                                    query.append(WHERE_GREATER_THAN);
8462                                            }
8463                                            else {
8464                                                    query.append(WHERE_LESSER_THAN);
8465                                            }
8466                                    }
8467                            }
8468    
8469                            query.append(ORDER_BY_CLAUSE);
8470    
8471                            String[] orderByFields = orderByComparator.getOrderByFields();
8472    
8473                            for (int i = 0; i < orderByFields.length; i++) {
8474                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8475                                    query.append(orderByFields[i]);
8476    
8477                                    if ((i + 1) < orderByFields.length) {
8478                                            if (orderByComparator.isAscending() ^ previous) {
8479                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8480                                            }
8481                                            else {
8482                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8483                                            }
8484                                    }
8485                                    else {
8486                                            if (orderByComparator.isAscending() ^ previous) {
8487                                                    query.append(ORDER_BY_ASC);
8488                                            }
8489                                            else {
8490                                                    query.append(ORDER_BY_DESC);
8491                                            }
8492                                    }
8493                            }
8494                    }
8495                    else {
8496                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
8497                    }
8498    
8499                    String sql = query.toString();
8500    
8501                    Query q = session.createQuery(sql);
8502    
8503                    q.setFirstResult(0);
8504                    q.setMaxResults(2);
8505    
8506                    QueryPos qPos = QueryPos.getInstance(q);
8507    
8508                    if (bindDisplayDate) {
8509                            qPos.add(new Timestamp(displayDate.getTime()));
8510                    }
8511    
8512                    qPos.add(status);
8513    
8514                    if (orderByComparator != null) {
8515                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
8516    
8517                            for (Object value : values) {
8518                                    qPos.add(value);
8519                            }
8520                    }
8521    
8522                    List<BlogsEntry> list = q.list();
8523    
8524                    if (list.size() == 2) {
8525                            return list.get(1);
8526                    }
8527                    else {
8528                            return null;
8529                    }
8530            }
8531    
8532            /**
8533             * Removes all the blogs entries where displayDate &lt; &#63; and status = &#63; from the database.
8534             *
8535             * @param displayDate the display date
8536             * @param status the status
8537             */
8538            @Override
8539            public void removeByLtD_S(Date displayDate, int status) {
8540                    for (BlogsEntry blogsEntry : findByLtD_S(displayDate, status,
8541                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
8542                            remove(blogsEntry);
8543                    }
8544            }
8545    
8546            /**
8547             * Returns the number of blogs entries where displayDate &lt; &#63; and status = &#63;.
8548             *
8549             * @param displayDate the display date
8550             * @param status the status
8551             * @return the number of matching blogs entries
8552             */
8553            @Override
8554            public int countByLtD_S(Date displayDate, int status) {
8555                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_LTD_S;
8556    
8557                    Object[] finderArgs = new Object[] { displayDate, status };
8558    
8559                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
8560    
8561                    if (count == null) {
8562                            StringBundler query = new StringBundler(3);
8563    
8564                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
8565    
8566                            boolean bindDisplayDate = false;
8567    
8568                            if (displayDate == null) {
8569                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_1);
8570                            }
8571                            else {
8572                                    bindDisplayDate = true;
8573    
8574                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_2);
8575                            }
8576    
8577                            query.append(_FINDER_COLUMN_LTD_S_STATUS_2);
8578    
8579                            String sql = query.toString();
8580    
8581                            Session session = null;
8582    
8583                            try {
8584                                    session = openSession();
8585    
8586                                    Query q = session.createQuery(sql);
8587    
8588                                    QueryPos qPos = QueryPos.getInstance(q);
8589    
8590                                    if (bindDisplayDate) {
8591                                            qPos.add(new Timestamp(displayDate.getTime()));
8592                                    }
8593    
8594                                    qPos.add(status);
8595    
8596                                    count = (Long)q.uniqueResult();
8597    
8598                                    finderCache.putResult(finderPath, finderArgs, count);
8599                            }
8600                            catch (Exception e) {
8601                                    finderCache.removeResult(finderPath, finderArgs);
8602    
8603                                    throw processException(e);
8604                            }
8605                            finally {
8606                                    closeSession(session);
8607                            }
8608                    }
8609    
8610                    return count.intValue();
8611            }
8612    
8613            private static final String _FINDER_COLUMN_LTD_S_DISPLAYDATE_1 = "blogsEntry.displayDate IS NULL AND ";
8614            private static final String _FINDER_COLUMN_LTD_S_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
8615            private static final String _FINDER_COLUMN_LTD_S_STATUS_2 = "blogsEntry.status = ?";
8616            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
8617                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
8618                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_LtD",
8619                            new String[] {
8620                                    Long.class.getName(), Long.class.getName(), Date.class.getName(),
8621                                    
8622                            Integer.class.getName(), Integer.class.getName(),
8623                                    OrderByComparator.class.getName()
8624                            });
8625            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
8626                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
8627                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_U_LtD",
8628                            new String[] {
8629                                    Long.class.getName(), Long.class.getName(), Date.class.getName()
8630                            });
8631    
8632            /**
8633             * Returns all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
8634             *
8635             * @param groupId the group ID
8636             * @param userId the user ID
8637             * @param displayDate the display date
8638             * @return the matching blogs entries
8639             */
8640            @Override
8641            public List<BlogsEntry> findByG_U_LtD(long groupId, long userId,
8642                    Date displayDate) {
8643                    return findByG_U_LtD(groupId, userId, displayDate, QueryUtil.ALL_POS,
8644                            QueryUtil.ALL_POS, null);
8645            }
8646    
8647            /**
8648             * Returns a range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
8649             *
8650             * <p>
8651             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
8652             * </p>
8653             *
8654             * @param groupId the group ID
8655             * @param userId the user ID
8656             * @param displayDate the display date
8657             * @param start the lower bound of the range of blogs entries
8658             * @param end the upper bound of the range of blogs entries (not inclusive)
8659             * @return the range of matching blogs entries
8660             */
8661            @Override
8662            public List<BlogsEntry> findByG_U_LtD(long groupId, long userId,
8663                    Date displayDate, int start, int end) {
8664                    return findByG_U_LtD(groupId, userId, displayDate, start, end, null);
8665            }
8666    
8667            /**
8668             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
8669             *
8670             * <p>
8671             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
8672             * </p>
8673             *
8674             * @param groupId the group ID
8675             * @param userId the user ID
8676             * @param displayDate the display date
8677             * @param start the lower bound of the range of blogs entries
8678             * @param end the upper bound of the range of blogs entries (not inclusive)
8679             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8680             * @return the ordered range of matching blogs entries
8681             */
8682            @Override
8683            public List<BlogsEntry> findByG_U_LtD(long groupId, long userId,
8684                    Date displayDate, int start, int end,
8685                    OrderByComparator<BlogsEntry> orderByComparator) {
8686                    return findByG_U_LtD(groupId, userId, displayDate, start, end,
8687                            orderByComparator, true);
8688            }
8689    
8690            /**
8691             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
8692             *
8693             * <p>
8694             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
8695             * </p>
8696             *
8697             * @param groupId the group ID
8698             * @param userId the user ID
8699             * @param displayDate the display date
8700             * @param start the lower bound of the range of blogs entries
8701             * @param end the upper bound of the range of blogs entries (not inclusive)
8702             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8703             * @param retrieveFromCache whether to retrieve from the finder cache
8704             * @return the ordered range of matching blogs entries
8705             */
8706            @Override
8707            public List<BlogsEntry> findByG_U_LtD(long groupId, long userId,
8708                    Date displayDate, int start, int end,
8709                    OrderByComparator<BlogsEntry> orderByComparator,
8710                    boolean retrieveFromCache) {
8711                    boolean pagination = true;
8712                    FinderPath finderPath = null;
8713                    Object[] finderArgs = null;
8714    
8715                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD;
8716                    finderArgs = new Object[] {
8717                                    groupId, userId, displayDate,
8718                                    
8719                                    start, end, orderByComparator
8720                            };
8721    
8722                    List<BlogsEntry> list = null;
8723    
8724                    if (retrieveFromCache) {
8725                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
8726                                            finderArgs, this);
8727    
8728                            if ((list != null) && !list.isEmpty()) {
8729                                    for (BlogsEntry blogsEntry : list) {
8730                                            if ((groupId != blogsEntry.getGroupId()) ||
8731                                                            (userId != blogsEntry.getUserId()) ||
8732                                                            (displayDate.getTime() <= blogsEntry.getDisplayDate()
8733                                                                                                                                            .getTime())) {
8734                                                    list = null;
8735    
8736                                                    break;
8737                                            }
8738                                    }
8739                            }
8740                    }
8741    
8742                    if (list == null) {
8743                            StringBundler query = null;
8744    
8745                            if (orderByComparator != null) {
8746                                    query = new StringBundler(5 +
8747                                                    (orderByComparator.getOrderByFields().length * 3));
8748                            }
8749                            else {
8750                                    query = new StringBundler(5);
8751                            }
8752    
8753                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
8754    
8755                            query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
8756    
8757                            query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
8758    
8759                            boolean bindDisplayDate = false;
8760    
8761                            if (displayDate == null) {
8762                                    query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
8763                            }
8764                            else {
8765                                    bindDisplayDate = true;
8766    
8767                                    query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
8768                            }
8769    
8770                            if (orderByComparator != null) {
8771                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8772                                            orderByComparator);
8773                            }
8774                            else
8775                             if (pagination) {
8776                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
8777                            }
8778    
8779                            String sql = query.toString();
8780    
8781                            Session session = null;
8782    
8783                            try {
8784                                    session = openSession();
8785    
8786                                    Query q = session.createQuery(sql);
8787    
8788                                    QueryPos qPos = QueryPos.getInstance(q);
8789    
8790                                    qPos.add(groupId);
8791    
8792                                    qPos.add(userId);
8793    
8794                                    if (bindDisplayDate) {
8795                                            qPos.add(new Timestamp(displayDate.getTime()));
8796                                    }
8797    
8798                                    if (!pagination) {
8799                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
8800                                                            start, end, false);
8801    
8802                                            Collections.sort(list);
8803    
8804                                            list = Collections.unmodifiableList(list);
8805                                    }
8806                                    else {
8807                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
8808                                                            start, end);
8809                                    }
8810    
8811                                    cacheResult(list);
8812    
8813                                    finderCache.putResult(finderPath, finderArgs, list);
8814                            }
8815                            catch (Exception e) {
8816                                    finderCache.removeResult(finderPath, finderArgs);
8817    
8818                                    throw processException(e);
8819                            }
8820                            finally {
8821                                    closeSession(session);
8822                            }
8823                    }
8824    
8825                    return list;
8826            }
8827    
8828            /**
8829             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
8830             *
8831             * @param groupId the group ID
8832             * @param userId the user ID
8833             * @param displayDate the display date
8834             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8835             * @return the first matching blogs entry
8836             * @throws NoSuchEntryException if a matching blogs entry could not be found
8837             */
8838            @Override
8839            public BlogsEntry findByG_U_LtD_First(long groupId, long userId,
8840                    Date displayDate, OrderByComparator<BlogsEntry> orderByComparator)
8841                    throws NoSuchEntryException {
8842                    BlogsEntry blogsEntry = fetchByG_U_LtD_First(groupId, userId,
8843                                    displayDate, orderByComparator);
8844    
8845                    if (blogsEntry != null) {
8846                            return blogsEntry;
8847                    }
8848    
8849                    StringBundler msg = new StringBundler(8);
8850    
8851                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8852    
8853                    msg.append("groupId=");
8854                    msg.append(groupId);
8855    
8856                    msg.append(", userId=");
8857                    msg.append(userId);
8858    
8859                    msg.append(", displayDate=");
8860                    msg.append(displayDate);
8861    
8862                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8863    
8864                    throw new NoSuchEntryException(msg.toString());
8865            }
8866    
8867            /**
8868             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
8869             *
8870             * @param groupId the group ID
8871             * @param userId the user ID
8872             * @param displayDate the display date
8873             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8874             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
8875             */
8876            @Override
8877            public BlogsEntry fetchByG_U_LtD_First(long groupId, long userId,
8878                    Date displayDate, OrderByComparator<BlogsEntry> orderByComparator) {
8879                    List<BlogsEntry> list = findByG_U_LtD(groupId, userId, displayDate, 0,
8880                                    1, orderByComparator);
8881    
8882                    if (!list.isEmpty()) {
8883                            return list.get(0);
8884                    }
8885    
8886                    return null;
8887            }
8888    
8889            /**
8890             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
8891             *
8892             * @param groupId the group ID
8893             * @param userId the user ID
8894             * @param displayDate the display date
8895             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8896             * @return the last matching blogs entry
8897             * @throws NoSuchEntryException if a matching blogs entry could not be found
8898             */
8899            @Override
8900            public BlogsEntry findByG_U_LtD_Last(long groupId, long userId,
8901                    Date displayDate, OrderByComparator<BlogsEntry> orderByComparator)
8902                    throws NoSuchEntryException {
8903                    BlogsEntry blogsEntry = fetchByG_U_LtD_Last(groupId, userId,
8904                                    displayDate, orderByComparator);
8905    
8906                    if (blogsEntry != null) {
8907                            return blogsEntry;
8908                    }
8909    
8910                    StringBundler msg = new StringBundler(8);
8911    
8912                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8913    
8914                    msg.append("groupId=");
8915                    msg.append(groupId);
8916    
8917                    msg.append(", userId=");
8918                    msg.append(userId);
8919    
8920                    msg.append(", displayDate=");
8921                    msg.append(displayDate);
8922    
8923                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8924    
8925                    throw new NoSuchEntryException(msg.toString());
8926            }
8927    
8928            /**
8929             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
8930             *
8931             * @param groupId the group ID
8932             * @param userId the user ID
8933             * @param displayDate the display date
8934             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8935             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
8936             */
8937            @Override
8938            public BlogsEntry fetchByG_U_LtD_Last(long groupId, long userId,
8939                    Date displayDate, OrderByComparator<BlogsEntry> orderByComparator) {
8940                    int count = countByG_U_LtD(groupId, userId, displayDate);
8941    
8942                    if (count == 0) {
8943                            return null;
8944                    }
8945    
8946                    List<BlogsEntry> list = findByG_U_LtD(groupId, userId, displayDate,
8947                                    count - 1, count, orderByComparator);
8948    
8949                    if (!list.isEmpty()) {
8950                            return list.get(0);
8951                    }
8952    
8953                    return null;
8954            }
8955    
8956            /**
8957             * 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;.
8958             *
8959             * @param entryId the primary key of the current blogs entry
8960             * @param groupId the group ID
8961             * @param userId the user ID
8962             * @param displayDate the display date
8963             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8964             * @return the previous, current, and next blogs entry
8965             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
8966             */
8967            @Override
8968            public BlogsEntry[] findByG_U_LtD_PrevAndNext(long entryId, long groupId,
8969                    long userId, Date displayDate,
8970                    OrderByComparator<BlogsEntry> orderByComparator)
8971                    throws NoSuchEntryException {
8972                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
8973    
8974                    Session session = null;
8975    
8976                    try {
8977                            session = openSession();
8978    
8979                            BlogsEntry[] array = new BlogsEntryImpl[3];
8980    
8981                            array[0] = getByG_U_LtD_PrevAndNext(session, blogsEntry, groupId,
8982                                            userId, displayDate, orderByComparator, true);
8983    
8984                            array[1] = blogsEntry;
8985    
8986                            array[2] = getByG_U_LtD_PrevAndNext(session, blogsEntry, groupId,
8987                                            userId, displayDate, orderByComparator, false);
8988    
8989                            return array;
8990                    }
8991                    catch (Exception e) {
8992                            throw processException(e);
8993                    }
8994                    finally {
8995                            closeSession(session);
8996                    }
8997            }
8998    
8999            protected BlogsEntry getByG_U_LtD_PrevAndNext(Session session,
9000                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
9001                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
9002                    StringBundler query = null;
9003    
9004                    if (orderByComparator != null) {
9005                            query = new StringBundler(6 +
9006                                            (orderByComparator.getOrderByFields().length * 6));
9007                    }
9008                    else {
9009                            query = new StringBundler(3);
9010                    }
9011    
9012                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
9013    
9014                    query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
9015    
9016                    query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
9017    
9018                    boolean bindDisplayDate = false;
9019    
9020                    if (displayDate == null) {
9021                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
9022                    }
9023                    else {
9024                            bindDisplayDate = true;
9025    
9026                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
9027                    }
9028    
9029                    if (orderByComparator != null) {
9030                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9031    
9032                            if (orderByConditionFields.length > 0) {
9033                                    query.append(WHERE_AND);
9034                            }
9035    
9036                            for (int i = 0; i < orderByConditionFields.length; i++) {
9037                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9038                                    query.append(orderByConditionFields[i]);
9039    
9040                                    if ((i + 1) < orderByConditionFields.length) {
9041                                            if (orderByComparator.isAscending() ^ previous) {
9042                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9043                                            }
9044                                            else {
9045                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
9046                                            }
9047                                    }
9048                                    else {
9049                                            if (orderByComparator.isAscending() ^ previous) {
9050                                                    query.append(WHERE_GREATER_THAN);
9051                                            }
9052                                            else {
9053                                                    query.append(WHERE_LESSER_THAN);
9054                                            }
9055                                    }
9056                            }
9057    
9058                            query.append(ORDER_BY_CLAUSE);
9059    
9060                            String[] orderByFields = orderByComparator.getOrderByFields();
9061    
9062                            for (int i = 0; i < orderByFields.length; i++) {
9063                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9064                                    query.append(orderByFields[i]);
9065    
9066                                    if ((i + 1) < orderByFields.length) {
9067                                            if (orderByComparator.isAscending() ^ previous) {
9068                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
9069                                            }
9070                                            else {
9071                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
9072                                            }
9073                                    }
9074                                    else {
9075                                            if (orderByComparator.isAscending() ^ previous) {
9076                                                    query.append(ORDER_BY_ASC);
9077                                            }
9078                                            else {
9079                                                    query.append(ORDER_BY_DESC);
9080                                            }
9081                                    }
9082                            }
9083                    }
9084                    else {
9085                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
9086                    }
9087    
9088                    String sql = query.toString();
9089    
9090                    Query q = session.createQuery(sql);
9091    
9092                    q.setFirstResult(0);
9093                    q.setMaxResults(2);
9094    
9095                    QueryPos qPos = QueryPos.getInstance(q);
9096    
9097                    qPos.add(groupId);
9098    
9099                    qPos.add(userId);
9100    
9101                    if (bindDisplayDate) {
9102                            qPos.add(new Timestamp(displayDate.getTime()));
9103                    }
9104    
9105                    if (orderByComparator != null) {
9106                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
9107    
9108                            for (Object value : values) {
9109                                    qPos.add(value);
9110                            }
9111                    }
9112    
9113                    List<BlogsEntry> list = q.list();
9114    
9115                    if (list.size() == 2) {
9116                            return list.get(1);
9117                    }
9118                    else {
9119                            return null;
9120                    }
9121            }
9122    
9123            /**
9124             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
9125             *
9126             * @param groupId the group ID
9127             * @param userId the user ID
9128             * @param displayDate the display date
9129             * @return the matching blogs entries that the user has permission to view
9130             */
9131            @Override
9132            public List<BlogsEntry> filterFindByG_U_LtD(long groupId, long userId,
9133                    Date displayDate) {
9134                    return filterFindByG_U_LtD(groupId, userId, displayDate,
9135                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
9136            }
9137    
9138            /**
9139             * 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;.
9140             *
9141             * <p>
9142             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
9143             * </p>
9144             *
9145             * @param groupId the group ID
9146             * @param userId the user ID
9147             * @param displayDate the display date
9148             * @param start the lower bound of the range of blogs entries
9149             * @param end the upper bound of the range of blogs entries (not inclusive)
9150             * @return the range of matching blogs entries that the user has permission to view
9151             */
9152            @Override
9153            public List<BlogsEntry> filterFindByG_U_LtD(long groupId, long userId,
9154                    Date displayDate, int start, int end) {
9155                    return filterFindByG_U_LtD(groupId, userId, displayDate, start, end,
9156                            null);
9157            }
9158    
9159            /**
9160             * 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;.
9161             *
9162             * <p>
9163             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
9164             * </p>
9165             *
9166             * @param groupId the group ID
9167             * @param userId the user ID
9168             * @param displayDate the display date
9169             * @param start the lower bound of the range of blogs entries
9170             * @param end the upper bound of the range of blogs entries (not inclusive)
9171             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9172             * @return the ordered range of matching blogs entries that the user has permission to view
9173             */
9174            @Override
9175            public List<BlogsEntry> filterFindByG_U_LtD(long groupId, long userId,
9176                    Date displayDate, int start, int end,
9177                    OrderByComparator<BlogsEntry> orderByComparator) {
9178                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9179                            return findByG_U_LtD(groupId, userId, displayDate, start, end,
9180                                    orderByComparator);
9181                    }
9182    
9183                    StringBundler query = null;
9184    
9185                    if (orderByComparator != null) {
9186                            query = new StringBundler(5 +
9187                                            (orderByComparator.getOrderByFields().length * 3));
9188                    }
9189                    else {
9190                            query = new StringBundler(5);
9191                    }
9192    
9193                    if (getDB().isSupportsInlineDistinct()) {
9194                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
9195                    }
9196                    else {
9197                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
9198                    }
9199    
9200                    query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
9201    
9202                    query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
9203    
9204                    boolean bindDisplayDate = false;
9205    
9206                    if (displayDate == null) {
9207                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
9208                    }
9209                    else {
9210                            bindDisplayDate = true;
9211    
9212                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
9213                    }
9214    
9215                    if (!getDB().isSupportsInlineDistinct()) {
9216                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
9217                    }
9218    
9219                    if (orderByComparator != null) {
9220                            if (getDB().isSupportsInlineDistinct()) {
9221                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9222                                            orderByComparator, true);
9223                            }
9224                            else {
9225                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
9226                                            orderByComparator, true);
9227                            }
9228                    }
9229                    else {
9230                            if (getDB().isSupportsInlineDistinct()) {
9231                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
9232                            }
9233                            else {
9234                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
9235                            }
9236                    }
9237    
9238                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9239                                    BlogsEntry.class.getName(),
9240                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9241    
9242                    Session session = null;
9243    
9244                    try {
9245                            session = openSession();
9246    
9247                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
9248    
9249                            if (getDB().isSupportsInlineDistinct()) {
9250                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
9251                            }
9252                            else {
9253                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
9254                            }
9255    
9256                            QueryPos qPos = QueryPos.getInstance(q);
9257    
9258                            qPos.add(groupId);
9259    
9260                            qPos.add(userId);
9261    
9262                            if (bindDisplayDate) {
9263                                    qPos.add(new Timestamp(displayDate.getTime()));
9264                            }
9265    
9266                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
9267                    }
9268                    catch (Exception e) {
9269                            throw processException(e);
9270                    }
9271                    finally {
9272                            closeSession(session);
9273                    }
9274            }
9275    
9276            /**
9277             * 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;.
9278             *
9279             * @param entryId the primary key of the current blogs entry
9280             * @param groupId the group ID
9281             * @param userId the user ID
9282             * @param displayDate the display date
9283             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9284             * @return the previous, current, and next blogs entry
9285             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
9286             */
9287            @Override
9288            public BlogsEntry[] filterFindByG_U_LtD_PrevAndNext(long entryId,
9289                    long groupId, long userId, Date displayDate,
9290                    OrderByComparator<BlogsEntry> orderByComparator)
9291                    throws NoSuchEntryException {
9292                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9293                            return findByG_U_LtD_PrevAndNext(entryId, groupId, userId,
9294                                    displayDate, orderByComparator);
9295                    }
9296    
9297                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
9298    
9299                    Session session = null;
9300    
9301                    try {
9302                            session = openSession();
9303    
9304                            BlogsEntry[] array = new BlogsEntryImpl[3];
9305    
9306                            array[0] = filterGetByG_U_LtD_PrevAndNext(session, blogsEntry,
9307                                            groupId, userId, displayDate, orderByComparator, true);
9308    
9309                            array[1] = blogsEntry;
9310    
9311                            array[2] = filterGetByG_U_LtD_PrevAndNext(session, blogsEntry,
9312                                            groupId, userId, displayDate, orderByComparator, false);
9313    
9314                            return array;
9315                    }
9316                    catch (Exception e) {
9317                            throw processException(e);
9318                    }
9319                    finally {
9320                            closeSession(session);
9321                    }
9322            }
9323    
9324            protected BlogsEntry filterGetByG_U_LtD_PrevAndNext(Session session,
9325                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
9326                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
9327                    StringBundler query = null;
9328    
9329                    if (orderByComparator != null) {
9330                            query = new StringBundler(6 +
9331                                            (orderByComparator.getOrderByFields().length * 6));
9332                    }
9333                    else {
9334                            query = new StringBundler(3);
9335                    }
9336    
9337                    if (getDB().isSupportsInlineDistinct()) {
9338                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
9339                    }
9340                    else {
9341                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
9342                    }
9343    
9344                    query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
9345    
9346                    query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
9347    
9348                    boolean bindDisplayDate = false;
9349    
9350                    if (displayDate == null) {
9351                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
9352                    }
9353                    else {
9354                            bindDisplayDate = true;
9355    
9356                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
9357                    }
9358    
9359                    if (!getDB().isSupportsInlineDistinct()) {
9360                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
9361                    }
9362    
9363                    if (orderByComparator != null) {
9364                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9365    
9366                            if (orderByConditionFields.length > 0) {
9367                                    query.append(WHERE_AND);
9368                            }
9369    
9370                            for (int i = 0; i < orderByConditionFields.length; i++) {
9371                                    if (getDB().isSupportsInlineDistinct()) {
9372                                            query.append(_ORDER_BY_ENTITY_ALIAS);
9373                                    }
9374                                    else {
9375                                            query.append(_ORDER_BY_ENTITY_TABLE);
9376                                    }
9377    
9378                                    query.append(orderByConditionFields[i]);
9379    
9380                                    if ((i + 1) < orderByConditionFields.length) {
9381                                            if (orderByComparator.isAscending() ^ previous) {
9382                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9383                                            }
9384                                            else {
9385                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
9386                                            }
9387                                    }
9388                                    else {
9389                                            if (orderByComparator.isAscending() ^ previous) {
9390                                                    query.append(WHERE_GREATER_THAN);
9391                                            }
9392                                            else {
9393                                                    query.append(WHERE_LESSER_THAN);
9394                                            }
9395                                    }
9396                            }
9397    
9398                            query.append(ORDER_BY_CLAUSE);
9399    
9400                            String[] orderByFields = orderByComparator.getOrderByFields();
9401    
9402                            for (int i = 0; i < orderByFields.length; i++) {
9403                                    if (getDB().isSupportsInlineDistinct()) {
9404                                            query.append(_ORDER_BY_ENTITY_ALIAS);
9405                                    }
9406                                    else {
9407                                            query.append(_ORDER_BY_ENTITY_TABLE);
9408                                    }
9409    
9410                                    query.append(orderByFields[i]);
9411    
9412                                    if ((i + 1) < orderByFields.length) {
9413                                            if (orderByComparator.isAscending() ^ previous) {
9414                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
9415                                            }
9416                                            else {
9417                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
9418                                            }
9419                                    }
9420                                    else {
9421                                            if (orderByComparator.isAscending() ^ previous) {
9422                                                    query.append(ORDER_BY_ASC);
9423                                            }
9424                                            else {
9425                                                    query.append(ORDER_BY_DESC);
9426                                            }
9427                                    }
9428                            }
9429                    }
9430                    else {
9431                            if (getDB().isSupportsInlineDistinct()) {
9432                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
9433                            }
9434                            else {
9435                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
9436                            }
9437                    }
9438    
9439                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9440                                    BlogsEntry.class.getName(),
9441                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9442    
9443                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
9444    
9445                    q.setFirstResult(0);
9446                    q.setMaxResults(2);
9447    
9448                    if (getDB().isSupportsInlineDistinct()) {
9449                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
9450                    }
9451                    else {
9452                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
9453                    }
9454    
9455                    QueryPos qPos = QueryPos.getInstance(q);
9456    
9457                    qPos.add(groupId);
9458    
9459                    qPos.add(userId);
9460    
9461                    if (bindDisplayDate) {
9462                            qPos.add(new Timestamp(displayDate.getTime()));
9463                    }
9464    
9465                    if (orderByComparator != null) {
9466                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
9467    
9468                            for (Object value : values) {
9469                                    qPos.add(value);
9470                            }
9471                    }
9472    
9473                    List<BlogsEntry> list = q.list();
9474    
9475                    if (list.size() == 2) {
9476                            return list.get(1);
9477                    }
9478                    else {
9479                            return null;
9480                    }
9481            }
9482    
9483            /**
9484             * Removes all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; from the database.
9485             *
9486             * @param groupId the group ID
9487             * @param userId the user ID
9488             * @param displayDate the display date
9489             */
9490            @Override
9491            public void removeByG_U_LtD(long groupId, long userId, Date displayDate) {
9492                    for (BlogsEntry blogsEntry : findByG_U_LtD(groupId, userId,
9493                                    displayDate, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
9494                            remove(blogsEntry);
9495                    }
9496            }
9497    
9498            /**
9499             * Returns the number of blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
9500             *
9501             * @param groupId the group ID
9502             * @param userId the user ID
9503             * @param displayDate the display date
9504             * @return the number of matching blogs entries
9505             */
9506            @Override
9507            public int countByG_U_LtD(long groupId, long userId, Date displayDate) {
9508                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD;
9509    
9510                    Object[] finderArgs = new Object[] { groupId, userId, displayDate };
9511    
9512                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
9513    
9514                    if (count == null) {
9515                            StringBundler query = new StringBundler(4);
9516    
9517                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
9518    
9519                            query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
9520    
9521                            query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
9522    
9523                            boolean bindDisplayDate = false;
9524    
9525                            if (displayDate == null) {
9526                                    query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
9527                            }
9528                            else {
9529                                    bindDisplayDate = true;
9530    
9531                                    query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
9532                            }
9533    
9534                            String sql = query.toString();
9535    
9536                            Session session = null;
9537    
9538                            try {
9539                                    session = openSession();
9540    
9541                                    Query q = session.createQuery(sql);
9542    
9543                                    QueryPos qPos = QueryPos.getInstance(q);
9544    
9545                                    qPos.add(groupId);
9546    
9547                                    qPos.add(userId);
9548    
9549                                    if (bindDisplayDate) {
9550                                            qPos.add(new Timestamp(displayDate.getTime()));
9551                                    }
9552    
9553                                    count = (Long)q.uniqueResult();
9554    
9555                                    finderCache.putResult(finderPath, finderArgs, count);
9556                            }
9557                            catch (Exception e) {
9558                                    finderCache.removeResult(finderPath, finderArgs);
9559    
9560                                    throw processException(e);
9561                            }
9562                            finally {
9563                                    closeSession(session);
9564                            }
9565                    }
9566    
9567                    return count.intValue();
9568            }
9569    
9570            /**
9571             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
9572             *
9573             * @param groupId the group ID
9574             * @param userId the user ID
9575             * @param displayDate the display date
9576             * @return the number of matching blogs entries that the user has permission to view
9577             */
9578            @Override
9579            public int filterCountByG_U_LtD(long groupId, long userId, Date displayDate) {
9580                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9581                            return countByG_U_LtD(groupId, userId, displayDate);
9582                    }
9583    
9584                    StringBundler query = new StringBundler(4);
9585    
9586                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
9587    
9588                    query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
9589    
9590                    query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
9591    
9592                    boolean bindDisplayDate = false;
9593    
9594                    if (displayDate == null) {
9595                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
9596                    }
9597                    else {
9598                            bindDisplayDate = true;
9599    
9600                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
9601                    }
9602    
9603                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9604                                    BlogsEntry.class.getName(),
9605                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9606    
9607                    Session session = null;
9608    
9609                    try {
9610                            session = openSession();
9611    
9612                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
9613    
9614                            q.addScalar(COUNT_COLUMN_NAME,
9615                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
9616    
9617                            QueryPos qPos = QueryPos.getInstance(q);
9618    
9619                            qPos.add(groupId);
9620    
9621                            qPos.add(userId);
9622    
9623                            if (bindDisplayDate) {
9624                                    qPos.add(new Timestamp(displayDate.getTime()));
9625                            }
9626    
9627                            Long count = (Long)q.uniqueResult();
9628    
9629                            return count.intValue();
9630                    }
9631                    catch (Exception e) {
9632                            throw processException(e);
9633                    }
9634                    finally {
9635                            closeSession(session);
9636                    }
9637            }
9638    
9639            private static final String _FINDER_COLUMN_G_U_LTD_GROUPID_2 = "blogsEntry.groupId = ? AND ";
9640            private static final String _FINDER_COLUMN_G_U_LTD_USERID_2 = "blogsEntry.userId = ? AND ";
9641            private static final String _FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1 = "blogsEntry.displayDate IS NULL";
9642            private static final String _FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2 = "blogsEntry.displayDate < ?";
9643            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
9644                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
9645                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_S",
9646                            new String[] {
9647                                    Long.class.getName(), Long.class.getName(),
9648                                    Integer.class.getName(),
9649                                    
9650                            Integer.class.getName(), Integer.class.getName(),
9651                                    OrderByComparator.class.getName()
9652                            });
9653            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
9654                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
9655                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U_S",
9656                            new String[] {
9657                                    Long.class.getName(), Long.class.getName(),
9658                                    Integer.class.getName()
9659                            },
9660                            BlogsEntryModelImpl.GROUPID_COLUMN_BITMASK |
9661                            BlogsEntryModelImpl.USERID_COLUMN_BITMASK |
9662                            BlogsEntryModelImpl.STATUS_COLUMN_BITMASK |
9663                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
9664                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
9665            public static final FinderPath FINDER_PATH_COUNT_BY_G_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
9666                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
9667                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U_S",
9668                            new String[] {
9669                                    Long.class.getName(), Long.class.getName(),
9670                                    Integer.class.getName()
9671                            });
9672    
9673            /**
9674             * Returns all the blogs entries where groupId = &#63; and userId = &#63; and status = &#63;.
9675             *
9676             * @param groupId the group ID
9677             * @param userId the user ID
9678             * @param status the status
9679             * @return the matching blogs entries
9680             */
9681            @Override
9682            public List<BlogsEntry> findByG_U_S(long groupId, long userId, int status) {
9683                    return findByG_U_S(groupId, userId, status, QueryUtil.ALL_POS,
9684                            QueryUtil.ALL_POS, null);
9685            }
9686    
9687            /**
9688             * Returns a range of all the blogs entries where groupId = &#63; and userId = &#63; and status = &#63;.
9689             *
9690             * <p>
9691             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
9692             * </p>
9693             *
9694             * @param groupId the group ID
9695             * @param userId the user ID
9696             * @param status the status
9697             * @param start the lower bound of the range of blogs entries
9698             * @param end the upper bound of the range of blogs entries (not inclusive)
9699             * @return the range of matching blogs entries
9700             */
9701            @Override
9702            public List<BlogsEntry> findByG_U_S(long groupId, long userId, int status,
9703                    int start, int end) {
9704                    return findByG_U_S(groupId, userId, status, start, end, null);
9705            }
9706    
9707            /**
9708             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and status = &#63;.
9709             *
9710             * <p>
9711             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
9712             * </p>
9713             *
9714             * @param groupId the group ID
9715             * @param userId the user ID
9716             * @param status the status
9717             * @param start the lower bound of the range of blogs entries
9718             * @param end the upper bound of the range of blogs entries (not inclusive)
9719             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9720             * @return the ordered range of matching blogs entries
9721             */
9722            @Override
9723            public List<BlogsEntry> findByG_U_S(long groupId, long userId, int status,
9724                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator) {
9725                    return findByG_U_S(groupId, userId, status, start, end,
9726                            orderByComparator, true);
9727            }
9728    
9729            /**
9730             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and status = &#63;.
9731             *
9732             * <p>
9733             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
9734             * </p>
9735             *
9736             * @param groupId the group ID
9737             * @param userId the user ID
9738             * @param status the status
9739             * @param start the lower bound of the range of blogs entries
9740             * @param end the upper bound of the range of blogs entries (not inclusive)
9741             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9742             * @param retrieveFromCache whether to retrieve from the finder cache
9743             * @return the ordered range of matching blogs entries
9744             */
9745            @Override
9746            public List<BlogsEntry> findByG_U_S(long groupId, long userId, int status,
9747                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator,
9748                    boolean retrieveFromCache) {
9749                    boolean pagination = true;
9750                    FinderPath finderPath = null;
9751                    Object[] finderArgs = null;
9752    
9753                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
9754                                    (orderByComparator == null)) {
9755                            pagination = false;
9756                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S;
9757                            finderArgs = new Object[] { groupId, userId, status };
9758                    }
9759                    else {
9760                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_S;
9761                            finderArgs = new Object[] {
9762                                            groupId, userId, status,
9763                                            
9764                                            start, end, orderByComparator
9765                                    };
9766                    }
9767    
9768                    List<BlogsEntry> list = null;
9769    
9770                    if (retrieveFromCache) {
9771                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
9772                                            finderArgs, this);
9773    
9774                            if ((list != null) && !list.isEmpty()) {
9775                                    for (BlogsEntry blogsEntry : list) {
9776                                            if ((groupId != blogsEntry.getGroupId()) ||
9777                                                            (userId != blogsEntry.getUserId()) ||
9778                                                            (status != blogsEntry.getStatus())) {
9779                                                    list = null;
9780    
9781                                                    break;
9782                                            }
9783                                    }
9784                            }
9785                    }
9786    
9787                    if (list == null) {
9788                            StringBundler query = null;
9789    
9790                            if (orderByComparator != null) {
9791                                    query = new StringBundler(5 +
9792                                                    (orderByComparator.getOrderByFields().length * 3));
9793                            }
9794                            else {
9795                                    query = new StringBundler(5);
9796                            }
9797    
9798                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
9799    
9800                            query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
9801    
9802                            query.append(_FINDER_COLUMN_G_U_S_USERID_2);
9803    
9804                            query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
9805    
9806                            if (orderByComparator != null) {
9807                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9808                                            orderByComparator);
9809                            }
9810                            else
9811                             if (pagination) {
9812                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
9813                            }
9814    
9815                            String sql = query.toString();
9816    
9817                            Session session = null;
9818    
9819                            try {
9820                                    session = openSession();
9821    
9822                                    Query q = session.createQuery(sql);
9823    
9824                                    QueryPos qPos = QueryPos.getInstance(q);
9825    
9826                                    qPos.add(groupId);
9827    
9828                                    qPos.add(userId);
9829    
9830                                    qPos.add(status);
9831    
9832                                    if (!pagination) {
9833                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
9834                                                            start, end, false);
9835    
9836                                            Collections.sort(list);
9837    
9838                                            list = Collections.unmodifiableList(list);
9839                                    }
9840                                    else {
9841                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
9842                                                            start, end);
9843                                    }
9844    
9845                                    cacheResult(list);
9846    
9847                                    finderCache.putResult(finderPath, finderArgs, list);
9848                            }
9849                            catch (Exception e) {
9850                                    finderCache.removeResult(finderPath, finderArgs);
9851    
9852                                    throw processException(e);
9853                            }
9854                            finally {
9855                                    closeSession(session);
9856                            }
9857                    }
9858    
9859                    return list;
9860            }
9861    
9862            /**
9863             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
9864             *
9865             * @param groupId the group ID
9866             * @param userId the user ID
9867             * @param status the status
9868             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9869             * @return the first matching blogs entry
9870             * @throws NoSuchEntryException if a matching blogs entry could not be found
9871             */
9872            @Override
9873            public BlogsEntry findByG_U_S_First(long groupId, long userId, int status,
9874                    OrderByComparator<BlogsEntry> orderByComparator)
9875                    throws NoSuchEntryException {
9876                    BlogsEntry blogsEntry = fetchByG_U_S_First(groupId, userId, status,
9877                                    orderByComparator);
9878    
9879                    if (blogsEntry != null) {
9880                            return blogsEntry;
9881                    }
9882    
9883                    StringBundler msg = new StringBundler(8);
9884    
9885                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9886    
9887                    msg.append("groupId=");
9888                    msg.append(groupId);
9889    
9890                    msg.append(", userId=");
9891                    msg.append(userId);
9892    
9893                    msg.append(", status=");
9894                    msg.append(status);
9895    
9896                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9897    
9898                    throw new NoSuchEntryException(msg.toString());
9899            }
9900    
9901            /**
9902             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
9903             *
9904             * @param groupId the group ID
9905             * @param userId the user ID
9906             * @param status the status
9907             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9908             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
9909             */
9910            @Override
9911            public BlogsEntry fetchByG_U_S_First(long groupId, long userId, int status,
9912                    OrderByComparator<BlogsEntry> orderByComparator) {
9913                    List<BlogsEntry> list = findByG_U_S(groupId, userId, status, 0, 1,
9914                                    orderByComparator);
9915    
9916                    if (!list.isEmpty()) {
9917                            return list.get(0);
9918                    }
9919    
9920                    return null;
9921            }
9922    
9923            /**
9924             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
9925             *
9926             * @param groupId the group ID
9927             * @param userId the user ID
9928             * @param status the status
9929             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9930             * @return the last matching blogs entry
9931             * @throws NoSuchEntryException if a matching blogs entry could not be found
9932             */
9933            @Override
9934            public BlogsEntry findByG_U_S_Last(long groupId, long userId, int status,
9935                    OrderByComparator<BlogsEntry> orderByComparator)
9936                    throws NoSuchEntryException {
9937                    BlogsEntry blogsEntry = fetchByG_U_S_Last(groupId, userId, status,
9938                                    orderByComparator);
9939    
9940                    if (blogsEntry != null) {
9941                            return blogsEntry;
9942                    }
9943    
9944                    StringBundler msg = new StringBundler(8);
9945    
9946                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9947    
9948                    msg.append("groupId=");
9949                    msg.append(groupId);
9950    
9951                    msg.append(", userId=");
9952                    msg.append(userId);
9953    
9954                    msg.append(", status=");
9955                    msg.append(status);
9956    
9957                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9958    
9959                    throw new NoSuchEntryException(msg.toString());
9960            }
9961    
9962            /**
9963             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
9964             *
9965             * @param groupId the group ID
9966             * @param userId the user ID
9967             * @param status the status
9968             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9969             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
9970             */
9971            @Override
9972            public BlogsEntry fetchByG_U_S_Last(long groupId, long userId, int status,
9973                    OrderByComparator<BlogsEntry> orderByComparator) {
9974                    int count = countByG_U_S(groupId, userId, status);
9975    
9976                    if (count == 0) {
9977                            return null;
9978                    }
9979    
9980                    List<BlogsEntry> list = findByG_U_S(groupId, userId, status, count - 1,
9981                                    count, orderByComparator);
9982    
9983                    if (!list.isEmpty()) {
9984                            return list.get(0);
9985                    }
9986    
9987                    return null;
9988            }
9989    
9990            /**
9991             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
9992             *
9993             * @param entryId the primary key of the current blogs entry
9994             * @param groupId the group ID
9995             * @param userId the user ID
9996             * @param status the status
9997             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9998             * @return the previous, current, and next blogs entry
9999             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
10000             */
10001            @Override
10002            public BlogsEntry[] findByG_U_S_PrevAndNext(long entryId, long groupId,
10003                    long userId, int status, OrderByComparator<BlogsEntry> orderByComparator)
10004                    throws NoSuchEntryException {
10005                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
10006    
10007                    Session session = null;
10008    
10009                    try {
10010                            session = openSession();
10011    
10012                            BlogsEntry[] array = new BlogsEntryImpl[3];
10013    
10014                            array[0] = getByG_U_S_PrevAndNext(session, blogsEntry, groupId,
10015                                            userId, status, orderByComparator, true);
10016    
10017                            array[1] = blogsEntry;
10018    
10019                            array[2] = getByG_U_S_PrevAndNext(session, blogsEntry, groupId,
10020                                            userId, status, orderByComparator, false);
10021    
10022                            return array;
10023                    }
10024                    catch (Exception e) {
10025                            throw processException(e);
10026                    }
10027                    finally {
10028                            closeSession(session);
10029                    }
10030            }
10031    
10032            protected BlogsEntry getByG_U_S_PrevAndNext(Session session,
10033                    BlogsEntry blogsEntry, long groupId, long userId, int status,
10034                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
10035                    StringBundler query = null;
10036    
10037                    if (orderByComparator != null) {
10038                            query = new StringBundler(6 +
10039                                            (orderByComparator.getOrderByFields().length * 6));
10040                    }
10041                    else {
10042                            query = new StringBundler(3);
10043                    }
10044    
10045                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
10046    
10047                    query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
10048    
10049                    query.append(_FINDER_COLUMN_G_U_S_USERID_2);
10050    
10051                    query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
10052    
10053                    if (orderByComparator != null) {
10054                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10055    
10056                            if (orderByConditionFields.length > 0) {
10057                                    query.append(WHERE_AND);
10058                            }
10059    
10060                            for (int i = 0; i < orderByConditionFields.length; i++) {
10061                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10062                                    query.append(orderByConditionFields[i]);
10063    
10064                                    if ((i + 1) < orderByConditionFields.length) {
10065                                            if (orderByComparator.isAscending() ^ previous) {
10066                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10067                                            }
10068                                            else {
10069                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10070                                            }
10071                                    }
10072                                    else {
10073                                            if (orderByComparator.isAscending() ^ previous) {
10074                                                    query.append(WHERE_GREATER_THAN);
10075                                            }
10076                                            else {
10077                                                    query.append(WHERE_LESSER_THAN);
10078                                            }
10079                                    }
10080                            }
10081    
10082                            query.append(ORDER_BY_CLAUSE);
10083    
10084                            String[] orderByFields = orderByComparator.getOrderByFields();
10085    
10086                            for (int i = 0; i < orderByFields.length; i++) {
10087                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10088                                    query.append(orderByFields[i]);
10089    
10090                                    if ((i + 1) < orderByFields.length) {
10091                                            if (orderByComparator.isAscending() ^ previous) {
10092                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10093                                            }
10094                                            else {
10095                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10096                                            }
10097                                    }
10098                                    else {
10099                                            if (orderByComparator.isAscending() ^ previous) {
10100                                                    query.append(ORDER_BY_ASC);
10101                                            }
10102                                            else {
10103                                                    query.append(ORDER_BY_DESC);
10104                                            }
10105                                    }
10106                            }
10107                    }
10108                    else {
10109                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
10110                    }
10111    
10112                    String sql = query.toString();
10113    
10114                    Query q = session.createQuery(sql);
10115    
10116                    q.setFirstResult(0);
10117                    q.setMaxResults(2);
10118    
10119                    QueryPos qPos = QueryPos.getInstance(q);
10120    
10121                    qPos.add(groupId);
10122    
10123                    qPos.add(userId);
10124    
10125                    qPos.add(status);
10126    
10127                    if (orderByComparator != null) {
10128                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
10129    
10130                            for (Object value : values) {
10131                                    qPos.add(value);
10132                            }
10133                    }
10134    
10135                    List<BlogsEntry> list = q.list();
10136    
10137                    if (list.size() == 2) {
10138                            return list.get(1);
10139                    }
10140                    else {
10141                            return null;
10142                    }
10143            }
10144    
10145            /**
10146             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status = &#63;.
10147             *
10148             * @param groupId the group ID
10149             * @param userId the user ID
10150             * @param status the status
10151             * @return the matching blogs entries that the user has permission to view
10152             */
10153            @Override
10154            public List<BlogsEntry> filterFindByG_U_S(long groupId, long userId,
10155                    int status) {
10156                    return filterFindByG_U_S(groupId, userId, status, QueryUtil.ALL_POS,
10157                            QueryUtil.ALL_POS, null);
10158            }
10159    
10160            /**
10161             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status = &#63;.
10162             *
10163             * <p>
10164             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
10165             * </p>
10166             *
10167             * @param groupId the group ID
10168             * @param userId the user ID
10169             * @param status the status
10170             * @param start the lower bound of the range of blogs entries
10171             * @param end the upper bound of the range of blogs entries (not inclusive)
10172             * @return the range of matching blogs entries that the user has permission to view
10173             */
10174            @Override
10175            public List<BlogsEntry> filterFindByG_U_S(long groupId, long userId,
10176                    int status, int start, int end) {
10177                    return filterFindByG_U_S(groupId, userId, status, start, end, null);
10178            }
10179    
10180            /**
10181             * 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;.
10182             *
10183             * <p>
10184             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
10185             * </p>
10186             *
10187             * @param groupId the group ID
10188             * @param userId the user ID
10189             * @param status the status
10190             * @param start the lower bound of the range of blogs entries
10191             * @param end the upper bound of the range of blogs entries (not inclusive)
10192             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10193             * @return the ordered range of matching blogs entries that the user has permission to view
10194             */
10195            @Override
10196            public List<BlogsEntry> filterFindByG_U_S(long groupId, long userId,
10197                    int status, int start, int end,
10198                    OrderByComparator<BlogsEntry> orderByComparator) {
10199                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10200                            return findByG_U_S(groupId, userId, status, start, end,
10201                                    orderByComparator);
10202                    }
10203    
10204                    StringBundler query = null;
10205    
10206                    if (orderByComparator != null) {
10207                            query = new StringBundler(5 +
10208                                            (orderByComparator.getOrderByFields().length * 3));
10209                    }
10210                    else {
10211                            query = new StringBundler(5);
10212                    }
10213    
10214                    if (getDB().isSupportsInlineDistinct()) {
10215                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
10216                    }
10217                    else {
10218                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
10219                    }
10220    
10221                    query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
10222    
10223                    query.append(_FINDER_COLUMN_G_U_S_USERID_2);
10224    
10225                    query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
10226    
10227                    if (!getDB().isSupportsInlineDistinct()) {
10228                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
10229                    }
10230    
10231                    if (orderByComparator != null) {
10232                            if (getDB().isSupportsInlineDistinct()) {
10233                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10234                                            orderByComparator, true);
10235                            }
10236                            else {
10237                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
10238                                            orderByComparator, true);
10239                            }
10240                    }
10241                    else {
10242                            if (getDB().isSupportsInlineDistinct()) {
10243                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
10244                            }
10245                            else {
10246                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
10247                            }
10248                    }
10249    
10250                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10251                                    BlogsEntry.class.getName(),
10252                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10253    
10254                    Session session = null;
10255    
10256                    try {
10257                            session = openSession();
10258    
10259                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
10260    
10261                            if (getDB().isSupportsInlineDistinct()) {
10262                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
10263                            }
10264                            else {
10265                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
10266                            }
10267    
10268                            QueryPos qPos = QueryPos.getInstance(q);
10269    
10270                            qPos.add(groupId);
10271    
10272                            qPos.add(userId);
10273    
10274                            qPos.add(status);
10275    
10276                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
10277                    }
10278                    catch (Exception e) {
10279                            throw processException(e);
10280                    }
10281                    finally {
10282                            closeSession(session);
10283                    }
10284            }
10285    
10286            /**
10287             * 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;.
10288             *
10289             * @param entryId the primary key of the current blogs entry
10290             * @param groupId the group ID
10291             * @param userId the user ID
10292             * @param status the status
10293             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10294             * @return the previous, current, and next blogs entry
10295             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
10296             */
10297            @Override
10298            public BlogsEntry[] filterFindByG_U_S_PrevAndNext(long entryId,
10299                    long groupId, long userId, int status,
10300                    OrderByComparator<BlogsEntry> orderByComparator)
10301                    throws NoSuchEntryException {
10302                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10303                            return findByG_U_S_PrevAndNext(entryId, groupId, userId, status,
10304                                    orderByComparator);
10305                    }
10306    
10307                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
10308    
10309                    Session session = null;
10310    
10311                    try {
10312                            session = openSession();
10313    
10314                            BlogsEntry[] array = new BlogsEntryImpl[3];
10315    
10316                            array[0] = filterGetByG_U_S_PrevAndNext(session, blogsEntry,
10317                                            groupId, userId, status, orderByComparator, true);
10318    
10319                            array[1] = blogsEntry;
10320    
10321                            array[2] = filterGetByG_U_S_PrevAndNext(session, blogsEntry,
10322                                            groupId, userId, status, orderByComparator, false);
10323    
10324                            return array;
10325                    }
10326                    catch (Exception e) {
10327                            throw processException(e);
10328                    }
10329                    finally {
10330                            closeSession(session);
10331                    }
10332            }
10333    
10334            protected BlogsEntry filterGetByG_U_S_PrevAndNext(Session session,
10335                    BlogsEntry blogsEntry, long groupId, long userId, int status,
10336                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
10337                    StringBundler query = null;
10338    
10339                    if (orderByComparator != null) {
10340                            query = new StringBundler(6 +
10341                                            (orderByComparator.getOrderByFields().length * 6));
10342                    }
10343                    else {
10344                            query = new StringBundler(3);
10345                    }
10346    
10347                    if (getDB().isSupportsInlineDistinct()) {
10348                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
10349                    }
10350                    else {
10351                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
10352                    }
10353    
10354                    query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
10355    
10356                    query.append(_FINDER_COLUMN_G_U_S_USERID_2);
10357    
10358                    query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
10359    
10360                    if (!getDB().isSupportsInlineDistinct()) {
10361                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
10362                    }
10363    
10364                    if (orderByComparator != null) {
10365                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10366    
10367                            if (orderByConditionFields.length > 0) {
10368                                    query.append(WHERE_AND);
10369                            }
10370    
10371                            for (int i = 0; i < orderByConditionFields.length; i++) {
10372                                    if (getDB().isSupportsInlineDistinct()) {
10373                                            query.append(_ORDER_BY_ENTITY_ALIAS);
10374                                    }
10375                                    else {
10376                                            query.append(_ORDER_BY_ENTITY_TABLE);
10377                                    }
10378    
10379                                    query.append(orderByConditionFields[i]);
10380    
10381                                    if ((i + 1) < orderByConditionFields.length) {
10382                                            if (orderByComparator.isAscending() ^ previous) {
10383                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10384                                            }
10385                                            else {
10386                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10387                                            }
10388                                    }
10389                                    else {
10390                                            if (orderByComparator.isAscending() ^ previous) {
10391                                                    query.append(WHERE_GREATER_THAN);
10392                                            }
10393                                            else {
10394                                                    query.append(WHERE_LESSER_THAN);
10395                                            }
10396                                    }
10397                            }
10398    
10399                            query.append(ORDER_BY_CLAUSE);
10400    
10401                            String[] orderByFields = orderByComparator.getOrderByFields();
10402    
10403                            for (int i = 0; i < orderByFields.length; i++) {
10404                                    if (getDB().isSupportsInlineDistinct()) {
10405                                            query.append(_ORDER_BY_ENTITY_ALIAS);
10406                                    }
10407                                    else {
10408                                            query.append(_ORDER_BY_ENTITY_TABLE);
10409                                    }
10410    
10411                                    query.append(orderByFields[i]);
10412    
10413                                    if ((i + 1) < orderByFields.length) {
10414                                            if (orderByComparator.isAscending() ^ previous) {
10415                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10416                                            }
10417                                            else {
10418                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10419                                            }
10420                                    }
10421                                    else {
10422                                            if (orderByComparator.isAscending() ^ previous) {
10423                                                    query.append(ORDER_BY_ASC);
10424                                            }
10425                                            else {
10426                                                    query.append(ORDER_BY_DESC);
10427                                            }
10428                                    }
10429                            }
10430                    }
10431                    else {
10432                            if (getDB().isSupportsInlineDistinct()) {
10433                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
10434                            }
10435                            else {
10436                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
10437                            }
10438                    }
10439    
10440                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10441                                    BlogsEntry.class.getName(),
10442                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10443    
10444                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
10445    
10446                    q.setFirstResult(0);
10447                    q.setMaxResults(2);
10448    
10449                    if (getDB().isSupportsInlineDistinct()) {
10450                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
10451                    }
10452                    else {
10453                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
10454                    }
10455    
10456                    QueryPos qPos = QueryPos.getInstance(q);
10457    
10458                    qPos.add(groupId);
10459    
10460                    qPos.add(userId);
10461    
10462                    qPos.add(status);
10463    
10464                    if (orderByComparator != null) {
10465                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
10466    
10467                            for (Object value : values) {
10468                                    qPos.add(value);
10469                            }
10470                    }
10471    
10472                    List<BlogsEntry> list = q.list();
10473    
10474                    if (list.size() == 2) {
10475                            return list.get(1);
10476                    }
10477                    else {
10478                            return null;
10479                    }
10480            }
10481    
10482            /**
10483             * Removes all the blogs entries where groupId = &#63; and userId = &#63; and status = &#63; from the database.
10484             *
10485             * @param groupId the group ID
10486             * @param userId the user ID
10487             * @param status the status
10488             */
10489            @Override
10490            public void removeByG_U_S(long groupId, long userId, int status) {
10491                    for (BlogsEntry blogsEntry : findByG_U_S(groupId, userId, status,
10492                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
10493                            remove(blogsEntry);
10494                    }
10495            }
10496    
10497            /**
10498             * Returns the number of blogs entries where groupId = &#63; and userId = &#63; and status = &#63;.
10499             *
10500             * @param groupId the group ID
10501             * @param userId the user ID
10502             * @param status the status
10503             * @return the number of matching blogs entries
10504             */
10505            @Override
10506            public int countByG_U_S(long groupId, long userId, int status) {
10507                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_U_S;
10508    
10509                    Object[] finderArgs = new Object[] { groupId, userId, status };
10510    
10511                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
10512    
10513                    if (count == null) {
10514                            StringBundler query = new StringBundler(4);
10515    
10516                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
10517    
10518                            query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
10519    
10520                            query.append(_FINDER_COLUMN_G_U_S_USERID_2);
10521    
10522                            query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
10523    
10524                            String sql = query.toString();
10525    
10526                            Session session = null;
10527    
10528                            try {
10529                                    session = openSession();
10530    
10531                                    Query q = session.createQuery(sql);
10532    
10533                                    QueryPos qPos = QueryPos.getInstance(q);
10534    
10535                                    qPos.add(groupId);
10536    
10537                                    qPos.add(userId);
10538    
10539                                    qPos.add(status);
10540    
10541                                    count = (Long)q.uniqueResult();
10542    
10543                                    finderCache.putResult(finderPath, finderArgs, count);
10544                            }
10545                            catch (Exception e) {
10546                                    finderCache.removeResult(finderPath, finderArgs);
10547    
10548                                    throw processException(e);
10549                            }
10550                            finally {
10551                                    closeSession(session);
10552                            }
10553                    }
10554    
10555                    return count.intValue();
10556            }
10557    
10558            /**
10559             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status = &#63;.
10560             *
10561             * @param groupId the group ID
10562             * @param userId the user ID
10563             * @param status the status
10564             * @return the number of matching blogs entries that the user has permission to view
10565             */
10566            @Override
10567            public int filterCountByG_U_S(long groupId, long userId, int status) {
10568                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10569                            return countByG_U_S(groupId, userId, status);
10570                    }
10571    
10572                    StringBundler query = new StringBundler(4);
10573    
10574                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
10575    
10576                    query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
10577    
10578                    query.append(_FINDER_COLUMN_G_U_S_USERID_2);
10579    
10580                    query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
10581    
10582                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10583                                    BlogsEntry.class.getName(),
10584                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10585    
10586                    Session session = null;
10587    
10588                    try {
10589                            session = openSession();
10590    
10591                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
10592    
10593                            q.addScalar(COUNT_COLUMN_NAME,
10594                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
10595    
10596                            QueryPos qPos = QueryPos.getInstance(q);
10597    
10598                            qPos.add(groupId);
10599    
10600                            qPos.add(userId);
10601    
10602                            qPos.add(status);
10603    
10604                            Long count = (Long)q.uniqueResult();
10605    
10606                            return count.intValue();
10607                    }
10608                    catch (Exception e) {
10609                            throw processException(e);
10610                    }
10611                    finally {
10612                            closeSession(session);
10613                    }
10614            }
10615    
10616            private static final String _FINDER_COLUMN_G_U_S_GROUPID_2 = "blogsEntry.groupId = ? AND ";
10617            private static final String _FINDER_COLUMN_G_U_S_USERID_2 = "blogsEntry.userId = ? AND ";
10618            private static final String _FINDER_COLUMN_G_U_S_STATUS_2 = "blogsEntry.status = ?";
10619            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_NOTS = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
10620                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
10621                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_NotS",
10622                            new String[] {
10623                                    Long.class.getName(), Long.class.getName(),
10624                                    Integer.class.getName(),
10625                                    
10626                            Integer.class.getName(), Integer.class.getName(),
10627                                    OrderByComparator.class.getName()
10628                            });
10629            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_NOTS =
10630                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
10631                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
10632                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_U_NotS",
10633                            new String[] {
10634                                    Long.class.getName(), Long.class.getName(),
10635                                    Integer.class.getName()
10636                            });
10637    
10638            /**
10639             * Returns all the blogs entries where groupId = &#63; and userId = &#63; and status &ne; &#63;.
10640             *
10641             * @param groupId the group ID
10642             * @param userId the user ID
10643             * @param status the status
10644             * @return the matching blogs entries
10645             */
10646            @Override
10647            public List<BlogsEntry> findByG_U_NotS(long groupId, long userId, int status) {
10648                    return findByG_U_NotS(groupId, userId, status, QueryUtil.ALL_POS,
10649                            QueryUtil.ALL_POS, null);
10650            }
10651    
10652            /**
10653             * Returns a range of all the blogs entries where groupId = &#63; and userId = &#63; and status &ne; &#63;.
10654             *
10655             * <p>
10656             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
10657             * </p>
10658             *
10659             * @param groupId the group ID
10660             * @param userId the user ID
10661             * @param status the status
10662             * @param start the lower bound of the range of blogs entries
10663             * @param end the upper bound of the range of blogs entries (not inclusive)
10664             * @return the range of matching blogs entries
10665             */
10666            @Override
10667            public List<BlogsEntry> findByG_U_NotS(long groupId, long userId,
10668                    int status, int start, int end) {
10669                    return findByG_U_NotS(groupId, userId, status, start, end, null);
10670            }
10671    
10672            /**
10673             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and status &ne; &#63;.
10674             *
10675             * <p>
10676             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
10677             * </p>
10678             *
10679             * @param groupId the group ID
10680             * @param userId the user ID
10681             * @param status the status
10682             * @param start the lower bound of the range of blogs entries
10683             * @param end the upper bound of the range of blogs entries (not inclusive)
10684             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10685             * @return the ordered range of matching blogs entries
10686             */
10687            @Override
10688            public List<BlogsEntry> findByG_U_NotS(long groupId, long userId,
10689                    int status, int start, int end,
10690                    OrderByComparator<BlogsEntry> orderByComparator) {
10691                    return findByG_U_NotS(groupId, userId, status, start, end,
10692                            orderByComparator, true);
10693            }
10694    
10695            /**
10696             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and status &ne; &#63;.
10697             *
10698             * <p>
10699             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
10700             * </p>
10701             *
10702             * @param groupId the group ID
10703             * @param userId the user ID
10704             * @param status the status
10705             * @param start the lower bound of the range of blogs entries
10706             * @param end the upper bound of the range of blogs entries (not inclusive)
10707             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10708             * @param retrieveFromCache whether to retrieve from the finder cache
10709             * @return the ordered range of matching blogs entries
10710             */
10711            @Override
10712            public List<BlogsEntry> findByG_U_NotS(long groupId, long userId,
10713                    int status, int start, int end,
10714                    OrderByComparator<BlogsEntry> orderByComparator,
10715                    boolean retrieveFromCache) {
10716                    boolean pagination = true;
10717                    FinderPath finderPath = null;
10718                    Object[] finderArgs = null;
10719    
10720                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_NOTS;
10721                    finderArgs = new Object[] {
10722                                    groupId, userId, status,
10723                                    
10724                                    start, end, orderByComparator
10725                            };
10726    
10727                    List<BlogsEntry> list = null;
10728    
10729                    if (retrieveFromCache) {
10730                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
10731                                            finderArgs, this);
10732    
10733                            if ((list != null) && !list.isEmpty()) {
10734                                    for (BlogsEntry blogsEntry : list) {
10735                                            if ((groupId != blogsEntry.getGroupId()) ||
10736                                                            (userId != blogsEntry.getUserId()) ||
10737                                                            (status == blogsEntry.getStatus())) {
10738                                                    list = null;
10739    
10740                                                    break;
10741                                            }
10742                                    }
10743                            }
10744                    }
10745    
10746                    if (list == null) {
10747                            StringBundler query = null;
10748    
10749                            if (orderByComparator != null) {
10750                                    query = new StringBundler(5 +
10751                                                    (orderByComparator.getOrderByFields().length * 3));
10752                            }
10753                            else {
10754                                    query = new StringBundler(5);
10755                            }
10756    
10757                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
10758    
10759                            query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
10760    
10761                            query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
10762    
10763                            query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
10764    
10765                            if (orderByComparator != null) {
10766                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10767                                            orderByComparator);
10768                            }
10769                            else
10770                             if (pagination) {
10771                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
10772                            }
10773    
10774                            String sql = query.toString();
10775    
10776                            Session session = null;
10777    
10778                            try {
10779                                    session = openSession();
10780    
10781                                    Query q = session.createQuery(sql);
10782    
10783                                    QueryPos qPos = QueryPos.getInstance(q);
10784    
10785                                    qPos.add(groupId);
10786    
10787                                    qPos.add(userId);
10788    
10789                                    qPos.add(status);
10790    
10791                                    if (!pagination) {
10792                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
10793                                                            start, end, false);
10794    
10795                                            Collections.sort(list);
10796    
10797                                            list = Collections.unmodifiableList(list);
10798                                    }
10799                                    else {
10800                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
10801                                                            start, end);
10802                                    }
10803    
10804                                    cacheResult(list);
10805    
10806                                    finderCache.putResult(finderPath, finderArgs, list);
10807                            }
10808                            catch (Exception e) {
10809                                    finderCache.removeResult(finderPath, finderArgs);
10810    
10811                                    throw processException(e);
10812                            }
10813                            finally {
10814                                    closeSession(session);
10815                            }
10816                    }
10817    
10818                    return list;
10819            }
10820    
10821            /**
10822             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status &ne; &#63;.
10823             *
10824             * @param groupId the group ID
10825             * @param userId the user ID
10826             * @param status the status
10827             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10828             * @return the first matching blogs entry
10829             * @throws NoSuchEntryException if a matching blogs entry could not be found
10830             */
10831            @Override
10832            public BlogsEntry findByG_U_NotS_First(long groupId, long userId,
10833                    int status, OrderByComparator<BlogsEntry> orderByComparator)
10834                    throws NoSuchEntryException {
10835                    BlogsEntry blogsEntry = fetchByG_U_NotS_First(groupId, userId, status,
10836                                    orderByComparator);
10837    
10838                    if (blogsEntry != null) {
10839                            return blogsEntry;
10840                    }
10841    
10842                    StringBundler msg = new StringBundler(8);
10843    
10844                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10845    
10846                    msg.append("groupId=");
10847                    msg.append(groupId);
10848    
10849                    msg.append(", userId=");
10850                    msg.append(userId);
10851    
10852                    msg.append(", status=");
10853                    msg.append(status);
10854    
10855                    msg.append(StringPool.CLOSE_CURLY_BRACE);
10856    
10857                    throw new NoSuchEntryException(msg.toString());
10858            }
10859    
10860            /**
10861             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status &ne; &#63;.
10862             *
10863             * @param groupId the group ID
10864             * @param userId the user ID
10865             * @param status the status
10866             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10867             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
10868             */
10869            @Override
10870            public BlogsEntry fetchByG_U_NotS_First(long groupId, long userId,
10871                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
10872                    List<BlogsEntry> list = findByG_U_NotS(groupId, userId, status, 0, 1,
10873                                    orderByComparator);
10874    
10875                    if (!list.isEmpty()) {
10876                            return list.get(0);
10877                    }
10878    
10879                    return null;
10880            }
10881    
10882            /**
10883             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status &ne; &#63;.
10884             *
10885             * @param groupId the group ID
10886             * @param userId the user ID
10887             * @param status the status
10888             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10889             * @return the last matching blogs entry
10890             * @throws NoSuchEntryException if a matching blogs entry could not be found
10891             */
10892            @Override
10893            public BlogsEntry findByG_U_NotS_Last(long groupId, long userId,
10894                    int status, OrderByComparator<BlogsEntry> orderByComparator)
10895                    throws NoSuchEntryException {
10896                    BlogsEntry blogsEntry = fetchByG_U_NotS_Last(groupId, userId, status,
10897                                    orderByComparator);
10898    
10899                    if (blogsEntry != null) {
10900                            return blogsEntry;
10901                    }
10902    
10903                    StringBundler msg = new StringBundler(8);
10904    
10905                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10906    
10907                    msg.append("groupId=");
10908                    msg.append(groupId);
10909    
10910                    msg.append(", userId=");
10911                    msg.append(userId);
10912    
10913                    msg.append(", status=");
10914                    msg.append(status);
10915    
10916                    msg.append(StringPool.CLOSE_CURLY_BRACE);
10917    
10918                    throw new NoSuchEntryException(msg.toString());
10919            }
10920    
10921            /**
10922             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status &ne; &#63;.
10923             *
10924             * @param groupId the group ID
10925             * @param userId the user ID
10926             * @param status the status
10927             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10928             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
10929             */
10930            @Override
10931            public BlogsEntry fetchByG_U_NotS_Last(long groupId, long userId,
10932                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
10933                    int count = countByG_U_NotS(groupId, userId, status);
10934    
10935                    if (count == 0) {
10936                            return null;
10937                    }
10938    
10939                    List<BlogsEntry> list = findByG_U_NotS(groupId, userId, status,
10940                                    count - 1, count, orderByComparator);
10941    
10942                    if (!list.isEmpty()) {
10943                            return list.get(0);
10944                    }
10945    
10946                    return null;
10947            }
10948    
10949            /**
10950             * 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;.
10951             *
10952             * @param entryId the primary key of the current blogs entry
10953             * @param groupId the group ID
10954             * @param userId the user ID
10955             * @param status the status
10956             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10957             * @return the previous, current, and next blogs entry
10958             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
10959             */
10960            @Override
10961            public BlogsEntry[] findByG_U_NotS_PrevAndNext(long entryId, long groupId,
10962                    long userId, int status, OrderByComparator<BlogsEntry> orderByComparator)
10963                    throws NoSuchEntryException {
10964                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
10965    
10966                    Session session = null;
10967    
10968                    try {
10969                            session = openSession();
10970    
10971                            BlogsEntry[] array = new BlogsEntryImpl[3];
10972    
10973                            array[0] = getByG_U_NotS_PrevAndNext(session, blogsEntry, groupId,
10974                                            userId, status, orderByComparator, true);
10975    
10976                            array[1] = blogsEntry;
10977    
10978                            array[2] = getByG_U_NotS_PrevAndNext(session, blogsEntry, groupId,
10979                                            userId, status, orderByComparator, false);
10980    
10981                            return array;
10982                    }
10983                    catch (Exception e) {
10984                            throw processException(e);
10985                    }
10986                    finally {
10987                            closeSession(session);
10988                    }
10989            }
10990    
10991            protected BlogsEntry getByG_U_NotS_PrevAndNext(Session session,
10992                    BlogsEntry blogsEntry, long groupId, long userId, int status,
10993                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
10994                    StringBundler query = null;
10995    
10996                    if (orderByComparator != null) {
10997                            query = new StringBundler(6 +
10998                                            (orderByComparator.getOrderByFields().length * 6));
10999                    }
11000                    else {
11001                            query = new StringBundler(3);
11002                    }
11003    
11004                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
11005    
11006                    query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
11007    
11008                    query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
11009    
11010                    query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
11011    
11012                    if (orderByComparator != null) {
11013                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11014    
11015                            if (orderByConditionFields.length > 0) {
11016                                    query.append(WHERE_AND);
11017                            }
11018    
11019                            for (int i = 0; i < orderByConditionFields.length; i++) {
11020                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11021                                    query.append(orderByConditionFields[i]);
11022    
11023                                    if ((i + 1) < orderByConditionFields.length) {
11024                                            if (orderByComparator.isAscending() ^ previous) {
11025                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
11026                                            }
11027                                            else {
11028                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
11029                                            }
11030                                    }
11031                                    else {
11032                                            if (orderByComparator.isAscending() ^ previous) {
11033                                                    query.append(WHERE_GREATER_THAN);
11034                                            }
11035                                            else {
11036                                                    query.append(WHERE_LESSER_THAN);
11037                                            }
11038                                    }
11039                            }
11040    
11041                            query.append(ORDER_BY_CLAUSE);
11042    
11043                            String[] orderByFields = orderByComparator.getOrderByFields();
11044    
11045                            for (int i = 0; i < orderByFields.length; i++) {
11046                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11047                                    query.append(orderByFields[i]);
11048    
11049                                    if ((i + 1) < orderByFields.length) {
11050                                            if (orderByComparator.isAscending() ^ previous) {
11051                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
11052                                            }
11053                                            else {
11054                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
11055                                            }
11056                                    }
11057                                    else {
11058                                            if (orderByComparator.isAscending() ^ previous) {
11059                                                    query.append(ORDER_BY_ASC);
11060                                            }
11061                                            else {
11062                                                    query.append(ORDER_BY_DESC);
11063                                            }
11064                                    }
11065                            }
11066                    }
11067                    else {
11068                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
11069                    }
11070    
11071                    String sql = query.toString();
11072    
11073                    Query q = session.createQuery(sql);
11074    
11075                    q.setFirstResult(0);
11076                    q.setMaxResults(2);
11077    
11078                    QueryPos qPos = QueryPos.getInstance(q);
11079    
11080                    qPos.add(groupId);
11081    
11082                    qPos.add(userId);
11083    
11084                    qPos.add(status);
11085    
11086                    if (orderByComparator != null) {
11087                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
11088    
11089                            for (Object value : values) {
11090                                    qPos.add(value);
11091                            }
11092                    }
11093    
11094                    List<BlogsEntry> list = q.list();
11095    
11096                    if (list.size() == 2) {
11097                            return list.get(1);
11098                    }
11099                    else {
11100                            return null;
11101                    }
11102            }
11103    
11104            /**
11105             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status &ne; &#63;.
11106             *
11107             * @param groupId the group ID
11108             * @param userId the user ID
11109             * @param status the status
11110             * @return the matching blogs entries that the user has permission to view
11111             */
11112            @Override
11113            public List<BlogsEntry> filterFindByG_U_NotS(long groupId, long userId,
11114                    int status) {
11115                    return filterFindByG_U_NotS(groupId, userId, status, QueryUtil.ALL_POS,
11116                            QueryUtil.ALL_POS, null);
11117            }
11118    
11119            /**
11120             * 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;.
11121             *
11122             * <p>
11123             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
11124             * </p>
11125             *
11126             * @param groupId the group ID
11127             * @param userId the user ID
11128             * @param status the status
11129             * @param start the lower bound of the range of blogs entries
11130             * @param end the upper bound of the range of blogs entries (not inclusive)
11131             * @return the range of matching blogs entries that the user has permission to view
11132             */
11133            @Override
11134            public List<BlogsEntry> filterFindByG_U_NotS(long groupId, long userId,
11135                    int status, int start, int end) {
11136                    return filterFindByG_U_NotS(groupId, userId, status, start, end, null);
11137            }
11138    
11139            /**
11140             * 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;.
11141             *
11142             * <p>
11143             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
11144             * </p>
11145             *
11146             * @param groupId the group ID
11147             * @param userId the user ID
11148             * @param status the status
11149             * @param start the lower bound of the range of blogs entries
11150             * @param end the upper bound of the range of blogs entries (not inclusive)
11151             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11152             * @return the ordered range of matching blogs entries that the user has permission to view
11153             */
11154            @Override
11155            public List<BlogsEntry> filterFindByG_U_NotS(long groupId, long userId,
11156                    int status, int start, int end,
11157                    OrderByComparator<BlogsEntry> orderByComparator) {
11158                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11159                            return findByG_U_NotS(groupId, userId, status, start, end,
11160                                    orderByComparator);
11161                    }
11162    
11163                    StringBundler query = null;
11164    
11165                    if (orderByComparator != null) {
11166                            query = new StringBundler(5 +
11167                                            (orderByComparator.getOrderByFields().length * 3));
11168                    }
11169                    else {
11170                            query = new StringBundler(5);
11171                    }
11172    
11173                    if (getDB().isSupportsInlineDistinct()) {
11174                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
11175                    }
11176                    else {
11177                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
11178                    }
11179    
11180                    query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
11181    
11182                    query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
11183    
11184                    query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
11185    
11186                    if (!getDB().isSupportsInlineDistinct()) {
11187                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
11188                    }
11189    
11190                    if (orderByComparator != null) {
11191                            if (getDB().isSupportsInlineDistinct()) {
11192                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11193                                            orderByComparator, true);
11194                            }
11195                            else {
11196                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
11197                                            orderByComparator, true);
11198                            }
11199                    }
11200                    else {
11201                            if (getDB().isSupportsInlineDistinct()) {
11202                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
11203                            }
11204                            else {
11205                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
11206                            }
11207                    }
11208    
11209                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11210                                    BlogsEntry.class.getName(),
11211                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11212    
11213                    Session session = null;
11214    
11215                    try {
11216                            session = openSession();
11217    
11218                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
11219    
11220                            if (getDB().isSupportsInlineDistinct()) {
11221                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
11222                            }
11223                            else {
11224                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
11225                            }
11226    
11227                            QueryPos qPos = QueryPos.getInstance(q);
11228    
11229                            qPos.add(groupId);
11230    
11231                            qPos.add(userId);
11232    
11233                            qPos.add(status);
11234    
11235                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
11236                    }
11237                    catch (Exception e) {
11238                            throw processException(e);
11239                    }
11240                    finally {
11241                            closeSession(session);
11242                    }
11243            }
11244    
11245            /**
11246             * 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;.
11247             *
11248             * @param entryId the primary key of the current blogs entry
11249             * @param groupId the group ID
11250             * @param userId the user ID
11251             * @param status the status
11252             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11253             * @return the previous, current, and next blogs entry
11254             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
11255             */
11256            @Override
11257            public BlogsEntry[] filterFindByG_U_NotS_PrevAndNext(long entryId,
11258                    long groupId, long userId, int status,
11259                    OrderByComparator<BlogsEntry> orderByComparator)
11260                    throws NoSuchEntryException {
11261                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11262                            return findByG_U_NotS_PrevAndNext(entryId, groupId, userId, status,
11263                                    orderByComparator);
11264                    }
11265    
11266                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
11267    
11268                    Session session = null;
11269    
11270                    try {
11271                            session = openSession();
11272    
11273                            BlogsEntry[] array = new BlogsEntryImpl[3];
11274    
11275                            array[0] = filterGetByG_U_NotS_PrevAndNext(session, blogsEntry,
11276                                            groupId, userId, status, orderByComparator, true);
11277    
11278                            array[1] = blogsEntry;
11279    
11280                            array[2] = filterGetByG_U_NotS_PrevAndNext(session, blogsEntry,
11281                                            groupId, userId, status, orderByComparator, false);
11282    
11283                            return array;
11284                    }
11285                    catch (Exception e) {
11286                            throw processException(e);
11287                    }
11288                    finally {
11289                            closeSession(session);
11290                    }
11291            }
11292    
11293            protected BlogsEntry filterGetByG_U_NotS_PrevAndNext(Session session,
11294                    BlogsEntry blogsEntry, long groupId, long userId, int status,
11295                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
11296                    StringBundler query = null;
11297    
11298                    if (orderByComparator != null) {
11299                            query = new StringBundler(6 +
11300                                            (orderByComparator.getOrderByFields().length * 6));
11301                    }
11302                    else {
11303                            query = new StringBundler(3);
11304                    }
11305    
11306                    if (getDB().isSupportsInlineDistinct()) {
11307                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
11308                    }
11309                    else {
11310                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
11311                    }
11312    
11313                    query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
11314    
11315                    query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
11316    
11317                    query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
11318    
11319                    if (!getDB().isSupportsInlineDistinct()) {
11320                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
11321                    }
11322    
11323                    if (orderByComparator != null) {
11324                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11325    
11326                            if (orderByConditionFields.length > 0) {
11327                                    query.append(WHERE_AND);
11328                            }
11329    
11330                            for (int i = 0; i < orderByConditionFields.length; i++) {
11331                                    if (getDB().isSupportsInlineDistinct()) {
11332                                            query.append(_ORDER_BY_ENTITY_ALIAS);
11333                                    }
11334                                    else {
11335                                            query.append(_ORDER_BY_ENTITY_TABLE);
11336                                    }
11337    
11338                                    query.append(orderByConditionFields[i]);
11339    
11340                                    if ((i + 1) < orderByConditionFields.length) {
11341                                            if (orderByComparator.isAscending() ^ previous) {
11342                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
11343                                            }
11344                                            else {
11345                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
11346                                            }
11347                                    }
11348                                    else {
11349                                            if (orderByComparator.isAscending() ^ previous) {
11350                                                    query.append(WHERE_GREATER_THAN);
11351                                            }
11352                                            else {
11353                                                    query.append(WHERE_LESSER_THAN);
11354                                            }
11355                                    }
11356                            }
11357    
11358                            query.append(ORDER_BY_CLAUSE);
11359    
11360                            String[] orderByFields = orderByComparator.getOrderByFields();
11361    
11362                            for (int i = 0; i < orderByFields.length; i++) {
11363                                    if (getDB().isSupportsInlineDistinct()) {
11364                                            query.append(_ORDER_BY_ENTITY_ALIAS);
11365                                    }
11366                                    else {
11367                                            query.append(_ORDER_BY_ENTITY_TABLE);
11368                                    }
11369    
11370                                    query.append(orderByFields[i]);
11371    
11372                                    if ((i + 1) < orderByFields.length) {
11373                                            if (orderByComparator.isAscending() ^ previous) {
11374                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
11375                                            }
11376                                            else {
11377                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
11378                                            }
11379                                    }
11380                                    else {
11381                                            if (orderByComparator.isAscending() ^ previous) {
11382                                                    query.append(ORDER_BY_ASC);
11383                                            }
11384                                            else {
11385                                                    query.append(ORDER_BY_DESC);
11386                                            }
11387                                    }
11388                            }
11389                    }
11390                    else {
11391                            if (getDB().isSupportsInlineDistinct()) {
11392                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
11393                            }
11394                            else {
11395                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
11396                            }
11397                    }
11398    
11399                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11400                                    BlogsEntry.class.getName(),
11401                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11402    
11403                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
11404    
11405                    q.setFirstResult(0);
11406                    q.setMaxResults(2);
11407    
11408                    if (getDB().isSupportsInlineDistinct()) {
11409                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
11410                    }
11411                    else {
11412                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
11413                    }
11414    
11415                    QueryPos qPos = QueryPos.getInstance(q);
11416    
11417                    qPos.add(groupId);
11418    
11419                    qPos.add(userId);
11420    
11421                    qPos.add(status);
11422    
11423                    if (orderByComparator != null) {
11424                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
11425    
11426                            for (Object value : values) {
11427                                    qPos.add(value);
11428                            }
11429                    }
11430    
11431                    List<BlogsEntry> list = q.list();
11432    
11433                    if (list.size() == 2) {
11434                            return list.get(1);
11435                    }
11436                    else {
11437                            return null;
11438                    }
11439            }
11440    
11441            /**
11442             * Removes all the blogs entries where groupId = &#63; and userId = &#63; and status &ne; &#63; from the database.
11443             *
11444             * @param groupId the group ID
11445             * @param userId the user ID
11446             * @param status the status
11447             */
11448            @Override
11449            public void removeByG_U_NotS(long groupId, long userId, int status) {
11450                    for (BlogsEntry blogsEntry : findByG_U_NotS(groupId, userId, status,
11451                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
11452                            remove(blogsEntry);
11453                    }
11454            }
11455    
11456            /**
11457             * Returns the number of blogs entries where groupId = &#63; and userId = &#63; and status &ne; &#63;.
11458             *
11459             * @param groupId the group ID
11460             * @param userId the user ID
11461             * @param status the status
11462             * @return the number of matching blogs entries
11463             */
11464            @Override
11465            public int countByG_U_NotS(long groupId, long userId, int status) {
11466                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_NOTS;
11467    
11468                    Object[] finderArgs = new Object[] { groupId, userId, status };
11469    
11470                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
11471    
11472                    if (count == null) {
11473                            StringBundler query = new StringBundler(4);
11474    
11475                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
11476    
11477                            query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
11478    
11479                            query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
11480    
11481                            query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
11482    
11483                            String sql = query.toString();
11484    
11485                            Session session = null;
11486    
11487                            try {
11488                                    session = openSession();
11489    
11490                                    Query q = session.createQuery(sql);
11491    
11492                                    QueryPos qPos = QueryPos.getInstance(q);
11493    
11494                                    qPos.add(groupId);
11495    
11496                                    qPos.add(userId);
11497    
11498                                    qPos.add(status);
11499    
11500                                    count = (Long)q.uniqueResult();
11501    
11502                                    finderCache.putResult(finderPath, finderArgs, count);
11503                            }
11504                            catch (Exception e) {
11505                                    finderCache.removeResult(finderPath, finderArgs);
11506    
11507                                    throw processException(e);
11508                            }
11509                            finally {
11510                                    closeSession(session);
11511                            }
11512                    }
11513    
11514                    return count.intValue();
11515            }
11516    
11517            /**
11518             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status &ne; &#63;.
11519             *
11520             * @param groupId the group ID
11521             * @param userId the user ID
11522             * @param status the status
11523             * @return the number of matching blogs entries that the user has permission to view
11524             */
11525            @Override
11526            public int filterCountByG_U_NotS(long groupId, long userId, int status) {
11527                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11528                            return countByG_U_NotS(groupId, userId, status);
11529                    }
11530    
11531                    StringBundler query = new StringBundler(4);
11532    
11533                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
11534    
11535                    query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
11536    
11537                    query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
11538    
11539                    query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
11540    
11541                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11542                                    BlogsEntry.class.getName(),
11543                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11544    
11545                    Session session = null;
11546    
11547                    try {
11548                            session = openSession();
11549    
11550                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
11551    
11552                            q.addScalar(COUNT_COLUMN_NAME,
11553                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
11554    
11555                            QueryPos qPos = QueryPos.getInstance(q);
11556    
11557                            qPos.add(groupId);
11558    
11559                            qPos.add(userId);
11560    
11561                            qPos.add(status);
11562    
11563                            Long count = (Long)q.uniqueResult();
11564    
11565                            return count.intValue();
11566                    }
11567                    catch (Exception e) {
11568                            throw processException(e);
11569                    }
11570                    finally {
11571                            closeSession(session);
11572                    }
11573            }
11574    
11575            private static final String _FINDER_COLUMN_G_U_NOTS_GROUPID_2 = "blogsEntry.groupId = ? AND ";
11576            private static final String _FINDER_COLUMN_G_U_NOTS_USERID_2 = "blogsEntry.userId = ? AND ";
11577            private static final String _FINDER_COLUMN_G_U_NOTS_STATUS_2 = "blogsEntry.status != ?";
11578            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
11579                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
11580                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_LtD_S",
11581                            new String[] {
11582                                    Long.class.getName(), Date.class.getName(),
11583                                    Integer.class.getName(),
11584                                    
11585                            Integer.class.getName(), Integer.class.getName(),
11586                                    OrderByComparator.class.getName()
11587                            });
11588            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
11589                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
11590                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_LtD_S",
11591                            new String[] {
11592                                    Long.class.getName(), Date.class.getName(),
11593                                    Integer.class.getName()
11594                            });
11595    
11596            /**
11597             * Returns all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
11598             *
11599             * @param groupId the group ID
11600             * @param displayDate the display date
11601             * @param status the status
11602             * @return the matching blogs entries
11603             */
11604            @Override
11605            public List<BlogsEntry> findByG_LtD_S(long groupId, Date displayDate,
11606                    int status) {
11607                    return findByG_LtD_S(groupId, displayDate, status, QueryUtil.ALL_POS,
11608                            QueryUtil.ALL_POS, null);
11609            }
11610    
11611            /**
11612             * Returns a range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
11613             *
11614             * <p>
11615             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
11616             * </p>
11617             *
11618             * @param groupId the group ID
11619             * @param displayDate the display date
11620             * @param status the status
11621             * @param start the lower bound of the range of blogs entries
11622             * @param end the upper bound of the range of blogs entries (not inclusive)
11623             * @return the range of matching blogs entries
11624             */
11625            @Override
11626            public List<BlogsEntry> findByG_LtD_S(long groupId, Date displayDate,
11627                    int status, int start, int end) {
11628                    return findByG_LtD_S(groupId, displayDate, status, start, end, null);
11629            }
11630    
11631            /**
11632             * Returns an ordered range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
11633             *
11634             * <p>
11635             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
11636             * </p>
11637             *
11638             * @param groupId the group ID
11639             * @param displayDate the display date
11640             * @param status the status
11641             * @param start the lower bound of the range of blogs entries
11642             * @param end the upper bound of the range of blogs entries (not inclusive)
11643             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11644             * @return the ordered range of matching blogs entries
11645             */
11646            @Override
11647            public List<BlogsEntry> findByG_LtD_S(long groupId, Date displayDate,
11648                    int status, int start, int end,
11649                    OrderByComparator<BlogsEntry> orderByComparator) {
11650                    return findByG_LtD_S(groupId, displayDate, status, start, end,
11651                            orderByComparator, true);
11652            }
11653    
11654            /**
11655             * Returns an ordered range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
11656             *
11657             * <p>
11658             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
11659             * </p>
11660             *
11661             * @param groupId the group ID
11662             * @param displayDate the display date
11663             * @param status the status
11664             * @param start the lower bound of the range of blogs entries
11665             * @param end the upper bound of the range of blogs entries (not inclusive)
11666             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11667             * @param retrieveFromCache whether to retrieve from the finder cache
11668             * @return the ordered range of matching blogs entries
11669             */
11670            @Override
11671            public List<BlogsEntry> findByG_LtD_S(long groupId, Date displayDate,
11672                    int status, int start, int end,
11673                    OrderByComparator<BlogsEntry> orderByComparator,
11674                    boolean retrieveFromCache) {
11675                    boolean pagination = true;
11676                    FinderPath finderPath = null;
11677                    Object[] finderArgs = null;
11678    
11679                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD_S;
11680                    finderArgs = new Object[] {
11681                                    groupId, displayDate, status,
11682                                    
11683                                    start, end, orderByComparator
11684                            };
11685    
11686                    List<BlogsEntry> list = null;
11687    
11688                    if (retrieveFromCache) {
11689                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
11690                                            finderArgs, this);
11691    
11692                            if ((list != null) && !list.isEmpty()) {
11693                                    for (BlogsEntry blogsEntry : list) {
11694                                            if ((groupId != blogsEntry.getGroupId()) ||
11695                                                            (displayDate.getTime() <= blogsEntry.getDisplayDate()
11696                                                                                                                                            .getTime()) ||
11697                                                            (status != blogsEntry.getStatus())) {
11698                                                    list = null;
11699    
11700                                                    break;
11701                                            }
11702                                    }
11703                            }
11704                    }
11705    
11706                    if (list == null) {
11707                            StringBundler query = null;
11708    
11709                            if (orderByComparator != null) {
11710                                    query = new StringBundler(5 +
11711                                                    (orderByComparator.getOrderByFields().length * 3));
11712                            }
11713                            else {
11714                                    query = new StringBundler(5);
11715                            }
11716    
11717                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
11718    
11719                            query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
11720    
11721                            boolean bindDisplayDate = false;
11722    
11723                            if (displayDate == null) {
11724                                    query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
11725                            }
11726                            else {
11727                                    bindDisplayDate = true;
11728    
11729                                    query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
11730                            }
11731    
11732                            query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
11733    
11734                            if (orderByComparator != null) {
11735                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11736                                            orderByComparator);
11737                            }
11738                            else
11739                             if (pagination) {
11740                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
11741                            }
11742    
11743                            String sql = query.toString();
11744    
11745                            Session session = null;
11746    
11747                            try {
11748                                    session = openSession();
11749    
11750                                    Query q = session.createQuery(sql);
11751    
11752                                    QueryPos qPos = QueryPos.getInstance(q);
11753    
11754                                    qPos.add(groupId);
11755    
11756                                    if (bindDisplayDate) {
11757                                            qPos.add(new Timestamp(displayDate.getTime()));
11758                                    }
11759    
11760                                    qPos.add(status);
11761    
11762                                    if (!pagination) {
11763                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
11764                                                            start, end, false);
11765    
11766                                            Collections.sort(list);
11767    
11768                                            list = Collections.unmodifiableList(list);
11769                                    }
11770                                    else {
11771                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
11772                                                            start, end);
11773                                    }
11774    
11775                                    cacheResult(list);
11776    
11777                                    finderCache.putResult(finderPath, finderArgs, list);
11778                            }
11779                            catch (Exception e) {
11780                                    finderCache.removeResult(finderPath, finderArgs);
11781    
11782                                    throw processException(e);
11783                            }
11784                            finally {
11785                                    closeSession(session);
11786                            }
11787                    }
11788    
11789                    return list;
11790            }
11791    
11792            /**
11793             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
11794             *
11795             * @param groupId the group ID
11796             * @param displayDate the display date
11797             * @param status the status
11798             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11799             * @return the first matching blogs entry
11800             * @throws NoSuchEntryException if a matching blogs entry could not be found
11801             */
11802            @Override
11803            public BlogsEntry findByG_LtD_S_First(long groupId, Date displayDate,
11804                    int status, OrderByComparator<BlogsEntry> orderByComparator)
11805                    throws NoSuchEntryException {
11806                    BlogsEntry blogsEntry = fetchByG_LtD_S_First(groupId, displayDate,
11807                                    status, orderByComparator);
11808    
11809                    if (blogsEntry != null) {
11810                            return blogsEntry;
11811                    }
11812    
11813                    StringBundler msg = new StringBundler(8);
11814    
11815                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11816    
11817                    msg.append("groupId=");
11818                    msg.append(groupId);
11819    
11820                    msg.append(", displayDate=");
11821                    msg.append(displayDate);
11822    
11823                    msg.append(", status=");
11824                    msg.append(status);
11825    
11826                    msg.append(StringPool.CLOSE_CURLY_BRACE);
11827    
11828                    throw new NoSuchEntryException(msg.toString());
11829            }
11830    
11831            /**
11832             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
11833             *
11834             * @param groupId the group ID
11835             * @param displayDate the display date
11836             * @param status the status
11837             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11838             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
11839             */
11840            @Override
11841            public BlogsEntry fetchByG_LtD_S_First(long groupId, Date displayDate,
11842                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
11843                    List<BlogsEntry> list = findByG_LtD_S(groupId, displayDate, status, 0,
11844                                    1, orderByComparator);
11845    
11846                    if (!list.isEmpty()) {
11847                            return list.get(0);
11848                    }
11849    
11850                    return null;
11851            }
11852    
11853            /**
11854             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
11855             *
11856             * @param groupId the group ID
11857             * @param displayDate the display date
11858             * @param status the status
11859             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11860             * @return the last matching blogs entry
11861             * @throws NoSuchEntryException if a matching blogs entry could not be found
11862             */
11863            @Override
11864            public BlogsEntry findByG_LtD_S_Last(long groupId, Date displayDate,
11865                    int status, OrderByComparator<BlogsEntry> orderByComparator)
11866                    throws NoSuchEntryException {
11867                    BlogsEntry blogsEntry = fetchByG_LtD_S_Last(groupId, displayDate,
11868                                    status, orderByComparator);
11869    
11870                    if (blogsEntry != null) {
11871                            return blogsEntry;
11872                    }
11873    
11874                    StringBundler msg = new StringBundler(8);
11875    
11876                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11877    
11878                    msg.append("groupId=");
11879                    msg.append(groupId);
11880    
11881                    msg.append(", displayDate=");
11882                    msg.append(displayDate);
11883    
11884                    msg.append(", status=");
11885                    msg.append(status);
11886    
11887                    msg.append(StringPool.CLOSE_CURLY_BRACE);
11888    
11889                    throw new NoSuchEntryException(msg.toString());
11890            }
11891    
11892            /**
11893             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
11894             *
11895             * @param groupId the group ID
11896             * @param displayDate the display date
11897             * @param status the status
11898             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11899             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
11900             */
11901            @Override
11902            public BlogsEntry fetchByG_LtD_S_Last(long groupId, Date displayDate,
11903                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
11904                    int count = countByG_LtD_S(groupId, displayDate, status);
11905    
11906                    if (count == 0) {
11907                            return null;
11908                    }
11909    
11910                    List<BlogsEntry> list = findByG_LtD_S(groupId, displayDate, status,
11911                                    count - 1, count, orderByComparator);
11912    
11913                    if (!list.isEmpty()) {
11914                            return list.get(0);
11915                    }
11916    
11917                    return null;
11918            }
11919    
11920            /**
11921             * 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;.
11922             *
11923             * @param entryId the primary key of the current blogs entry
11924             * @param groupId the group ID
11925             * @param displayDate the display date
11926             * @param status the status
11927             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11928             * @return the previous, current, and next blogs entry
11929             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
11930             */
11931            @Override
11932            public BlogsEntry[] findByG_LtD_S_PrevAndNext(long entryId, long groupId,
11933                    Date displayDate, int status,
11934                    OrderByComparator<BlogsEntry> orderByComparator)
11935                    throws NoSuchEntryException {
11936                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
11937    
11938                    Session session = null;
11939    
11940                    try {
11941                            session = openSession();
11942    
11943                            BlogsEntry[] array = new BlogsEntryImpl[3];
11944    
11945                            array[0] = getByG_LtD_S_PrevAndNext(session, blogsEntry, groupId,
11946                                            displayDate, status, orderByComparator, true);
11947    
11948                            array[1] = blogsEntry;
11949    
11950                            array[2] = getByG_LtD_S_PrevAndNext(session, blogsEntry, groupId,
11951                                            displayDate, status, orderByComparator, false);
11952    
11953                            return array;
11954                    }
11955                    catch (Exception e) {
11956                            throw processException(e);
11957                    }
11958                    finally {
11959                            closeSession(session);
11960                    }
11961            }
11962    
11963            protected BlogsEntry getByG_LtD_S_PrevAndNext(Session session,
11964                    BlogsEntry blogsEntry, long groupId, Date displayDate, int status,
11965                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
11966                    StringBundler query = null;
11967    
11968                    if (orderByComparator != null) {
11969                            query = new StringBundler(6 +
11970                                            (orderByComparator.getOrderByFields().length * 6));
11971                    }
11972                    else {
11973                            query = new StringBundler(3);
11974                    }
11975    
11976                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
11977    
11978                    query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
11979    
11980                    boolean bindDisplayDate = false;
11981    
11982                    if (displayDate == null) {
11983                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
11984                    }
11985                    else {
11986                            bindDisplayDate = true;
11987    
11988                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
11989                    }
11990    
11991                    query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
11992    
11993                    if (orderByComparator != null) {
11994                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11995    
11996                            if (orderByConditionFields.length > 0) {
11997                                    query.append(WHERE_AND);
11998                            }
11999    
12000                            for (int i = 0; i < orderByConditionFields.length; i++) {
12001                                    query.append(_ORDER_BY_ENTITY_ALIAS);
12002                                    query.append(orderByConditionFields[i]);
12003    
12004                                    if ((i + 1) < orderByConditionFields.length) {
12005                                            if (orderByComparator.isAscending() ^ previous) {
12006                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
12007                                            }
12008                                            else {
12009                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
12010                                            }
12011                                    }
12012                                    else {
12013                                            if (orderByComparator.isAscending() ^ previous) {
12014                                                    query.append(WHERE_GREATER_THAN);
12015                                            }
12016                                            else {
12017                                                    query.append(WHERE_LESSER_THAN);
12018                                            }
12019                                    }
12020                            }
12021    
12022                            query.append(ORDER_BY_CLAUSE);
12023    
12024                            String[] orderByFields = orderByComparator.getOrderByFields();
12025    
12026                            for (int i = 0; i < orderByFields.length; i++) {
12027                                    query.append(_ORDER_BY_ENTITY_ALIAS);
12028                                    query.append(orderByFields[i]);
12029    
12030                                    if ((i + 1) < orderByFields.length) {
12031                                            if (orderByComparator.isAscending() ^ previous) {
12032                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
12033                                            }
12034                                            else {
12035                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
12036                                            }
12037                                    }
12038                                    else {
12039                                            if (orderByComparator.isAscending() ^ previous) {
12040                                                    query.append(ORDER_BY_ASC);
12041                                            }
12042                                            else {
12043                                                    query.append(ORDER_BY_DESC);
12044                                            }
12045                                    }
12046                            }
12047                    }
12048                    else {
12049                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
12050                    }
12051    
12052                    String sql = query.toString();
12053    
12054                    Query q = session.createQuery(sql);
12055    
12056                    q.setFirstResult(0);
12057                    q.setMaxResults(2);
12058    
12059                    QueryPos qPos = QueryPos.getInstance(q);
12060    
12061                    qPos.add(groupId);
12062    
12063                    if (bindDisplayDate) {
12064                            qPos.add(new Timestamp(displayDate.getTime()));
12065                    }
12066    
12067                    qPos.add(status);
12068    
12069                    if (orderByComparator != null) {
12070                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
12071    
12072                            for (Object value : values) {
12073                                    qPos.add(value);
12074                            }
12075                    }
12076    
12077                    List<BlogsEntry> list = q.list();
12078    
12079                    if (list.size() == 2) {
12080                            return list.get(1);
12081                    }
12082                    else {
12083                            return null;
12084                    }
12085            }
12086    
12087            /**
12088             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
12089             *
12090             * @param groupId the group ID
12091             * @param displayDate the display date
12092             * @param status the status
12093             * @return the matching blogs entries that the user has permission to view
12094             */
12095            @Override
12096            public List<BlogsEntry> filterFindByG_LtD_S(long groupId, Date displayDate,
12097                    int status) {
12098                    return filterFindByG_LtD_S(groupId, displayDate, status,
12099                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
12100            }
12101    
12102            /**
12103             * 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;.
12104             *
12105             * <p>
12106             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
12107             * </p>
12108             *
12109             * @param groupId the group ID
12110             * @param displayDate the display date
12111             * @param status the status
12112             * @param start the lower bound of the range of blogs entries
12113             * @param end the upper bound of the range of blogs entries (not inclusive)
12114             * @return the range of matching blogs entries that the user has permission to view
12115             */
12116            @Override
12117            public List<BlogsEntry> filterFindByG_LtD_S(long groupId, Date displayDate,
12118                    int status, int start, int end) {
12119                    return filterFindByG_LtD_S(groupId, displayDate, status, start, end,
12120                            null);
12121            }
12122    
12123            /**
12124             * 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;.
12125             *
12126             * <p>
12127             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
12128             * </p>
12129             *
12130             * @param groupId the group ID
12131             * @param displayDate the display date
12132             * @param status the status
12133             * @param start the lower bound of the range of blogs entries
12134             * @param end the upper bound of the range of blogs entries (not inclusive)
12135             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12136             * @return the ordered range of matching blogs entries that the user has permission to view
12137             */
12138            @Override
12139            public List<BlogsEntry> filterFindByG_LtD_S(long groupId, Date displayDate,
12140                    int status, int start, int end,
12141                    OrderByComparator<BlogsEntry> orderByComparator) {
12142                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12143                            return findByG_LtD_S(groupId, displayDate, status, start, end,
12144                                    orderByComparator);
12145                    }
12146    
12147                    StringBundler query = null;
12148    
12149                    if (orderByComparator != null) {
12150                            query = new StringBundler(5 +
12151                                            (orderByComparator.getOrderByFields().length * 3));
12152                    }
12153                    else {
12154                            query = new StringBundler(5);
12155                    }
12156    
12157                    if (getDB().isSupportsInlineDistinct()) {
12158                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
12159                    }
12160                    else {
12161                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
12162                    }
12163    
12164                    query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
12165    
12166                    boolean bindDisplayDate = false;
12167    
12168                    if (displayDate == null) {
12169                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
12170                    }
12171                    else {
12172                            bindDisplayDate = true;
12173    
12174                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
12175                    }
12176    
12177                    query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
12178    
12179                    if (!getDB().isSupportsInlineDistinct()) {
12180                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
12181                    }
12182    
12183                    if (orderByComparator != null) {
12184                            if (getDB().isSupportsInlineDistinct()) {
12185                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12186                                            orderByComparator, true);
12187                            }
12188                            else {
12189                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
12190                                            orderByComparator, true);
12191                            }
12192                    }
12193                    else {
12194                            if (getDB().isSupportsInlineDistinct()) {
12195                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
12196                            }
12197                            else {
12198                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
12199                            }
12200                    }
12201    
12202                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12203                                    BlogsEntry.class.getName(),
12204                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12205    
12206                    Session session = null;
12207    
12208                    try {
12209                            session = openSession();
12210    
12211                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
12212    
12213                            if (getDB().isSupportsInlineDistinct()) {
12214                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
12215                            }
12216                            else {
12217                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
12218                            }
12219    
12220                            QueryPos qPos = QueryPos.getInstance(q);
12221    
12222                            qPos.add(groupId);
12223    
12224                            if (bindDisplayDate) {
12225                                    qPos.add(new Timestamp(displayDate.getTime()));
12226                            }
12227    
12228                            qPos.add(status);
12229    
12230                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
12231                    }
12232                    catch (Exception e) {
12233                            throw processException(e);
12234                    }
12235                    finally {
12236                            closeSession(session);
12237                    }
12238            }
12239    
12240            /**
12241             * 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;.
12242             *
12243             * @param entryId the primary key of the current blogs entry
12244             * @param groupId the group ID
12245             * @param displayDate the display date
12246             * @param status the status
12247             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12248             * @return the previous, current, and next blogs entry
12249             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
12250             */
12251            @Override
12252            public BlogsEntry[] filterFindByG_LtD_S_PrevAndNext(long entryId,
12253                    long groupId, Date displayDate, int status,
12254                    OrderByComparator<BlogsEntry> orderByComparator)
12255                    throws NoSuchEntryException {
12256                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12257                            return findByG_LtD_S_PrevAndNext(entryId, groupId, displayDate,
12258                                    status, orderByComparator);
12259                    }
12260    
12261                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
12262    
12263                    Session session = null;
12264    
12265                    try {
12266                            session = openSession();
12267    
12268                            BlogsEntry[] array = new BlogsEntryImpl[3];
12269    
12270                            array[0] = filterGetByG_LtD_S_PrevAndNext(session, blogsEntry,
12271                                            groupId, displayDate, status, orderByComparator, true);
12272    
12273                            array[1] = blogsEntry;
12274    
12275                            array[2] = filterGetByG_LtD_S_PrevAndNext(session, blogsEntry,
12276                                            groupId, displayDate, status, orderByComparator, false);
12277    
12278                            return array;
12279                    }
12280                    catch (Exception e) {
12281                            throw processException(e);
12282                    }
12283                    finally {
12284                            closeSession(session);
12285                    }
12286            }
12287    
12288            protected BlogsEntry filterGetByG_LtD_S_PrevAndNext(Session session,
12289                    BlogsEntry blogsEntry, long groupId, Date displayDate, int status,
12290                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
12291                    StringBundler query = null;
12292    
12293                    if (orderByComparator != null) {
12294                            query = new StringBundler(6 +
12295                                            (orderByComparator.getOrderByFields().length * 6));
12296                    }
12297                    else {
12298                            query = new StringBundler(3);
12299                    }
12300    
12301                    if (getDB().isSupportsInlineDistinct()) {
12302                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
12303                    }
12304                    else {
12305                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
12306                    }
12307    
12308                    query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
12309    
12310                    boolean bindDisplayDate = false;
12311    
12312                    if (displayDate == null) {
12313                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
12314                    }
12315                    else {
12316                            bindDisplayDate = true;
12317    
12318                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
12319                    }
12320    
12321                    query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
12322    
12323                    if (!getDB().isSupportsInlineDistinct()) {
12324                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
12325                    }
12326    
12327                    if (orderByComparator != null) {
12328                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
12329    
12330                            if (orderByConditionFields.length > 0) {
12331                                    query.append(WHERE_AND);
12332                            }
12333    
12334                            for (int i = 0; i < orderByConditionFields.length; i++) {
12335                                    if (getDB().isSupportsInlineDistinct()) {
12336                                            query.append(_ORDER_BY_ENTITY_ALIAS);
12337                                    }
12338                                    else {
12339                                            query.append(_ORDER_BY_ENTITY_TABLE);
12340                                    }
12341    
12342                                    query.append(orderByConditionFields[i]);
12343    
12344                                    if ((i + 1) < orderByConditionFields.length) {
12345                                            if (orderByComparator.isAscending() ^ previous) {
12346                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
12347                                            }
12348                                            else {
12349                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
12350                                            }
12351                                    }
12352                                    else {
12353                                            if (orderByComparator.isAscending() ^ previous) {
12354                                                    query.append(WHERE_GREATER_THAN);
12355                                            }
12356                                            else {
12357                                                    query.append(WHERE_LESSER_THAN);
12358                                            }
12359                                    }
12360                            }
12361    
12362                            query.append(ORDER_BY_CLAUSE);
12363    
12364                            String[] orderByFields = orderByComparator.getOrderByFields();
12365    
12366                            for (int i = 0; i < orderByFields.length; i++) {
12367                                    if (getDB().isSupportsInlineDistinct()) {
12368                                            query.append(_ORDER_BY_ENTITY_ALIAS);
12369                                    }
12370                                    else {
12371                                            query.append(_ORDER_BY_ENTITY_TABLE);
12372                                    }
12373    
12374                                    query.append(orderByFields[i]);
12375    
12376                                    if ((i + 1) < orderByFields.length) {
12377                                            if (orderByComparator.isAscending() ^ previous) {
12378                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
12379                                            }
12380                                            else {
12381                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
12382                                            }
12383                                    }
12384                                    else {
12385                                            if (orderByComparator.isAscending() ^ previous) {
12386                                                    query.append(ORDER_BY_ASC);
12387                                            }
12388                                            else {
12389                                                    query.append(ORDER_BY_DESC);
12390                                            }
12391                                    }
12392                            }
12393                    }
12394                    else {
12395                            if (getDB().isSupportsInlineDistinct()) {
12396                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
12397                            }
12398                            else {
12399                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
12400                            }
12401                    }
12402    
12403                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12404                                    BlogsEntry.class.getName(),
12405                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12406    
12407                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
12408    
12409                    q.setFirstResult(0);
12410                    q.setMaxResults(2);
12411    
12412                    if (getDB().isSupportsInlineDistinct()) {
12413                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
12414                    }
12415                    else {
12416                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
12417                    }
12418    
12419                    QueryPos qPos = QueryPos.getInstance(q);
12420    
12421                    qPos.add(groupId);
12422    
12423                    if (bindDisplayDate) {
12424                            qPos.add(new Timestamp(displayDate.getTime()));
12425                    }
12426    
12427                    qPos.add(status);
12428    
12429                    if (orderByComparator != null) {
12430                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
12431    
12432                            for (Object value : values) {
12433                                    qPos.add(value);
12434                            }
12435                    }
12436    
12437                    List<BlogsEntry> list = q.list();
12438    
12439                    if (list.size() == 2) {
12440                            return list.get(1);
12441                    }
12442                    else {
12443                            return null;
12444                    }
12445            }
12446    
12447            /**
12448             * Removes all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63; from the database.
12449             *
12450             * @param groupId the group ID
12451             * @param displayDate the display date
12452             * @param status the status
12453             */
12454            @Override
12455            public void removeByG_LtD_S(long groupId, Date displayDate, int status) {
12456                    for (BlogsEntry blogsEntry : findByG_LtD_S(groupId, displayDate,
12457                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
12458                            remove(blogsEntry);
12459                    }
12460            }
12461    
12462            /**
12463             * Returns the number of blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
12464             *
12465             * @param groupId the group ID
12466             * @param displayDate the display date
12467             * @param status the status
12468             * @return the number of matching blogs entries
12469             */
12470            @Override
12471            public int countByG_LtD_S(long groupId, Date displayDate, int status) {
12472                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD_S;
12473    
12474                    Object[] finderArgs = new Object[] { groupId, displayDate, status };
12475    
12476                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
12477    
12478                    if (count == null) {
12479                            StringBundler query = new StringBundler(4);
12480    
12481                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
12482    
12483                            query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
12484    
12485                            boolean bindDisplayDate = false;
12486    
12487                            if (displayDate == null) {
12488                                    query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
12489                            }
12490                            else {
12491                                    bindDisplayDate = true;
12492    
12493                                    query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
12494                            }
12495    
12496                            query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
12497    
12498                            String sql = query.toString();
12499    
12500                            Session session = null;
12501    
12502                            try {
12503                                    session = openSession();
12504    
12505                                    Query q = session.createQuery(sql);
12506    
12507                                    QueryPos qPos = QueryPos.getInstance(q);
12508    
12509                                    qPos.add(groupId);
12510    
12511                                    if (bindDisplayDate) {
12512                                            qPos.add(new Timestamp(displayDate.getTime()));
12513                                    }
12514    
12515                                    qPos.add(status);
12516    
12517                                    count = (Long)q.uniqueResult();
12518    
12519                                    finderCache.putResult(finderPath, finderArgs, count);
12520                            }
12521                            catch (Exception e) {
12522                                    finderCache.removeResult(finderPath, finderArgs);
12523    
12524                                    throw processException(e);
12525                            }
12526                            finally {
12527                                    closeSession(session);
12528                            }
12529                    }
12530    
12531                    return count.intValue();
12532            }
12533    
12534            /**
12535             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
12536             *
12537             * @param groupId the group ID
12538             * @param displayDate the display date
12539             * @param status the status
12540             * @return the number of matching blogs entries that the user has permission to view
12541             */
12542            @Override
12543            public int filterCountByG_LtD_S(long groupId, Date displayDate, int status) {
12544                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12545                            return countByG_LtD_S(groupId, displayDate, status);
12546                    }
12547    
12548                    StringBundler query = new StringBundler(4);
12549    
12550                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
12551    
12552                    query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
12553    
12554                    boolean bindDisplayDate = false;
12555    
12556                    if (displayDate == null) {
12557                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
12558                    }
12559                    else {
12560                            bindDisplayDate = true;
12561    
12562                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
12563                    }
12564    
12565                    query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
12566    
12567                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12568                                    BlogsEntry.class.getName(),
12569                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12570    
12571                    Session session = null;
12572    
12573                    try {
12574                            session = openSession();
12575    
12576                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
12577    
12578                            q.addScalar(COUNT_COLUMN_NAME,
12579                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
12580    
12581                            QueryPos qPos = QueryPos.getInstance(q);
12582    
12583                            qPos.add(groupId);
12584    
12585                            if (bindDisplayDate) {
12586                                    qPos.add(new Timestamp(displayDate.getTime()));
12587                            }
12588    
12589                            qPos.add(status);
12590    
12591                            Long count = (Long)q.uniqueResult();
12592    
12593                            return count.intValue();
12594                    }
12595                    catch (Exception e) {
12596                            throw processException(e);
12597                    }
12598                    finally {
12599                            closeSession(session);
12600                    }
12601            }
12602    
12603            private static final String _FINDER_COLUMN_G_LTD_S_GROUPID_2 = "blogsEntry.groupId = ? AND ";
12604            private static final String _FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1 = "blogsEntry.displayDate IS NULL AND ";
12605            private static final String _FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
12606            private static final String _FINDER_COLUMN_G_LTD_S_STATUS_2 = "blogsEntry.status = ?";
12607            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD_NOTS =
12608                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
12609                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
12610                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_LtD_NotS",
12611                            new String[] {
12612                                    Long.class.getName(), Date.class.getName(),
12613                                    Integer.class.getName(),
12614                                    
12615                            Integer.class.getName(), Integer.class.getName(),
12616                                    OrderByComparator.class.getName()
12617                            });
12618            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD_NOTS =
12619                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
12620                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
12621                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_LtD_NotS",
12622                            new String[] {
12623                                    Long.class.getName(), Date.class.getName(),
12624                                    Integer.class.getName()
12625                            });
12626    
12627            /**
12628             * Returns all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
12629             *
12630             * @param groupId the group ID
12631             * @param displayDate the display date
12632             * @param status the status
12633             * @return the matching blogs entries
12634             */
12635            @Override
12636            public List<BlogsEntry> findByG_LtD_NotS(long groupId, Date displayDate,
12637                    int status) {
12638                    return findByG_LtD_NotS(groupId, displayDate, status,
12639                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
12640            }
12641    
12642            /**
12643             * Returns a range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
12644             *
12645             * <p>
12646             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
12647             * </p>
12648             *
12649             * @param groupId the group ID
12650             * @param displayDate the display date
12651             * @param status the status
12652             * @param start the lower bound of the range of blogs entries
12653             * @param end the upper bound of the range of blogs entries (not inclusive)
12654             * @return the range of matching blogs entries
12655             */
12656            @Override
12657            public List<BlogsEntry> findByG_LtD_NotS(long groupId, Date displayDate,
12658                    int status, int start, int end) {
12659                    return findByG_LtD_NotS(groupId, displayDate, status, start, end, null);
12660            }
12661    
12662            /**
12663             * Returns an ordered range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
12664             *
12665             * <p>
12666             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
12667             * </p>
12668             *
12669             * @param groupId the group ID
12670             * @param displayDate the display date
12671             * @param status the status
12672             * @param start the lower bound of the range of blogs entries
12673             * @param end the upper bound of the range of blogs entries (not inclusive)
12674             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12675             * @return the ordered range of matching blogs entries
12676             */
12677            @Override
12678            public List<BlogsEntry> findByG_LtD_NotS(long groupId, Date displayDate,
12679                    int status, int start, int end,
12680                    OrderByComparator<BlogsEntry> orderByComparator) {
12681                    return findByG_LtD_NotS(groupId, displayDate, status, start, end,
12682                            orderByComparator, true);
12683            }
12684    
12685            /**
12686             * Returns an ordered range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
12687             *
12688             * <p>
12689             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
12690             * </p>
12691             *
12692             * @param groupId the group ID
12693             * @param displayDate the display date
12694             * @param status the status
12695             * @param start the lower bound of the range of blogs entries
12696             * @param end the upper bound of the range of blogs entries (not inclusive)
12697             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12698             * @param retrieveFromCache whether to retrieve from the finder cache
12699             * @return the ordered range of matching blogs entries
12700             */
12701            @Override
12702            public List<BlogsEntry> findByG_LtD_NotS(long groupId, Date displayDate,
12703                    int status, int start, int end,
12704                    OrderByComparator<BlogsEntry> orderByComparator,
12705                    boolean retrieveFromCache) {
12706                    boolean pagination = true;
12707                    FinderPath finderPath = null;
12708                    Object[] finderArgs = null;
12709    
12710                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD_NOTS;
12711                    finderArgs = new Object[] {
12712                                    groupId, displayDate, status,
12713                                    
12714                                    start, end, orderByComparator
12715                            };
12716    
12717                    List<BlogsEntry> list = null;
12718    
12719                    if (retrieveFromCache) {
12720                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
12721                                            finderArgs, this);
12722    
12723                            if ((list != null) && !list.isEmpty()) {
12724                                    for (BlogsEntry blogsEntry : list) {
12725                                            if ((groupId != blogsEntry.getGroupId()) ||
12726                                                            (displayDate.getTime() <= blogsEntry.getDisplayDate()
12727                                                                                                                                            .getTime()) ||
12728                                                            (status == blogsEntry.getStatus())) {
12729                                                    list = null;
12730    
12731                                                    break;
12732                                            }
12733                                    }
12734                            }
12735                    }
12736    
12737                    if (list == null) {
12738                            StringBundler query = null;
12739    
12740                            if (orderByComparator != null) {
12741                                    query = new StringBundler(5 +
12742                                                    (orderByComparator.getOrderByFields().length * 3));
12743                            }
12744                            else {
12745                                    query = new StringBundler(5);
12746                            }
12747    
12748                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
12749    
12750                            query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
12751    
12752                            boolean bindDisplayDate = false;
12753    
12754                            if (displayDate == null) {
12755                                    query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
12756                            }
12757                            else {
12758                                    bindDisplayDate = true;
12759    
12760                                    query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
12761                            }
12762    
12763                            query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
12764    
12765                            if (orderByComparator != null) {
12766                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12767                                            orderByComparator);
12768                            }
12769                            else
12770                             if (pagination) {
12771                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
12772                            }
12773    
12774                            String sql = query.toString();
12775    
12776                            Session session = null;
12777    
12778                            try {
12779                                    session = openSession();
12780    
12781                                    Query q = session.createQuery(sql);
12782    
12783                                    QueryPos qPos = QueryPos.getInstance(q);
12784    
12785                                    qPos.add(groupId);
12786    
12787                                    if (bindDisplayDate) {
12788                                            qPos.add(new Timestamp(displayDate.getTime()));
12789                                    }
12790    
12791                                    qPos.add(status);
12792    
12793                                    if (!pagination) {
12794                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
12795                                                            start, end, false);
12796    
12797                                            Collections.sort(list);
12798    
12799                                            list = Collections.unmodifiableList(list);
12800                                    }
12801                                    else {
12802                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
12803                                                            start, end);
12804                                    }
12805    
12806                                    cacheResult(list);
12807    
12808                                    finderCache.putResult(finderPath, finderArgs, list);
12809                            }
12810                            catch (Exception e) {
12811                                    finderCache.removeResult(finderPath, finderArgs);
12812    
12813                                    throw processException(e);
12814                            }
12815                            finally {
12816                                    closeSession(session);
12817                            }
12818                    }
12819    
12820                    return list;
12821            }
12822    
12823            /**
12824             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
12825             *
12826             * @param groupId the group ID
12827             * @param displayDate the display date
12828             * @param status the status
12829             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12830             * @return the first matching blogs entry
12831             * @throws NoSuchEntryException if a matching blogs entry could not be found
12832             */
12833            @Override
12834            public BlogsEntry findByG_LtD_NotS_First(long groupId, Date displayDate,
12835                    int status, OrderByComparator<BlogsEntry> orderByComparator)
12836                    throws NoSuchEntryException {
12837                    BlogsEntry blogsEntry = fetchByG_LtD_NotS_First(groupId, displayDate,
12838                                    status, orderByComparator);
12839    
12840                    if (blogsEntry != null) {
12841                            return blogsEntry;
12842                    }
12843    
12844                    StringBundler msg = new StringBundler(8);
12845    
12846                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12847    
12848                    msg.append("groupId=");
12849                    msg.append(groupId);
12850    
12851                    msg.append(", displayDate=");
12852                    msg.append(displayDate);
12853    
12854                    msg.append(", status=");
12855                    msg.append(status);
12856    
12857                    msg.append(StringPool.CLOSE_CURLY_BRACE);
12858    
12859                    throw new NoSuchEntryException(msg.toString());
12860            }
12861    
12862            /**
12863             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
12864             *
12865             * @param groupId the group ID
12866             * @param displayDate the display date
12867             * @param status the status
12868             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12869             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
12870             */
12871            @Override
12872            public BlogsEntry fetchByG_LtD_NotS_First(long groupId, Date displayDate,
12873                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
12874                    List<BlogsEntry> list = findByG_LtD_NotS(groupId, displayDate, status,
12875                                    0, 1, orderByComparator);
12876    
12877                    if (!list.isEmpty()) {
12878                            return list.get(0);
12879                    }
12880    
12881                    return null;
12882            }
12883    
12884            /**
12885             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
12886             *
12887             * @param groupId the group ID
12888             * @param displayDate the display date
12889             * @param status the status
12890             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12891             * @return the last matching blogs entry
12892             * @throws NoSuchEntryException if a matching blogs entry could not be found
12893             */
12894            @Override
12895            public BlogsEntry findByG_LtD_NotS_Last(long groupId, Date displayDate,
12896                    int status, OrderByComparator<BlogsEntry> orderByComparator)
12897                    throws NoSuchEntryException {
12898                    BlogsEntry blogsEntry = fetchByG_LtD_NotS_Last(groupId, displayDate,
12899                                    status, orderByComparator);
12900    
12901                    if (blogsEntry != null) {
12902                            return blogsEntry;
12903                    }
12904    
12905                    StringBundler msg = new StringBundler(8);
12906    
12907                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12908    
12909                    msg.append("groupId=");
12910                    msg.append(groupId);
12911    
12912                    msg.append(", displayDate=");
12913                    msg.append(displayDate);
12914    
12915                    msg.append(", status=");
12916                    msg.append(status);
12917    
12918                    msg.append(StringPool.CLOSE_CURLY_BRACE);
12919    
12920                    throw new NoSuchEntryException(msg.toString());
12921            }
12922    
12923            /**
12924             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
12925             *
12926             * @param groupId the group ID
12927             * @param displayDate the display date
12928             * @param status the status
12929             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12930             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
12931             */
12932            @Override
12933            public BlogsEntry fetchByG_LtD_NotS_Last(long groupId, Date displayDate,
12934                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
12935                    int count = countByG_LtD_NotS(groupId, displayDate, status);
12936    
12937                    if (count == 0) {
12938                            return null;
12939                    }
12940    
12941                    List<BlogsEntry> list = findByG_LtD_NotS(groupId, displayDate, status,
12942                                    count - 1, count, orderByComparator);
12943    
12944                    if (!list.isEmpty()) {
12945                            return list.get(0);
12946                    }
12947    
12948                    return null;
12949            }
12950    
12951            /**
12952             * 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;.
12953             *
12954             * @param entryId the primary key of the current blogs entry
12955             * @param groupId the group ID
12956             * @param displayDate the display date
12957             * @param status the status
12958             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12959             * @return the previous, current, and next blogs entry
12960             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
12961             */
12962            @Override
12963            public BlogsEntry[] findByG_LtD_NotS_PrevAndNext(long entryId,
12964                    long groupId, Date displayDate, int status,
12965                    OrderByComparator<BlogsEntry> orderByComparator)
12966                    throws NoSuchEntryException {
12967                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
12968    
12969                    Session session = null;
12970    
12971                    try {
12972                            session = openSession();
12973    
12974                            BlogsEntry[] array = new BlogsEntryImpl[3];
12975    
12976                            array[0] = getByG_LtD_NotS_PrevAndNext(session, blogsEntry,
12977                                            groupId, displayDate, status, orderByComparator, true);
12978    
12979                            array[1] = blogsEntry;
12980    
12981                            array[2] = getByG_LtD_NotS_PrevAndNext(session, blogsEntry,
12982                                            groupId, displayDate, status, orderByComparator, false);
12983    
12984                            return array;
12985                    }
12986                    catch (Exception e) {
12987                            throw processException(e);
12988                    }
12989                    finally {
12990                            closeSession(session);
12991                    }
12992            }
12993    
12994            protected BlogsEntry getByG_LtD_NotS_PrevAndNext(Session session,
12995                    BlogsEntry blogsEntry, long groupId, Date displayDate, int status,
12996                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
12997                    StringBundler query = null;
12998    
12999                    if (orderByComparator != null) {
13000                            query = new StringBundler(6 +
13001                                            (orderByComparator.getOrderByFields().length * 6));
13002                    }
13003                    else {
13004                            query = new StringBundler(3);
13005                    }
13006    
13007                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
13008    
13009                    query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
13010    
13011                    boolean bindDisplayDate = false;
13012    
13013                    if (displayDate == null) {
13014                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
13015                    }
13016                    else {
13017                            bindDisplayDate = true;
13018    
13019                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
13020                    }
13021    
13022                    query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
13023    
13024                    if (orderByComparator != null) {
13025                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
13026    
13027                            if (orderByConditionFields.length > 0) {
13028                                    query.append(WHERE_AND);
13029                            }
13030    
13031                            for (int i = 0; i < orderByConditionFields.length; i++) {
13032                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13033                                    query.append(orderByConditionFields[i]);
13034    
13035                                    if ((i + 1) < orderByConditionFields.length) {
13036                                            if (orderByComparator.isAscending() ^ previous) {
13037                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
13038                                            }
13039                                            else {
13040                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
13041                                            }
13042                                    }
13043                                    else {
13044                                            if (orderByComparator.isAscending() ^ previous) {
13045                                                    query.append(WHERE_GREATER_THAN);
13046                                            }
13047                                            else {
13048                                                    query.append(WHERE_LESSER_THAN);
13049                                            }
13050                                    }
13051                            }
13052    
13053                            query.append(ORDER_BY_CLAUSE);
13054    
13055                            String[] orderByFields = orderByComparator.getOrderByFields();
13056    
13057                            for (int i = 0; i < orderByFields.length; i++) {
13058                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13059                                    query.append(orderByFields[i]);
13060    
13061                                    if ((i + 1) < orderByFields.length) {
13062                                            if (orderByComparator.isAscending() ^ previous) {
13063                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
13064                                            }
13065                                            else {
13066                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
13067                                            }
13068                                    }
13069                                    else {
13070                                            if (orderByComparator.isAscending() ^ previous) {
13071                                                    query.append(ORDER_BY_ASC);
13072                                            }
13073                                            else {
13074                                                    query.append(ORDER_BY_DESC);
13075                                            }
13076                                    }
13077                            }
13078                    }
13079                    else {
13080                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
13081                    }
13082    
13083                    String sql = query.toString();
13084    
13085                    Query q = session.createQuery(sql);
13086    
13087                    q.setFirstResult(0);
13088                    q.setMaxResults(2);
13089    
13090                    QueryPos qPos = QueryPos.getInstance(q);
13091    
13092                    qPos.add(groupId);
13093    
13094                    if (bindDisplayDate) {
13095                            qPos.add(new Timestamp(displayDate.getTime()));
13096                    }
13097    
13098                    qPos.add(status);
13099    
13100                    if (orderByComparator != null) {
13101                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
13102    
13103                            for (Object value : values) {
13104                                    qPos.add(value);
13105                            }
13106                    }
13107    
13108                    List<BlogsEntry> list = q.list();
13109    
13110                    if (list.size() == 2) {
13111                            return list.get(1);
13112                    }
13113                    else {
13114                            return null;
13115                    }
13116            }
13117    
13118            /**
13119             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13120             *
13121             * @param groupId the group ID
13122             * @param displayDate the display date
13123             * @param status the status
13124             * @return the matching blogs entries that the user has permission to view
13125             */
13126            @Override
13127            public List<BlogsEntry> filterFindByG_LtD_NotS(long groupId,
13128                    Date displayDate, int status) {
13129                    return filterFindByG_LtD_NotS(groupId, displayDate, status,
13130                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
13131            }
13132    
13133            /**
13134             * 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;.
13135             *
13136             * <p>
13137             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
13138             * </p>
13139             *
13140             * @param groupId the group ID
13141             * @param displayDate the display date
13142             * @param status the status
13143             * @param start the lower bound of the range of blogs entries
13144             * @param end the upper bound of the range of blogs entries (not inclusive)
13145             * @return the range of matching blogs entries that the user has permission to view
13146             */
13147            @Override
13148            public List<BlogsEntry> filterFindByG_LtD_NotS(long groupId,
13149                    Date displayDate, int status, int start, int end) {
13150                    return filterFindByG_LtD_NotS(groupId, displayDate, status, start, end,
13151                            null);
13152            }
13153    
13154            /**
13155             * 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;.
13156             *
13157             * <p>
13158             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
13159             * </p>
13160             *
13161             * @param groupId the group ID
13162             * @param displayDate the display date
13163             * @param status the status
13164             * @param start the lower bound of the range of blogs entries
13165             * @param end the upper bound of the range of blogs entries (not inclusive)
13166             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13167             * @return the ordered range of matching blogs entries that the user has permission to view
13168             */
13169            @Override
13170            public List<BlogsEntry> filterFindByG_LtD_NotS(long groupId,
13171                    Date displayDate, int status, int start, int end,
13172                    OrderByComparator<BlogsEntry> orderByComparator) {
13173                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13174                            return findByG_LtD_NotS(groupId, displayDate, status, start, end,
13175                                    orderByComparator);
13176                    }
13177    
13178                    StringBundler query = null;
13179    
13180                    if (orderByComparator != null) {
13181                            query = new StringBundler(5 +
13182                                            (orderByComparator.getOrderByFields().length * 3));
13183                    }
13184                    else {
13185                            query = new StringBundler(5);
13186                    }
13187    
13188                    if (getDB().isSupportsInlineDistinct()) {
13189                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
13190                    }
13191                    else {
13192                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
13193                    }
13194    
13195                    query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
13196    
13197                    boolean bindDisplayDate = false;
13198    
13199                    if (displayDate == null) {
13200                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
13201                    }
13202                    else {
13203                            bindDisplayDate = true;
13204    
13205                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
13206                    }
13207    
13208                    query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
13209    
13210                    if (!getDB().isSupportsInlineDistinct()) {
13211                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
13212                    }
13213    
13214                    if (orderByComparator != null) {
13215                            if (getDB().isSupportsInlineDistinct()) {
13216                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13217                                            orderByComparator, true);
13218                            }
13219                            else {
13220                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
13221                                            orderByComparator, true);
13222                            }
13223                    }
13224                    else {
13225                            if (getDB().isSupportsInlineDistinct()) {
13226                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
13227                            }
13228                            else {
13229                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
13230                            }
13231                    }
13232    
13233                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13234                                    BlogsEntry.class.getName(),
13235                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13236    
13237                    Session session = null;
13238    
13239                    try {
13240                            session = openSession();
13241    
13242                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
13243    
13244                            if (getDB().isSupportsInlineDistinct()) {
13245                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
13246                            }
13247                            else {
13248                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
13249                            }
13250    
13251                            QueryPos qPos = QueryPos.getInstance(q);
13252    
13253                            qPos.add(groupId);
13254    
13255                            if (bindDisplayDate) {
13256                                    qPos.add(new Timestamp(displayDate.getTime()));
13257                            }
13258    
13259                            qPos.add(status);
13260    
13261                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
13262                    }
13263                    catch (Exception e) {
13264                            throw processException(e);
13265                    }
13266                    finally {
13267                            closeSession(session);
13268                    }
13269            }
13270    
13271            /**
13272             * 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;.
13273             *
13274             * @param entryId the primary key of the current blogs entry
13275             * @param groupId the group ID
13276             * @param displayDate the display date
13277             * @param status the status
13278             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13279             * @return the previous, current, and next blogs entry
13280             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
13281             */
13282            @Override
13283            public BlogsEntry[] filterFindByG_LtD_NotS_PrevAndNext(long entryId,
13284                    long groupId, Date displayDate, int status,
13285                    OrderByComparator<BlogsEntry> orderByComparator)
13286                    throws NoSuchEntryException {
13287                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13288                            return findByG_LtD_NotS_PrevAndNext(entryId, groupId, displayDate,
13289                                    status, orderByComparator);
13290                    }
13291    
13292                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
13293    
13294                    Session session = null;
13295    
13296                    try {
13297                            session = openSession();
13298    
13299                            BlogsEntry[] array = new BlogsEntryImpl[3];
13300    
13301                            array[0] = filterGetByG_LtD_NotS_PrevAndNext(session, blogsEntry,
13302                                            groupId, displayDate, status, orderByComparator, true);
13303    
13304                            array[1] = blogsEntry;
13305    
13306                            array[2] = filterGetByG_LtD_NotS_PrevAndNext(session, blogsEntry,
13307                                            groupId, displayDate, status, orderByComparator, false);
13308    
13309                            return array;
13310                    }
13311                    catch (Exception e) {
13312                            throw processException(e);
13313                    }
13314                    finally {
13315                            closeSession(session);
13316                    }
13317            }
13318    
13319            protected BlogsEntry filterGetByG_LtD_NotS_PrevAndNext(Session session,
13320                    BlogsEntry blogsEntry, long groupId, Date displayDate, int status,
13321                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
13322                    StringBundler query = null;
13323    
13324                    if (orderByComparator != null) {
13325                            query = new StringBundler(6 +
13326                                            (orderByComparator.getOrderByFields().length * 6));
13327                    }
13328                    else {
13329                            query = new StringBundler(3);
13330                    }
13331    
13332                    if (getDB().isSupportsInlineDistinct()) {
13333                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
13334                    }
13335                    else {
13336                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
13337                    }
13338    
13339                    query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
13340    
13341                    boolean bindDisplayDate = false;
13342    
13343                    if (displayDate == null) {
13344                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
13345                    }
13346                    else {
13347                            bindDisplayDate = true;
13348    
13349                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
13350                    }
13351    
13352                    query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
13353    
13354                    if (!getDB().isSupportsInlineDistinct()) {
13355                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
13356                    }
13357    
13358                    if (orderByComparator != null) {
13359                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
13360    
13361                            if (orderByConditionFields.length > 0) {
13362                                    query.append(WHERE_AND);
13363                            }
13364    
13365                            for (int i = 0; i < orderByConditionFields.length; i++) {
13366                                    if (getDB().isSupportsInlineDistinct()) {
13367                                            query.append(_ORDER_BY_ENTITY_ALIAS);
13368                                    }
13369                                    else {
13370                                            query.append(_ORDER_BY_ENTITY_TABLE);
13371                                    }
13372    
13373                                    query.append(orderByConditionFields[i]);
13374    
13375                                    if ((i + 1) < orderByConditionFields.length) {
13376                                            if (orderByComparator.isAscending() ^ previous) {
13377                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
13378                                            }
13379                                            else {
13380                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
13381                                            }
13382                                    }
13383                                    else {
13384                                            if (orderByComparator.isAscending() ^ previous) {
13385                                                    query.append(WHERE_GREATER_THAN);
13386                                            }
13387                                            else {
13388                                                    query.append(WHERE_LESSER_THAN);
13389                                            }
13390                                    }
13391                            }
13392    
13393                            query.append(ORDER_BY_CLAUSE);
13394    
13395                            String[] orderByFields = orderByComparator.getOrderByFields();
13396    
13397                            for (int i = 0; i < orderByFields.length; i++) {
13398                                    if (getDB().isSupportsInlineDistinct()) {
13399                                            query.append(_ORDER_BY_ENTITY_ALIAS);
13400                                    }
13401                                    else {
13402                                            query.append(_ORDER_BY_ENTITY_TABLE);
13403                                    }
13404    
13405                                    query.append(orderByFields[i]);
13406    
13407                                    if ((i + 1) < orderByFields.length) {
13408                                            if (orderByComparator.isAscending() ^ previous) {
13409                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
13410                                            }
13411                                            else {
13412                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
13413                                            }
13414                                    }
13415                                    else {
13416                                            if (orderByComparator.isAscending() ^ previous) {
13417                                                    query.append(ORDER_BY_ASC);
13418                                            }
13419                                            else {
13420                                                    query.append(ORDER_BY_DESC);
13421                                            }
13422                                    }
13423                            }
13424                    }
13425                    else {
13426                            if (getDB().isSupportsInlineDistinct()) {
13427                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
13428                            }
13429                            else {
13430                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
13431                            }
13432                    }
13433    
13434                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13435                                    BlogsEntry.class.getName(),
13436                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13437    
13438                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
13439    
13440                    q.setFirstResult(0);
13441                    q.setMaxResults(2);
13442    
13443                    if (getDB().isSupportsInlineDistinct()) {
13444                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
13445                    }
13446                    else {
13447                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
13448                    }
13449    
13450                    QueryPos qPos = QueryPos.getInstance(q);
13451    
13452                    qPos.add(groupId);
13453    
13454                    if (bindDisplayDate) {
13455                            qPos.add(new Timestamp(displayDate.getTime()));
13456                    }
13457    
13458                    qPos.add(status);
13459    
13460                    if (orderByComparator != null) {
13461                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
13462    
13463                            for (Object value : values) {
13464                                    qPos.add(value);
13465                            }
13466                    }
13467    
13468                    List<BlogsEntry> list = q.list();
13469    
13470                    if (list.size() == 2) {
13471                            return list.get(1);
13472                    }
13473                    else {
13474                            return null;
13475                    }
13476            }
13477    
13478            /**
13479             * Removes all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63; from the database.
13480             *
13481             * @param groupId the group ID
13482             * @param displayDate the display date
13483             * @param status the status
13484             */
13485            @Override
13486            public void removeByG_LtD_NotS(long groupId, Date displayDate, int status) {
13487                    for (BlogsEntry blogsEntry : findByG_LtD_NotS(groupId, displayDate,
13488                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
13489                            remove(blogsEntry);
13490                    }
13491            }
13492    
13493            /**
13494             * Returns the number of blogs entries where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13495             *
13496             * @param groupId the group ID
13497             * @param displayDate the display date
13498             * @param status the status
13499             * @return the number of matching blogs entries
13500             */
13501            @Override
13502            public int countByG_LtD_NotS(long groupId, Date displayDate, int status) {
13503                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD_NOTS;
13504    
13505                    Object[] finderArgs = new Object[] { groupId, displayDate, status };
13506    
13507                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
13508    
13509                    if (count == null) {
13510                            StringBundler query = new StringBundler(4);
13511    
13512                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
13513    
13514                            query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
13515    
13516                            boolean bindDisplayDate = false;
13517    
13518                            if (displayDate == null) {
13519                                    query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
13520                            }
13521                            else {
13522                                    bindDisplayDate = true;
13523    
13524                                    query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
13525                            }
13526    
13527                            query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
13528    
13529                            String sql = query.toString();
13530    
13531                            Session session = null;
13532    
13533                            try {
13534                                    session = openSession();
13535    
13536                                    Query q = session.createQuery(sql);
13537    
13538                                    QueryPos qPos = QueryPos.getInstance(q);
13539    
13540                                    qPos.add(groupId);
13541    
13542                                    if (bindDisplayDate) {
13543                                            qPos.add(new Timestamp(displayDate.getTime()));
13544                                    }
13545    
13546                                    qPos.add(status);
13547    
13548                                    count = (Long)q.uniqueResult();
13549    
13550                                    finderCache.putResult(finderPath, finderArgs, count);
13551                            }
13552                            catch (Exception e) {
13553                                    finderCache.removeResult(finderPath, finderArgs);
13554    
13555                                    throw processException(e);
13556                            }
13557                            finally {
13558                                    closeSession(session);
13559                            }
13560                    }
13561    
13562                    return count.intValue();
13563            }
13564    
13565            /**
13566             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13567             *
13568             * @param groupId the group ID
13569             * @param displayDate the display date
13570             * @param status the status
13571             * @return the number of matching blogs entries that the user has permission to view
13572             */
13573            @Override
13574            public int filterCountByG_LtD_NotS(long groupId, Date displayDate,
13575                    int status) {
13576                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13577                            return countByG_LtD_NotS(groupId, displayDate, status);
13578                    }
13579    
13580                    StringBundler query = new StringBundler(4);
13581    
13582                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
13583    
13584                    query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
13585    
13586                    boolean bindDisplayDate = false;
13587    
13588                    if (displayDate == null) {
13589                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
13590                    }
13591                    else {
13592                            bindDisplayDate = true;
13593    
13594                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
13595                    }
13596    
13597                    query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
13598    
13599                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13600                                    BlogsEntry.class.getName(),
13601                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13602    
13603                    Session session = null;
13604    
13605                    try {
13606                            session = openSession();
13607    
13608                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
13609    
13610                            q.addScalar(COUNT_COLUMN_NAME,
13611                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
13612    
13613                            QueryPos qPos = QueryPos.getInstance(q);
13614    
13615                            qPos.add(groupId);
13616    
13617                            if (bindDisplayDate) {
13618                                    qPos.add(new Timestamp(displayDate.getTime()));
13619                            }
13620    
13621                            qPos.add(status);
13622    
13623                            Long count = (Long)q.uniqueResult();
13624    
13625                            return count.intValue();
13626                    }
13627                    catch (Exception e) {
13628                            throw processException(e);
13629                    }
13630                    finally {
13631                            closeSession(session);
13632                    }
13633            }
13634    
13635            private static final String _FINDER_COLUMN_G_LTD_NOTS_GROUPID_2 = "blogsEntry.groupId = ? AND ";
13636            private static final String _FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1 = "blogsEntry.displayDate IS NULL AND ";
13637            private static final String _FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
13638            private static final String _FINDER_COLUMN_G_LTD_NOTS_STATUS_2 = "blogsEntry.status != ?";
13639            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
13640                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
13641                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_U_S",
13642                            new String[] {
13643                                    Long.class.getName(), Long.class.getName(),
13644                                    Integer.class.getName(),
13645                                    
13646                            Integer.class.getName(), Integer.class.getName(),
13647                                    OrderByComparator.class.getName()
13648                            });
13649            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
13650                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
13651                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_U_S",
13652                            new String[] {
13653                                    Long.class.getName(), Long.class.getName(),
13654                                    Integer.class.getName()
13655                            },
13656                            BlogsEntryModelImpl.COMPANYID_COLUMN_BITMASK |
13657                            BlogsEntryModelImpl.USERID_COLUMN_BITMASK |
13658                            BlogsEntryModelImpl.STATUS_COLUMN_BITMASK |
13659                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
13660                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
13661            public static final FinderPath FINDER_PATH_COUNT_BY_C_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
13662                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
13663                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_U_S",
13664                            new String[] {
13665                                    Long.class.getName(), Long.class.getName(),
13666                                    Integer.class.getName()
13667                            });
13668    
13669            /**
13670             * Returns all the blogs entries where companyId = &#63; and userId = &#63; and status = &#63;.
13671             *
13672             * @param companyId the company ID
13673             * @param userId the user ID
13674             * @param status the status
13675             * @return the matching blogs entries
13676             */
13677            @Override
13678            public List<BlogsEntry> findByC_U_S(long companyId, long userId, int status) {
13679                    return findByC_U_S(companyId, userId, status, QueryUtil.ALL_POS,
13680                            QueryUtil.ALL_POS, null);
13681            }
13682    
13683            /**
13684             * Returns a range of all the blogs entries where companyId = &#63; and userId = &#63; and status = &#63;.
13685             *
13686             * <p>
13687             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
13688             * </p>
13689             *
13690             * @param companyId the company ID
13691             * @param userId the user ID
13692             * @param status the status
13693             * @param start the lower bound of the range of blogs entries
13694             * @param end the upper bound of the range of blogs entries (not inclusive)
13695             * @return the range of matching blogs entries
13696             */
13697            @Override
13698            public List<BlogsEntry> findByC_U_S(long companyId, long userId,
13699                    int status, int start, int end) {
13700                    return findByC_U_S(companyId, userId, status, start, end, null);
13701            }
13702    
13703            /**
13704             * Returns an ordered range of all the blogs entries where companyId = &#63; and userId = &#63; and status = &#63;.
13705             *
13706             * <p>
13707             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
13708             * </p>
13709             *
13710             * @param companyId the company ID
13711             * @param userId the user ID
13712             * @param status the status
13713             * @param start the lower bound of the range of blogs entries
13714             * @param end the upper bound of the range of blogs entries (not inclusive)
13715             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13716             * @return the ordered range of matching blogs entries
13717             */
13718            @Override
13719            public List<BlogsEntry> findByC_U_S(long companyId, long userId,
13720                    int status, int start, int end,
13721                    OrderByComparator<BlogsEntry> orderByComparator) {
13722                    return findByC_U_S(companyId, userId, status, start, end,
13723                            orderByComparator, true);
13724            }
13725    
13726            /**
13727             * Returns an ordered range of all the blogs entries where companyId = &#63; and userId = &#63; and status = &#63;.
13728             *
13729             * <p>
13730             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
13731             * </p>
13732             *
13733             * @param companyId the company ID
13734             * @param userId the user ID
13735             * @param status the status
13736             * @param start the lower bound of the range of blogs entries
13737             * @param end the upper bound of the range of blogs entries (not inclusive)
13738             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13739             * @param retrieveFromCache whether to retrieve from the finder cache
13740             * @return the ordered range of matching blogs entries
13741             */
13742            @Override
13743            public List<BlogsEntry> findByC_U_S(long companyId, long userId,
13744                    int status, int start, int end,
13745                    OrderByComparator<BlogsEntry> orderByComparator,
13746                    boolean retrieveFromCache) {
13747                    boolean pagination = true;
13748                    FinderPath finderPath = null;
13749                    Object[] finderArgs = null;
13750    
13751                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
13752                                    (orderByComparator == null)) {
13753                            pagination = false;
13754                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U_S;
13755                            finderArgs = new Object[] { companyId, userId, status };
13756                    }
13757                    else {
13758                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U_S;
13759                            finderArgs = new Object[] {
13760                                            companyId, userId, status,
13761                                            
13762                                            start, end, orderByComparator
13763                                    };
13764                    }
13765    
13766                    List<BlogsEntry> list = null;
13767    
13768                    if (retrieveFromCache) {
13769                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
13770                                            finderArgs, this);
13771    
13772                            if ((list != null) && !list.isEmpty()) {
13773                                    for (BlogsEntry blogsEntry : list) {
13774                                            if ((companyId != blogsEntry.getCompanyId()) ||
13775                                                            (userId != blogsEntry.getUserId()) ||
13776                                                            (status != blogsEntry.getStatus())) {
13777                                                    list = null;
13778    
13779                                                    break;
13780                                            }
13781                                    }
13782                            }
13783                    }
13784    
13785                    if (list == null) {
13786                            StringBundler query = null;
13787    
13788                            if (orderByComparator != null) {
13789                                    query = new StringBundler(5 +
13790                                                    (orderByComparator.getOrderByFields().length * 3));
13791                            }
13792                            else {
13793                                    query = new StringBundler(5);
13794                            }
13795    
13796                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
13797    
13798                            query.append(_FINDER_COLUMN_C_U_S_COMPANYID_2);
13799    
13800                            query.append(_FINDER_COLUMN_C_U_S_USERID_2);
13801    
13802                            query.append(_FINDER_COLUMN_C_U_S_STATUS_2);
13803    
13804                            if (orderByComparator != null) {
13805                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13806                                            orderByComparator);
13807                            }
13808                            else
13809                             if (pagination) {
13810                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
13811                            }
13812    
13813                            String sql = query.toString();
13814    
13815                            Session session = null;
13816    
13817                            try {
13818                                    session = openSession();
13819    
13820                                    Query q = session.createQuery(sql);
13821    
13822                                    QueryPos qPos = QueryPos.getInstance(q);
13823    
13824                                    qPos.add(companyId);
13825    
13826                                    qPos.add(userId);
13827    
13828                                    qPos.add(status);
13829    
13830                                    if (!pagination) {
13831                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
13832                                                            start, end, false);
13833    
13834                                            Collections.sort(list);
13835    
13836                                            list = Collections.unmodifiableList(list);
13837                                    }
13838                                    else {
13839                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
13840                                                            start, end);
13841                                    }
13842    
13843                                    cacheResult(list);
13844    
13845                                    finderCache.putResult(finderPath, finderArgs, list);
13846                            }
13847                            catch (Exception e) {
13848                                    finderCache.removeResult(finderPath, finderArgs);
13849    
13850                                    throw processException(e);
13851                            }
13852                            finally {
13853                                    closeSession(session);
13854                            }
13855                    }
13856    
13857                    return list;
13858            }
13859    
13860            /**
13861             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status = &#63;.
13862             *
13863             * @param companyId the company ID
13864             * @param userId the user ID
13865             * @param status the status
13866             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13867             * @return the first matching blogs entry
13868             * @throws NoSuchEntryException if a matching blogs entry could not be found
13869             */
13870            @Override
13871            public BlogsEntry findByC_U_S_First(long companyId, long userId,
13872                    int status, OrderByComparator<BlogsEntry> orderByComparator)
13873                    throws NoSuchEntryException {
13874                    BlogsEntry blogsEntry = fetchByC_U_S_First(companyId, userId, status,
13875                                    orderByComparator);
13876    
13877                    if (blogsEntry != null) {
13878                            return blogsEntry;
13879                    }
13880    
13881                    StringBundler msg = new StringBundler(8);
13882    
13883                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13884    
13885                    msg.append("companyId=");
13886                    msg.append(companyId);
13887    
13888                    msg.append(", userId=");
13889                    msg.append(userId);
13890    
13891                    msg.append(", status=");
13892                    msg.append(status);
13893    
13894                    msg.append(StringPool.CLOSE_CURLY_BRACE);
13895    
13896                    throw new NoSuchEntryException(msg.toString());
13897            }
13898    
13899            /**
13900             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status = &#63;.
13901             *
13902             * @param companyId the company ID
13903             * @param userId the user ID
13904             * @param status the status
13905             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13906             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
13907             */
13908            @Override
13909            public BlogsEntry fetchByC_U_S_First(long companyId, long userId,
13910                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
13911                    List<BlogsEntry> list = findByC_U_S(companyId, userId, status, 0, 1,
13912                                    orderByComparator);
13913    
13914                    if (!list.isEmpty()) {
13915                            return list.get(0);
13916                    }
13917    
13918                    return null;
13919            }
13920    
13921            /**
13922             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status = &#63;.
13923             *
13924             * @param companyId the company ID
13925             * @param userId the user ID
13926             * @param status the status
13927             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13928             * @return the last matching blogs entry
13929             * @throws NoSuchEntryException if a matching blogs entry could not be found
13930             */
13931            @Override
13932            public BlogsEntry findByC_U_S_Last(long companyId, long userId, int status,
13933                    OrderByComparator<BlogsEntry> orderByComparator)
13934                    throws NoSuchEntryException {
13935                    BlogsEntry blogsEntry = fetchByC_U_S_Last(companyId, userId, status,
13936                                    orderByComparator);
13937    
13938                    if (blogsEntry != null) {
13939                            return blogsEntry;
13940                    }
13941    
13942                    StringBundler msg = new StringBundler(8);
13943    
13944                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13945    
13946                    msg.append("companyId=");
13947                    msg.append(companyId);
13948    
13949                    msg.append(", userId=");
13950                    msg.append(userId);
13951    
13952                    msg.append(", status=");
13953                    msg.append(status);
13954    
13955                    msg.append(StringPool.CLOSE_CURLY_BRACE);
13956    
13957                    throw new NoSuchEntryException(msg.toString());
13958            }
13959    
13960            /**
13961             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status = &#63;.
13962             *
13963             * @param companyId the company ID
13964             * @param userId the user ID
13965             * @param status the status
13966             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13967             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
13968             */
13969            @Override
13970            public BlogsEntry fetchByC_U_S_Last(long companyId, long userId,
13971                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
13972                    int count = countByC_U_S(companyId, userId, status);
13973    
13974                    if (count == 0) {
13975                            return null;
13976                    }
13977    
13978                    List<BlogsEntry> list = findByC_U_S(companyId, userId, status,
13979                                    count - 1, count, orderByComparator);
13980    
13981                    if (!list.isEmpty()) {
13982                            return list.get(0);
13983                    }
13984    
13985                    return null;
13986            }
13987    
13988            /**
13989             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status = &#63;.
13990             *
13991             * @param entryId the primary key of the current blogs entry
13992             * @param companyId the company ID
13993             * @param userId the user ID
13994             * @param status the status
13995             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13996             * @return the previous, current, and next blogs entry
13997             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
13998             */
13999            @Override
14000            public BlogsEntry[] findByC_U_S_PrevAndNext(long entryId, long companyId,
14001                    long userId, int status, OrderByComparator<BlogsEntry> orderByComparator)
14002                    throws NoSuchEntryException {
14003                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
14004    
14005                    Session session = null;
14006    
14007                    try {
14008                            session = openSession();
14009    
14010                            BlogsEntry[] array = new BlogsEntryImpl[3];
14011    
14012                            array[0] = getByC_U_S_PrevAndNext(session, blogsEntry, companyId,
14013                                            userId, status, orderByComparator, true);
14014    
14015                            array[1] = blogsEntry;
14016    
14017                            array[2] = getByC_U_S_PrevAndNext(session, blogsEntry, companyId,
14018                                            userId, status, orderByComparator, false);
14019    
14020                            return array;
14021                    }
14022                    catch (Exception e) {
14023                            throw processException(e);
14024                    }
14025                    finally {
14026                            closeSession(session);
14027                    }
14028            }
14029    
14030            protected BlogsEntry getByC_U_S_PrevAndNext(Session session,
14031                    BlogsEntry blogsEntry, long companyId, long userId, int status,
14032                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
14033                    StringBundler query = null;
14034    
14035                    if (orderByComparator != null) {
14036                            query = new StringBundler(6 +
14037                                            (orderByComparator.getOrderByFields().length * 6));
14038                    }
14039                    else {
14040                            query = new StringBundler(3);
14041                    }
14042    
14043                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
14044    
14045                    query.append(_FINDER_COLUMN_C_U_S_COMPANYID_2);
14046    
14047                    query.append(_FINDER_COLUMN_C_U_S_USERID_2);
14048    
14049                    query.append(_FINDER_COLUMN_C_U_S_STATUS_2);
14050    
14051                    if (orderByComparator != null) {
14052                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
14053    
14054                            if (orderByConditionFields.length > 0) {
14055                                    query.append(WHERE_AND);
14056                            }
14057    
14058                            for (int i = 0; i < orderByConditionFields.length; i++) {
14059                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14060                                    query.append(orderByConditionFields[i]);
14061    
14062                                    if ((i + 1) < orderByConditionFields.length) {
14063                                            if (orderByComparator.isAscending() ^ previous) {
14064                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
14065                                            }
14066                                            else {
14067                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
14068                                            }
14069                                    }
14070                                    else {
14071                                            if (orderByComparator.isAscending() ^ previous) {
14072                                                    query.append(WHERE_GREATER_THAN);
14073                                            }
14074                                            else {
14075                                                    query.append(WHERE_LESSER_THAN);
14076                                            }
14077                                    }
14078                            }
14079    
14080                            query.append(ORDER_BY_CLAUSE);
14081    
14082                            String[] orderByFields = orderByComparator.getOrderByFields();
14083    
14084                            for (int i = 0; i < orderByFields.length; i++) {
14085                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14086                                    query.append(orderByFields[i]);
14087    
14088                                    if ((i + 1) < orderByFields.length) {
14089                                            if (orderByComparator.isAscending() ^ previous) {
14090                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
14091                                            }
14092                                            else {
14093                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
14094                                            }
14095                                    }
14096                                    else {
14097                                            if (orderByComparator.isAscending() ^ previous) {
14098                                                    query.append(ORDER_BY_ASC);
14099                                            }
14100                                            else {
14101                                                    query.append(ORDER_BY_DESC);
14102                                            }
14103                                    }
14104                            }
14105                    }
14106                    else {
14107                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
14108                    }
14109    
14110                    String sql = query.toString();
14111    
14112                    Query q = session.createQuery(sql);
14113    
14114                    q.setFirstResult(0);
14115                    q.setMaxResults(2);
14116    
14117                    QueryPos qPos = QueryPos.getInstance(q);
14118    
14119                    qPos.add(companyId);
14120    
14121                    qPos.add(userId);
14122    
14123                    qPos.add(status);
14124    
14125                    if (orderByComparator != null) {
14126                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
14127    
14128                            for (Object value : values) {
14129                                    qPos.add(value);
14130                            }
14131                    }
14132    
14133                    List<BlogsEntry> list = q.list();
14134    
14135                    if (list.size() == 2) {
14136                            return list.get(1);
14137                    }
14138                    else {
14139                            return null;
14140                    }
14141            }
14142    
14143            /**
14144             * Removes all the blogs entries where companyId = &#63; and userId = &#63; and status = &#63; from the database.
14145             *
14146             * @param companyId the company ID
14147             * @param userId the user ID
14148             * @param status the status
14149             */
14150            @Override
14151            public void removeByC_U_S(long companyId, long userId, int status) {
14152                    for (BlogsEntry blogsEntry : findByC_U_S(companyId, userId, status,
14153                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
14154                            remove(blogsEntry);
14155                    }
14156            }
14157    
14158            /**
14159             * Returns the number of blogs entries where companyId = &#63; and userId = &#63; and status = &#63;.
14160             *
14161             * @param companyId the company ID
14162             * @param userId the user ID
14163             * @param status the status
14164             * @return the number of matching blogs entries
14165             */
14166            @Override
14167            public int countByC_U_S(long companyId, long userId, int status) {
14168                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_U_S;
14169    
14170                    Object[] finderArgs = new Object[] { companyId, userId, status };
14171    
14172                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
14173    
14174                    if (count == null) {
14175                            StringBundler query = new StringBundler(4);
14176    
14177                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
14178    
14179                            query.append(_FINDER_COLUMN_C_U_S_COMPANYID_2);
14180    
14181                            query.append(_FINDER_COLUMN_C_U_S_USERID_2);
14182    
14183                            query.append(_FINDER_COLUMN_C_U_S_STATUS_2);
14184    
14185                            String sql = query.toString();
14186    
14187                            Session session = null;
14188    
14189                            try {
14190                                    session = openSession();
14191    
14192                                    Query q = session.createQuery(sql);
14193    
14194                                    QueryPos qPos = QueryPos.getInstance(q);
14195    
14196                                    qPos.add(companyId);
14197    
14198                                    qPos.add(userId);
14199    
14200                                    qPos.add(status);
14201    
14202                                    count = (Long)q.uniqueResult();
14203    
14204                                    finderCache.putResult(finderPath, finderArgs, count);
14205                            }
14206                            catch (Exception e) {
14207                                    finderCache.removeResult(finderPath, finderArgs);
14208    
14209                                    throw processException(e);
14210                            }
14211                            finally {
14212                                    closeSession(session);
14213                            }
14214                    }
14215    
14216                    return count.intValue();
14217            }
14218    
14219            private static final String _FINDER_COLUMN_C_U_S_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
14220            private static final String _FINDER_COLUMN_C_U_S_USERID_2 = "blogsEntry.userId = ? AND ";
14221            private static final String _FINDER_COLUMN_C_U_S_STATUS_2 = "blogsEntry.status = ?";
14222            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U_NOTS = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
14223                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
14224                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_U_NotS",
14225                            new String[] {
14226                                    Long.class.getName(), Long.class.getName(),
14227                                    Integer.class.getName(),
14228                                    
14229                            Integer.class.getName(), Integer.class.getName(),
14230                                    OrderByComparator.class.getName()
14231                            });
14232            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_U_NOTS =
14233                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
14234                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
14235                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_U_NotS",
14236                            new String[] {
14237                                    Long.class.getName(), Long.class.getName(),
14238                                    Integer.class.getName()
14239                            });
14240    
14241            /**
14242             * Returns all the blogs entries where companyId = &#63; and userId = &#63; and status &ne; &#63;.
14243             *
14244             * @param companyId the company ID
14245             * @param userId the user ID
14246             * @param status the status
14247             * @return the matching blogs entries
14248             */
14249            @Override
14250            public List<BlogsEntry> findByC_U_NotS(long companyId, long userId,
14251                    int status) {
14252                    return findByC_U_NotS(companyId, userId, status, QueryUtil.ALL_POS,
14253                            QueryUtil.ALL_POS, null);
14254            }
14255    
14256            /**
14257             * Returns a range of all the blogs entries where companyId = &#63; and userId = &#63; and status &ne; &#63;.
14258             *
14259             * <p>
14260             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
14261             * </p>
14262             *
14263             * @param companyId the company ID
14264             * @param userId the user ID
14265             * @param status the status
14266             * @param start the lower bound of the range of blogs entries
14267             * @param end the upper bound of the range of blogs entries (not inclusive)
14268             * @return the range of matching blogs entries
14269             */
14270            @Override
14271            public List<BlogsEntry> findByC_U_NotS(long companyId, long userId,
14272                    int status, int start, int end) {
14273                    return findByC_U_NotS(companyId, userId, status, start, end, null);
14274            }
14275    
14276            /**
14277             * Returns an ordered range of all the blogs entries where companyId = &#63; and userId = &#63; and status &ne; &#63;.
14278             *
14279             * <p>
14280             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
14281             * </p>
14282             *
14283             * @param companyId the company ID
14284             * @param userId the user ID
14285             * @param status the status
14286             * @param start the lower bound of the range of blogs entries
14287             * @param end the upper bound of the range of blogs entries (not inclusive)
14288             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14289             * @return the ordered range of matching blogs entries
14290             */
14291            @Override
14292            public List<BlogsEntry> findByC_U_NotS(long companyId, long userId,
14293                    int status, int start, int end,
14294                    OrderByComparator<BlogsEntry> orderByComparator) {
14295                    return findByC_U_NotS(companyId, userId, status, start, end,
14296                            orderByComparator, true);
14297            }
14298    
14299            /**
14300             * Returns an ordered range of all the blogs entries where companyId = &#63; and userId = &#63; and status &ne; &#63;.
14301             *
14302             * <p>
14303             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
14304             * </p>
14305             *
14306             * @param companyId the company ID
14307             * @param userId the user ID
14308             * @param status the status
14309             * @param start the lower bound of the range of blogs entries
14310             * @param end the upper bound of the range of blogs entries (not inclusive)
14311             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14312             * @param retrieveFromCache whether to retrieve from the finder cache
14313             * @return the ordered range of matching blogs entries
14314             */
14315            @Override
14316            public List<BlogsEntry> findByC_U_NotS(long companyId, long userId,
14317                    int status, int start, int end,
14318                    OrderByComparator<BlogsEntry> orderByComparator,
14319                    boolean retrieveFromCache) {
14320                    boolean pagination = true;
14321                    FinderPath finderPath = null;
14322                    Object[] finderArgs = null;
14323    
14324                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U_NOTS;
14325                    finderArgs = new Object[] {
14326                                    companyId, userId, status,
14327                                    
14328                                    start, end, orderByComparator
14329                            };
14330    
14331                    List<BlogsEntry> list = null;
14332    
14333                    if (retrieveFromCache) {
14334                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
14335                                            finderArgs, this);
14336    
14337                            if ((list != null) && !list.isEmpty()) {
14338                                    for (BlogsEntry blogsEntry : list) {
14339                                            if ((companyId != blogsEntry.getCompanyId()) ||
14340                                                            (userId != blogsEntry.getUserId()) ||
14341                                                            (status == blogsEntry.getStatus())) {
14342                                                    list = null;
14343    
14344                                                    break;
14345                                            }
14346                                    }
14347                            }
14348                    }
14349    
14350                    if (list == null) {
14351                            StringBundler query = null;
14352    
14353                            if (orderByComparator != null) {
14354                                    query = new StringBundler(5 +
14355                                                    (orderByComparator.getOrderByFields().length * 3));
14356                            }
14357                            else {
14358                                    query = new StringBundler(5);
14359                            }
14360    
14361                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
14362    
14363                            query.append(_FINDER_COLUMN_C_U_NOTS_COMPANYID_2);
14364    
14365                            query.append(_FINDER_COLUMN_C_U_NOTS_USERID_2);
14366    
14367                            query.append(_FINDER_COLUMN_C_U_NOTS_STATUS_2);
14368    
14369                            if (orderByComparator != null) {
14370                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
14371                                            orderByComparator);
14372                            }
14373                            else
14374                             if (pagination) {
14375                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
14376                            }
14377    
14378                            String sql = query.toString();
14379    
14380                            Session session = null;
14381    
14382                            try {
14383                                    session = openSession();
14384    
14385                                    Query q = session.createQuery(sql);
14386    
14387                                    QueryPos qPos = QueryPos.getInstance(q);
14388    
14389                                    qPos.add(companyId);
14390    
14391                                    qPos.add(userId);
14392    
14393                                    qPos.add(status);
14394    
14395                                    if (!pagination) {
14396                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
14397                                                            start, end, false);
14398    
14399                                            Collections.sort(list);
14400    
14401                                            list = Collections.unmodifiableList(list);
14402                                    }
14403                                    else {
14404                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
14405                                                            start, end);
14406                                    }
14407    
14408                                    cacheResult(list);
14409    
14410                                    finderCache.putResult(finderPath, finderArgs, list);
14411                            }
14412                            catch (Exception e) {
14413                                    finderCache.removeResult(finderPath, finderArgs);
14414    
14415                                    throw processException(e);
14416                            }
14417                            finally {
14418                                    closeSession(session);
14419                            }
14420                    }
14421    
14422                    return list;
14423            }
14424    
14425            /**
14426             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status &ne; &#63;.
14427             *
14428             * @param companyId the company ID
14429             * @param userId the user ID
14430             * @param status the status
14431             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14432             * @return the first matching blogs entry
14433             * @throws NoSuchEntryException if a matching blogs entry could not be found
14434             */
14435            @Override
14436            public BlogsEntry findByC_U_NotS_First(long companyId, long userId,
14437                    int status, OrderByComparator<BlogsEntry> orderByComparator)
14438                    throws NoSuchEntryException {
14439                    BlogsEntry blogsEntry = fetchByC_U_NotS_First(companyId, userId,
14440                                    status, orderByComparator);
14441    
14442                    if (blogsEntry != null) {
14443                            return blogsEntry;
14444                    }
14445    
14446                    StringBundler msg = new StringBundler(8);
14447    
14448                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
14449    
14450                    msg.append("companyId=");
14451                    msg.append(companyId);
14452    
14453                    msg.append(", userId=");
14454                    msg.append(userId);
14455    
14456                    msg.append(", status=");
14457                    msg.append(status);
14458    
14459                    msg.append(StringPool.CLOSE_CURLY_BRACE);
14460    
14461                    throw new NoSuchEntryException(msg.toString());
14462            }
14463    
14464            /**
14465             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status &ne; &#63;.
14466             *
14467             * @param companyId the company ID
14468             * @param userId the user ID
14469             * @param status the status
14470             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14471             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
14472             */
14473            @Override
14474            public BlogsEntry fetchByC_U_NotS_First(long companyId, long userId,
14475                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
14476                    List<BlogsEntry> list = findByC_U_NotS(companyId, userId, status, 0, 1,
14477                                    orderByComparator);
14478    
14479                    if (!list.isEmpty()) {
14480                            return list.get(0);
14481                    }
14482    
14483                    return null;
14484            }
14485    
14486            /**
14487             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status &ne; &#63;.
14488             *
14489             * @param companyId the company ID
14490             * @param userId the user ID
14491             * @param status the status
14492             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14493             * @return the last matching blogs entry
14494             * @throws NoSuchEntryException if a matching blogs entry could not be found
14495             */
14496            @Override
14497            public BlogsEntry findByC_U_NotS_Last(long companyId, long userId,
14498                    int status, OrderByComparator<BlogsEntry> orderByComparator)
14499                    throws NoSuchEntryException {
14500                    BlogsEntry blogsEntry = fetchByC_U_NotS_Last(companyId, userId, status,
14501                                    orderByComparator);
14502    
14503                    if (blogsEntry != null) {
14504                            return blogsEntry;
14505                    }
14506    
14507                    StringBundler msg = new StringBundler(8);
14508    
14509                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
14510    
14511                    msg.append("companyId=");
14512                    msg.append(companyId);
14513    
14514                    msg.append(", userId=");
14515                    msg.append(userId);
14516    
14517                    msg.append(", status=");
14518                    msg.append(status);
14519    
14520                    msg.append(StringPool.CLOSE_CURLY_BRACE);
14521    
14522                    throw new NoSuchEntryException(msg.toString());
14523            }
14524    
14525            /**
14526             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status &ne; &#63;.
14527             *
14528             * @param companyId the company ID
14529             * @param userId the user ID
14530             * @param status the status
14531             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14532             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
14533             */
14534            @Override
14535            public BlogsEntry fetchByC_U_NotS_Last(long companyId, long userId,
14536                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
14537                    int count = countByC_U_NotS(companyId, userId, status);
14538    
14539                    if (count == 0) {
14540                            return null;
14541                    }
14542    
14543                    List<BlogsEntry> list = findByC_U_NotS(companyId, userId, status,
14544                                    count - 1, count, orderByComparator);
14545    
14546                    if (!list.isEmpty()) {
14547                            return list.get(0);
14548                    }
14549    
14550                    return null;
14551            }
14552    
14553            /**
14554             * 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;.
14555             *
14556             * @param entryId the primary key of the current blogs entry
14557             * @param companyId the company ID
14558             * @param userId the user ID
14559             * @param status the status
14560             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14561             * @return the previous, current, and next blogs entry
14562             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
14563             */
14564            @Override
14565            public BlogsEntry[] findByC_U_NotS_PrevAndNext(long entryId,
14566                    long companyId, long userId, int status,
14567                    OrderByComparator<BlogsEntry> orderByComparator)
14568                    throws NoSuchEntryException {
14569                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
14570    
14571                    Session session = null;
14572    
14573                    try {
14574                            session = openSession();
14575    
14576                            BlogsEntry[] array = new BlogsEntryImpl[3];
14577    
14578                            array[0] = getByC_U_NotS_PrevAndNext(session, blogsEntry,
14579                                            companyId, userId, status, orderByComparator, true);
14580    
14581                            array[1] = blogsEntry;
14582    
14583                            array[2] = getByC_U_NotS_PrevAndNext(session, blogsEntry,
14584                                            companyId, userId, status, orderByComparator, false);
14585    
14586                            return array;
14587                    }
14588                    catch (Exception e) {
14589                            throw processException(e);
14590                    }
14591                    finally {
14592                            closeSession(session);
14593                    }
14594            }
14595    
14596            protected BlogsEntry getByC_U_NotS_PrevAndNext(Session session,
14597                    BlogsEntry blogsEntry, long companyId, long userId, int status,
14598                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
14599                    StringBundler query = null;
14600    
14601                    if (orderByComparator != null) {
14602                            query = new StringBundler(6 +
14603                                            (orderByComparator.getOrderByFields().length * 6));
14604                    }
14605                    else {
14606                            query = new StringBundler(3);
14607                    }
14608    
14609                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
14610    
14611                    query.append(_FINDER_COLUMN_C_U_NOTS_COMPANYID_2);
14612    
14613                    query.append(_FINDER_COLUMN_C_U_NOTS_USERID_2);
14614    
14615                    query.append(_FINDER_COLUMN_C_U_NOTS_STATUS_2);
14616    
14617                    if (orderByComparator != null) {
14618                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
14619    
14620                            if (orderByConditionFields.length > 0) {
14621                                    query.append(WHERE_AND);
14622                            }
14623    
14624                            for (int i = 0; i < orderByConditionFields.length; i++) {
14625                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14626                                    query.append(orderByConditionFields[i]);
14627    
14628                                    if ((i + 1) < orderByConditionFields.length) {
14629                                            if (orderByComparator.isAscending() ^ previous) {
14630                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
14631                                            }
14632                                            else {
14633                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
14634                                            }
14635                                    }
14636                                    else {
14637                                            if (orderByComparator.isAscending() ^ previous) {
14638                                                    query.append(WHERE_GREATER_THAN);
14639                                            }
14640                                            else {
14641                                                    query.append(WHERE_LESSER_THAN);
14642                                            }
14643                                    }
14644                            }
14645    
14646                            query.append(ORDER_BY_CLAUSE);
14647    
14648                            String[] orderByFields = orderByComparator.getOrderByFields();
14649    
14650                            for (int i = 0; i < orderByFields.length; i++) {
14651                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14652                                    query.append(orderByFields[i]);
14653    
14654                                    if ((i + 1) < orderByFields.length) {
14655                                            if (orderByComparator.isAscending() ^ previous) {
14656                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
14657                                            }
14658                                            else {
14659                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
14660                                            }
14661                                    }
14662                                    else {
14663                                            if (orderByComparator.isAscending() ^ previous) {
14664                                                    query.append(ORDER_BY_ASC);
14665                                            }
14666                                            else {
14667                                                    query.append(ORDER_BY_DESC);
14668                                            }
14669                                    }
14670                            }
14671                    }
14672                    else {
14673                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
14674                    }
14675    
14676                    String sql = query.toString();
14677    
14678                    Query q = session.createQuery(sql);
14679    
14680                    q.setFirstResult(0);
14681                    q.setMaxResults(2);
14682    
14683                    QueryPos qPos = QueryPos.getInstance(q);
14684    
14685                    qPos.add(companyId);
14686    
14687                    qPos.add(userId);
14688    
14689                    qPos.add(status);
14690    
14691                    if (orderByComparator != null) {
14692                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
14693    
14694                            for (Object value : values) {
14695                                    qPos.add(value);
14696                            }
14697                    }
14698    
14699                    List<BlogsEntry> list = q.list();
14700    
14701                    if (list.size() == 2) {
14702                            return list.get(1);
14703                    }
14704                    else {
14705                            return null;
14706                    }
14707            }
14708    
14709            /**
14710             * Removes all the blogs entries where companyId = &#63; and userId = &#63; and status &ne; &#63; from the database.
14711             *
14712             * @param companyId the company ID
14713             * @param userId the user ID
14714             * @param status the status
14715             */
14716            @Override
14717            public void removeByC_U_NotS(long companyId, long userId, int status) {
14718                    for (BlogsEntry blogsEntry : findByC_U_NotS(companyId, userId, status,
14719                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
14720                            remove(blogsEntry);
14721                    }
14722            }
14723    
14724            /**
14725             * Returns the number of blogs entries where companyId = &#63; and userId = &#63; and status &ne; &#63;.
14726             *
14727             * @param companyId the company ID
14728             * @param userId the user ID
14729             * @param status the status
14730             * @return the number of matching blogs entries
14731             */
14732            @Override
14733            public int countByC_U_NotS(long companyId, long userId, int status) {
14734                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_U_NOTS;
14735    
14736                    Object[] finderArgs = new Object[] { companyId, userId, status };
14737    
14738                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
14739    
14740                    if (count == null) {
14741                            StringBundler query = new StringBundler(4);
14742    
14743                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
14744    
14745                            query.append(_FINDER_COLUMN_C_U_NOTS_COMPANYID_2);
14746    
14747                            query.append(_FINDER_COLUMN_C_U_NOTS_USERID_2);
14748    
14749                            query.append(_FINDER_COLUMN_C_U_NOTS_STATUS_2);
14750    
14751                            String sql = query.toString();
14752    
14753                            Session session = null;
14754    
14755                            try {
14756                                    session = openSession();
14757    
14758                                    Query q = session.createQuery(sql);
14759    
14760                                    QueryPos qPos = QueryPos.getInstance(q);
14761    
14762                                    qPos.add(companyId);
14763    
14764                                    qPos.add(userId);
14765    
14766                                    qPos.add(status);
14767    
14768                                    count = (Long)q.uniqueResult();
14769    
14770                                    finderCache.putResult(finderPath, finderArgs, count);
14771                            }
14772                            catch (Exception e) {
14773                                    finderCache.removeResult(finderPath, finderArgs);
14774    
14775                                    throw processException(e);
14776                            }
14777                            finally {
14778                                    closeSession(session);
14779                            }
14780                    }
14781    
14782                    return count.intValue();
14783            }
14784    
14785            private static final String _FINDER_COLUMN_C_U_NOTS_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
14786            private static final String _FINDER_COLUMN_C_U_NOTS_USERID_2 = "blogsEntry.userId = ? AND ";
14787            private static final String _FINDER_COLUMN_C_U_NOTS_STATUS_2 = "blogsEntry.status != ?";
14788            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
14789                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
14790                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_LtD_S",
14791                            new String[] {
14792                                    Long.class.getName(), Date.class.getName(),
14793                                    Integer.class.getName(),
14794                                    
14795                            Integer.class.getName(), Integer.class.getName(),
14796                                    OrderByComparator.class.getName()
14797                            });
14798            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
14799                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
14800                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_LtD_S",
14801                            new String[] {
14802                                    Long.class.getName(), Date.class.getName(),
14803                                    Integer.class.getName()
14804                            });
14805    
14806            /**
14807             * Returns all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
14808             *
14809             * @param companyId the company ID
14810             * @param displayDate the display date
14811             * @param status the status
14812             * @return the matching blogs entries
14813             */
14814            @Override
14815            public List<BlogsEntry> findByC_LtD_S(long companyId, Date displayDate,
14816                    int status) {
14817                    return findByC_LtD_S(companyId, displayDate, status, QueryUtil.ALL_POS,
14818                            QueryUtil.ALL_POS, null);
14819            }
14820    
14821            /**
14822             * Returns a range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
14823             *
14824             * <p>
14825             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
14826             * </p>
14827             *
14828             * @param companyId the company ID
14829             * @param displayDate the display date
14830             * @param status the status
14831             * @param start the lower bound of the range of blogs entries
14832             * @param end the upper bound of the range of blogs entries (not inclusive)
14833             * @return the range of matching blogs entries
14834             */
14835            @Override
14836            public List<BlogsEntry> findByC_LtD_S(long companyId, Date displayDate,
14837                    int status, int start, int end) {
14838                    return findByC_LtD_S(companyId, displayDate, status, start, end, null);
14839            }
14840    
14841            /**
14842             * Returns an ordered range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
14843             *
14844             * <p>
14845             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
14846             * </p>
14847             *
14848             * @param companyId the company ID
14849             * @param displayDate the display date
14850             * @param status the status
14851             * @param start the lower bound of the range of blogs entries
14852             * @param end the upper bound of the range of blogs entries (not inclusive)
14853             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14854             * @return the ordered range of matching blogs entries
14855             */
14856            @Override
14857            public List<BlogsEntry> findByC_LtD_S(long companyId, Date displayDate,
14858                    int status, int start, int end,
14859                    OrderByComparator<BlogsEntry> orderByComparator) {
14860                    return findByC_LtD_S(companyId, displayDate, status, start, end,
14861                            orderByComparator, true);
14862            }
14863    
14864            /**
14865             * Returns an ordered range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
14866             *
14867             * <p>
14868             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
14869             * </p>
14870             *
14871             * @param companyId the company ID
14872             * @param displayDate the display date
14873             * @param status the status
14874             * @param start the lower bound of the range of blogs entries
14875             * @param end the upper bound of the range of blogs entries (not inclusive)
14876             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14877             * @param retrieveFromCache whether to retrieve from the finder cache
14878             * @return the ordered range of matching blogs entries
14879             */
14880            @Override
14881            public List<BlogsEntry> findByC_LtD_S(long companyId, Date displayDate,
14882                    int status, int start, int end,
14883                    OrderByComparator<BlogsEntry> orderByComparator,
14884                    boolean retrieveFromCache) {
14885                    boolean pagination = true;
14886                    FinderPath finderPath = null;
14887                    Object[] finderArgs = null;
14888    
14889                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD_S;
14890                    finderArgs = new Object[] {
14891                                    companyId, displayDate, status,
14892                                    
14893                                    start, end, orderByComparator
14894                            };
14895    
14896                    List<BlogsEntry> list = null;
14897    
14898                    if (retrieveFromCache) {
14899                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
14900                                            finderArgs, this);
14901    
14902                            if ((list != null) && !list.isEmpty()) {
14903                                    for (BlogsEntry blogsEntry : list) {
14904                                            if ((companyId != blogsEntry.getCompanyId()) ||
14905                                                            (displayDate.getTime() <= blogsEntry.getDisplayDate()
14906                                                                                                                                            .getTime()) ||
14907                                                            (status != blogsEntry.getStatus())) {
14908                                                    list = null;
14909    
14910                                                    break;
14911                                            }
14912                                    }
14913                            }
14914                    }
14915    
14916                    if (list == null) {
14917                            StringBundler query = null;
14918    
14919                            if (orderByComparator != null) {
14920                                    query = new StringBundler(5 +
14921                                                    (orderByComparator.getOrderByFields().length * 3));
14922                            }
14923                            else {
14924                                    query = new StringBundler(5);
14925                            }
14926    
14927                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
14928    
14929                            query.append(_FINDER_COLUMN_C_LTD_S_COMPANYID_2);
14930    
14931                            boolean bindDisplayDate = false;
14932    
14933                            if (displayDate == null) {
14934                                    query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_1);
14935                            }
14936                            else {
14937                                    bindDisplayDate = true;
14938    
14939                                    query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_2);
14940                            }
14941    
14942                            query.append(_FINDER_COLUMN_C_LTD_S_STATUS_2);
14943    
14944                            if (orderByComparator != null) {
14945                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
14946                                            orderByComparator);
14947                            }
14948                            else
14949                             if (pagination) {
14950                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
14951                            }
14952    
14953                            String sql = query.toString();
14954    
14955                            Session session = null;
14956    
14957                            try {
14958                                    session = openSession();
14959    
14960                                    Query q = session.createQuery(sql);
14961    
14962                                    QueryPos qPos = QueryPos.getInstance(q);
14963    
14964                                    qPos.add(companyId);
14965    
14966                                    if (bindDisplayDate) {
14967                                            qPos.add(new Timestamp(displayDate.getTime()));
14968                                    }
14969    
14970                                    qPos.add(status);
14971    
14972                                    if (!pagination) {
14973                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
14974                                                            start, end, false);
14975    
14976                                            Collections.sort(list);
14977    
14978                                            list = Collections.unmodifiableList(list);
14979                                    }
14980                                    else {
14981                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
14982                                                            start, end);
14983                                    }
14984    
14985                                    cacheResult(list);
14986    
14987                                    finderCache.putResult(finderPath, finderArgs, list);
14988                            }
14989                            catch (Exception e) {
14990                                    finderCache.removeResult(finderPath, finderArgs);
14991    
14992                                    throw processException(e);
14993                            }
14994                            finally {
14995                                    closeSession(session);
14996                            }
14997                    }
14998    
14999                    return list;
15000            }
15001    
15002            /**
15003             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
15004             *
15005             * @param companyId the company ID
15006             * @param displayDate the display date
15007             * @param status the status
15008             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15009             * @return the first matching blogs entry
15010             * @throws NoSuchEntryException if a matching blogs entry could not be found
15011             */
15012            @Override
15013            public BlogsEntry findByC_LtD_S_First(long companyId, Date displayDate,
15014                    int status, OrderByComparator<BlogsEntry> orderByComparator)
15015                    throws NoSuchEntryException {
15016                    BlogsEntry blogsEntry = fetchByC_LtD_S_First(companyId, displayDate,
15017                                    status, orderByComparator);
15018    
15019                    if (blogsEntry != null) {
15020                            return blogsEntry;
15021                    }
15022    
15023                    StringBundler msg = new StringBundler(8);
15024    
15025                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15026    
15027                    msg.append("companyId=");
15028                    msg.append(companyId);
15029    
15030                    msg.append(", displayDate=");
15031                    msg.append(displayDate);
15032    
15033                    msg.append(", status=");
15034                    msg.append(status);
15035    
15036                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15037    
15038                    throw new NoSuchEntryException(msg.toString());
15039            }
15040    
15041            /**
15042             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
15043             *
15044             * @param companyId the company ID
15045             * @param displayDate the display date
15046             * @param status the status
15047             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15048             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
15049             */
15050            @Override
15051            public BlogsEntry fetchByC_LtD_S_First(long companyId, Date displayDate,
15052                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
15053                    List<BlogsEntry> list = findByC_LtD_S(companyId, displayDate, status,
15054                                    0, 1, orderByComparator);
15055    
15056                    if (!list.isEmpty()) {
15057                            return list.get(0);
15058                    }
15059    
15060                    return null;
15061            }
15062    
15063            /**
15064             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
15065             *
15066             * @param companyId the company ID
15067             * @param displayDate the display date
15068             * @param status the status
15069             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15070             * @return the last matching blogs entry
15071             * @throws NoSuchEntryException if a matching blogs entry could not be found
15072             */
15073            @Override
15074            public BlogsEntry findByC_LtD_S_Last(long companyId, Date displayDate,
15075                    int status, OrderByComparator<BlogsEntry> orderByComparator)
15076                    throws NoSuchEntryException {
15077                    BlogsEntry blogsEntry = fetchByC_LtD_S_Last(companyId, displayDate,
15078                                    status, orderByComparator);
15079    
15080                    if (blogsEntry != null) {
15081                            return blogsEntry;
15082                    }
15083    
15084                    StringBundler msg = new StringBundler(8);
15085    
15086                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15087    
15088                    msg.append("companyId=");
15089                    msg.append(companyId);
15090    
15091                    msg.append(", displayDate=");
15092                    msg.append(displayDate);
15093    
15094                    msg.append(", status=");
15095                    msg.append(status);
15096    
15097                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15098    
15099                    throw new NoSuchEntryException(msg.toString());
15100            }
15101    
15102            /**
15103             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
15104             *
15105             * @param companyId the company ID
15106             * @param displayDate the display date
15107             * @param status the status
15108             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15109             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
15110             */
15111            @Override
15112            public BlogsEntry fetchByC_LtD_S_Last(long companyId, Date displayDate,
15113                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
15114                    int count = countByC_LtD_S(companyId, displayDate, status);
15115    
15116                    if (count == 0) {
15117                            return null;
15118                    }
15119    
15120                    List<BlogsEntry> list = findByC_LtD_S(companyId, displayDate, status,
15121                                    count - 1, count, orderByComparator);
15122    
15123                    if (!list.isEmpty()) {
15124                            return list.get(0);
15125                    }
15126    
15127                    return null;
15128            }
15129    
15130            /**
15131             * 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;.
15132             *
15133             * @param entryId the primary key of the current blogs entry
15134             * @param companyId the company ID
15135             * @param displayDate the display date
15136             * @param status the status
15137             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15138             * @return the previous, current, and next blogs entry
15139             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
15140             */
15141            @Override
15142            public BlogsEntry[] findByC_LtD_S_PrevAndNext(long entryId, long companyId,
15143                    Date displayDate, int status,
15144                    OrderByComparator<BlogsEntry> orderByComparator)
15145                    throws NoSuchEntryException {
15146                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
15147    
15148                    Session session = null;
15149    
15150                    try {
15151                            session = openSession();
15152    
15153                            BlogsEntry[] array = new BlogsEntryImpl[3];
15154    
15155                            array[0] = getByC_LtD_S_PrevAndNext(session, blogsEntry, companyId,
15156                                            displayDate, status, orderByComparator, true);
15157    
15158                            array[1] = blogsEntry;
15159    
15160                            array[2] = getByC_LtD_S_PrevAndNext(session, blogsEntry, companyId,
15161                                            displayDate, status, orderByComparator, false);
15162    
15163                            return array;
15164                    }
15165                    catch (Exception e) {
15166                            throw processException(e);
15167                    }
15168                    finally {
15169                            closeSession(session);
15170                    }
15171            }
15172    
15173            protected BlogsEntry getByC_LtD_S_PrevAndNext(Session session,
15174                    BlogsEntry blogsEntry, long companyId, Date displayDate, int status,
15175                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
15176                    StringBundler query = null;
15177    
15178                    if (orderByComparator != null) {
15179                            query = new StringBundler(6 +
15180                                            (orderByComparator.getOrderByFields().length * 6));
15181                    }
15182                    else {
15183                            query = new StringBundler(3);
15184                    }
15185    
15186                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
15187    
15188                    query.append(_FINDER_COLUMN_C_LTD_S_COMPANYID_2);
15189    
15190                    boolean bindDisplayDate = false;
15191    
15192                    if (displayDate == null) {
15193                            query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_1);
15194                    }
15195                    else {
15196                            bindDisplayDate = true;
15197    
15198                            query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_2);
15199                    }
15200    
15201                    query.append(_FINDER_COLUMN_C_LTD_S_STATUS_2);
15202    
15203                    if (orderByComparator != null) {
15204                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
15205    
15206                            if (orderByConditionFields.length > 0) {
15207                                    query.append(WHERE_AND);
15208                            }
15209    
15210                            for (int i = 0; i < orderByConditionFields.length; i++) {
15211                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15212                                    query.append(orderByConditionFields[i]);
15213    
15214                                    if ((i + 1) < orderByConditionFields.length) {
15215                                            if (orderByComparator.isAscending() ^ previous) {
15216                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
15217                                            }
15218                                            else {
15219                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
15220                                            }
15221                                    }
15222                                    else {
15223                                            if (orderByComparator.isAscending() ^ previous) {
15224                                                    query.append(WHERE_GREATER_THAN);
15225                                            }
15226                                            else {
15227                                                    query.append(WHERE_LESSER_THAN);
15228                                            }
15229                                    }
15230                            }
15231    
15232                            query.append(ORDER_BY_CLAUSE);
15233    
15234                            String[] orderByFields = orderByComparator.getOrderByFields();
15235    
15236                            for (int i = 0; i < orderByFields.length; i++) {
15237                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15238                                    query.append(orderByFields[i]);
15239    
15240                                    if ((i + 1) < orderByFields.length) {
15241                                            if (orderByComparator.isAscending() ^ previous) {
15242                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
15243                                            }
15244                                            else {
15245                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
15246                                            }
15247                                    }
15248                                    else {
15249                                            if (orderByComparator.isAscending() ^ previous) {
15250                                                    query.append(ORDER_BY_ASC);
15251                                            }
15252                                            else {
15253                                                    query.append(ORDER_BY_DESC);
15254                                            }
15255                                    }
15256                            }
15257                    }
15258                    else {
15259                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
15260                    }
15261    
15262                    String sql = query.toString();
15263    
15264                    Query q = session.createQuery(sql);
15265    
15266                    q.setFirstResult(0);
15267                    q.setMaxResults(2);
15268    
15269                    QueryPos qPos = QueryPos.getInstance(q);
15270    
15271                    qPos.add(companyId);
15272    
15273                    if (bindDisplayDate) {
15274                            qPos.add(new Timestamp(displayDate.getTime()));
15275                    }
15276    
15277                    qPos.add(status);
15278    
15279                    if (orderByComparator != null) {
15280                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
15281    
15282                            for (Object value : values) {
15283                                    qPos.add(value);
15284                            }
15285                    }
15286    
15287                    List<BlogsEntry> list = q.list();
15288    
15289                    if (list.size() == 2) {
15290                            return list.get(1);
15291                    }
15292                    else {
15293                            return null;
15294                    }
15295            }
15296    
15297            /**
15298             * Removes all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63; from the database.
15299             *
15300             * @param companyId the company ID
15301             * @param displayDate the display date
15302             * @param status the status
15303             */
15304            @Override
15305            public void removeByC_LtD_S(long companyId, Date displayDate, int status) {
15306                    for (BlogsEntry blogsEntry : findByC_LtD_S(companyId, displayDate,
15307                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
15308                            remove(blogsEntry);
15309                    }
15310            }
15311    
15312            /**
15313             * Returns the number of blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
15314             *
15315             * @param companyId the company ID
15316             * @param displayDate the display date
15317             * @param status the status
15318             * @return the number of matching blogs entries
15319             */
15320            @Override
15321            public int countByC_LtD_S(long companyId, Date displayDate, int status) {
15322                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD_S;
15323    
15324                    Object[] finderArgs = new Object[] { companyId, displayDate, status };
15325    
15326                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
15327    
15328                    if (count == null) {
15329                            StringBundler query = new StringBundler(4);
15330    
15331                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
15332    
15333                            query.append(_FINDER_COLUMN_C_LTD_S_COMPANYID_2);
15334    
15335                            boolean bindDisplayDate = false;
15336    
15337                            if (displayDate == null) {
15338                                    query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_1);
15339                            }
15340                            else {
15341                                    bindDisplayDate = true;
15342    
15343                                    query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_2);
15344                            }
15345    
15346                            query.append(_FINDER_COLUMN_C_LTD_S_STATUS_2);
15347    
15348                            String sql = query.toString();
15349    
15350                            Session session = null;
15351    
15352                            try {
15353                                    session = openSession();
15354    
15355                                    Query q = session.createQuery(sql);
15356    
15357                                    QueryPos qPos = QueryPos.getInstance(q);
15358    
15359                                    qPos.add(companyId);
15360    
15361                                    if (bindDisplayDate) {
15362                                            qPos.add(new Timestamp(displayDate.getTime()));
15363                                    }
15364    
15365                                    qPos.add(status);
15366    
15367                                    count = (Long)q.uniqueResult();
15368    
15369                                    finderCache.putResult(finderPath, finderArgs, count);
15370                            }
15371                            catch (Exception e) {
15372                                    finderCache.removeResult(finderPath, finderArgs);
15373    
15374                                    throw processException(e);
15375                            }
15376                            finally {
15377                                    closeSession(session);
15378                            }
15379                    }
15380    
15381                    return count.intValue();
15382            }
15383    
15384            private static final String _FINDER_COLUMN_C_LTD_S_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
15385            private static final String _FINDER_COLUMN_C_LTD_S_DISPLAYDATE_1 = "blogsEntry.displayDate IS NULL AND ";
15386            private static final String _FINDER_COLUMN_C_LTD_S_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
15387            private static final String _FINDER_COLUMN_C_LTD_S_STATUS_2 = "blogsEntry.status = ?";
15388            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD_NOTS =
15389                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
15390                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
15391                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_LtD_NotS",
15392                            new String[] {
15393                                    Long.class.getName(), Date.class.getName(),
15394                                    Integer.class.getName(),
15395                                    
15396                            Integer.class.getName(), Integer.class.getName(),
15397                                    OrderByComparator.class.getName()
15398                            });
15399            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD_NOTS =
15400                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
15401                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
15402                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_LtD_NotS",
15403                            new String[] {
15404                                    Long.class.getName(), Date.class.getName(),
15405                                    Integer.class.getName()
15406                            });
15407    
15408            /**
15409             * Returns all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
15410             *
15411             * @param companyId the company ID
15412             * @param displayDate the display date
15413             * @param status the status
15414             * @return the matching blogs entries
15415             */
15416            @Override
15417            public List<BlogsEntry> findByC_LtD_NotS(long companyId, Date displayDate,
15418                    int status) {
15419                    return findByC_LtD_NotS(companyId, displayDate, status,
15420                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
15421            }
15422    
15423            /**
15424             * Returns a range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
15425             *
15426             * <p>
15427             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
15428             * </p>
15429             *
15430             * @param companyId the company ID
15431             * @param displayDate the display date
15432             * @param status the status
15433             * @param start the lower bound of the range of blogs entries
15434             * @param end the upper bound of the range of blogs entries (not inclusive)
15435             * @return the range of matching blogs entries
15436             */
15437            @Override
15438            public List<BlogsEntry> findByC_LtD_NotS(long companyId, Date displayDate,
15439                    int status, int start, int end) {
15440                    return findByC_LtD_NotS(companyId, displayDate, status, start, end, null);
15441            }
15442    
15443            /**
15444             * Returns an ordered range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
15445             *
15446             * <p>
15447             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
15448             * </p>
15449             *
15450             * @param companyId the company ID
15451             * @param displayDate the display date
15452             * @param status the status
15453             * @param start the lower bound of the range of blogs entries
15454             * @param end the upper bound of the range of blogs entries (not inclusive)
15455             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
15456             * @return the ordered range of matching blogs entries
15457             */
15458            @Override
15459            public List<BlogsEntry> findByC_LtD_NotS(long companyId, Date displayDate,
15460                    int status, int start, int end,
15461                    OrderByComparator<BlogsEntry> orderByComparator) {
15462                    return findByC_LtD_NotS(companyId, displayDate, status, start, end,
15463                            orderByComparator, true);
15464            }
15465    
15466            /**
15467             * Returns an ordered range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
15468             *
15469             * <p>
15470             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
15471             * </p>
15472             *
15473             * @param companyId the company ID
15474             * @param displayDate the display date
15475             * @param status the status
15476             * @param start the lower bound of the range of blogs entries
15477             * @param end the upper bound of the range of blogs entries (not inclusive)
15478             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
15479             * @param retrieveFromCache whether to retrieve from the finder cache
15480             * @return the ordered range of matching blogs entries
15481             */
15482            @Override
15483            public List<BlogsEntry> findByC_LtD_NotS(long companyId, Date displayDate,
15484                    int status, int start, int end,
15485                    OrderByComparator<BlogsEntry> orderByComparator,
15486                    boolean retrieveFromCache) {
15487                    boolean pagination = true;
15488                    FinderPath finderPath = null;
15489                    Object[] finderArgs = null;
15490    
15491                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD_NOTS;
15492                    finderArgs = new Object[] {
15493                                    companyId, displayDate, status,
15494                                    
15495                                    start, end, orderByComparator
15496                            };
15497    
15498                    List<BlogsEntry> list = null;
15499    
15500                    if (retrieveFromCache) {
15501                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
15502                                            finderArgs, this);
15503    
15504                            if ((list != null) && !list.isEmpty()) {
15505                                    for (BlogsEntry blogsEntry : list) {
15506                                            if ((companyId != blogsEntry.getCompanyId()) ||
15507                                                            (displayDate.getTime() <= blogsEntry.getDisplayDate()
15508                                                                                                                                            .getTime()) ||
15509                                                            (status == blogsEntry.getStatus())) {
15510                                                    list = null;
15511    
15512                                                    break;
15513                                            }
15514                                    }
15515                            }
15516                    }
15517    
15518                    if (list == null) {
15519                            StringBundler query = null;
15520    
15521                            if (orderByComparator != null) {
15522                                    query = new StringBundler(5 +
15523                                                    (orderByComparator.getOrderByFields().length * 3));
15524                            }
15525                            else {
15526                                    query = new StringBundler(5);
15527                            }
15528    
15529                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
15530    
15531                            query.append(_FINDER_COLUMN_C_LTD_NOTS_COMPANYID_2);
15532    
15533                            boolean bindDisplayDate = false;
15534    
15535                            if (displayDate == null) {
15536                                    query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_1);
15537                            }
15538                            else {
15539                                    bindDisplayDate = true;
15540    
15541                                    query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_2);
15542                            }
15543    
15544                            query.append(_FINDER_COLUMN_C_LTD_NOTS_STATUS_2);
15545    
15546                            if (orderByComparator != null) {
15547                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
15548                                            orderByComparator);
15549                            }
15550                            else
15551                             if (pagination) {
15552                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
15553                            }
15554    
15555                            String sql = query.toString();
15556    
15557                            Session session = null;
15558    
15559                            try {
15560                                    session = openSession();
15561    
15562                                    Query q = session.createQuery(sql);
15563    
15564                                    QueryPos qPos = QueryPos.getInstance(q);
15565    
15566                                    qPos.add(companyId);
15567    
15568                                    if (bindDisplayDate) {
15569                                            qPos.add(new Timestamp(displayDate.getTime()));
15570                                    }
15571    
15572                                    qPos.add(status);
15573    
15574                                    if (!pagination) {
15575                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
15576                                                            start, end, false);
15577    
15578                                            Collections.sort(list);
15579    
15580                                            list = Collections.unmodifiableList(list);
15581                                    }
15582                                    else {
15583                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
15584                                                            start, end);
15585                                    }
15586    
15587                                    cacheResult(list);
15588    
15589                                    finderCache.putResult(finderPath, finderArgs, list);
15590                            }
15591                            catch (Exception e) {
15592                                    finderCache.removeResult(finderPath, finderArgs);
15593    
15594                                    throw processException(e);
15595                            }
15596                            finally {
15597                                    closeSession(session);
15598                            }
15599                    }
15600    
15601                    return list;
15602            }
15603    
15604            /**
15605             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
15606             *
15607             * @param companyId the company ID
15608             * @param displayDate the display date
15609             * @param status the status
15610             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15611             * @return the first matching blogs entry
15612             * @throws NoSuchEntryException if a matching blogs entry could not be found
15613             */
15614            @Override
15615            public BlogsEntry findByC_LtD_NotS_First(long companyId, Date displayDate,
15616                    int status, OrderByComparator<BlogsEntry> orderByComparator)
15617                    throws NoSuchEntryException {
15618                    BlogsEntry blogsEntry = fetchByC_LtD_NotS_First(companyId, displayDate,
15619                                    status, orderByComparator);
15620    
15621                    if (blogsEntry != null) {
15622                            return blogsEntry;
15623                    }
15624    
15625                    StringBundler msg = new StringBundler(8);
15626    
15627                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15628    
15629                    msg.append("companyId=");
15630                    msg.append(companyId);
15631    
15632                    msg.append(", displayDate=");
15633                    msg.append(displayDate);
15634    
15635                    msg.append(", status=");
15636                    msg.append(status);
15637    
15638                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15639    
15640                    throw new NoSuchEntryException(msg.toString());
15641            }
15642    
15643            /**
15644             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
15645             *
15646             * @param companyId the company ID
15647             * @param displayDate the display date
15648             * @param status the status
15649             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15650             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
15651             */
15652            @Override
15653            public BlogsEntry fetchByC_LtD_NotS_First(long companyId, Date displayDate,
15654                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
15655                    List<BlogsEntry> list = findByC_LtD_NotS(companyId, displayDate,
15656                                    status, 0, 1, orderByComparator);
15657    
15658                    if (!list.isEmpty()) {
15659                            return list.get(0);
15660                    }
15661    
15662                    return null;
15663            }
15664    
15665            /**
15666             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
15667             *
15668             * @param companyId the company ID
15669             * @param displayDate the display date
15670             * @param status the status
15671             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15672             * @return the last matching blogs entry
15673             * @throws NoSuchEntryException if a matching blogs entry could not be found
15674             */
15675            @Override
15676            public BlogsEntry findByC_LtD_NotS_Last(long companyId, Date displayDate,
15677                    int status, OrderByComparator<BlogsEntry> orderByComparator)
15678                    throws NoSuchEntryException {
15679                    BlogsEntry blogsEntry = fetchByC_LtD_NotS_Last(companyId, displayDate,
15680                                    status, orderByComparator);
15681    
15682                    if (blogsEntry != null) {
15683                            return blogsEntry;
15684                    }
15685    
15686                    StringBundler msg = new StringBundler(8);
15687    
15688                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15689    
15690                    msg.append("companyId=");
15691                    msg.append(companyId);
15692    
15693                    msg.append(", displayDate=");
15694                    msg.append(displayDate);
15695    
15696                    msg.append(", status=");
15697                    msg.append(status);
15698    
15699                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15700    
15701                    throw new NoSuchEntryException(msg.toString());
15702            }
15703    
15704            /**
15705             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
15706             *
15707             * @param companyId the company ID
15708             * @param displayDate the display date
15709             * @param status the status
15710             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15711             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
15712             */
15713            @Override
15714            public BlogsEntry fetchByC_LtD_NotS_Last(long companyId, Date displayDate,
15715                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
15716                    int count = countByC_LtD_NotS(companyId, displayDate, status);
15717    
15718                    if (count == 0) {
15719                            return null;
15720                    }
15721    
15722                    List<BlogsEntry> list = findByC_LtD_NotS(companyId, displayDate,
15723                                    status, count - 1, count, orderByComparator);
15724    
15725                    if (!list.isEmpty()) {
15726                            return list.get(0);
15727                    }
15728    
15729                    return null;
15730            }
15731    
15732            /**
15733             * 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;.
15734             *
15735             * @param entryId the primary key of the current blogs entry
15736             * @param companyId the company ID
15737             * @param displayDate the display date
15738             * @param status the status
15739             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15740             * @return the previous, current, and next blogs entry
15741             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
15742             */
15743            @Override
15744            public BlogsEntry[] findByC_LtD_NotS_PrevAndNext(long entryId,
15745                    long companyId, Date displayDate, int status,
15746                    OrderByComparator<BlogsEntry> orderByComparator)
15747                    throws NoSuchEntryException {
15748                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
15749    
15750                    Session session = null;
15751    
15752                    try {
15753                            session = openSession();
15754    
15755                            BlogsEntry[] array = new BlogsEntryImpl[3];
15756    
15757                            array[0] = getByC_LtD_NotS_PrevAndNext(session, blogsEntry,
15758                                            companyId, displayDate, status, orderByComparator, true);
15759    
15760                            array[1] = blogsEntry;
15761    
15762                            array[2] = getByC_LtD_NotS_PrevAndNext(session, blogsEntry,
15763                                            companyId, displayDate, status, orderByComparator, false);
15764    
15765                            return array;
15766                    }
15767                    catch (Exception e) {
15768                            throw processException(e);
15769                    }
15770                    finally {
15771                            closeSession(session);
15772                    }
15773            }
15774    
15775            protected BlogsEntry getByC_LtD_NotS_PrevAndNext(Session session,
15776                    BlogsEntry blogsEntry, long companyId, Date displayDate, int status,
15777                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
15778                    StringBundler query = null;
15779    
15780                    if (orderByComparator != null) {
15781                            query = new StringBundler(6 +
15782                                            (orderByComparator.getOrderByFields().length * 6));
15783                    }
15784                    else {
15785                            query = new StringBundler(3);
15786                    }
15787    
15788                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
15789    
15790                    query.append(_FINDER_COLUMN_C_LTD_NOTS_COMPANYID_2);
15791    
15792                    boolean bindDisplayDate = false;
15793    
15794                    if (displayDate == null) {
15795                            query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_1);
15796                    }
15797                    else {
15798                            bindDisplayDate = true;
15799    
15800                            query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_2);
15801                    }
15802    
15803                    query.append(_FINDER_COLUMN_C_LTD_NOTS_STATUS_2);
15804    
15805                    if (orderByComparator != null) {
15806                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
15807    
15808                            if (orderByConditionFields.length > 0) {
15809                                    query.append(WHERE_AND);
15810                            }
15811    
15812                            for (int i = 0; i < orderByConditionFields.length; i++) {
15813                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15814                                    query.append(orderByConditionFields[i]);
15815    
15816                                    if ((i + 1) < orderByConditionFields.length) {
15817                                            if (orderByComparator.isAscending() ^ previous) {
15818                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
15819                                            }
15820                                            else {
15821                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
15822                                            }
15823                                    }
15824                                    else {
15825                                            if (orderByComparator.isAscending() ^ previous) {
15826                                                    query.append(WHERE_GREATER_THAN);
15827                                            }
15828                                            else {
15829                                                    query.append(WHERE_LESSER_THAN);
15830                                            }
15831                                    }
15832                            }
15833    
15834                            query.append(ORDER_BY_CLAUSE);
15835    
15836                            String[] orderByFields = orderByComparator.getOrderByFields();
15837    
15838                            for (int i = 0; i < orderByFields.length; i++) {
15839                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15840                                    query.append(orderByFields[i]);
15841    
15842                                    if ((i + 1) < orderByFields.length) {
15843                                            if (orderByComparator.isAscending() ^ previous) {
15844                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
15845                                            }
15846                                            else {
15847                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
15848                                            }
15849                                    }
15850                                    else {
15851                                            if (orderByComparator.isAscending() ^ previous) {
15852                                                    query.append(ORDER_BY_ASC);
15853                                            }
15854                                            else {
15855                                                    query.append(ORDER_BY_DESC);
15856                                            }
15857                                    }
15858                            }
15859                    }
15860                    else {
15861                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
15862                    }
15863    
15864                    String sql = query.toString();
15865    
15866                    Query q = session.createQuery(sql);
15867    
15868                    q.setFirstResult(0);
15869                    q.setMaxResults(2);
15870    
15871                    QueryPos qPos = QueryPos.getInstance(q);
15872    
15873                    qPos.add(companyId);
15874    
15875                    if (bindDisplayDate) {
15876                            qPos.add(new Timestamp(displayDate.getTime()));
15877                    }
15878    
15879                    qPos.add(status);
15880    
15881                    if (orderByComparator != null) {
15882                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
15883    
15884                            for (Object value : values) {
15885                                    qPos.add(value);
15886                            }
15887                    }
15888    
15889                    List<BlogsEntry> list = q.list();
15890    
15891                    if (list.size() == 2) {
15892                            return list.get(1);
15893                    }
15894                    else {
15895                            return null;
15896                    }
15897            }
15898    
15899            /**
15900             * Removes all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63; from the database.
15901             *
15902             * @param companyId the company ID
15903             * @param displayDate the display date
15904             * @param status the status
15905             */
15906            @Override
15907            public void removeByC_LtD_NotS(long companyId, Date displayDate, int status) {
15908                    for (BlogsEntry blogsEntry : findByC_LtD_NotS(companyId, displayDate,
15909                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
15910                            remove(blogsEntry);
15911                    }
15912            }
15913    
15914            /**
15915             * Returns the number of blogs entries where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
15916             *
15917             * @param companyId the company ID
15918             * @param displayDate the display date
15919             * @param status the status
15920             * @return the number of matching blogs entries
15921             */
15922            @Override
15923            public int countByC_LtD_NotS(long companyId, Date displayDate, int status) {
15924                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD_NOTS;
15925    
15926                    Object[] finderArgs = new Object[] { companyId, displayDate, status };
15927    
15928                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
15929    
15930                    if (count == null) {
15931                            StringBundler query = new StringBundler(4);
15932    
15933                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
15934    
15935                            query.append(_FINDER_COLUMN_C_LTD_NOTS_COMPANYID_2);
15936    
15937                            boolean bindDisplayDate = false;
15938    
15939                            if (displayDate == null) {
15940                                    query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_1);
15941                            }
15942                            else {
15943                                    bindDisplayDate = true;
15944    
15945                                    query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_2);
15946                            }
15947    
15948                            query.append(_FINDER_COLUMN_C_LTD_NOTS_STATUS_2);
15949    
15950                            String sql = query.toString();
15951    
15952                            Session session = null;
15953    
15954                            try {
15955                                    session = openSession();
15956    
15957                                    Query q = session.createQuery(sql);
15958    
15959                                    QueryPos qPos = QueryPos.getInstance(q);
15960    
15961                                    qPos.add(companyId);
15962    
15963                                    if (bindDisplayDate) {
15964                                            qPos.add(new Timestamp(displayDate.getTime()));
15965                                    }
15966    
15967                                    qPos.add(status);
15968    
15969                                    count = (Long)q.uniqueResult();
15970    
15971                                    finderCache.putResult(finderPath, finderArgs, count);
15972                            }
15973                            catch (Exception e) {
15974                                    finderCache.removeResult(finderPath, finderArgs);
15975    
15976                                    throw processException(e);
15977                            }
15978                            finally {
15979                                    closeSession(session);
15980                            }
15981                    }
15982    
15983                    return count.intValue();
15984            }
15985    
15986            private static final String _FINDER_COLUMN_C_LTD_NOTS_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
15987            private static final String _FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_1 = "blogsEntry.displayDate IS NULL AND ";
15988            private static final String _FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
15989            private static final String _FINDER_COLUMN_C_LTD_NOTS_STATUS_2 = "blogsEntry.status != ?";
15990            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD_S =
15991                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
15992                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
15993                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_LtD_S",
15994                            new String[] {
15995                                    Long.class.getName(), Long.class.getName(), Date.class.getName(),
15996                                    Integer.class.getName(),
15997                                    
15998                            Integer.class.getName(), Integer.class.getName(),
15999                                    OrderByComparator.class.getName()
16000                            });
16001            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD_S =
16002                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
16003                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
16004                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_U_LtD_S",
16005                            new String[] {
16006                                    Long.class.getName(), Long.class.getName(), Date.class.getName(),
16007                                    Integer.class.getName()
16008                            });
16009    
16010            /**
16011             * Returns all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16012             *
16013             * @param groupId the group ID
16014             * @param userId the user ID
16015             * @param displayDate the display date
16016             * @param status the status
16017             * @return the matching blogs entries
16018             */
16019            @Override
16020            public List<BlogsEntry> findByG_U_LtD_S(long groupId, long userId,
16021                    Date displayDate, int status) {
16022                    return findByG_U_LtD_S(groupId, userId, displayDate, status,
16023                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
16024            }
16025    
16026            /**
16027             * Returns a range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16028             *
16029             * <p>
16030             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
16031             * </p>
16032             *
16033             * @param groupId the group ID
16034             * @param userId the user ID
16035             * @param displayDate the display date
16036             * @param status the status
16037             * @param start the lower bound of the range of blogs entries
16038             * @param end the upper bound of the range of blogs entries (not inclusive)
16039             * @return the range of matching blogs entries
16040             */
16041            @Override
16042            public List<BlogsEntry> findByG_U_LtD_S(long groupId, long userId,
16043                    Date displayDate, int status, int start, int end) {
16044                    return findByG_U_LtD_S(groupId, userId, displayDate, status, start,
16045                            end, null);
16046            }
16047    
16048            /**
16049             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16050             *
16051             * <p>
16052             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
16053             * </p>
16054             *
16055             * @param groupId the group ID
16056             * @param userId the user ID
16057             * @param displayDate the display date
16058             * @param status the status
16059             * @param start the lower bound of the range of blogs entries
16060             * @param end the upper bound of the range of blogs entries (not inclusive)
16061             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
16062             * @return the ordered range of matching blogs entries
16063             */
16064            @Override
16065            public List<BlogsEntry> findByG_U_LtD_S(long groupId, long userId,
16066                    Date displayDate, int status, int start, int end,
16067                    OrderByComparator<BlogsEntry> orderByComparator) {
16068                    return findByG_U_LtD_S(groupId, userId, displayDate, status, start,
16069                            end, orderByComparator, true);
16070            }
16071    
16072            /**
16073             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16074             *
16075             * <p>
16076             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
16077             * </p>
16078             *
16079             * @param groupId the group ID
16080             * @param userId the user ID
16081             * @param displayDate the display date
16082             * @param status the status
16083             * @param start the lower bound of the range of blogs entries
16084             * @param end the upper bound of the range of blogs entries (not inclusive)
16085             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
16086             * @param retrieveFromCache whether to retrieve from the finder cache
16087             * @return the ordered range of matching blogs entries
16088             */
16089            @Override
16090            public List<BlogsEntry> findByG_U_LtD_S(long groupId, long userId,
16091                    Date displayDate, int status, int start, int end,
16092                    OrderByComparator<BlogsEntry> orderByComparator,
16093                    boolean retrieveFromCache) {
16094                    boolean pagination = true;
16095                    FinderPath finderPath = null;
16096                    Object[] finderArgs = null;
16097    
16098                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD_S;
16099                    finderArgs = new Object[] {
16100                                    groupId, userId, displayDate, status,
16101                                    
16102                                    start, end, orderByComparator
16103                            };
16104    
16105                    List<BlogsEntry> list = null;
16106    
16107                    if (retrieveFromCache) {
16108                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
16109                                            finderArgs, this);
16110    
16111                            if ((list != null) && !list.isEmpty()) {
16112                                    for (BlogsEntry blogsEntry : list) {
16113                                            if ((groupId != blogsEntry.getGroupId()) ||
16114                                                            (userId != blogsEntry.getUserId()) ||
16115                                                            (displayDate.getTime() <= blogsEntry.getDisplayDate()
16116                                                                                                                                            .getTime()) ||
16117                                                            (status != blogsEntry.getStatus())) {
16118                                                    list = null;
16119    
16120                                                    break;
16121                                            }
16122                                    }
16123                            }
16124                    }
16125    
16126                    if (list == null) {
16127                            StringBundler query = null;
16128    
16129                            if (orderByComparator != null) {
16130                                    query = new StringBundler(6 +
16131                                                    (orderByComparator.getOrderByFields().length * 3));
16132                            }
16133                            else {
16134                                    query = new StringBundler(6);
16135                            }
16136    
16137                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
16138    
16139                            query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
16140    
16141                            query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
16142    
16143                            boolean bindDisplayDate = false;
16144    
16145                            if (displayDate == null) {
16146                                    query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
16147                            }
16148                            else {
16149                                    bindDisplayDate = true;
16150    
16151                                    query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
16152                            }
16153    
16154                            query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
16155    
16156                            if (orderByComparator != null) {
16157                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
16158                                            orderByComparator);
16159                            }
16160                            else
16161                             if (pagination) {
16162                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
16163                            }
16164    
16165                            String sql = query.toString();
16166    
16167                            Session session = null;
16168    
16169                            try {
16170                                    session = openSession();
16171    
16172                                    Query q = session.createQuery(sql);
16173    
16174                                    QueryPos qPos = QueryPos.getInstance(q);
16175    
16176                                    qPos.add(groupId);
16177    
16178                                    qPos.add(userId);
16179    
16180                                    if (bindDisplayDate) {
16181                                            qPos.add(new Timestamp(displayDate.getTime()));
16182                                    }
16183    
16184                                    qPos.add(status);
16185    
16186                                    if (!pagination) {
16187                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
16188                                                            start, end, false);
16189    
16190                                            Collections.sort(list);
16191    
16192                                            list = Collections.unmodifiableList(list);
16193                                    }
16194                                    else {
16195                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
16196                                                            start, end);
16197                                    }
16198    
16199                                    cacheResult(list);
16200    
16201                                    finderCache.putResult(finderPath, finderArgs, list);
16202                            }
16203                            catch (Exception e) {
16204                                    finderCache.removeResult(finderPath, finderArgs);
16205    
16206                                    throw processException(e);
16207                            }
16208                            finally {
16209                                    closeSession(session);
16210                            }
16211                    }
16212    
16213                    return list;
16214            }
16215    
16216            /**
16217             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16218             *
16219             * @param groupId the group ID
16220             * @param userId the user ID
16221             * @param displayDate the display date
16222             * @param status the status
16223             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16224             * @return the first matching blogs entry
16225             * @throws NoSuchEntryException if a matching blogs entry could not be found
16226             */
16227            @Override
16228            public BlogsEntry findByG_U_LtD_S_First(long groupId, long userId,
16229                    Date displayDate, int status,
16230                    OrderByComparator<BlogsEntry> orderByComparator)
16231                    throws NoSuchEntryException {
16232                    BlogsEntry blogsEntry = fetchByG_U_LtD_S_First(groupId, userId,
16233                                    displayDate, status, orderByComparator);
16234    
16235                    if (blogsEntry != null) {
16236                            return blogsEntry;
16237                    }
16238    
16239                    StringBundler msg = new StringBundler(10);
16240    
16241                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
16242    
16243                    msg.append("groupId=");
16244                    msg.append(groupId);
16245    
16246                    msg.append(", userId=");
16247                    msg.append(userId);
16248    
16249                    msg.append(", displayDate=");
16250                    msg.append(displayDate);
16251    
16252                    msg.append(", status=");
16253                    msg.append(status);
16254    
16255                    msg.append(StringPool.CLOSE_CURLY_BRACE);
16256    
16257                    throw new NoSuchEntryException(msg.toString());
16258            }
16259    
16260            /**
16261             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16262             *
16263             * @param groupId the group ID
16264             * @param userId the user ID
16265             * @param displayDate the display date
16266             * @param status the status
16267             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16268             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
16269             */
16270            @Override
16271            public BlogsEntry fetchByG_U_LtD_S_First(long groupId, long userId,
16272                    Date displayDate, int status,
16273                    OrderByComparator<BlogsEntry> orderByComparator) {
16274                    List<BlogsEntry> list = findByG_U_LtD_S(groupId, userId, displayDate,
16275                                    status, 0, 1, orderByComparator);
16276    
16277                    if (!list.isEmpty()) {
16278                            return list.get(0);
16279                    }
16280    
16281                    return null;
16282            }
16283    
16284            /**
16285             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16286             *
16287             * @param groupId the group ID
16288             * @param userId the user ID
16289             * @param displayDate the display date
16290             * @param status the status
16291             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16292             * @return the last matching blogs entry
16293             * @throws NoSuchEntryException if a matching blogs entry could not be found
16294             */
16295            @Override
16296            public BlogsEntry findByG_U_LtD_S_Last(long groupId, long userId,
16297                    Date displayDate, int status,
16298                    OrderByComparator<BlogsEntry> orderByComparator)
16299                    throws NoSuchEntryException {
16300                    BlogsEntry blogsEntry = fetchByG_U_LtD_S_Last(groupId, userId,
16301                                    displayDate, status, orderByComparator);
16302    
16303                    if (blogsEntry != null) {
16304                            return blogsEntry;
16305                    }
16306    
16307                    StringBundler msg = new StringBundler(10);
16308    
16309                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
16310    
16311                    msg.append("groupId=");
16312                    msg.append(groupId);
16313    
16314                    msg.append(", userId=");
16315                    msg.append(userId);
16316    
16317                    msg.append(", displayDate=");
16318                    msg.append(displayDate);
16319    
16320                    msg.append(", status=");
16321                    msg.append(status);
16322    
16323                    msg.append(StringPool.CLOSE_CURLY_BRACE);
16324    
16325                    throw new NoSuchEntryException(msg.toString());
16326            }
16327    
16328            /**
16329             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16330             *
16331             * @param groupId the group ID
16332             * @param userId the user ID
16333             * @param displayDate the display date
16334             * @param status the status
16335             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16336             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
16337             */
16338            @Override
16339            public BlogsEntry fetchByG_U_LtD_S_Last(long groupId, long userId,
16340                    Date displayDate, int status,
16341                    OrderByComparator<BlogsEntry> orderByComparator) {
16342                    int count = countByG_U_LtD_S(groupId, userId, displayDate, status);
16343    
16344                    if (count == 0) {
16345                            return null;
16346                    }
16347    
16348                    List<BlogsEntry> list = findByG_U_LtD_S(groupId, userId, displayDate,
16349                                    status, count - 1, count, orderByComparator);
16350    
16351                    if (!list.isEmpty()) {
16352                            return list.get(0);
16353                    }
16354    
16355                    return null;
16356            }
16357    
16358            /**
16359             * 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;.
16360             *
16361             * @param entryId the primary key of the current blogs entry
16362             * @param groupId the group ID
16363             * @param userId the user ID
16364             * @param displayDate the display date
16365             * @param status the status
16366             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16367             * @return the previous, current, and next blogs entry
16368             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
16369             */
16370            @Override
16371            public BlogsEntry[] findByG_U_LtD_S_PrevAndNext(long entryId, long groupId,
16372                    long userId, Date displayDate, int status,
16373                    OrderByComparator<BlogsEntry> orderByComparator)
16374                    throws NoSuchEntryException {
16375                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
16376    
16377                    Session session = null;
16378    
16379                    try {
16380                            session = openSession();
16381    
16382                            BlogsEntry[] array = new BlogsEntryImpl[3];
16383    
16384                            array[0] = getByG_U_LtD_S_PrevAndNext(session, blogsEntry, groupId,
16385                                            userId, displayDate, status, orderByComparator, true);
16386    
16387                            array[1] = blogsEntry;
16388    
16389                            array[2] = getByG_U_LtD_S_PrevAndNext(session, blogsEntry, groupId,
16390                                            userId, displayDate, status, orderByComparator, false);
16391    
16392                            return array;
16393                    }
16394                    catch (Exception e) {
16395                            throw processException(e);
16396                    }
16397                    finally {
16398                            closeSession(session);
16399                    }
16400            }
16401    
16402            protected BlogsEntry getByG_U_LtD_S_PrevAndNext(Session session,
16403                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
16404                    int status, OrderByComparator<BlogsEntry> orderByComparator,
16405                    boolean previous) {
16406                    StringBundler query = null;
16407    
16408                    if (orderByComparator != null) {
16409                            query = new StringBundler(6 +
16410                                            (orderByComparator.getOrderByFields().length * 6));
16411                    }
16412                    else {
16413                            query = new StringBundler(3);
16414                    }
16415    
16416                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
16417    
16418                    query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
16419    
16420                    query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
16421    
16422                    boolean bindDisplayDate = false;
16423    
16424                    if (displayDate == null) {
16425                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
16426                    }
16427                    else {
16428                            bindDisplayDate = true;
16429    
16430                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
16431                    }
16432    
16433                    query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
16434    
16435                    if (orderByComparator != null) {
16436                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
16437    
16438                            if (orderByConditionFields.length > 0) {
16439                                    query.append(WHERE_AND);
16440                            }
16441    
16442                            for (int i = 0; i < orderByConditionFields.length; i++) {
16443                                    query.append(_ORDER_BY_ENTITY_ALIAS);
16444                                    query.append(orderByConditionFields[i]);
16445    
16446                                    if ((i + 1) < orderByConditionFields.length) {
16447                                            if (orderByComparator.isAscending() ^ previous) {
16448                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
16449                                            }
16450                                            else {
16451                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
16452                                            }
16453                                    }
16454                                    else {
16455                                            if (orderByComparator.isAscending() ^ previous) {
16456                                                    query.append(WHERE_GREATER_THAN);
16457                                            }
16458                                            else {
16459                                                    query.append(WHERE_LESSER_THAN);
16460                                            }
16461                                    }
16462                            }
16463    
16464                            query.append(ORDER_BY_CLAUSE);
16465    
16466                            String[] orderByFields = orderByComparator.getOrderByFields();
16467    
16468                            for (int i = 0; i < orderByFields.length; i++) {
16469                                    query.append(_ORDER_BY_ENTITY_ALIAS);
16470                                    query.append(orderByFields[i]);
16471    
16472                                    if ((i + 1) < orderByFields.length) {
16473                                            if (orderByComparator.isAscending() ^ previous) {
16474                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
16475                                            }
16476                                            else {
16477                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
16478                                            }
16479                                    }
16480                                    else {
16481                                            if (orderByComparator.isAscending() ^ previous) {
16482                                                    query.append(ORDER_BY_ASC);
16483                                            }
16484                                            else {
16485                                                    query.append(ORDER_BY_DESC);
16486                                            }
16487                                    }
16488                            }
16489                    }
16490                    else {
16491                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
16492                    }
16493    
16494                    String sql = query.toString();
16495    
16496                    Query q = session.createQuery(sql);
16497    
16498                    q.setFirstResult(0);
16499                    q.setMaxResults(2);
16500    
16501                    QueryPos qPos = QueryPos.getInstance(q);
16502    
16503                    qPos.add(groupId);
16504    
16505                    qPos.add(userId);
16506    
16507                    if (bindDisplayDate) {
16508                            qPos.add(new Timestamp(displayDate.getTime()));
16509                    }
16510    
16511                    qPos.add(status);
16512    
16513                    if (orderByComparator != null) {
16514                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
16515    
16516                            for (Object value : values) {
16517                                    qPos.add(value);
16518                            }
16519                    }
16520    
16521                    List<BlogsEntry> list = q.list();
16522    
16523                    if (list.size() == 2) {
16524                            return list.get(1);
16525                    }
16526                    else {
16527                            return null;
16528                    }
16529            }
16530    
16531            /**
16532             * 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;.
16533             *
16534             * @param groupId the group ID
16535             * @param userId the user ID
16536             * @param displayDate the display date
16537             * @param status the status
16538             * @return the matching blogs entries that the user has permission to view
16539             */
16540            @Override
16541            public List<BlogsEntry> filterFindByG_U_LtD_S(long groupId, long userId,
16542                    Date displayDate, int status) {
16543                    return filterFindByG_U_LtD_S(groupId, userId, displayDate, status,
16544                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
16545            }
16546    
16547            /**
16548             * 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;.
16549             *
16550             * <p>
16551             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
16552             * </p>
16553             *
16554             * @param groupId the group ID
16555             * @param userId the user ID
16556             * @param displayDate the display date
16557             * @param status the status
16558             * @param start the lower bound of the range of blogs entries
16559             * @param end the upper bound of the range of blogs entries (not inclusive)
16560             * @return the range of matching blogs entries that the user has permission to view
16561             */
16562            @Override
16563            public List<BlogsEntry> filterFindByG_U_LtD_S(long groupId, long userId,
16564                    Date displayDate, int status, int start, int end) {
16565                    return filterFindByG_U_LtD_S(groupId, userId, displayDate, status,
16566                            start, end, null);
16567            }
16568    
16569            /**
16570             * 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;.
16571             *
16572             * <p>
16573             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
16574             * </p>
16575             *
16576             * @param groupId the group ID
16577             * @param userId the user ID
16578             * @param displayDate the display date
16579             * @param status the status
16580             * @param start the lower bound of the range of blogs entries
16581             * @param end the upper bound of the range of blogs entries (not inclusive)
16582             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
16583             * @return the ordered range of matching blogs entries that the user has permission to view
16584             */
16585            @Override
16586            public List<BlogsEntry> filterFindByG_U_LtD_S(long groupId, long userId,
16587                    Date displayDate, int status, int start, int end,
16588                    OrderByComparator<BlogsEntry> orderByComparator) {
16589                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16590                            return findByG_U_LtD_S(groupId, userId, displayDate, status, start,
16591                                    end, orderByComparator);
16592                    }
16593    
16594                    StringBundler query = null;
16595    
16596                    if (orderByComparator != null) {
16597                            query = new StringBundler(6 +
16598                                            (orderByComparator.getOrderByFields().length * 3));
16599                    }
16600                    else {
16601                            query = new StringBundler(6);
16602                    }
16603    
16604                    if (getDB().isSupportsInlineDistinct()) {
16605                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
16606                    }
16607                    else {
16608                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
16609                    }
16610    
16611                    query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
16612    
16613                    query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
16614    
16615                    boolean bindDisplayDate = false;
16616    
16617                    if (displayDate == null) {
16618                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
16619                    }
16620                    else {
16621                            bindDisplayDate = true;
16622    
16623                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
16624                    }
16625    
16626                    query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
16627    
16628                    if (!getDB().isSupportsInlineDistinct()) {
16629                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
16630                    }
16631    
16632                    if (orderByComparator != null) {
16633                            if (getDB().isSupportsInlineDistinct()) {
16634                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
16635                                            orderByComparator, true);
16636                            }
16637                            else {
16638                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
16639                                            orderByComparator, true);
16640                            }
16641                    }
16642                    else {
16643                            if (getDB().isSupportsInlineDistinct()) {
16644                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
16645                            }
16646                            else {
16647                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
16648                            }
16649                    }
16650    
16651                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16652                                    BlogsEntry.class.getName(),
16653                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16654    
16655                    Session session = null;
16656    
16657                    try {
16658                            session = openSession();
16659    
16660                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
16661    
16662                            if (getDB().isSupportsInlineDistinct()) {
16663                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
16664                            }
16665                            else {
16666                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
16667                            }
16668    
16669                            QueryPos qPos = QueryPos.getInstance(q);
16670    
16671                            qPos.add(groupId);
16672    
16673                            qPos.add(userId);
16674    
16675                            if (bindDisplayDate) {
16676                                    qPos.add(new Timestamp(displayDate.getTime()));
16677                            }
16678    
16679                            qPos.add(status);
16680    
16681                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
16682                    }
16683                    catch (Exception e) {
16684                            throw processException(e);
16685                    }
16686                    finally {
16687                            closeSession(session);
16688                    }
16689            }
16690    
16691            /**
16692             * 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;.
16693             *
16694             * @param entryId the primary key of the current blogs entry
16695             * @param groupId the group ID
16696             * @param userId the user ID
16697             * @param displayDate the display date
16698             * @param status the status
16699             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16700             * @return the previous, current, and next blogs entry
16701             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
16702             */
16703            @Override
16704            public BlogsEntry[] filterFindByG_U_LtD_S_PrevAndNext(long entryId,
16705                    long groupId, long userId, Date displayDate, int status,
16706                    OrderByComparator<BlogsEntry> orderByComparator)
16707                    throws NoSuchEntryException {
16708                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16709                            return findByG_U_LtD_S_PrevAndNext(entryId, groupId, userId,
16710                                    displayDate, status, orderByComparator);
16711                    }
16712    
16713                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
16714    
16715                    Session session = null;
16716    
16717                    try {
16718                            session = openSession();
16719    
16720                            BlogsEntry[] array = new BlogsEntryImpl[3];
16721    
16722                            array[0] = filterGetByG_U_LtD_S_PrevAndNext(session, blogsEntry,
16723                                            groupId, userId, displayDate, status, orderByComparator,
16724                                            true);
16725    
16726                            array[1] = blogsEntry;
16727    
16728                            array[2] = filterGetByG_U_LtD_S_PrevAndNext(session, blogsEntry,
16729                                            groupId, userId, displayDate, status, orderByComparator,
16730                                            false);
16731    
16732                            return array;
16733                    }
16734                    catch (Exception e) {
16735                            throw processException(e);
16736                    }
16737                    finally {
16738                            closeSession(session);
16739                    }
16740            }
16741    
16742            protected BlogsEntry filterGetByG_U_LtD_S_PrevAndNext(Session session,
16743                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
16744                    int status, OrderByComparator<BlogsEntry> orderByComparator,
16745                    boolean previous) {
16746                    StringBundler query = null;
16747    
16748                    if (orderByComparator != null) {
16749                            query = new StringBundler(6 +
16750                                            (orderByComparator.getOrderByFields().length * 6));
16751                    }
16752                    else {
16753                            query = new StringBundler(3);
16754                    }
16755    
16756                    if (getDB().isSupportsInlineDistinct()) {
16757                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
16758                    }
16759                    else {
16760                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
16761                    }
16762    
16763                    query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
16764    
16765                    query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
16766    
16767                    boolean bindDisplayDate = false;
16768    
16769                    if (displayDate == null) {
16770                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
16771                    }
16772                    else {
16773                            bindDisplayDate = true;
16774    
16775                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
16776                    }
16777    
16778                    query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
16779    
16780                    if (!getDB().isSupportsInlineDistinct()) {
16781                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
16782                    }
16783    
16784                    if (orderByComparator != null) {
16785                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
16786    
16787                            if (orderByConditionFields.length > 0) {
16788                                    query.append(WHERE_AND);
16789                            }
16790    
16791                            for (int i = 0; i < orderByConditionFields.length; i++) {
16792                                    if (getDB().isSupportsInlineDistinct()) {
16793                                            query.append(_ORDER_BY_ENTITY_ALIAS);
16794                                    }
16795                                    else {
16796                                            query.append(_ORDER_BY_ENTITY_TABLE);
16797                                    }
16798    
16799                                    query.append(orderByConditionFields[i]);
16800    
16801                                    if ((i + 1) < orderByConditionFields.length) {
16802                                            if (orderByComparator.isAscending() ^ previous) {
16803                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
16804                                            }
16805                                            else {
16806                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
16807                                            }
16808                                    }
16809                                    else {
16810                                            if (orderByComparator.isAscending() ^ previous) {
16811                                                    query.append(WHERE_GREATER_THAN);
16812                                            }
16813                                            else {
16814                                                    query.append(WHERE_LESSER_THAN);
16815                                            }
16816                                    }
16817                            }
16818    
16819                            query.append(ORDER_BY_CLAUSE);
16820    
16821                            String[] orderByFields = orderByComparator.getOrderByFields();
16822    
16823                            for (int i = 0; i < orderByFields.length; i++) {
16824                                    if (getDB().isSupportsInlineDistinct()) {
16825                                            query.append(_ORDER_BY_ENTITY_ALIAS);
16826                                    }
16827                                    else {
16828                                            query.append(_ORDER_BY_ENTITY_TABLE);
16829                                    }
16830    
16831                                    query.append(orderByFields[i]);
16832    
16833                                    if ((i + 1) < orderByFields.length) {
16834                                            if (orderByComparator.isAscending() ^ previous) {
16835                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
16836                                            }
16837                                            else {
16838                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
16839                                            }
16840                                    }
16841                                    else {
16842                                            if (orderByComparator.isAscending() ^ previous) {
16843                                                    query.append(ORDER_BY_ASC);
16844                                            }
16845                                            else {
16846                                                    query.append(ORDER_BY_DESC);
16847                                            }
16848                                    }
16849                            }
16850                    }
16851                    else {
16852                            if (getDB().isSupportsInlineDistinct()) {
16853                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
16854                            }
16855                            else {
16856                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
16857                            }
16858                    }
16859    
16860                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16861                                    BlogsEntry.class.getName(),
16862                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16863    
16864                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
16865    
16866                    q.setFirstResult(0);
16867                    q.setMaxResults(2);
16868    
16869                    if (getDB().isSupportsInlineDistinct()) {
16870                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
16871                    }
16872                    else {
16873                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
16874                    }
16875    
16876                    QueryPos qPos = QueryPos.getInstance(q);
16877    
16878                    qPos.add(groupId);
16879    
16880                    qPos.add(userId);
16881    
16882                    if (bindDisplayDate) {
16883                            qPos.add(new Timestamp(displayDate.getTime()));
16884                    }
16885    
16886                    qPos.add(status);
16887    
16888                    if (orderByComparator != null) {
16889                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
16890    
16891                            for (Object value : values) {
16892                                    qPos.add(value);
16893                            }
16894                    }
16895    
16896                    List<BlogsEntry> list = q.list();
16897    
16898                    if (list.size() == 2) {
16899                            return list.get(1);
16900                    }
16901                    else {
16902                            return null;
16903                    }
16904            }
16905    
16906            /**
16907             * Removes all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63; from the database.
16908             *
16909             * @param groupId the group ID
16910             * @param userId the user ID
16911             * @param displayDate the display date
16912             * @param status the status
16913             */
16914            @Override
16915            public void removeByG_U_LtD_S(long groupId, long userId, Date displayDate,
16916                    int status) {
16917                    for (BlogsEntry blogsEntry : findByG_U_LtD_S(groupId, userId,
16918                                    displayDate, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
16919                            remove(blogsEntry);
16920                    }
16921            }
16922    
16923            /**
16924             * Returns the number of blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16925             *
16926             * @param groupId the group ID
16927             * @param userId the user ID
16928             * @param displayDate the display date
16929             * @param status the status
16930             * @return the number of matching blogs entries
16931             */
16932            @Override
16933            public int countByG_U_LtD_S(long groupId, long userId, Date displayDate,
16934                    int status) {
16935                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD_S;
16936    
16937                    Object[] finderArgs = new Object[] { groupId, userId, displayDate, status };
16938    
16939                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
16940    
16941                    if (count == null) {
16942                            StringBundler query = new StringBundler(5);
16943    
16944                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
16945    
16946                            query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
16947    
16948                            query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
16949    
16950                            boolean bindDisplayDate = false;
16951    
16952                            if (displayDate == null) {
16953                                    query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
16954                            }
16955                            else {
16956                                    bindDisplayDate = true;
16957    
16958                                    query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
16959                            }
16960    
16961                            query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
16962    
16963                            String sql = query.toString();
16964    
16965                            Session session = null;
16966    
16967                            try {
16968                                    session = openSession();
16969    
16970                                    Query q = session.createQuery(sql);
16971    
16972                                    QueryPos qPos = QueryPos.getInstance(q);
16973    
16974                                    qPos.add(groupId);
16975    
16976                                    qPos.add(userId);
16977    
16978                                    if (bindDisplayDate) {
16979                                            qPos.add(new Timestamp(displayDate.getTime()));
16980                                    }
16981    
16982                                    qPos.add(status);
16983    
16984                                    count = (Long)q.uniqueResult();
16985    
16986                                    finderCache.putResult(finderPath, finderArgs, count);
16987                            }
16988                            catch (Exception e) {
16989                                    finderCache.removeResult(finderPath, finderArgs);
16990    
16991                                    throw processException(e);
16992                            }
16993                            finally {
16994                                    closeSession(session);
16995                            }
16996                    }
16997    
16998                    return count.intValue();
16999            }
17000    
17001            /**
17002             * 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;.
17003             *
17004             * @param groupId the group ID
17005             * @param userId the user ID
17006             * @param displayDate the display date
17007             * @param status the status
17008             * @return the number of matching blogs entries that the user has permission to view
17009             */
17010            @Override
17011            public int filterCountByG_U_LtD_S(long groupId, long userId,
17012                    Date displayDate, int status) {
17013                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17014                            return countByG_U_LtD_S(groupId, userId, displayDate, status);
17015                    }
17016    
17017                    StringBundler query = new StringBundler(5);
17018    
17019                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
17020    
17021                    query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
17022    
17023                    query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
17024    
17025                    boolean bindDisplayDate = false;
17026    
17027                    if (displayDate == null) {
17028                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
17029                    }
17030                    else {
17031                            bindDisplayDate = true;
17032    
17033                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
17034                    }
17035    
17036                    query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
17037    
17038                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17039                                    BlogsEntry.class.getName(),
17040                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17041    
17042                    Session session = null;
17043    
17044                    try {
17045                            session = openSession();
17046    
17047                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
17048    
17049                            q.addScalar(COUNT_COLUMN_NAME,
17050                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
17051    
17052                            QueryPos qPos = QueryPos.getInstance(q);
17053    
17054                            qPos.add(groupId);
17055    
17056                            qPos.add(userId);
17057    
17058                            if (bindDisplayDate) {
17059                                    qPos.add(new Timestamp(displayDate.getTime()));
17060                            }
17061    
17062                            qPos.add(status);
17063    
17064                            Long count = (Long)q.uniqueResult();
17065    
17066                            return count.intValue();
17067                    }
17068                    catch (Exception e) {
17069                            throw processException(e);
17070                    }
17071                    finally {
17072                            closeSession(session);
17073                    }
17074            }
17075    
17076            private static final String _FINDER_COLUMN_G_U_LTD_S_GROUPID_2 = "blogsEntry.groupId = ? AND ";
17077            private static final String _FINDER_COLUMN_G_U_LTD_S_USERID_2 = "blogsEntry.userId = ? AND ";
17078            private static final String _FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1 = "blogsEntry.displayDate IS NULL AND ";
17079            private static final String _FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
17080            private static final String _FINDER_COLUMN_G_U_LTD_S_STATUS_2 = "blogsEntry.status = ?";
17081            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD_NOTS =
17082                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
17083                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
17084                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_LtD_NotS",
17085                            new String[] {
17086                                    Long.class.getName(), Long.class.getName(), Date.class.getName(),
17087                                    Integer.class.getName(),
17088                                    
17089                            Integer.class.getName(), Integer.class.getName(),
17090                                    OrderByComparator.class.getName()
17091                            });
17092            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD_NOTS =
17093                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
17094                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
17095                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_U_LtD_NotS",
17096                            new String[] {
17097                                    Long.class.getName(), Long.class.getName(), Date.class.getName(),
17098                                    Integer.class.getName()
17099                            });
17100    
17101            /**
17102             * Returns all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
17103             *
17104             * @param groupId the group ID
17105             * @param userId the user ID
17106             * @param displayDate the display date
17107             * @param status the status
17108             * @return the matching blogs entries
17109             */
17110            @Override
17111            public List<BlogsEntry> findByG_U_LtD_NotS(long groupId, long userId,
17112                    Date displayDate, int status) {
17113                    return findByG_U_LtD_NotS(groupId, userId, displayDate, status,
17114                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
17115            }
17116    
17117            /**
17118             * Returns a range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
17119             *
17120             * <p>
17121             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
17122             * </p>
17123             *
17124             * @param groupId the group ID
17125             * @param userId the user ID
17126             * @param displayDate the display date
17127             * @param status the status
17128             * @param start the lower bound of the range of blogs entries
17129             * @param end the upper bound of the range of blogs entries (not inclusive)
17130             * @return the range of matching blogs entries
17131             */
17132            @Override
17133            public List<BlogsEntry> findByG_U_LtD_NotS(long groupId, long userId,
17134                    Date displayDate, int status, int start, int end) {
17135                    return findByG_U_LtD_NotS(groupId, userId, displayDate, status, start,
17136                            end, null);
17137            }
17138    
17139            /**
17140             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
17141             *
17142             * <p>
17143             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
17144             * </p>
17145             *
17146             * @param groupId the group ID
17147             * @param userId the user ID
17148             * @param displayDate the display date
17149             * @param status the status
17150             * @param start the lower bound of the range of blogs entries
17151             * @param end the upper bound of the range of blogs entries (not inclusive)
17152             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
17153             * @return the ordered range of matching blogs entries
17154             */
17155            @Override
17156            public List<BlogsEntry> findByG_U_LtD_NotS(long groupId, long userId,
17157                    Date displayDate, int status, int start, int end,
17158                    OrderByComparator<BlogsEntry> orderByComparator) {
17159                    return findByG_U_LtD_NotS(groupId, userId, displayDate, status, start,
17160                            end, orderByComparator, true);
17161            }
17162    
17163            /**
17164             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
17165             *
17166             * <p>
17167             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
17168             * </p>
17169             *
17170             * @param groupId the group ID
17171             * @param userId the user ID
17172             * @param displayDate the display date
17173             * @param status the status
17174             * @param start the lower bound of the range of blogs entries
17175             * @param end the upper bound of the range of blogs entries (not inclusive)
17176             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
17177             * @param retrieveFromCache whether to retrieve from the finder cache
17178             * @return the ordered range of matching blogs entries
17179             */
17180            @Override
17181            public List<BlogsEntry> findByG_U_LtD_NotS(long groupId, long userId,
17182                    Date displayDate, int status, int start, int end,
17183                    OrderByComparator<BlogsEntry> orderByComparator,
17184                    boolean retrieveFromCache) {
17185                    boolean pagination = true;
17186                    FinderPath finderPath = null;
17187                    Object[] finderArgs = null;
17188    
17189                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD_NOTS;
17190                    finderArgs = new Object[] {
17191                                    groupId, userId, displayDate, status,
17192                                    
17193                                    start, end, orderByComparator
17194                            };
17195    
17196                    List<BlogsEntry> list = null;
17197    
17198                    if (retrieveFromCache) {
17199                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
17200                                            finderArgs, this);
17201    
17202                            if ((list != null) && !list.isEmpty()) {
17203                                    for (BlogsEntry blogsEntry : list) {
17204                                            if ((groupId != blogsEntry.getGroupId()) ||
17205                                                            (userId != blogsEntry.getUserId()) ||
17206                                                            (displayDate.getTime() <= blogsEntry.getDisplayDate()
17207                                                                                                                                            .getTime()) ||
17208                                                            (status == blogsEntry.getStatus())) {
17209                                                    list = null;
17210    
17211                                                    break;
17212                                            }
17213                                    }
17214                            }
17215                    }
17216    
17217                    if (list == null) {
17218                            StringBundler query = null;
17219    
17220                            if (orderByComparator != null) {
17221                                    query = new StringBundler(6 +
17222                                                    (orderByComparator.getOrderByFields().length * 3));
17223                            }
17224                            else {
17225                                    query = new StringBundler(6);
17226                            }
17227    
17228                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
17229    
17230                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
17231    
17232                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
17233    
17234                            boolean bindDisplayDate = false;
17235    
17236                            if (displayDate == null) {
17237                                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
17238                            }
17239                            else {
17240                                    bindDisplayDate = true;
17241    
17242                                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
17243                            }
17244    
17245                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
17246    
17247                            if (orderByComparator != null) {
17248                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
17249                                            orderByComparator);
17250                            }
17251                            else
17252                             if (pagination) {
17253                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
17254                            }
17255    
17256                            String sql = query.toString();
17257    
17258                            Session session = null;
17259    
17260                            try {
17261                                    session = openSession();
17262    
17263                                    Query q = session.createQuery(sql);
17264    
17265                                    QueryPos qPos = QueryPos.getInstance(q);
17266    
17267                                    qPos.add(groupId);
17268    
17269                                    qPos.add(userId);
17270    
17271                                    if (bindDisplayDate) {
17272                                            qPos.add(new Timestamp(displayDate.getTime()));
17273                                    }
17274    
17275                                    qPos.add(status);
17276    
17277                                    if (!pagination) {
17278                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
17279                                                            start, end, false);
17280    
17281                                            Collections.sort(list);
17282    
17283                                            list = Collections.unmodifiableList(list);
17284                                    }
17285                                    else {
17286                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
17287                                                            start, end);
17288                                    }
17289    
17290                                    cacheResult(list);
17291    
17292                                    finderCache.putResult(finderPath, finderArgs, list);
17293                            }
17294                            catch (Exception e) {
17295                                    finderCache.removeResult(finderPath, finderArgs);
17296    
17297                                    throw processException(e);
17298                            }
17299                            finally {
17300                                    closeSession(session);
17301                            }
17302                    }
17303    
17304                    return list;
17305            }
17306    
17307            /**
17308             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
17309             *
17310             * @param groupId the group ID
17311             * @param userId the user ID
17312             * @param displayDate the display date
17313             * @param status the status
17314             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17315             * @return the first matching blogs entry
17316             * @throws NoSuchEntryException if a matching blogs entry could not be found
17317             */
17318            @Override
17319            public BlogsEntry findByG_U_LtD_NotS_First(long groupId, long userId,
17320                    Date displayDate, int status,
17321                    OrderByComparator<BlogsEntry> orderByComparator)
17322                    throws NoSuchEntryException {
17323                    BlogsEntry blogsEntry = fetchByG_U_LtD_NotS_First(groupId, userId,
17324                                    displayDate, status, orderByComparator);
17325    
17326                    if (blogsEntry != null) {
17327                            return blogsEntry;
17328                    }
17329    
17330                    StringBundler msg = new StringBundler(10);
17331    
17332                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
17333    
17334                    msg.append("groupId=");
17335                    msg.append(groupId);
17336    
17337                    msg.append(", userId=");
17338                    msg.append(userId);
17339    
17340                    msg.append(", displayDate=");
17341                    msg.append(displayDate);
17342    
17343                    msg.append(", status=");
17344                    msg.append(status);
17345    
17346                    msg.append(StringPool.CLOSE_CURLY_BRACE);
17347    
17348                    throw new NoSuchEntryException(msg.toString());
17349            }
17350    
17351            /**
17352             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
17353             *
17354             * @param groupId the group ID
17355             * @param userId the user ID
17356             * @param displayDate the display date
17357             * @param status the status
17358             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17359             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
17360             */
17361            @Override
17362            public BlogsEntry fetchByG_U_LtD_NotS_First(long groupId, long userId,
17363                    Date displayDate, int status,
17364                    OrderByComparator<BlogsEntry> orderByComparator) {
17365                    List<BlogsEntry> list = findByG_U_LtD_NotS(groupId, userId,
17366                                    displayDate, status, 0, 1, orderByComparator);
17367    
17368                    if (!list.isEmpty()) {
17369                            return list.get(0);
17370                    }
17371    
17372                    return null;
17373            }
17374    
17375            /**
17376             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
17377             *
17378             * @param groupId the group ID
17379             * @param userId the user ID
17380             * @param displayDate the display date
17381             * @param status the status
17382             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17383             * @return the last matching blogs entry
17384             * @throws NoSuchEntryException if a matching blogs entry could not be found
17385             */
17386            @Override
17387            public BlogsEntry findByG_U_LtD_NotS_Last(long groupId, long userId,
17388                    Date displayDate, int status,
17389                    OrderByComparator<BlogsEntry> orderByComparator)
17390                    throws NoSuchEntryException {
17391                    BlogsEntry blogsEntry = fetchByG_U_LtD_NotS_Last(groupId, userId,
17392                                    displayDate, status, orderByComparator);
17393    
17394                    if (blogsEntry != null) {
17395                            return blogsEntry;
17396                    }
17397    
17398                    StringBundler msg = new StringBundler(10);
17399    
17400                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
17401    
17402                    msg.append("groupId=");
17403                    msg.append(groupId);
17404    
17405                    msg.append(", userId=");
17406                    msg.append(userId);
17407    
17408                    msg.append(", displayDate=");
17409                    msg.append(displayDate);
17410    
17411                    msg.append(", status=");
17412                    msg.append(status);
17413    
17414                    msg.append(StringPool.CLOSE_CURLY_BRACE);
17415    
17416                    throw new NoSuchEntryException(msg.toString());
17417            }
17418    
17419            /**
17420             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
17421             *
17422             * @param groupId the group ID
17423             * @param userId the user ID
17424             * @param displayDate the display date
17425             * @param status the status
17426             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17427             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
17428             */
17429            @Override
17430            public BlogsEntry fetchByG_U_LtD_NotS_Last(long groupId, long userId,
17431                    Date displayDate, int status,
17432                    OrderByComparator<BlogsEntry> orderByComparator) {
17433                    int count = countByG_U_LtD_NotS(groupId, userId, displayDate, status);
17434    
17435                    if (count == 0) {
17436                            return null;
17437                    }
17438    
17439                    List<BlogsEntry> list = findByG_U_LtD_NotS(groupId, userId,
17440                                    displayDate, status, count - 1, count, orderByComparator);
17441    
17442                    if (!list.isEmpty()) {
17443                            return list.get(0);
17444                    }
17445    
17446                    return null;
17447            }
17448    
17449            /**
17450             * 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;.
17451             *
17452             * @param entryId the primary key of the current blogs entry
17453             * @param groupId the group ID
17454             * @param userId the user ID
17455             * @param displayDate the display date
17456             * @param status the status
17457             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17458             * @return the previous, current, and next blogs entry
17459             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
17460             */
17461            @Override
17462            public BlogsEntry[] findByG_U_LtD_NotS_PrevAndNext(long entryId,
17463                    long groupId, long userId, Date displayDate, int status,
17464                    OrderByComparator<BlogsEntry> orderByComparator)
17465                    throws NoSuchEntryException {
17466                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
17467    
17468                    Session session = null;
17469    
17470                    try {
17471                            session = openSession();
17472    
17473                            BlogsEntry[] array = new BlogsEntryImpl[3];
17474    
17475                            array[0] = getByG_U_LtD_NotS_PrevAndNext(session, blogsEntry,
17476                                            groupId, userId, displayDate, status, orderByComparator,
17477                                            true);
17478    
17479                            array[1] = blogsEntry;
17480    
17481                            array[2] = getByG_U_LtD_NotS_PrevAndNext(session, blogsEntry,
17482                                            groupId, userId, displayDate, status, orderByComparator,
17483                                            false);
17484    
17485                            return array;
17486                    }
17487                    catch (Exception e) {
17488                            throw processException(e);
17489                    }
17490                    finally {
17491                            closeSession(session);
17492                    }
17493            }
17494    
17495            protected BlogsEntry getByG_U_LtD_NotS_PrevAndNext(Session session,
17496                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
17497                    int status, OrderByComparator<BlogsEntry> orderByComparator,
17498                    boolean previous) {
17499                    StringBundler query = null;
17500    
17501                    if (orderByComparator != null) {
17502                            query = new StringBundler(6 +
17503                                            (orderByComparator.getOrderByFields().length * 6));
17504                    }
17505                    else {
17506                            query = new StringBundler(3);
17507                    }
17508    
17509                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
17510    
17511                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
17512    
17513                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
17514    
17515                    boolean bindDisplayDate = false;
17516    
17517                    if (displayDate == null) {
17518                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
17519                    }
17520                    else {
17521                            bindDisplayDate = true;
17522    
17523                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
17524                    }
17525    
17526                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
17527    
17528                    if (orderByComparator != null) {
17529                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
17530    
17531                            if (orderByConditionFields.length > 0) {
17532                                    query.append(WHERE_AND);
17533                            }
17534    
17535                            for (int i = 0; i < orderByConditionFields.length; i++) {
17536                                    query.append(_ORDER_BY_ENTITY_ALIAS);
17537                                    query.append(orderByConditionFields[i]);
17538    
17539                                    if ((i + 1) < orderByConditionFields.length) {
17540                                            if (orderByComparator.isAscending() ^ previous) {
17541                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
17542                                            }
17543                                            else {
17544                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
17545                                            }
17546                                    }
17547                                    else {
17548                                            if (orderByComparator.isAscending() ^ previous) {
17549                                                    query.append(WHERE_GREATER_THAN);
17550                                            }
17551                                            else {
17552                                                    query.append(WHERE_LESSER_THAN);
17553                                            }
17554                                    }
17555                            }
17556    
17557                            query.append(ORDER_BY_CLAUSE);
17558    
17559                            String[] orderByFields = orderByComparator.getOrderByFields();
17560    
17561                            for (int i = 0; i < orderByFields.length; i++) {
17562                                    query.append(_ORDER_BY_ENTITY_ALIAS);
17563                                    query.append(orderByFields[i]);
17564    
17565                                    if ((i + 1) < orderByFields.length) {
17566                                            if (orderByComparator.isAscending() ^ previous) {
17567                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
17568                                            }
17569                                            else {
17570                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
17571                                            }
17572                                    }
17573                                    else {
17574                                            if (orderByComparator.isAscending() ^ previous) {
17575                                                    query.append(ORDER_BY_ASC);
17576                                            }
17577                                            else {
17578                                                    query.append(ORDER_BY_DESC);
17579                                            }
17580                                    }
17581                            }
17582                    }
17583                    else {
17584                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
17585                    }
17586    
17587                    String sql = query.toString();
17588    
17589                    Query q = session.createQuery(sql);
17590    
17591                    q.setFirstResult(0);
17592                    q.setMaxResults(2);
17593    
17594                    QueryPos qPos = QueryPos.getInstance(q);
17595    
17596                    qPos.add(groupId);
17597    
17598                    qPos.add(userId);
17599    
17600                    if (bindDisplayDate) {
17601                            qPos.add(new Timestamp(displayDate.getTime()));
17602                    }
17603    
17604                    qPos.add(status);
17605    
17606                    if (orderByComparator != null) {
17607                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
17608    
17609                            for (Object value : values) {
17610                                    qPos.add(value);
17611                            }
17612                    }
17613    
17614                    List<BlogsEntry> list = q.list();
17615    
17616                    if (list.size() == 2) {
17617                            return list.get(1);
17618                    }
17619                    else {
17620                            return null;
17621                    }
17622            }
17623    
17624            /**
17625             * 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;.
17626             *
17627             * @param groupId the group ID
17628             * @param userId the user ID
17629             * @param displayDate the display date
17630             * @param status the status
17631             * @return the matching blogs entries that the user has permission to view
17632             */
17633            @Override
17634            public List<BlogsEntry> filterFindByG_U_LtD_NotS(long groupId, long userId,
17635                    Date displayDate, int status) {
17636                    return filterFindByG_U_LtD_NotS(groupId, userId, displayDate, status,
17637                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
17638            }
17639    
17640            /**
17641             * 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;.
17642             *
17643             * <p>
17644             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
17645             * </p>
17646             *
17647             * @param groupId the group ID
17648             * @param userId the user ID
17649             * @param displayDate the display date
17650             * @param status the status
17651             * @param start the lower bound of the range of blogs entries
17652             * @param end the upper bound of the range of blogs entries (not inclusive)
17653             * @return the range of matching blogs entries that the user has permission to view
17654             */
17655            @Override
17656            public List<BlogsEntry> filterFindByG_U_LtD_NotS(long groupId, long userId,
17657                    Date displayDate, int status, int start, int end) {
17658                    return filterFindByG_U_LtD_NotS(groupId, userId, displayDate, status,
17659                            start, end, null);
17660            }
17661    
17662            /**
17663             * 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;.
17664             *
17665             * <p>
17666             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
17667             * </p>
17668             *
17669             * @param groupId the group ID
17670             * @param userId the user ID
17671             * @param displayDate the display date
17672             * @param status the status
17673             * @param start the lower bound of the range of blogs entries
17674             * @param end the upper bound of the range of blogs entries (not inclusive)
17675             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
17676             * @return the ordered range of matching blogs entries that the user has permission to view
17677             */
17678            @Override
17679            public List<BlogsEntry> filterFindByG_U_LtD_NotS(long groupId, long userId,
17680                    Date displayDate, int status, int start, int end,
17681                    OrderByComparator<BlogsEntry> orderByComparator) {
17682                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17683                            return findByG_U_LtD_NotS(groupId, userId, displayDate, status,
17684                                    start, end, orderByComparator);
17685                    }
17686    
17687                    StringBundler query = null;
17688    
17689                    if (orderByComparator != null) {
17690                            query = new StringBundler(6 +
17691                                            (orderByComparator.getOrderByFields().length * 3));
17692                    }
17693                    else {
17694                            query = new StringBundler(6);
17695                    }
17696    
17697                    if (getDB().isSupportsInlineDistinct()) {
17698                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
17699                    }
17700                    else {
17701                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
17702                    }
17703    
17704                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
17705    
17706                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
17707    
17708                    boolean bindDisplayDate = false;
17709    
17710                    if (displayDate == null) {
17711                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
17712                    }
17713                    else {
17714                            bindDisplayDate = true;
17715    
17716                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
17717                    }
17718    
17719                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
17720    
17721                    if (!getDB().isSupportsInlineDistinct()) {
17722                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
17723                    }
17724    
17725                    if (orderByComparator != null) {
17726                            if (getDB().isSupportsInlineDistinct()) {
17727                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
17728                                            orderByComparator, true);
17729                            }
17730                            else {
17731                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
17732                                            orderByComparator, true);
17733                            }
17734                    }
17735                    else {
17736                            if (getDB().isSupportsInlineDistinct()) {
17737                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
17738                            }
17739                            else {
17740                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
17741                            }
17742                    }
17743    
17744                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17745                                    BlogsEntry.class.getName(),
17746                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17747    
17748                    Session session = null;
17749    
17750                    try {
17751                            session = openSession();
17752    
17753                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
17754    
17755                            if (getDB().isSupportsInlineDistinct()) {
17756                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
17757                            }
17758                            else {
17759                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
17760                            }
17761    
17762                            QueryPos qPos = QueryPos.getInstance(q);
17763    
17764                            qPos.add(groupId);
17765    
17766                            qPos.add(userId);
17767    
17768                            if (bindDisplayDate) {
17769                                    qPos.add(new Timestamp(displayDate.getTime()));
17770                            }
17771    
17772                            qPos.add(status);
17773    
17774                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
17775                    }
17776                    catch (Exception e) {
17777                            throw processException(e);
17778                    }
17779                    finally {
17780                            closeSession(session);
17781                    }
17782            }
17783    
17784            /**
17785             * 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;.
17786             *
17787             * @param entryId the primary key of the current blogs entry
17788             * @param groupId the group ID
17789             * @param userId the user ID
17790             * @param displayDate the display date
17791             * @param status the status
17792             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17793             * @return the previous, current, and next blogs entry
17794             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
17795             */
17796            @Override
17797            public BlogsEntry[] filterFindByG_U_LtD_NotS_PrevAndNext(long entryId,
17798                    long groupId, long userId, Date displayDate, int status,
17799                    OrderByComparator<BlogsEntry> orderByComparator)
17800                    throws NoSuchEntryException {
17801                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17802                            return findByG_U_LtD_NotS_PrevAndNext(entryId, groupId, userId,
17803                                    displayDate, status, orderByComparator);
17804                    }
17805    
17806                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
17807    
17808                    Session session = null;
17809    
17810                    try {
17811                            session = openSession();
17812    
17813                            BlogsEntry[] array = new BlogsEntryImpl[3];
17814    
17815                            array[0] = filterGetByG_U_LtD_NotS_PrevAndNext(session, blogsEntry,
17816                                            groupId, userId, displayDate, status, orderByComparator,
17817                                            true);
17818    
17819                            array[1] = blogsEntry;
17820    
17821                            array[2] = filterGetByG_U_LtD_NotS_PrevAndNext(session, blogsEntry,
17822                                            groupId, userId, displayDate, status, orderByComparator,
17823                                            false);
17824    
17825                            return array;
17826                    }
17827                    catch (Exception e) {
17828                            throw processException(e);
17829                    }
17830                    finally {
17831                            closeSession(session);
17832                    }
17833            }
17834    
17835            protected BlogsEntry filterGetByG_U_LtD_NotS_PrevAndNext(Session session,
17836                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
17837                    int status, OrderByComparator<BlogsEntry> orderByComparator,
17838                    boolean previous) {
17839                    StringBundler query = null;
17840    
17841                    if (orderByComparator != null) {
17842                            query = new StringBundler(6 +
17843                                            (orderByComparator.getOrderByFields().length * 6));
17844                    }
17845                    else {
17846                            query = new StringBundler(3);
17847                    }
17848    
17849                    if (getDB().isSupportsInlineDistinct()) {
17850                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
17851                    }
17852                    else {
17853                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
17854                    }
17855    
17856                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
17857    
17858                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
17859    
17860                    boolean bindDisplayDate = false;
17861    
17862                    if (displayDate == null) {
17863                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
17864                    }
17865                    else {
17866                            bindDisplayDate = true;
17867    
17868                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
17869                    }
17870    
17871                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
17872    
17873                    if (!getDB().isSupportsInlineDistinct()) {
17874                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
17875                    }
17876    
17877                    if (orderByComparator != null) {
17878                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
17879    
17880                            if (orderByConditionFields.length > 0) {
17881                                    query.append(WHERE_AND);
17882                            }
17883    
17884                            for (int i = 0; i < orderByConditionFields.length; i++) {
17885                                    if (getDB().isSupportsInlineDistinct()) {
17886                                            query.append(_ORDER_BY_ENTITY_ALIAS);
17887                                    }
17888                                    else {
17889                                            query.append(_ORDER_BY_ENTITY_TABLE);
17890                                    }
17891    
17892                                    query.append(orderByConditionFields[i]);
17893    
17894                                    if ((i + 1) < orderByConditionFields.length) {
17895                                            if (orderByComparator.isAscending() ^ previous) {
17896                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
17897                                            }
17898                                            else {
17899                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
17900                                            }
17901                                    }
17902                                    else {
17903                                            if (orderByComparator.isAscending() ^ previous) {
17904                                                    query.append(WHERE_GREATER_THAN);
17905                                            }
17906                                            else {
17907                                                    query.append(WHERE_LESSER_THAN);
17908                                            }
17909                                    }
17910                            }
17911    
17912                            query.append(ORDER_BY_CLAUSE);
17913    
17914                            String[] orderByFields = orderByComparator.getOrderByFields();
17915    
17916                            for (int i = 0; i < orderByFields.length; i++) {
17917                                    if (getDB().isSupportsInlineDistinct()) {
17918                                            query.append(_ORDER_BY_ENTITY_ALIAS);
17919                                    }
17920                                    else {
17921                                            query.append(_ORDER_BY_ENTITY_TABLE);
17922                                    }
17923    
17924                                    query.append(orderByFields[i]);
17925    
17926                                    if ((i + 1) < orderByFields.length) {
17927                                            if (orderByComparator.isAscending() ^ previous) {
17928                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
17929                                            }
17930                                            else {
17931                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
17932                                            }
17933                                    }
17934                                    else {
17935                                            if (orderByComparator.isAscending() ^ previous) {
17936                                                    query.append(ORDER_BY_ASC);
17937                                            }
17938                                            else {
17939                                                    query.append(ORDER_BY_DESC);
17940                                            }
17941                                    }
17942                            }
17943                    }
17944                    else {
17945                            if (getDB().isSupportsInlineDistinct()) {
17946                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
17947                            }
17948                            else {
17949                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
17950                            }
17951                    }
17952    
17953                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17954                                    BlogsEntry.class.getName(),
17955                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17956    
17957                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
17958    
17959                    q.setFirstResult(0);
17960                    q.setMaxResults(2);
17961    
17962                    if (getDB().isSupportsInlineDistinct()) {
17963                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
17964                    }
17965                    else {
17966                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
17967                    }
17968    
17969                    QueryPos qPos = QueryPos.getInstance(q);
17970    
17971                    qPos.add(groupId);
17972    
17973                    qPos.add(userId);
17974    
17975                    if (bindDisplayDate) {
17976                            qPos.add(new Timestamp(displayDate.getTime()));
17977                    }
17978    
17979                    qPos.add(status);
17980    
17981                    if (orderByComparator != null) {
17982                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
17983    
17984                            for (Object value : values) {
17985                                    qPos.add(value);
17986                            }
17987                    }
17988    
17989                    List<BlogsEntry> list = q.list();
17990    
17991                    if (list.size() == 2) {
17992                            return list.get(1);
17993                    }
17994                    else {
17995                            return null;
17996                    }
17997            }
17998    
17999            /**
18000             * Removes all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63; from the database.
18001             *
18002             * @param groupId the group ID
18003             * @param userId the user ID
18004             * @param displayDate the display date
18005             * @param status the status
18006             */
18007            @Override
18008            public void removeByG_U_LtD_NotS(long groupId, long userId,
18009                    Date displayDate, int status) {
18010                    for (BlogsEntry blogsEntry : findByG_U_LtD_NotS(groupId, userId,
18011                                    displayDate, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
18012                            remove(blogsEntry);
18013                    }
18014            }
18015    
18016            /**
18017             * Returns the number of blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
18018             *
18019             * @param groupId the group ID
18020             * @param userId the user ID
18021             * @param displayDate the display date
18022             * @param status the status
18023             * @return the number of matching blogs entries
18024             */
18025            @Override
18026            public int countByG_U_LtD_NotS(long groupId, long userId, Date displayDate,
18027                    int status) {
18028                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD_NOTS;
18029    
18030                    Object[] finderArgs = new Object[] { groupId, userId, displayDate, status };
18031    
18032                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
18033    
18034                    if (count == null) {
18035                            StringBundler query = new StringBundler(5);
18036    
18037                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
18038    
18039                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
18040    
18041                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
18042    
18043                            boolean bindDisplayDate = false;
18044    
18045                            if (displayDate == null) {
18046                                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
18047                            }
18048                            else {
18049                                    bindDisplayDate = true;
18050    
18051                                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
18052                            }
18053    
18054                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
18055    
18056                            String sql = query.toString();
18057    
18058                            Session session = null;
18059    
18060                            try {
18061                                    session = openSession();
18062    
18063                                    Query q = session.createQuery(sql);
18064    
18065                                    QueryPos qPos = QueryPos.getInstance(q);
18066    
18067                                    qPos.add(groupId);
18068    
18069                                    qPos.add(userId);
18070    
18071                                    if (bindDisplayDate) {
18072                                            qPos.add(new Timestamp(displayDate.getTime()));
18073                                    }
18074    
18075                                    qPos.add(status);
18076    
18077                                    count = (Long)q.uniqueResult();
18078    
18079                                    finderCache.putResult(finderPath, finderArgs, count);
18080                            }
18081                            catch (Exception e) {
18082                                    finderCache.removeResult(finderPath, finderArgs);
18083    
18084                                    throw processException(e);
18085                            }
18086                            finally {
18087                                    closeSession(session);
18088                            }
18089                    }
18090    
18091                    return count.intValue();
18092            }
18093    
18094            /**
18095             * 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;.
18096             *
18097             * @param groupId the group ID
18098             * @param userId the user ID
18099             * @param displayDate the display date
18100             * @param status the status
18101             * @return the number of matching blogs entries that the user has permission to view
18102             */
18103            @Override
18104            public int filterCountByG_U_LtD_NotS(long groupId, long userId,
18105                    Date displayDate, int status) {
18106                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
18107                            return countByG_U_LtD_NotS(groupId, userId, displayDate, status);
18108                    }
18109    
18110                    StringBundler query = new StringBundler(5);
18111    
18112                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
18113    
18114                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
18115    
18116                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
18117    
18118                    boolean bindDisplayDate = false;
18119    
18120                    if (displayDate == null) {
18121                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
18122                    }
18123                    else {
18124                            bindDisplayDate = true;
18125    
18126                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
18127                    }
18128    
18129                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
18130    
18131                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
18132                                    BlogsEntry.class.getName(),
18133                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
18134    
18135                    Session session = null;
18136    
18137                    try {
18138                            session = openSession();
18139    
18140                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
18141    
18142                            q.addScalar(COUNT_COLUMN_NAME,
18143                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
18144    
18145                            QueryPos qPos = QueryPos.getInstance(q);
18146    
18147                            qPos.add(groupId);
18148    
18149                            qPos.add(userId);
18150    
18151                            if (bindDisplayDate) {
18152                                    qPos.add(new Timestamp(displayDate.getTime()));
18153                            }
18154    
18155                            qPos.add(status);
18156    
18157                            Long count = (Long)q.uniqueResult();
18158    
18159                            return count.intValue();
18160                    }
18161                    catch (Exception e) {
18162                            throw processException(e);
18163                    }
18164                    finally {
18165                            closeSession(session);
18166                    }
18167            }
18168    
18169            private static final String _FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2 = "blogsEntry.groupId = ? AND ";
18170            private static final String _FINDER_COLUMN_G_U_LTD_NOTS_USERID_2 = "blogsEntry.userId = ? AND ";
18171            private static final String _FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1 = "blogsEntry.displayDate IS NULL AND ";
18172            private static final String _FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
18173            private static final String _FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2 = "blogsEntry.status != ?";
18174    
18175            public BlogsEntryPersistenceImpl() {
18176                    setModelClass(BlogsEntry.class);
18177            }
18178    
18179            /**
18180             * Caches the blogs entry in the entity cache if it is enabled.
18181             *
18182             * @param blogsEntry the blogs entry
18183             */
18184            @Override
18185            public void cacheResult(BlogsEntry blogsEntry) {
18186                    entityCache.putResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18187                            BlogsEntryImpl.class, blogsEntry.getPrimaryKey(), blogsEntry);
18188    
18189                    finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G,
18190                            new Object[] { blogsEntry.getUuid(), blogsEntry.getGroupId() },
18191                            blogsEntry);
18192    
18193                    finderCache.putResult(FINDER_PATH_FETCH_BY_G_UT,
18194                            new Object[] { blogsEntry.getGroupId(), blogsEntry.getUrlTitle() },
18195                            blogsEntry);
18196    
18197                    blogsEntry.resetOriginalValues();
18198            }
18199    
18200            /**
18201             * Caches the blogs entries in the entity cache if it is enabled.
18202             *
18203             * @param blogsEntries the blogs entries
18204             */
18205            @Override
18206            public void cacheResult(List<BlogsEntry> blogsEntries) {
18207                    for (BlogsEntry blogsEntry : blogsEntries) {
18208                            if (entityCache.getResult(
18209                                                    BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18210                                                    BlogsEntryImpl.class, blogsEntry.getPrimaryKey()) == null) {
18211                                    cacheResult(blogsEntry);
18212                            }
18213                            else {
18214                                    blogsEntry.resetOriginalValues();
18215                            }
18216                    }
18217            }
18218    
18219            /**
18220             * Clears the cache for all blogs entries.
18221             *
18222             * <p>
18223             * The {@link EntityCache} and {@link FinderCache} are both cleared by this method.
18224             * </p>
18225             */
18226            @Override
18227            public void clearCache() {
18228                    entityCache.clearCache(BlogsEntryImpl.class);
18229    
18230                    finderCache.clearCache(FINDER_CLASS_NAME_ENTITY);
18231                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
18232                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
18233            }
18234    
18235            /**
18236             * Clears the cache for the blogs entry.
18237             *
18238             * <p>
18239             * The {@link EntityCache} and {@link FinderCache} are both cleared by this method.
18240             * </p>
18241             */
18242            @Override
18243            public void clearCache(BlogsEntry blogsEntry) {
18244                    entityCache.removeResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18245                            BlogsEntryImpl.class, blogsEntry.getPrimaryKey());
18246    
18247                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
18248                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
18249    
18250                    clearUniqueFindersCache((BlogsEntryModelImpl)blogsEntry);
18251            }
18252    
18253            @Override
18254            public void clearCache(List<BlogsEntry> blogsEntries) {
18255                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
18256                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
18257    
18258                    for (BlogsEntry blogsEntry : blogsEntries) {
18259                            entityCache.removeResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18260                                    BlogsEntryImpl.class, blogsEntry.getPrimaryKey());
18261    
18262                            clearUniqueFindersCache((BlogsEntryModelImpl)blogsEntry);
18263                    }
18264            }
18265    
18266            protected void cacheUniqueFindersCache(
18267                    BlogsEntryModelImpl blogsEntryModelImpl, boolean isNew) {
18268                    if (isNew) {
18269                            Object[] args = new Object[] {
18270                                            blogsEntryModelImpl.getUuid(),
18271                                            blogsEntryModelImpl.getGroupId()
18272                                    };
18273    
18274                            finderCache.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
18275                                    Long.valueOf(1));
18276                            finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
18277                                    blogsEntryModelImpl);
18278    
18279                            args = new Object[] {
18280                                            blogsEntryModelImpl.getGroupId(),
18281                                            blogsEntryModelImpl.getUrlTitle()
18282                                    };
18283    
18284                            finderCache.putResult(FINDER_PATH_COUNT_BY_G_UT, args,
18285                                    Long.valueOf(1));
18286                            finderCache.putResult(FINDER_PATH_FETCH_BY_G_UT, args,
18287                                    blogsEntryModelImpl);
18288                    }
18289                    else {
18290                            if ((blogsEntryModelImpl.getColumnBitmask() &
18291                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
18292                                    Object[] args = new Object[] {
18293                                                    blogsEntryModelImpl.getUuid(),
18294                                                    blogsEntryModelImpl.getGroupId()
18295                                            };
18296    
18297                                    finderCache.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
18298                                            Long.valueOf(1));
18299                                    finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
18300                                            blogsEntryModelImpl);
18301                            }
18302    
18303                            if ((blogsEntryModelImpl.getColumnBitmask() &
18304                                            FINDER_PATH_FETCH_BY_G_UT.getColumnBitmask()) != 0) {
18305                                    Object[] args = new Object[] {
18306                                                    blogsEntryModelImpl.getGroupId(),
18307                                                    blogsEntryModelImpl.getUrlTitle()
18308                                            };
18309    
18310                                    finderCache.putResult(FINDER_PATH_COUNT_BY_G_UT, args,
18311                                            Long.valueOf(1));
18312                                    finderCache.putResult(FINDER_PATH_FETCH_BY_G_UT, args,
18313                                            blogsEntryModelImpl);
18314                            }
18315                    }
18316            }
18317    
18318            protected void clearUniqueFindersCache(
18319                    BlogsEntryModelImpl blogsEntryModelImpl) {
18320                    Object[] args = new Object[] {
18321                                    blogsEntryModelImpl.getUuid(), blogsEntryModelImpl.getGroupId()
18322                            };
18323    
18324                    finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
18325                    finderCache.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
18326    
18327                    if ((blogsEntryModelImpl.getColumnBitmask() &
18328                                    FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
18329                            args = new Object[] {
18330                                            blogsEntryModelImpl.getOriginalUuid(),
18331                                            blogsEntryModelImpl.getOriginalGroupId()
18332                                    };
18333    
18334                            finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
18335                            finderCache.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
18336                    }
18337    
18338                    args = new Object[] {
18339                                    blogsEntryModelImpl.getGroupId(),
18340                                    blogsEntryModelImpl.getUrlTitle()
18341                            };
18342    
18343                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_UT, args);
18344                    finderCache.removeResult(FINDER_PATH_FETCH_BY_G_UT, args);
18345    
18346                    if ((blogsEntryModelImpl.getColumnBitmask() &
18347                                    FINDER_PATH_FETCH_BY_G_UT.getColumnBitmask()) != 0) {
18348                            args = new Object[] {
18349                                            blogsEntryModelImpl.getOriginalGroupId(),
18350                                            blogsEntryModelImpl.getOriginalUrlTitle()
18351                                    };
18352    
18353                            finderCache.removeResult(FINDER_PATH_COUNT_BY_G_UT, args);
18354                            finderCache.removeResult(FINDER_PATH_FETCH_BY_G_UT, args);
18355                    }
18356            }
18357    
18358            /**
18359             * Creates a new blogs entry with the primary key. Does not add the blogs entry to the database.
18360             *
18361             * @param entryId the primary key for the new blogs entry
18362             * @return the new blogs entry
18363             */
18364            @Override
18365            public BlogsEntry create(long entryId) {
18366                    BlogsEntry blogsEntry = new BlogsEntryImpl();
18367    
18368                    blogsEntry.setNew(true);
18369                    blogsEntry.setPrimaryKey(entryId);
18370    
18371                    String uuid = PortalUUIDUtil.generate();
18372    
18373                    blogsEntry.setUuid(uuid);
18374    
18375                    return blogsEntry;
18376            }
18377    
18378            /**
18379             * Removes the blogs entry with the primary key from the database. Also notifies the appropriate model listeners.
18380             *
18381             * @param entryId the primary key of the blogs entry
18382             * @return the blogs entry that was removed
18383             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
18384             */
18385            @Override
18386            public BlogsEntry remove(long entryId) throws NoSuchEntryException {
18387                    return remove((Serializable)entryId);
18388            }
18389    
18390            /**
18391             * Removes the blogs entry with the primary key from the database. Also notifies the appropriate model listeners.
18392             *
18393             * @param primaryKey the primary key of the blogs entry
18394             * @return the blogs entry that was removed
18395             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
18396             */
18397            @Override
18398            public BlogsEntry remove(Serializable primaryKey)
18399                    throws NoSuchEntryException {
18400                    Session session = null;
18401    
18402                    try {
18403                            session = openSession();
18404    
18405                            BlogsEntry blogsEntry = (BlogsEntry)session.get(BlogsEntryImpl.class,
18406                                            primaryKey);
18407    
18408                            if (blogsEntry == null) {
18409                                    if (_log.isWarnEnabled()) {
18410                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
18411                                    }
18412    
18413                                    throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
18414                                            primaryKey);
18415                            }
18416    
18417                            return remove(blogsEntry);
18418                    }
18419                    catch (NoSuchEntryException nsee) {
18420                            throw nsee;
18421                    }
18422                    catch (Exception e) {
18423                            throw processException(e);
18424                    }
18425                    finally {
18426                            closeSession(session);
18427                    }
18428            }
18429    
18430            @Override
18431            protected BlogsEntry removeImpl(BlogsEntry blogsEntry) {
18432                    blogsEntry = toUnwrappedModel(blogsEntry);
18433    
18434                    Session session = null;
18435    
18436                    try {
18437                            session = openSession();
18438    
18439                            if (!session.contains(blogsEntry)) {
18440                                    blogsEntry = (BlogsEntry)session.get(BlogsEntryImpl.class,
18441                                                    blogsEntry.getPrimaryKeyObj());
18442                            }
18443    
18444                            if (blogsEntry != null) {
18445                                    session.delete(blogsEntry);
18446                            }
18447                    }
18448                    catch (Exception e) {
18449                            throw processException(e);
18450                    }
18451                    finally {
18452                            closeSession(session);
18453                    }
18454    
18455                    if (blogsEntry != null) {
18456                            clearCache(blogsEntry);
18457                    }
18458    
18459                    return blogsEntry;
18460            }
18461    
18462            @Override
18463            public BlogsEntry updateImpl(BlogsEntry blogsEntry) {
18464                    blogsEntry = toUnwrappedModel(blogsEntry);
18465    
18466                    boolean isNew = blogsEntry.isNew();
18467    
18468                    BlogsEntryModelImpl blogsEntryModelImpl = (BlogsEntryModelImpl)blogsEntry;
18469    
18470                    if (Validator.isNull(blogsEntry.getUuid())) {
18471                            String uuid = PortalUUIDUtil.generate();
18472    
18473                            blogsEntry.setUuid(uuid);
18474                    }
18475    
18476                    ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();
18477    
18478                    Date now = new Date();
18479    
18480                    if (isNew && (blogsEntry.getCreateDate() == null)) {
18481                            if (serviceContext == null) {
18482                                    blogsEntry.setCreateDate(now);
18483                            }
18484                            else {
18485                                    blogsEntry.setCreateDate(serviceContext.getCreateDate(now));
18486                            }
18487                    }
18488    
18489                    if (!blogsEntryModelImpl.hasSetModifiedDate()) {
18490                            if (serviceContext == null) {
18491                                    blogsEntry.setModifiedDate(now);
18492                            }
18493                            else {
18494                                    blogsEntry.setModifiedDate(serviceContext.getModifiedDate(now));
18495                            }
18496                    }
18497    
18498                    long userId = GetterUtil.getLong(PrincipalThreadLocal.getName());
18499    
18500                    if (userId > 0) {
18501                            long companyId = blogsEntry.getCompanyId();
18502    
18503                            long groupId = blogsEntry.getGroupId();
18504    
18505                            long entryId = 0;
18506    
18507                            if (!isNew) {
18508                                    entryId = blogsEntry.getPrimaryKey();
18509                            }
18510    
18511                            try {
18512                                    blogsEntry.setTitle(SanitizerUtil.sanitize(companyId, groupId,
18513                                                    userId,
18514                                                    com.liferay.portlet.blogs.model.BlogsEntry.class.getName(),
18515                                                    entryId, ContentTypes.TEXT_PLAIN, Sanitizer.MODE_ALL,
18516                                                    blogsEntry.getTitle(), null));
18517    
18518                                    blogsEntry.setContent(SanitizerUtil.sanitize(companyId,
18519                                                    groupId, userId,
18520                                                    com.liferay.portlet.blogs.model.BlogsEntry.class.getName(),
18521                                                    entryId, ContentTypes.TEXT_HTML, Sanitizer.MODE_ALL,
18522                                                    blogsEntry.getContent(), null));
18523                            }
18524                            catch (SanitizerException se) {
18525                                    throw new SystemException(se);
18526                            }
18527                    }
18528    
18529                    Session session = null;
18530    
18531                    try {
18532                            session = openSession();
18533    
18534                            if (blogsEntry.isNew()) {
18535                                    session.save(blogsEntry);
18536    
18537                                    blogsEntry.setNew(false);
18538                            }
18539                            else {
18540                                    blogsEntry = (BlogsEntry)session.merge(blogsEntry);
18541                            }
18542                    }
18543                    catch (Exception e) {
18544                            throw processException(e);
18545                    }
18546                    finally {
18547                            closeSession(session);
18548                    }
18549    
18550                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
18551    
18552                    if (isNew || !BlogsEntryModelImpl.COLUMN_BITMASK_ENABLED) {
18553                            finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
18554                    }
18555    
18556                    else {
18557                            if ((blogsEntryModelImpl.getColumnBitmask() &
18558                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
18559                                    Object[] args = new Object[] {
18560                                                    blogsEntryModelImpl.getOriginalUuid()
18561                                            };
18562    
18563                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
18564                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
18565                                            args);
18566    
18567                                    args = new Object[] { blogsEntryModelImpl.getUuid() };
18568    
18569                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
18570                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
18571                                            args);
18572                            }
18573    
18574                            if ((blogsEntryModelImpl.getColumnBitmask() &
18575                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
18576                                    Object[] args = new Object[] {
18577                                                    blogsEntryModelImpl.getOriginalUuid(),
18578                                                    blogsEntryModelImpl.getOriginalCompanyId()
18579                                            };
18580    
18581                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
18582                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
18583                                            args);
18584    
18585                                    args = new Object[] {
18586                                                    blogsEntryModelImpl.getUuid(),
18587                                                    blogsEntryModelImpl.getCompanyId()
18588                                            };
18589    
18590                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
18591                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
18592                                            args);
18593                            }
18594    
18595                            if ((blogsEntryModelImpl.getColumnBitmask() &
18596                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
18597                                    Object[] args = new Object[] {
18598                                                    blogsEntryModelImpl.getOriginalGroupId()
18599                                            };
18600    
18601                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
18602                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
18603                                            args);
18604    
18605                                    args = new Object[] { blogsEntryModelImpl.getGroupId() };
18606    
18607                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
18608                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
18609                                            args);
18610                            }
18611    
18612                            if ((blogsEntryModelImpl.getColumnBitmask() &
18613                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
18614                                    Object[] args = new Object[] {
18615                                                    blogsEntryModelImpl.getOriginalCompanyId()
18616                                            };
18617    
18618                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_COMPANYID, args);
18619                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
18620                                            args);
18621    
18622                                    args = new Object[] { blogsEntryModelImpl.getCompanyId() };
18623    
18624                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_COMPANYID, args);
18625                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
18626                                            args);
18627                            }
18628    
18629                            if ((blogsEntryModelImpl.getColumnBitmask() &
18630                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S.getColumnBitmask()) != 0) {
18631                                    Object[] args = new Object[] {
18632                                                    blogsEntryModelImpl.getOriginalGroupId(),
18633                                                    blogsEntryModelImpl.getOriginalStatus()
18634                                            };
18635    
18636                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
18637                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
18638                                            args);
18639    
18640                                    args = new Object[] {
18641                                                    blogsEntryModelImpl.getGroupId(),
18642                                                    blogsEntryModelImpl.getStatus()
18643                                            };
18644    
18645                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
18646                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
18647                                            args);
18648                            }
18649    
18650                            if ((blogsEntryModelImpl.getColumnBitmask() &
18651                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U.getColumnBitmask()) != 0) {
18652                                    Object[] args = new Object[] {
18653                                                    blogsEntryModelImpl.getOriginalCompanyId(),
18654                                                    blogsEntryModelImpl.getOriginalUserId()
18655                                            };
18656    
18657                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_C_U, args);
18658                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U,
18659                                            args);
18660    
18661                                    args = new Object[] {
18662                                                    blogsEntryModelImpl.getCompanyId(),
18663                                                    blogsEntryModelImpl.getUserId()
18664                                            };
18665    
18666                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_C_U, args);
18667                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U,
18668                                            args);
18669                            }
18670    
18671                            if ((blogsEntryModelImpl.getColumnBitmask() &
18672                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S.getColumnBitmask()) != 0) {
18673                                    Object[] args = new Object[] {
18674                                                    blogsEntryModelImpl.getOriginalCompanyId(),
18675                                                    blogsEntryModelImpl.getOriginalStatus()
18676                                            };
18677    
18678                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_C_S, args);
18679                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S,
18680                                            args);
18681    
18682                                    args = new Object[] {
18683                                                    blogsEntryModelImpl.getCompanyId(),
18684                                                    blogsEntryModelImpl.getStatus()
18685                                            };
18686    
18687                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_C_S, args);
18688                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S,
18689                                            args);
18690                            }
18691    
18692                            if ((blogsEntryModelImpl.getColumnBitmask() &
18693                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S.getColumnBitmask()) != 0) {
18694                                    Object[] args = new Object[] {
18695                                                    blogsEntryModelImpl.getOriginalGroupId(),
18696                                                    blogsEntryModelImpl.getOriginalUserId(),
18697                                                    blogsEntryModelImpl.getOriginalStatus()
18698                                            };
18699    
18700                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_U_S, args);
18701                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S,
18702                                            args);
18703    
18704                                    args = new Object[] {
18705                                                    blogsEntryModelImpl.getGroupId(),
18706                                                    blogsEntryModelImpl.getUserId(),
18707                                                    blogsEntryModelImpl.getStatus()
18708                                            };
18709    
18710                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_U_S, args);
18711                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S,
18712                                            args);
18713                            }
18714    
18715                            if ((blogsEntryModelImpl.getColumnBitmask() &
18716                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U_S.getColumnBitmask()) != 0) {
18717                                    Object[] args = new Object[] {
18718                                                    blogsEntryModelImpl.getOriginalCompanyId(),
18719                                                    blogsEntryModelImpl.getOriginalUserId(),
18720                                                    blogsEntryModelImpl.getOriginalStatus()
18721                                            };
18722    
18723                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_C_U_S, args);
18724                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U_S,
18725                                            args);
18726    
18727                                    args = new Object[] {
18728                                                    blogsEntryModelImpl.getCompanyId(),
18729                                                    blogsEntryModelImpl.getUserId(),
18730                                                    blogsEntryModelImpl.getStatus()
18731                                            };
18732    
18733                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_C_U_S, args);
18734                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U_S,
18735                                            args);
18736                            }
18737                    }
18738    
18739                    entityCache.putResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18740                            BlogsEntryImpl.class, blogsEntry.getPrimaryKey(), blogsEntry, false);
18741    
18742                    clearUniqueFindersCache(blogsEntryModelImpl);
18743                    cacheUniqueFindersCache(blogsEntryModelImpl, isNew);
18744    
18745                    blogsEntry.resetOriginalValues();
18746    
18747                    return blogsEntry;
18748            }
18749    
18750            protected BlogsEntry toUnwrappedModel(BlogsEntry blogsEntry) {
18751                    if (blogsEntry instanceof BlogsEntryImpl) {
18752                            return blogsEntry;
18753                    }
18754    
18755                    BlogsEntryImpl blogsEntryImpl = new BlogsEntryImpl();
18756    
18757                    blogsEntryImpl.setNew(blogsEntry.isNew());
18758                    blogsEntryImpl.setPrimaryKey(blogsEntry.getPrimaryKey());
18759    
18760                    blogsEntryImpl.setUuid(blogsEntry.getUuid());
18761                    blogsEntryImpl.setEntryId(blogsEntry.getEntryId());
18762                    blogsEntryImpl.setGroupId(blogsEntry.getGroupId());
18763                    blogsEntryImpl.setCompanyId(blogsEntry.getCompanyId());
18764                    blogsEntryImpl.setUserId(blogsEntry.getUserId());
18765                    blogsEntryImpl.setUserName(blogsEntry.getUserName());
18766                    blogsEntryImpl.setCreateDate(blogsEntry.getCreateDate());
18767                    blogsEntryImpl.setModifiedDate(blogsEntry.getModifiedDate());
18768                    blogsEntryImpl.setTitle(blogsEntry.getTitle());
18769                    blogsEntryImpl.setSubtitle(blogsEntry.getSubtitle());
18770                    blogsEntryImpl.setUrlTitle(blogsEntry.getUrlTitle());
18771                    blogsEntryImpl.setDescription(blogsEntry.getDescription());
18772                    blogsEntryImpl.setContent(blogsEntry.getContent());
18773                    blogsEntryImpl.setDisplayDate(blogsEntry.getDisplayDate());
18774                    blogsEntryImpl.setAllowPingbacks(blogsEntry.isAllowPingbacks());
18775                    blogsEntryImpl.setAllowTrackbacks(blogsEntry.isAllowTrackbacks());
18776                    blogsEntryImpl.setTrackbacks(blogsEntry.getTrackbacks());
18777                    blogsEntryImpl.setCoverImageCaption(blogsEntry.getCoverImageCaption());
18778                    blogsEntryImpl.setCoverImageFileEntryId(blogsEntry.getCoverImageFileEntryId());
18779                    blogsEntryImpl.setCoverImageURL(blogsEntry.getCoverImageURL());
18780                    blogsEntryImpl.setSmallImage(blogsEntry.isSmallImage());
18781                    blogsEntryImpl.setSmallImageFileEntryId(blogsEntry.getSmallImageFileEntryId());
18782                    blogsEntryImpl.setSmallImageId(blogsEntry.getSmallImageId());
18783                    blogsEntryImpl.setSmallImageURL(blogsEntry.getSmallImageURL());
18784                    blogsEntryImpl.setLastPublishDate(blogsEntry.getLastPublishDate());
18785                    blogsEntryImpl.setStatus(blogsEntry.getStatus());
18786                    blogsEntryImpl.setStatusByUserId(blogsEntry.getStatusByUserId());
18787                    blogsEntryImpl.setStatusByUserName(blogsEntry.getStatusByUserName());
18788                    blogsEntryImpl.setStatusDate(blogsEntry.getStatusDate());
18789    
18790                    return blogsEntryImpl;
18791            }
18792    
18793            /**
18794             * Returns the blogs entry with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
18795             *
18796             * @param primaryKey the primary key of the blogs entry
18797             * @return the blogs entry
18798             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
18799             */
18800            @Override
18801            public BlogsEntry findByPrimaryKey(Serializable primaryKey)
18802                    throws NoSuchEntryException {
18803                    BlogsEntry blogsEntry = fetchByPrimaryKey(primaryKey);
18804    
18805                    if (blogsEntry == null) {
18806                            if (_log.isWarnEnabled()) {
18807                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
18808                            }
18809    
18810                            throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
18811                                    primaryKey);
18812                    }
18813    
18814                    return blogsEntry;
18815            }
18816    
18817            /**
18818             * Returns the blogs entry with the primary key or throws a {@link NoSuchEntryException} if it could not be found.
18819             *
18820             * @param entryId the primary key of the blogs entry
18821             * @return the blogs entry
18822             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
18823             */
18824            @Override
18825            public BlogsEntry findByPrimaryKey(long entryId)
18826                    throws NoSuchEntryException {
18827                    return findByPrimaryKey((Serializable)entryId);
18828            }
18829    
18830            /**
18831             * Returns the blogs entry with the primary key or returns <code>null</code> if it could not be found.
18832             *
18833             * @param primaryKey the primary key of the blogs entry
18834             * @return the blogs entry, or <code>null</code> if a blogs entry with the primary key could not be found
18835             */
18836            @Override
18837            public BlogsEntry fetchByPrimaryKey(Serializable primaryKey) {
18838                    BlogsEntry blogsEntry = (BlogsEntry)entityCache.getResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18839                                    BlogsEntryImpl.class, primaryKey);
18840    
18841                    if (blogsEntry == _nullBlogsEntry) {
18842                            return null;
18843                    }
18844    
18845                    if (blogsEntry == null) {
18846                            Session session = null;
18847    
18848                            try {
18849                                    session = openSession();
18850    
18851                                    blogsEntry = (BlogsEntry)session.get(BlogsEntryImpl.class,
18852                                                    primaryKey);
18853    
18854                                    if (blogsEntry != null) {
18855                                            cacheResult(blogsEntry);
18856                                    }
18857                                    else {
18858                                            entityCache.putResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18859                                                    BlogsEntryImpl.class, primaryKey, _nullBlogsEntry);
18860                                    }
18861                            }
18862                            catch (Exception e) {
18863                                    entityCache.removeResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18864                                            BlogsEntryImpl.class, primaryKey);
18865    
18866                                    throw processException(e);
18867                            }
18868                            finally {
18869                                    closeSession(session);
18870                            }
18871                    }
18872    
18873                    return blogsEntry;
18874            }
18875    
18876            /**
18877             * Returns the blogs entry with the primary key or returns <code>null</code> if it could not be found.
18878             *
18879             * @param entryId the primary key of the blogs entry
18880             * @return the blogs entry, or <code>null</code> if a blogs entry with the primary key could not be found
18881             */
18882            @Override
18883            public BlogsEntry fetchByPrimaryKey(long entryId) {
18884                    return fetchByPrimaryKey((Serializable)entryId);
18885            }
18886    
18887            @Override
18888            public Map<Serializable, BlogsEntry> fetchByPrimaryKeys(
18889                    Set<Serializable> primaryKeys) {
18890                    if (primaryKeys.isEmpty()) {
18891                            return Collections.emptyMap();
18892                    }
18893    
18894                    Map<Serializable, BlogsEntry> map = new HashMap<Serializable, BlogsEntry>();
18895    
18896                    if (primaryKeys.size() == 1) {
18897                            Iterator<Serializable> iterator = primaryKeys.iterator();
18898    
18899                            Serializable primaryKey = iterator.next();
18900    
18901                            BlogsEntry blogsEntry = fetchByPrimaryKey(primaryKey);
18902    
18903                            if (blogsEntry != null) {
18904                                    map.put(primaryKey, blogsEntry);
18905                            }
18906    
18907                            return map;
18908                    }
18909    
18910                    Set<Serializable> uncachedPrimaryKeys = null;
18911    
18912                    for (Serializable primaryKey : primaryKeys) {
18913                            BlogsEntry blogsEntry = (BlogsEntry)entityCache.getResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18914                                            BlogsEntryImpl.class, primaryKey);
18915    
18916                            if (blogsEntry == null) {
18917                                    if (uncachedPrimaryKeys == null) {
18918                                            uncachedPrimaryKeys = new HashSet<Serializable>();
18919                                    }
18920    
18921                                    uncachedPrimaryKeys.add(primaryKey);
18922                            }
18923                            else {
18924                                    map.put(primaryKey, blogsEntry);
18925                            }
18926                    }
18927    
18928                    if (uncachedPrimaryKeys == null) {
18929                            return map;
18930                    }
18931    
18932                    StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
18933                                    1);
18934    
18935                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE_PKS_IN);
18936    
18937                    for (Serializable primaryKey : uncachedPrimaryKeys) {
18938                            query.append(String.valueOf(primaryKey));
18939    
18940                            query.append(StringPool.COMMA);
18941                    }
18942    
18943                    query.setIndex(query.index() - 1);
18944    
18945                    query.append(StringPool.CLOSE_PARENTHESIS);
18946    
18947                    String sql = query.toString();
18948    
18949                    Session session = null;
18950    
18951                    try {
18952                            session = openSession();
18953    
18954                            Query q = session.createQuery(sql);
18955    
18956                            for (BlogsEntry blogsEntry : (List<BlogsEntry>)q.list()) {
18957                                    map.put(blogsEntry.getPrimaryKeyObj(), blogsEntry);
18958    
18959                                    cacheResult(blogsEntry);
18960    
18961                                    uncachedPrimaryKeys.remove(blogsEntry.getPrimaryKeyObj());
18962                            }
18963    
18964                            for (Serializable primaryKey : uncachedPrimaryKeys) {
18965                                    entityCache.putResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18966                                            BlogsEntryImpl.class, primaryKey, _nullBlogsEntry);
18967                            }
18968                    }
18969                    catch (Exception e) {
18970                            throw processException(e);
18971                    }
18972                    finally {
18973                            closeSession(session);
18974                    }
18975    
18976                    return map;
18977            }
18978    
18979            /**
18980             * Returns all the blogs entries.
18981             *
18982             * @return the blogs entries
18983             */
18984            @Override
18985            public List<BlogsEntry> findAll() {
18986                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
18987            }
18988    
18989            /**
18990             * Returns a range of all the blogs entries.
18991             *
18992             * <p>
18993             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
18994             * </p>
18995             *
18996             * @param start the lower bound of the range of blogs entries
18997             * @param end the upper bound of the range of blogs entries (not inclusive)
18998             * @return the range of blogs entries
18999             */
19000            @Override
19001            public List<BlogsEntry> findAll(int start, int end) {
19002                    return findAll(start, end, null);
19003            }
19004    
19005            /**
19006             * Returns an ordered range of all the blogs entries.
19007             *
19008             * <p>
19009             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
19010             * </p>
19011             *
19012             * @param start the lower bound of the range of blogs entries
19013             * @param end the upper bound of the range of blogs entries (not inclusive)
19014             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
19015             * @return the ordered range of blogs entries
19016             */
19017            @Override
19018            public List<BlogsEntry> findAll(int start, int end,
19019                    OrderByComparator<BlogsEntry> orderByComparator) {
19020                    return findAll(start, end, orderByComparator, true);
19021            }
19022    
19023            /**
19024             * Returns an ordered range of all the blogs entries.
19025             *
19026             * <p>
19027             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
19028             * </p>
19029             *
19030             * @param start the lower bound of the range of blogs entries
19031             * @param end the upper bound of the range of blogs entries (not inclusive)
19032             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
19033             * @param retrieveFromCache whether to retrieve from the finder cache
19034             * @return the ordered range of blogs entries
19035             */
19036            @Override
19037            public List<BlogsEntry> findAll(int start, int end,
19038                    OrderByComparator<BlogsEntry> orderByComparator,
19039                    boolean retrieveFromCache) {
19040                    boolean pagination = true;
19041                    FinderPath finderPath = null;
19042                    Object[] finderArgs = null;
19043    
19044                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
19045                                    (orderByComparator == null)) {
19046                            pagination = false;
19047                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
19048                            finderArgs = FINDER_ARGS_EMPTY;
19049                    }
19050                    else {
19051                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
19052                            finderArgs = new Object[] { start, end, orderByComparator };
19053                    }
19054    
19055                    List<BlogsEntry> list = null;
19056    
19057                    if (retrieveFromCache) {
19058                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
19059                                            finderArgs, this);
19060                    }
19061    
19062                    if (list == null) {
19063                            StringBundler query = null;
19064                            String sql = null;
19065    
19066                            if (orderByComparator != null) {
19067                                    query = new StringBundler(2 +
19068                                                    (orderByComparator.getOrderByFields().length * 3));
19069    
19070                                    query.append(_SQL_SELECT_BLOGSENTRY);
19071    
19072                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
19073                                            orderByComparator);
19074    
19075                                    sql = query.toString();
19076                            }
19077                            else {
19078                                    sql = _SQL_SELECT_BLOGSENTRY;
19079    
19080                                    if (pagination) {
19081                                            sql = sql.concat(BlogsEntryModelImpl.ORDER_BY_JPQL);
19082                                    }
19083                            }
19084    
19085                            Session session = null;
19086    
19087                            try {
19088                                    session = openSession();
19089    
19090                                    Query q = session.createQuery(sql);
19091    
19092                                    if (!pagination) {
19093                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
19094                                                            start, end, false);
19095    
19096                                            Collections.sort(list);
19097    
19098                                            list = Collections.unmodifiableList(list);
19099                                    }
19100                                    else {
19101                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
19102                                                            start, end);
19103                                    }
19104    
19105                                    cacheResult(list);
19106    
19107                                    finderCache.putResult(finderPath, finderArgs, list);
19108                            }
19109                            catch (Exception e) {
19110                                    finderCache.removeResult(finderPath, finderArgs);
19111    
19112                                    throw processException(e);
19113                            }
19114                            finally {
19115                                    closeSession(session);
19116                            }
19117                    }
19118    
19119                    return list;
19120            }
19121    
19122            /**
19123             * Removes all the blogs entries from the database.
19124             *
19125             */
19126            @Override
19127            public void removeAll() {
19128                    for (BlogsEntry blogsEntry : findAll()) {
19129                            remove(blogsEntry);
19130                    }
19131            }
19132    
19133            /**
19134             * Returns the number of blogs entries.
19135             *
19136             * @return the number of blogs entries
19137             */
19138            @Override
19139            public int countAll() {
19140                    Long count = (Long)finderCache.getResult(FINDER_PATH_COUNT_ALL,
19141                                    FINDER_ARGS_EMPTY, this);
19142    
19143                    if (count == null) {
19144                            Session session = null;
19145    
19146                            try {
19147                                    session = openSession();
19148    
19149                                    Query q = session.createQuery(_SQL_COUNT_BLOGSENTRY);
19150    
19151                                    count = (Long)q.uniqueResult();
19152    
19153                                    finderCache.putResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY,
19154                                            count);
19155                            }
19156                            catch (Exception e) {
19157                                    finderCache.removeResult(FINDER_PATH_COUNT_ALL,
19158                                            FINDER_ARGS_EMPTY);
19159    
19160                                    throw processException(e);
19161                            }
19162                            finally {
19163                                    closeSession(session);
19164                            }
19165                    }
19166    
19167                    return count.intValue();
19168            }
19169    
19170            @Override
19171            public Set<String> getBadColumnNames() {
19172                    return _badColumnNames;
19173            }
19174    
19175            @Override
19176            protected Map<String, Integer> getTableColumnsMap() {
19177                    return BlogsEntryModelImpl.TABLE_COLUMNS_MAP;
19178            }
19179    
19180            /**
19181             * Initializes the blogs entry persistence.
19182             */
19183            public void afterPropertiesSet() {
19184            }
19185    
19186            public void destroy() {
19187                    entityCache.removeCache(BlogsEntryImpl.class.getName());
19188                    finderCache.removeCache(FINDER_CLASS_NAME_ENTITY);
19189                    finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
19190                    finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
19191            }
19192    
19193            @BeanReference(type = CompanyProvider.class)
19194            protected CompanyProvider companyProvider;
19195            protected EntityCache entityCache = EntityCacheUtil.getEntityCache();
19196            protected FinderCache finderCache = FinderCacheUtil.getFinderCache();
19197            private static final String _SQL_SELECT_BLOGSENTRY = "SELECT blogsEntry FROM BlogsEntry blogsEntry";
19198            private static final String _SQL_SELECT_BLOGSENTRY_WHERE_PKS_IN = "SELECT blogsEntry FROM BlogsEntry blogsEntry WHERE entryId IN (";
19199            private static final String _SQL_SELECT_BLOGSENTRY_WHERE = "SELECT blogsEntry FROM BlogsEntry blogsEntry WHERE ";
19200            private static final String _SQL_COUNT_BLOGSENTRY = "SELECT COUNT(blogsEntry) FROM BlogsEntry blogsEntry";
19201            private static final String _SQL_COUNT_BLOGSENTRY_WHERE = "SELECT COUNT(blogsEntry) FROM BlogsEntry blogsEntry WHERE ";
19202            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "blogsEntry.entryId";
19203            private static final String _FILTER_SQL_SELECT_BLOGSENTRY_WHERE = "SELECT DISTINCT {blogsEntry.*} FROM BlogsEntry blogsEntry WHERE ";
19204            private static final String _FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1 =
19205                    "SELECT {BlogsEntry.*} FROM (SELECT DISTINCT blogsEntry.entryId FROM BlogsEntry blogsEntry WHERE ";
19206            private static final String _FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2 =
19207                    ") TEMP_TABLE INNER JOIN BlogsEntry ON TEMP_TABLE.entryId = BlogsEntry.entryId";
19208            private static final String _FILTER_SQL_COUNT_BLOGSENTRY_WHERE = "SELECT COUNT(DISTINCT blogsEntry.entryId) AS COUNT_VALUE FROM BlogsEntry blogsEntry WHERE ";
19209            private static final String _FILTER_ENTITY_ALIAS = "blogsEntry";
19210            private static final String _FILTER_ENTITY_TABLE = "BlogsEntry";
19211            private static final String _ORDER_BY_ENTITY_ALIAS = "blogsEntry.";
19212            private static final String _ORDER_BY_ENTITY_TABLE = "BlogsEntry.";
19213            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No BlogsEntry exists with the primary key ";
19214            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No BlogsEntry exists with the key {";
19215            private static final Log _log = LogFactoryUtil.getLog(BlogsEntryPersistenceImpl.class);
19216            private static final Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
19217                                    "uuid"
19218                            });
19219            private static final BlogsEntry _nullBlogsEntry = new BlogsEntryImpl() {
19220                            @Override
19221                            public Object clone() {
19222                                    return this;
19223                            }
19224    
19225                            @Override
19226                            public CacheModel<BlogsEntry> toCacheModel() {
19227                                    return _nullBlogsEntryCacheModel;
19228                            }
19229                    };
19230    
19231            private static final CacheModel<BlogsEntry> _nullBlogsEntryCacheModel = new CacheModel<BlogsEntry>() {
19232                            @Override
19233                            public BlogsEntry toEntityModel() {
19234                                    return _nullBlogsEntry;
19235                            }
19236                    };
19237    }