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.blogs.kernel.exception.NoSuchEntryException;
020    import com.liferay.blogs.kernel.model.BlogsEntry;
021    import com.liferay.blogs.kernel.service.persistence.BlogsEntryPersistence;
022    
023    import com.liferay.portal.kernel.bean.BeanReference;
024    import com.liferay.portal.kernel.dao.orm.EntityCache;
025    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
026    import com.liferay.portal.kernel.dao.orm.FinderCache;
027    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
028    import com.liferay.portal.kernel.dao.orm.FinderPath;
029    import com.liferay.portal.kernel.dao.orm.Query;
030    import com.liferay.portal.kernel.dao.orm.QueryPos;
031    import com.liferay.portal.kernel.dao.orm.QueryUtil;
032    import com.liferay.portal.kernel.dao.orm.SQLQuery;
033    import com.liferay.portal.kernel.dao.orm.Session;
034    import com.liferay.portal.kernel.exception.SystemException;
035    import com.liferay.portal.kernel.log.Log;
036    import com.liferay.portal.kernel.log.LogFactoryUtil;
037    import com.liferay.portal.kernel.model.CacheModel;
038    import com.liferay.portal.kernel.sanitizer.Sanitizer;
039    import com.liferay.portal.kernel.sanitizer.SanitizerException;
040    import com.liferay.portal.kernel.sanitizer.SanitizerUtil;
041    import com.liferay.portal.kernel.security.auth.PrincipalThreadLocal;
042    import com.liferay.portal.kernel.security.permission.InlineSQLHelperUtil;
043    import com.liferay.portal.kernel.service.ServiceContext;
044    import com.liferay.portal.kernel.service.ServiceContextThreadLocal;
045    import com.liferay.portal.kernel.service.persistence.CompanyProvider;
046    import com.liferay.portal.kernel.service.persistence.CompanyProviderWrapper;
047    import com.liferay.portal.kernel.service.persistence.impl.BasePersistenceImpl;
048    import com.liferay.portal.kernel.util.ArrayUtil;
049    import com.liferay.portal.kernel.util.ContentTypes;
050    import com.liferay.portal.kernel.util.GetterUtil;
051    import com.liferay.portal.kernel.util.OrderByComparator;
052    import com.liferay.portal.kernel.util.SetUtil;
053    import com.liferay.portal.kernel.util.StringBundler;
054    import com.liferay.portal.kernel.util.StringPool;
055    import com.liferay.portal.kernel.util.StringUtil;
056    import com.liferay.portal.kernel.util.Validator;
057    import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
058    
059    import com.liferay.portlet.blogs.model.impl.BlogsEntryImpl;
060    import com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl;
061    
062    import java.io.Serializable;
063    
064    import java.sql.Timestamp;
065    
066    import java.util.Arrays;
067    import java.util.Collections;
068    import java.util.Date;
069    import java.util.HashMap;
070    import java.util.HashSet;
071    import java.util.Iterator;
072    import java.util.List;
073    import java.util.Map;
074    import java.util.Objects;
075    import java.util.Set;
076    
077    /**
078     * The persistence implementation for the blogs entry service.
079     *
080     * <p>
081     * Caching information and settings can be found in <code>portal.properties</code>
082     * </p>
083     *
084     * @author Brian Wing Shun Chan
085     * @see BlogsEntryPersistence
086     * @see com.liferay.blogs.kernel.service.persistence.BlogsEntryUtil
087     * @generated
088     */
089    @ProviderType
090    public class BlogsEntryPersistenceImpl extends BasePersistenceImpl<BlogsEntry>
091            implements BlogsEntryPersistence {
092            /*
093             * NOTE FOR DEVELOPERS:
094             *
095             * 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.
096             */
097            public static final String FINDER_CLASS_NAME_ENTITY = BlogsEntryImpl.class.getName();
098            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
099                    ".List1";
100            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
101                    ".List2";
102            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
103                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
104                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
105            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
106                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
107                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
108            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
109                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
110                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
111            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
112                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
113                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
114                            new String[] {
115                                    String.class.getName(),
116                                    
117                            Integer.class.getName(), Integer.class.getName(),
118                                    OrderByComparator.class.getName()
119                            });
120            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
121                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
122                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
123                            new String[] { String.class.getName() },
124                            BlogsEntryModelImpl.UUID_COLUMN_BITMASK |
125                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
126                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
127            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
128                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
129                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
130                            new String[] { String.class.getName() });
131    
132            /**
133             * Returns all the blogs entries where uuid = &#63;.
134             *
135             * @param uuid the uuid
136             * @return the matching blogs entries
137             */
138            @Override
139            public List<BlogsEntry> findByUuid(String uuid) {
140                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
141            }
142    
143            /**
144             * Returns a range of all the blogs entries where uuid = &#63;.
145             *
146             * <p>
147             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
148             * </p>
149             *
150             * @param uuid the uuid
151             * @param start the lower bound of the range of blogs entries
152             * @param end the upper bound of the range of blogs entries (not inclusive)
153             * @return the range of matching blogs entries
154             */
155            @Override
156            public List<BlogsEntry> findByUuid(String uuid, int start, int end) {
157                    return findByUuid(uuid, start, end, null);
158            }
159    
160            /**
161             * Returns an ordered range of all the blogs entries where uuid = &#63;.
162             *
163             * <p>
164             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
165             * </p>
166             *
167             * @param uuid the uuid
168             * @param start the lower bound of the range of blogs entries
169             * @param end the upper bound of the range of blogs entries (not inclusive)
170             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
171             * @return the ordered range of matching blogs entries
172             */
173            @Override
174            public List<BlogsEntry> findByUuid(String uuid, int start, int end,
175                    OrderByComparator<BlogsEntry> orderByComparator) {
176                    return findByUuid(uuid, start, end, orderByComparator, true);
177            }
178    
179            /**
180             * Returns an ordered range of all the blogs entries where uuid = &#63;.
181             *
182             * <p>
183             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
184             * </p>
185             *
186             * @param uuid the uuid
187             * @param start the lower bound of the range of blogs entries
188             * @param end the upper bound of the range of blogs entries (not inclusive)
189             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
190             * @param retrieveFromCache whether to retrieve from the finder cache
191             * @return the ordered range of matching blogs entries
192             */
193            @Override
194            public List<BlogsEntry> findByUuid(String uuid, int start, int end,
195                    OrderByComparator<BlogsEntry> orderByComparator,
196                    boolean retrieveFromCache) {
197                    boolean pagination = true;
198                    FinderPath finderPath = null;
199                    Object[] finderArgs = null;
200    
201                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
202                                    (orderByComparator == null)) {
203                            pagination = false;
204                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
205                            finderArgs = new Object[] { uuid };
206                    }
207                    else {
208                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
209                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
210                    }
211    
212                    List<BlogsEntry> list = null;
213    
214                    if (retrieveFromCache) {
215                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
216                                            finderArgs, this);
217    
218                            if ((list != null) && !list.isEmpty()) {
219                                    for (BlogsEntry blogsEntry : list) {
220                                            if (!Objects.equals(uuid, blogsEntry.getUuid())) {
221                                                    list = null;
222    
223                                                    break;
224                                            }
225                                    }
226                            }
227                    }
228    
229                    if (list == null) {
230                            StringBundler query = null;
231    
232                            if (orderByComparator != null) {
233                                    query = new StringBundler(3 +
234                                                    (orderByComparator.getOrderByFields().length * 2));
235                            }
236                            else {
237                                    query = new StringBundler(3);
238                            }
239    
240                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
241    
242                            boolean bindUuid = false;
243    
244                            if (uuid == null) {
245                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
246                            }
247                            else if (uuid.equals(StringPool.BLANK)) {
248                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
249                            }
250                            else {
251                                    bindUuid = true;
252    
253                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
254                            }
255    
256                            if (orderByComparator != null) {
257                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
258                                            orderByComparator);
259                            }
260                            else
261                             if (pagination) {
262                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
263                            }
264    
265                            String sql = query.toString();
266    
267                            Session session = null;
268    
269                            try {
270                                    session = openSession();
271    
272                                    Query q = session.createQuery(sql);
273    
274                                    QueryPos qPos = QueryPos.getInstance(q);
275    
276                                    if (bindUuid) {
277                                            qPos.add(uuid);
278                                    }
279    
280                                    if (!pagination) {
281                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
282                                                            start, end, false);
283    
284                                            Collections.sort(list);
285    
286                                            list = Collections.unmodifiableList(list);
287                                    }
288                                    else {
289                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
290                                                            start, end);
291                                    }
292    
293                                    cacheResult(list);
294    
295                                    finderCache.putResult(finderPath, finderArgs, list);
296                            }
297                            catch (Exception e) {
298                                    finderCache.removeResult(finderPath, finderArgs);
299    
300                                    throw processException(e);
301                            }
302                            finally {
303                                    closeSession(session);
304                            }
305                    }
306    
307                    return list;
308            }
309    
310            /**
311             * Returns the first blogs entry in the ordered set where uuid = &#63;.
312             *
313             * @param uuid the uuid
314             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
315             * @return the first matching blogs entry
316             * @throws NoSuchEntryException if a matching blogs entry could not be found
317             */
318            @Override
319            public BlogsEntry findByUuid_First(String uuid,
320                    OrderByComparator<BlogsEntry> orderByComparator)
321                    throws NoSuchEntryException {
322                    BlogsEntry blogsEntry = fetchByUuid_First(uuid, orderByComparator);
323    
324                    if (blogsEntry != null) {
325                            return blogsEntry;
326                    }
327    
328                    StringBundler msg = new StringBundler(4);
329    
330                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
331    
332                    msg.append("uuid=");
333                    msg.append(uuid);
334    
335                    msg.append(StringPool.CLOSE_CURLY_BRACE);
336    
337                    throw new NoSuchEntryException(msg.toString());
338            }
339    
340            /**
341             * Returns the first blogs entry in the ordered set where uuid = &#63;.
342             *
343             * @param uuid the uuid
344             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
345             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
346             */
347            @Override
348            public BlogsEntry fetchByUuid_First(String uuid,
349                    OrderByComparator<BlogsEntry> orderByComparator) {
350                    List<BlogsEntry> list = findByUuid(uuid, 0, 1, orderByComparator);
351    
352                    if (!list.isEmpty()) {
353                            return list.get(0);
354                    }
355    
356                    return null;
357            }
358    
359            /**
360             * Returns the last blogs entry in the ordered set where uuid = &#63;.
361             *
362             * @param uuid the uuid
363             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
364             * @return the last matching blogs entry
365             * @throws NoSuchEntryException if a matching blogs entry could not be found
366             */
367            @Override
368            public BlogsEntry findByUuid_Last(String uuid,
369                    OrderByComparator<BlogsEntry> orderByComparator)
370                    throws NoSuchEntryException {
371                    BlogsEntry blogsEntry = fetchByUuid_Last(uuid, orderByComparator);
372    
373                    if (blogsEntry != null) {
374                            return blogsEntry;
375                    }
376    
377                    StringBundler msg = new StringBundler(4);
378    
379                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
380    
381                    msg.append("uuid=");
382                    msg.append(uuid);
383    
384                    msg.append(StringPool.CLOSE_CURLY_BRACE);
385    
386                    throw new NoSuchEntryException(msg.toString());
387            }
388    
389            /**
390             * Returns the last blogs entry in the ordered set where uuid = &#63;.
391             *
392             * @param uuid the uuid
393             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
394             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
395             */
396            @Override
397            public BlogsEntry fetchByUuid_Last(String uuid,
398                    OrderByComparator<BlogsEntry> orderByComparator) {
399                    int count = countByUuid(uuid);
400    
401                    if (count == 0) {
402                            return null;
403                    }
404    
405                    List<BlogsEntry> list = findByUuid(uuid, count - 1, count,
406                                    orderByComparator);
407    
408                    if (!list.isEmpty()) {
409                            return list.get(0);
410                    }
411    
412                    return null;
413            }
414    
415            /**
416             * Returns the blogs entries before and after the current blogs entry in the ordered set where uuid = &#63;.
417             *
418             * @param entryId the primary key of the current blogs entry
419             * @param uuid the uuid
420             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
421             * @return the previous, current, and next blogs entry
422             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
423             */
424            @Override
425            public BlogsEntry[] findByUuid_PrevAndNext(long entryId, String uuid,
426                    OrderByComparator<BlogsEntry> orderByComparator)
427                    throws NoSuchEntryException {
428                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
429    
430                    Session session = null;
431    
432                    try {
433                            session = openSession();
434    
435                            BlogsEntry[] array = new BlogsEntryImpl[3];
436    
437                            array[0] = getByUuid_PrevAndNext(session, blogsEntry, uuid,
438                                            orderByComparator, true);
439    
440                            array[1] = blogsEntry;
441    
442                            array[2] = getByUuid_PrevAndNext(session, blogsEntry, uuid,
443                                            orderByComparator, false);
444    
445                            return array;
446                    }
447                    catch (Exception e) {
448                            throw processException(e);
449                    }
450                    finally {
451                            closeSession(session);
452                    }
453            }
454    
455            protected BlogsEntry getByUuid_PrevAndNext(Session session,
456                    BlogsEntry blogsEntry, String uuid,
457                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
458                    StringBundler query = null;
459    
460                    if (orderByComparator != null) {
461                            query = new StringBundler(4 +
462                                            (orderByComparator.getOrderByConditionFields().length * 3) +
463                                            (orderByComparator.getOrderByFields().length * 3));
464                    }
465                    else {
466                            query = new StringBundler(3);
467                    }
468    
469                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
470    
471                    boolean bindUuid = false;
472    
473                    if (uuid == null) {
474                            query.append(_FINDER_COLUMN_UUID_UUID_1);
475                    }
476                    else if (uuid.equals(StringPool.BLANK)) {
477                            query.append(_FINDER_COLUMN_UUID_UUID_3);
478                    }
479                    else {
480                            bindUuid = true;
481    
482                            query.append(_FINDER_COLUMN_UUID_UUID_2);
483                    }
484    
485                    if (orderByComparator != null) {
486                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
487    
488                            if (orderByConditionFields.length > 0) {
489                                    query.append(WHERE_AND);
490                            }
491    
492                            for (int i = 0; i < orderByConditionFields.length; i++) {
493                                    query.append(_ORDER_BY_ENTITY_ALIAS);
494                                    query.append(orderByConditionFields[i]);
495    
496                                    if ((i + 1) < orderByConditionFields.length) {
497                                            if (orderByComparator.isAscending() ^ previous) {
498                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
499                                            }
500                                            else {
501                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
502                                            }
503                                    }
504                                    else {
505                                            if (orderByComparator.isAscending() ^ previous) {
506                                                    query.append(WHERE_GREATER_THAN);
507                                            }
508                                            else {
509                                                    query.append(WHERE_LESSER_THAN);
510                                            }
511                                    }
512                            }
513    
514                            query.append(ORDER_BY_CLAUSE);
515    
516                            String[] orderByFields = orderByComparator.getOrderByFields();
517    
518                            for (int i = 0; i < orderByFields.length; i++) {
519                                    query.append(_ORDER_BY_ENTITY_ALIAS);
520                                    query.append(orderByFields[i]);
521    
522                                    if ((i + 1) < orderByFields.length) {
523                                            if (orderByComparator.isAscending() ^ previous) {
524                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
525                                            }
526                                            else {
527                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
528                                            }
529                                    }
530                                    else {
531                                            if (orderByComparator.isAscending() ^ previous) {
532                                                    query.append(ORDER_BY_ASC);
533                                            }
534                                            else {
535                                                    query.append(ORDER_BY_DESC);
536                                            }
537                                    }
538                            }
539                    }
540                    else {
541                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
542                    }
543    
544                    String sql = query.toString();
545    
546                    Query q = session.createQuery(sql);
547    
548                    q.setFirstResult(0);
549                    q.setMaxResults(2);
550    
551                    QueryPos qPos = QueryPos.getInstance(q);
552    
553                    if (bindUuid) {
554                            qPos.add(uuid);
555                    }
556    
557                    if (orderByComparator != null) {
558                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
559    
560                            for (Object value : values) {
561                                    qPos.add(value);
562                            }
563                    }
564    
565                    List<BlogsEntry> list = q.list();
566    
567                    if (list.size() == 2) {
568                            return list.get(1);
569                    }
570                    else {
571                            return null;
572                    }
573            }
574    
575            /**
576             * Removes all the blogs entries where uuid = &#63; from the database.
577             *
578             * @param uuid the uuid
579             */
580            @Override
581            public void removeByUuid(String uuid) {
582                    for (BlogsEntry blogsEntry : findByUuid(uuid, QueryUtil.ALL_POS,
583                                    QueryUtil.ALL_POS, null)) {
584                            remove(blogsEntry);
585                    }
586            }
587    
588            /**
589             * Returns the number of blogs entries where uuid = &#63;.
590             *
591             * @param uuid the uuid
592             * @return the number of matching blogs entries
593             */
594            @Override
595            public int countByUuid(String uuid) {
596                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
597    
598                    Object[] finderArgs = new Object[] { uuid };
599    
600                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
601    
602                    if (count == null) {
603                            StringBundler query = new StringBundler(2);
604    
605                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
606    
607                            boolean bindUuid = false;
608    
609                            if (uuid == null) {
610                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
611                            }
612                            else if (uuid.equals(StringPool.BLANK)) {
613                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
614                            }
615                            else {
616                                    bindUuid = true;
617    
618                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
619                            }
620    
621                            String sql = query.toString();
622    
623                            Session session = null;
624    
625                            try {
626                                    session = openSession();
627    
628                                    Query q = session.createQuery(sql);
629    
630                                    QueryPos qPos = QueryPos.getInstance(q);
631    
632                                    if (bindUuid) {
633                                            qPos.add(uuid);
634                                    }
635    
636                                    count = (Long)q.uniqueResult();
637    
638                                    finderCache.putResult(finderPath, finderArgs, count);
639                            }
640                            catch (Exception e) {
641                                    finderCache.removeResult(finderPath, finderArgs);
642    
643                                    throw processException(e);
644                            }
645                            finally {
646                                    closeSession(session);
647                            }
648                    }
649    
650                    return count.intValue();
651            }
652    
653            private static final String _FINDER_COLUMN_UUID_UUID_1 = "blogsEntry.uuid IS NULL";
654            private static final String _FINDER_COLUMN_UUID_UUID_2 = "blogsEntry.uuid = ?";
655            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(blogsEntry.uuid IS NULL OR blogsEntry.uuid = '')";
656            public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
657                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
658                            FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
659                            new String[] { String.class.getName(), Long.class.getName() },
660                            BlogsEntryModelImpl.UUID_COLUMN_BITMASK |
661                            BlogsEntryModelImpl.GROUPID_COLUMN_BITMASK);
662            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
663                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
664                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
665                            new String[] { String.class.getName(), Long.class.getName() });
666    
667            /**
668             * Returns the blogs entry where uuid = &#63; and groupId = &#63; or throws a {@link NoSuchEntryException} if it could not be found.
669             *
670             * @param uuid the uuid
671             * @param groupId the group ID
672             * @return the matching blogs entry
673             * @throws NoSuchEntryException if a matching blogs entry could not be found
674             */
675            @Override
676            public BlogsEntry findByUUID_G(String uuid, long groupId)
677                    throws NoSuchEntryException {
678                    BlogsEntry blogsEntry = fetchByUUID_G(uuid, groupId);
679    
680                    if (blogsEntry == null) {
681                            StringBundler msg = new StringBundler(6);
682    
683                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
684    
685                            msg.append("uuid=");
686                            msg.append(uuid);
687    
688                            msg.append(", groupId=");
689                            msg.append(groupId);
690    
691                            msg.append(StringPool.CLOSE_CURLY_BRACE);
692    
693                            if (_log.isDebugEnabled()) {
694                                    _log.debug(msg.toString());
695                            }
696    
697                            throw new NoSuchEntryException(msg.toString());
698                    }
699    
700                    return blogsEntry;
701            }
702    
703            /**
704             * 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.
705             *
706             * @param uuid the uuid
707             * @param groupId the group ID
708             * @return the matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
709             */
710            @Override
711            public BlogsEntry fetchByUUID_G(String uuid, long groupId) {
712                    return fetchByUUID_G(uuid, groupId, true);
713            }
714    
715            /**
716             * 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.
717             *
718             * @param uuid the uuid
719             * @param groupId the group ID
720             * @param retrieveFromCache whether to retrieve from the finder cache
721             * @return the matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
722             */
723            @Override
724            public BlogsEntry fetchByUUID_G(String uuid, long groupId,
725                    boolean retrieveFromCache) {
726                    Object[] finderArgs = new Object[] { uuid, groupId };
727    
728                    Object result = null;
729    
730                    if (retrieveFromCache) {
731                            result = finderCache.getResult(FINDER_PATH_FETCH_BY_UUID_G,
732                                            finderArgs, this);
733                    }
734    
735                    if (result instanceof BlogsEntry) {
736                            BlogsEntry blogsEntry = (BlogsEntry)result;
737    
738                            if (!Objects.equals(uuid, blogsEntry.getUuid()) ||
739                                            (groupId != blogsEntry.getGroupId())) {
740                                    result = null;
741                            }
742                    }
743    
744                    if (result == null) {
745                            StringBundler query = new StringBundler(4);
746    
747                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
748    
749                            boolean bindUuid = false;
750    
751                            if (uuid == null) {
752                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
753                            }
754                            else if (uuid.equals(StringPool.BLANK)) {
755                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
756                            }
757                            else {
758                                    bindUuid = true;
759    
760                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
761                            }
762    
763                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
764    
765                            String sql = query.toString();
766    
767                            Session session = null;
768    
769                            try {
770                                    session = openSession();
771    
772                                    Query q = session.createQuery(sql);
773    
774                                    QueryPos qPos = QueryPos.getInstance(q);
775    
776                                    if (bindUuid) {
777                                            qPos.add(uuid);
778                                    }
779    
780                                    qPos.add(groupId);
781    
782                                    List<BlogsEntry> list = q.list();
783    
784                                    if (list.isEmpty()) {
785                                            finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G,
786                                                    finderArgs, list);
787                                    }
788                                    else {
789                                            BlogsEntry blogsEntry = list.get(0);
790    
791                                            result = blogsEntry;
792    
793                                            cacheResult(blogsEntry);
794    
795                                            if ((blogsEntry.getUuid() == null) ||
796                                                            !blogsEntry.getUuid().equals(uuid) ||
797                                                            (blogsEntry.getGroupId() != groupId)) {
798                                                    finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G,
799                                                            finderArgs, blogsEntry);
800                                            }
801                                    }
802                            }
803                            catch (Exception e) {
804                                    finderCache.removeResult(FINDER_PATH_FETCH_BY_UUID_G, finderArgs);
805    
806                                    throw processException(e);
807                            }
808                            finally {
809                                    closeSession(session);
810                            }
811                    }
812    
813                    if (result instanceof List<?>) {
814                            return null;
815                    }
816                    else {
817                            return (BlogsEntry)result;
818                    }
819            }
820    
821            /**
822             * Removes the blogs entry where uuid = &#63; and groupId = &#63; from the database.
823             *
824             * @param uuid the uuid
825             * @param groupId the group ID
826             * @return the blogs entry that was removed
827             */
828            @Override
829            public BlogsEntry removeByUUID_G(String uuid, long groupId)
830                    throws NoSuchEntryException {
831                    BlogsEntry blogsEntry = findByUUID_G(uuid, groupId);
832    
833                    return remove(blogsEntry);
834            }
835    
836            /**
837             * Returns the number of blogs entries where uuid = &#63; and groupId = &#63;.
838             *
839             * @param uuid the uuid
840             * @param groupId the group ID
841             * @return the number of matching blogs entries
842             */
843            @Override
844            public int countByUUID_G(String uuid, long groupId) {
845                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_G;
846    
847                    Object[] finderArgs = new Object[] { uuid, groupId };
848    
849                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
850    
851                    if (count == null) {
852                            StringBundler query = new StringBundler(3);
853    
854                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
855    
856                            boolean bindUuid = false;
857    
858                            if (uuid == null) {
859                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
860                            }
861                            else if (uuid.equals(StringPool.BLANK)) {
862                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
863                            }
864                            else {
865                                    bindUuid = true;
866    
867                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
868                            }
869    
870                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
871    
872                            String sql = query.toString();
873    
874                            Session session = null;
875    
876                            try {
877                                    session = openSession();
878    
879                                    Query q = session.createQuery(sql);
880    
881                                    QueryPos qPos = QueryPos.getInstance(q);
882    
883                                    if (bindUuid) {
884                                            qPos.add(uuid);
885                                    }
886    
887                                    qPos.add(groupId);
888    
889                                    count = (Long)q.uniqueResult();
890    
891                                    finderCache.putResult(finderPath, finderArgs, count);
892                            }
893                            catch (Exception e) {
894                                    finderCache.removeResult(finderPath, finderArgs);
895    
896                                    throw processException(e);
897                            }
898                            finally {
899                                    closeSession(session);
900                            }
901                    }
902    
903                    return count.intValue();
904            }
905    
906            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "blogsEntry.uuid IS NULL AND ";
907            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "blogsEntry.uuid = ? AND ";
908            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(blogsEntry.uuid IS NULL OR blogsEntry.uuid = '') AND ";
909            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "blogsEntry.groupId = ?";
910            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
911                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
912                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C",
913                            new String[] {
914                                    String.class.getName(), Long.class.getName(),
915                                    
916                            Integer.class.getName(), Integer.class.getName(),
917                                    OrderByComparator.class.getName()
918                            });
919            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
920                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
921                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
922                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
923                            new String[] { String.class.getName(), Long.class.getName() },
924                            BlogsEntryModelImpl.UUID_COLUMN_BITMASK |
925                            BlogsEntryModelImpl.COMPANYID_COLUMN_BITMASK |
926                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
927                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
928            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
929                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
930                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
931                            new String[] { String.class.getName(), Long.class.getName() });
932    
933            /**
934             * Returns all the blogs entries where uuid = &#63; and companyId = &#63;.
935             *
936             * @param uuid the uuid
937             * @param companyId the company ID
938             * @return the matching blogs entries
939             */
940            @Override
941            public List<BlogsEntry> findByUuid_C(String uuid, long companyId) {
942                    return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
943                            QueryUtil.ALL_POS, null);
944            }
945    
946            /**
947             * Returns a range of all the blogs entries where uuid = &#63; and companyId = &#63;.
948             *
949             * <p>
950             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
951             * </p>
952             *
953             * @param uuid the uuid
954             * @param companyId the company ID
955             * @param start the lower bound of the range of blogs entries
956             * @param end the upper bound of the range of blogs entries (not inclusive)
957             * @return the range of matching blogs entries
958             */
959            @Override
960            public List<BlogsEntry> findByUuid_C(String uuid, long companyId,
961                    int start, int end) {
962                    return findByUuid_C(uuid, companyId, start, end, null);
963            }
964    
965            /**
966             * Returns an ordered range of all the blogs entries where uuid = &#63; and companyId = &#63;.
967             *
968             * <p>
969             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
970             * </p>
971             *
972             * @param uuid the uuid
973             * @param companyId the company ID
974             * @param start the lower bound of the range of blogs entries
975             * @param end the upper bound of the range of blogs entries (not inclusive)
976             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
977             * @return the ordered range of matching blogs entries
978             */
979            @Override
980            public List<BlogsEntry> findByUuid_C(String uuid, long companyId,
981                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator) {
982                    return findByUuid_C(uuid, companyId, start, end, orderByComparator, true);
983            }
984    
985            /**
986             * Returns an ordered range of all the blogs entries where uuid = &#63; and companyId = &#63;.
987             *
988             * <p>
989             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
990             * </p>
991             *
992             * @param uuid the uuid
993             * @param companyId the company ID
994             * @param start the lower bound of the range of blogs entries
995             * @param end the upper bound of the range of blogs entries (not inclusive)
996             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
997             * @param retrieveFromCache whether to retrieve from the finder cache
998             * @return the ordered range of matching blogs entries
999             */
1000            @Override
1001            public List<BlogsEntry> findByUuid_C(String uuid, long companyId,
1002                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator,
1003                    boolean retrieveFromCache) {
1004                    boolean pagination = true;
1005                    FinderPath finderPath = null;
1006                    Object[] finderArgs = null;
1007    
1008                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1009                                    (orderByComparator == null)) {
1010                            pagination = false;
1011                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
1012                            finderArgs = new Object[] { uuid, companyId };
1013                    }
1014                    else {
1015                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
1016                            finderArgs = new Object[] {
1017                                            uuid, companyId,
1018                                            
1019                                            start, end, orderByComparator
1020                                    };
1021                    }
1022    
1023                    List<BlogsEntry> list = null;
1024    
1025                    if (retrieveFromCache) {
1026                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
1027                                            finderArgs, this);
1028    
1029                            if ((list != null) && !list.isEmpty()) {
1030                                    for (BlogsEntry blogsEntry : list) {
1031                                            if (!Objects.equals(uuid, blogsEntry.getUuid()) ||
1032                                                            (companyId != blogsEntry.getCompanyId())) {
1033                                                    list = null;
1034    
1035                                                    break;
1036                                            }
1037                                    }
1038                            }
1039                    }
1040    
1041                    if (list == null) {
1042                            StringBundler query = null;
1043    
1044                            if (orderByComparator != null) {
1045                                    query = new StringBundler(4 +
1046                                                    (orderByComparator.getOrderByFields().length * 2));
1047                            }
1048                            else {
1049                                    query = new StringBundler(4);
1050                            }
1051    
1052                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
1053    
1054                            boolean bindUuid = false;
1055    
1056                            if (uuid == null) {
1057                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1058                            }
1059                            else if (uuid.equals(StringPool.BLANK)) {
1060                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1061                            }
1062                            else {
1063                                    bindUuid = true;
1064    
1065                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1066                            }
1067    
1068                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1069    
1070                            if (orderByComparator != null) {
1071                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1072                                            orderByComparator);
1073                            }
1074                            else
1075                             if (pagination) {
1076                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
1077                            }
1078    
1079                            String sql = query.toString();
1080    
1081                            Session session = null;
1082    
1083                            try {
1084                                    session = openSession();
1085    
1086                                    Query q = session.createQuery(sql);
1087    
1088                                    QueryPos qPos = QueryPos.getInstance(q);
1089    
1090                                    if (bindUuid) {
1091                                            qPos.add(uuid);
1092                                    }
1093    
1094                                    qPos.add(companyId);
1095    
1096                                    if (!pagination) {
1097                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
1098                                                            start, end, false);
1099    
1100                                            Collections.sort(list);
1101    
1102                                            list = Collections.unmodifiableList(list);
1103                                    }
1104                                    else {
1105                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
1106                                                            start, end);
1107                                    }
1108    
1109                                    cacheResult(list);
1110    
1111                                    finderCache.putResult(finderPath, finderArgs, list);
1112                            }
1113                            catch (Exception e) {
1114                                    finderCache.removeResult(finderPath, finderArgs);
1115    
1116                                    throw processException(e);
1117                            }
1118                            finally {
1119                                    closeSession(session);
1120                            }
1121                    }
1122    
1123                    return list;
1124            }
1125    
1126            /**
1127             * Returns the first blogs entry in the ordered set where uuid = &#63; and companyId = &#63;.
1128             *
1129             * @param uuid the uuid
1130             * @param companyId the company ID
1131             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1132             * @return the first matching blogs entry
1133             * @throws NoSuchEntryException if a matching blogs entry could not be found
1134             */
1135            @Override
1136            public BlogsEntry findByUuid_C_First(String uuid, long companyId,
1137                    OrderByComparator<BlogsEntry> orderByComparator)
1138                    throws NoSuchEntryException {
1139                    BlogsEntry blogsEntry = fetchByUuid_C_First(uuid, companyId,
1140                                    orderByComparator);
1141    
1142                    if (blogsEntry != null) {
1143                            return blogsEntry;
1144                    }
1145    
1146                    StringBundler msg = new StringBundler(6);
1147    
1148                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1149    
1150                    msg.append("uuid=");
1151                    msg.append(uuid);
1152    
1153                    msg.append(", companyId=");
1154                    msg.append(companyId);
1155    
1156                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1157    
1158                    throw new NoSuchEntryException(msg.toString());
1159            }
1160    
1161            /**
1162             * Returns the first blogs entry in the ordered set where uuid = &#63; and companyId = &#63;.
1163             *
1164             * @param uuid the uuid
1165             * @param companyId the company ID
1166             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1167             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
1168             */
1169            @Override
1170            public BlogsEntry fetchByUuid_C_First(String uuid, long companyId,
1171                    OrderByComparator<BlogsEntry> orderByComparator) {
1172                    List<BlogsEntry> list = findByUuid_C(uuid, companyId, 0, 1,
1173                                    orderByComparator);
1174    
1175                    if (!list.isEmpty()) {
1176                            return list.get(0);
1177                    }
1178    
1179                    return null;
1180            }
1181    
1182            /**
1183             * Returns the last blogs entry in the ordered set where uuid = &#63; and companyId = &#63;.
1184             *
1185             * @param uuid the uuid
1186             * @param companyId the company ID
1187             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1188             * @return the last matching blogs entry
1189             * @throws NoSuchEntryException if a matching blogs entry could not be found
1190             */
1191            @Override
1192            public BlogsEntry findByUuid_C_Last(String uuid, long companyId,
1193                    OrderByComparator<BlogsEntry> orderByComparator)
1194                    throws NoSuchEntryException {
1195                    BlogsEntry blogsEntry = fetchByUuid_C_Last(uuid, companyId,
1196                                    orderByComparator);
1197    
1198                    if (blogsEntry != null) {
1199                            return blogsEntry;
1200                    }
1201    
1202                    StringBundler msg = new StringBundler(6);
1203    
1204                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1205    
1206                    msg.append("uuid=");
1207                    msg.append(uuid);
1208    
1209                    msg.append(", companyId=");
1210                    msg.append(companyId);
1211    
1212                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1213    
1214                    throw new NoSuchEntryException(msg.toString());
1215            }
1216    
1217            /**
1218             * Returns the last blogs entry in the ordered set where uuid = &#63; and companyId = &#63;.
1219             *
1220             * @param uuid the uuid
1221             * @param companyId the company ID
1222             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1223             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
1224             */
1225            @Override
1226            public BlogsEntry fetchByUuid_C_Last(String uuid, long companyId,
1227                    OrderByComparator<BlogsEntry> orderByComparator) {
1228                    int count = countByUuid_C(uuid, companyId);
1229    
1230                    if (count == 0) {
1231                            return null;
1232                    }
1233    
1234                    List<BlogsEntry> list = findByUuid_C(uuid, companyId, count - 1, count,
1235                                    orderByComparator);
1236    
1237                    if (!list.isEmpty()) {
1238                            return list.get(0);
1239                    }
1240    
1241                    return null;
1242            }
1243    
1244            /**
1245             * Returns the blogs entries before and after the current blogs entry in the ordered set where uuid = &#63; and companyId = &#63;.
1246             *
1247             * @param entryId the primary key of the current blogs entry
1248             * @param uuid the uuid
1249             * @param companyId the company ID
1250             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1251             * @return the previous, current, and next blogs entry
1252             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
1253             */
1254            @Override
1255            public BlogsEntry[] findByUuid_C_PrevAndNext(long entryId, String uuid,
1256                    long companyId, OrderByComparator<BlogsEntry> orderByComparator)
1257                    throws NoSuchEntryException {
1258                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
1259    
1260                    Session session = null;
1261    
1262                    try {
1263                            session = openSession();
1264    
1265                            BlogsEntry[] array = new BlogsEntryImpl[3];
1266    
1267                            array[0] = getByUuid_C_PrevAndNext(session, blogsEntry, uuid,
1268                                            companyId, orderByComparator, true);
1269    
1270                            array[1] = blogsEntry;
1271    
1272                            array[2] = getByUuid_C_PrevAndNext(session, blogsEntry, uuid,
1273                                            companyId, orderByComparator, false);
1274    
1275                            return array;
1276                    }
1277                    catch (Exception e) {
1278                            throw processException(e);
1279                    }
1280                    finally {
1281                            closeSession(session);
1282                    }
1283            }
1284    
1285            protected BlogsEntry getByUuid_C_PrevAndNext(Session session,
1286                    BlogsEntry blogsEntry, String uuid, long companyId,
1287                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
1288                    StringBundler query = null;
1289    
1290                    if (orderByComparator != null) {
1291                            query = new StringBundler(5 +
1292                                            (orderByComparator.getOrderByConditionFields().length * 3) +
1293                                            (orderByComparator.getOrderByFields().length * 3));
1294                    }
1295                    else {
1296                            query = new StringBundler(4);
1297                    }
1298    
1299                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
1300    
1301                    boolean bindUuid = false;
1302    
1303                    if (uuid == null) {
1304                            query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1305                    }
1306                    else if (uuid.equals(StringPool.BLANK)) {
1307                            query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1308                    }
1309                    else {
1310                            bindUuid = true;
1311    
1312                            query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1313                    }
1314    
1315                    query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1316    
1317                    if (orderByComparator != null) {
1318                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1319    
1320                            if (orderByConditionFields.length > 0) {
1321                                    query.append(WHERE_AND);
1322                            }
1323    
1324                            for (int i = 0; i < orderByConditionFields.length; i++) {
1325                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1326                                    query.append(orderByConditionFields[i]);
1327    
1328                                    if ((i + 1) < orderByConditionFields.length) {
1329                                            if (orderByComparator.isAscending() ^ previous) {
1330                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1331                                            }
1332                                            else {
1333                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1334                                            }
1335                                    }
1336                                    else {
1337                                            if (orderByComparator.isAscending() ^ previous) {
1338                                                    query.append(WHERE_GREATER_THAN);
1339                                            }
1340                                            else {
1341                                                    query.append(WHERE_LESSER_THAN);
1342                                            }
1343                                    }
1344                            }
1345    
1346                            query.append(ORDER_BY_CLAUSE);
1347    
1348                            String[] orderByFields = orderByComparator.getOrderByFields();
1349    
1350                            for (int i = 0; i < orderByFields.length; i++) {
1351                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1352                                    query.append(orderByFields[i]);
1353    
1354                                    if ((i + 1) < orderByFields.length) {
1355                                            if (orderByComparator.isAscending() ^ previous) {
1356                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1357                                            }
1358                                            else {
1359                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1360                                            }
1361                                    }
1362                                    else {
1363                                            if (orderByComparator.isAscending() ^ previous) {
1364                                                    query.append(ORDER_BY_ASC);
1365                                            }
1366                                            else {
1367                                                    query.append(ORDER_BY_DESC);
1368                                            }
1369                                    }
1370                            }
1371                    }
1372                    else {
1373                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
1374                    }
1375    
1376                    String sql = query.toString();
1377    
1378                    Query q = session.createQuery(sql);
1379    
1380                    q.setFirstResult(0);
1381                    q.setMaxResults(2);
1382    
1383                    QueryPos qPos = QueryPos.getInstance(q);
1384    
1385                    if (bindUuid) {
1386                            qPos.add(uuid);
1387                    }
1388    
1389                    qPos.add(companyId);
1390    
1391                    if (orderByComparator != null) {
1392                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
1393    
1394                            for (Object value : values) {
1395                                    qPos.add(value);
1396                            }
1397                    }
1398    
1399                    List<BlogsEntry> list = q.list();
1400    
1401                    if (list.size() == 2) {
1402                            return list.get(1);
1403                    }
1404                    else {
1405                            return null;
1406                    }
1407            }
1408    
1409            /**
1410             * Removes all the blogs entries where uuid = &#63; and companyId = &#63; from the database.
1411             *
1412             * @param uuid the uuid
1413             * @param companyId the company ID
1414             */
1415            @Override
1416            public void removeByUuid_C(String uuid, long companyId) {
1417                    for (BlogsEntry blogsEntry : findByUuid_C(uuid, companyId,
1418                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1419                            remove(blogsEntry);
1420                    }
1421            }
1422    
1423            /**
1424             * Returns the number of blogs entries where uuid = &#63; and companyId = &#63;.
1425             *
1426             * @param uuid the uuid
1427             * @param companyId the company ID
1428             * @return the number of matching blogs entries
1429             */
1430            @Override
1431            public int countByUuid_C(String uuid, long companyId) {
1432                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1433    
1434                    Object[] finderArgs = new Object[] { uuid, companyId };
1435    
1436                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
1437    
1438                    if (count == null) {
1439                            StringBundler query = new StringBundler(3);
1440    
1441                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
1442    
1443                            boolean bindUuid = false;
1444    
1445                            if (uuid == null) {
1446                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1447                            }
1448                            else if (uuid.equals(StringPool.BLANK)) {
1449                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1450                            }
1451                            else {
1452                                    bindUuid = true;
1453    
1454                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1455                            }
1456    
1457                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1458    
1459                            String sql = query.toString();
1460    
1461                            Session session = null;
1462    
1463                            try {
1464                                    session = openSession();
1465    
1466                                    Query q = session.createQuery(sql);
1467    
1468                                    QueryPos qPos = QueryPos.getInstance(q);
1469    
1470                                    if (bindUuid) {
1471                                            qPos.add(uuid);
1472                                    }
1473    
1474                                    qPos.add(companyId);
1475    
1476                                    count = (Long)q.uniqueResult();
1477    
1478                                    finderCache.putResult(finderPath, finderArgs, count);
1479                            }
1480                            catch (Exception e) {
1481                                    finderCache.removeResult(finderPath, finderArgs);
1482    
1483                                    throw processException(e);
1484                            }
1485                            finally {
1486                                    closeSession(session);
1487                            }
1488                    }
1489    
1490                    return count.intValue();
1491            }
1492    
1493            private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "blogsEntry.uuid IS NULL AND ";
1494            private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "blogsEntry.uuid = ? AND ";
1495            private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(blogsEntry.uuid IS NULL OR blogsEntry.uuid = '') AND ";
1496            private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "blogsEntry.companyId = ?";
1497            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
1498                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
1499                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId",
1500                            new String[] {
1501                                    Long.class.getName(),
1502                                    
1503                            Integer.class.getName(), Integer.class.getName(),
1504                                    OrderByComparator.class.getName()
1505                            });
1506            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
1507                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
1508                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
1509                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
1510                            new String[] { Long.class.getName() },
1511                            BlogsEntryModelImpl.GROUPID_COLUMN_BITMASK |
1512                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
1513                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
1514            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
1515                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
1516                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
1517                            new String[] { Long.class.getName() });
1518    
1519            /**
1520             * Returns all the blogs entries where groupId = &#63;.
1521             *
1522             * @param groupId the group ID
1523             * @return the matching blogs entries
1524             */
1525            @Override
1526            public List<BlogsEntry> findByGroupId(long groupId) {
1527                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1528            }
1529    
1530            /**
1531             * Returns a range of all the blogs entries where groupId = &#63;.
1532             *
1533             * <p>
1534             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1535             * </p>
1536             *
1537             * @param groupId the group ID
1538             * @param start the lower bound of the range of blogs entries
1539             * @param end the upper bound of the range of blogs entries (not inclusive)
1540             * @return the range of matching blogs entries
1541             */
1542            @Override
1543            public List<BlogsEntry> findByGroupId(long groupId, int start, int end) {
1544                    return findByGroupId(groupId, start, end, null);
1545            }
1546    
1547            /**
1548             * Returns an ordered range of all the blogs entries where groupId = &#63;.
1549             *
1550             * <p>
1551             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1552             * </p>
1553             *
1554             * @param groupId the group ID
1555             * @param start the lower bound of the range of blogs entries
1556             * @param end the upper bound of the range of blogs entries (not inclusive)
1557             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1558             * @return the ordered range of matching blogs entries
1559             */
1560            @Override
1561            public List<BlogsEntry> findByGroupId(long groupId, int start, int end,
1562                    OrderByComparator<BlogsEntry> orderByComparator) {
1563                    return findByGroupId(groupId, start, end, orderByComparator, true);
1564            }
1565    
1566            /**
1567             * Returns an ordered range of all the blogs entries where groupId = &#63;.
1568             *
1569             * <p>
1570             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1571             * </p>
1572             *
1573             * @param groupId the group ID
1574             * @param start the lower bound of the range of blogs entries
1575             * @param end the upper bound of the range of blogs entries (not inclusive)
1576             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1577             * @param retrieveFromCache whether to retrieve from the finder cache
1578             * @return the ordered range of matching blogs entries
1579             */
1580            @Override
1581            public List<BlogsEntry> findByGroupId(long groupId, int start, int end,
1582                    OrderByComparator<BlogsEntry> orderByComparator,
1583                    boolean retrieveFromCache) {
1584                    boolean pagination = true;
1585                    FinderPath finderPath = null;
1586                    Object[] finderArgs = null;
1587    
1588                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1589                                    (orderByComparator == null)) {
1590                            pagination = false;
1591                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1592                            finderArgs = new Object[] { groupId };
1593                    }
1594                    else {
1595                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1596                            finderArgs = new Object[] { groupId, start, end, orderByComparator };
1597                    }
1598    
1599                    List<BlogsEntry> list = null;
1600    
1601                    if (retrieveFromCache) {
1602                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
1603                                            finderArgs, this);
1604    
1605                            if ((list != null) && !list.isEmpty()) {
1606                                    for (BlogsEntry blogsEntry : list) {
1607                                            if ((groupId != blogsEntry.getGroupId())) {
1608                                                    list = null;
1609    
1610                                                    break;
1611                                            }
1612                                    }
1613                            }
1614                    }
1615    
1616                    if (list == null) {
1617                            StringBundler query = null;
1618    
1619                            if (orderByComparator != null) {
1620                                    query = new StringBundler(3 +
1621                                                    (orderByComparator.getOrderByFields().length * 2));
1622                            }
1623                            else {
1624                                    query = new StringBundler(3);
1625                            }
1626    
1627                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
1628    
1629                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1630    
1631                            if (orderByComparator != null) {
1632                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1633                                            orderByComparator);
1634                            }
1635                            else
1636                             if (pagination) {
1637                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
1638                            }
1639    
1640                            String sql = query.toString();
1641    
1642                            Session session = null;
1643    
1644                            try {
1645                                    session = openSession();
1646    
1647                                    Query q = session.createQuery(sql);
1648    
1649                                    QueryPos qPos = QueryPos.getInstance(q);
1650    
1651                                    qPos.add(groupId);
1652    
1653                                    if (!pagination) {
1654                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
1655                                                            start, end, false);
1656    
1657                                            Collections.sort(list);
1658    
1659                                            list = Collections.unmodifiableList(list);
1660                                    }
1661                                    else {
1662                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
1663                                                            start, end);
1664                                    }
1665    
1666                                    cacheResult(list);
1667    
1668                                    finderCache.putResult(finderPath, finderArgs, list);
1669                            }
1670                            catch (Exception e) {
1671                                    finderCache.removeResult(finderPath, finderArgs);
1672    
1673                                    throw processException(e);
1674                            }
1675                            finally {
1676                                    closeSession(session);
1677                            }
1678                    }
1679    
1680                    return list;
1681            }
1682    
1683            /**
1684             * Returns the first blogs entry in the ordered set where groupId = &#63;.
1685             *
1686             * @param groupId the group ID
1687             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1688             * @return the first matching blogs entry
1689             * @throws NoSuchEntryException if a matching blogs entry could not be found
1690             */
1691            @Override
1692            public BlogsEntry findByGroupId_First(long groupId,
1693                    OrderByComparator<BlogsEntry> orderByComparator)
1694                    throws NoSuchEntryException {
1695                    BlogsEntry blogsEntry = fetchByGroupId_First(groupId, orderByComparator);
1696    
1697                    if (blogsEntry != null) {
1698                            return blogsEntry;
1699                    }
1700    
1701                    StringBundler msg = new StringBundler(4);
1702    
1703                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1704    
1705                    msg.append("groupId=");
1706                    msg.append(groupId);
1707    
1708                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1709    
1710                    throw new NoSuchEntryException(msg.toString());
1711            }
1712    
1713            /**
1714             * Returns the first blogs entry in the ordered set where groupId = &#63;.
1715             *
1716             * @param groupId the group ID
1717             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1718             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
1719             */
1720            @Override
1721            public BlogsEntry fetchByGroupId_First(long groupId,
1722                    OrderByComparator<BlogsEntry> orderByComparator) {
1723                    List<BlogsEntry> list = findByGroupId(groupId, 0, 1, orderByComparator);
1724    
1725                    if (!list.isEmpty()) {
1726                            return list.get(0);
1727                    }
1728    
1729                    return null;
1730            }
1731    
1732            /**
1733             * Returns the last blogs entry in the ordered set where groupId = &#63;.
1734             *
1735             * @param groupId the group ID
1736             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1737             * @return the last matching blogs entry
1738             * @throws NoSuchEntryException if a matching blogs entry could not be found
1739             */
1740            @Override
1741            public BlogsEntry findByGroupId_Last(long groupId,
1742                    OrderByComparator<BlogsEntry> orderByComparator)
1743                    throws NoSuchEntryException {
1744                    BlogsEntry blogsEntry = fetchByGroupId_Last(groupId, orderByComparator);
1745    
1746                    if (blogsEntry != null) {
1747                            return blogsEntry;
1748                    }
1749    
1750                    StringBundler msg = new StringBundler(4);
1751    
1752                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1753    
1754                    msg.append("groupId=");
1755                    msg.append(groupId);
1756    
1757                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1758    
1759                    throw new NoSuchEntryException(msg.toString());
1760            }
1761    
1762            /**
1763             * Returns the last blogs entry in the ordered set where groupId = &#63;.
1764             *
1765             * @param groupId the group ID
1766             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1767             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
1768             */
1769            @Override
1770            public BlogsEntry fetchByGroupId_Last(long groupId,
1771                    OrderByComparator<BlogsEntry> orderByComparator) {
1772                    int count = countByGroupId(groupId);
1773    
1774                    if (count == 0) {
1775                            return null;
1776                    }
1777    
1778                    List<BlogsEntry> list = findByGroupId(groupId, count - 1, count,
1779                                    orderByComparator);
1780    
1781                    if (!list.isEmpty()) {
1782                            return list.get(0);
1783                    }
1784    
1785                    return null;
1786            }
1787    
1788            /**
1789             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63;.
1790             *
1791             * @param entryId the primary key of the current blogs entry
1792             * @param groupId the group ID
1793             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1794             * @return the previous, current, and next blogs entry
1795             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
1796             */
1797            @Override
1798            public BlogsEntry[] findByGroupId_PrevAndNext(long entryId, long groupId,
1799                    OrderByComparator<BlogsEntry> orderByComparator)
1800                    throws NoSuchEntryException {
1801                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
1802    
1803                    Session session = null;
1804    
1805                    try {
1806                            session = openSession();
1807    
1808                            BlogsEntry[] array = new BlogsEntryImpl[3];
1809    
1810                            array[0] = getByGroupId_PrevAndNext(session, blogsEntry, groupId,
1811                                            orderByComparator, true);
1812    
1813                            array[1] = blogsEntry;
1814    
1815                            array[2] = getByGroupId_PrevAndNext(session, blogsEntry, groupId,
1816                                            orderByComparator, false);
1817    
1818                            return array;
1819                    }
1820                    catch (Exception e) {
1821                            throw processException(e);
1822                    }
1823                    finally {
1824                            closeSession(session);
1825                    }
1826            }
1827    
1828            protected BlogsEntry getByGroupId_PrevAndNext(Session session,
1829                    BlogsEntry blogsEntry, long groupId,
1830                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
1831                    StringBundler query = null;
1832    
1833                    if (orderByComparator != null) {
1834                            query = new StringBundler(4 +
1835                                            (orderByComparator.getOrderByConditionFields().length * 3) +
1836                                            (orderByComparator.getOrderByFields().length * 3));
1837                    }
1838                    else {
1839                            query = new StringBundler(3);
1840                    }
1841    
1842                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
1843    
1844                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1845    
1846                    if (orderByComparator != null) {
1847                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1848    
1849                            if (orderByConditionFields.length > 0) {
1850                                    query.append(WHERE_AND);
1851                            }
1852    
1853                            for (int i = 0; i < orderByConditionFields.length; i++) {
1854                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1855                                    query.append(orderByConditionFields[i]);
1856    
1857                                    if ((i + 1) < orderByConditionFields.length) {
1858                                            if (orderByComparator.isAscending() ^ previous) {
1859                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1860                                            }
1861                                            else {
1862                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1863                                            }
1864                                    }
1865                                    else {
1866                                            if (orderByComparator.isAscending() ^ previous) {
1867                                                    query.append(WHERE_GREATER_THAN);
1868                                            }
1869                                            else {
1870                                                    query.append(WHERE_LESSER_THAN);
1871                                            }
1872                                    }
1873                            }
1874    
1875                            query.append(ORDER_BY_CLAUSE);
1876    
1877                            String[] orderByFields = orderByComparator.getOrderByFields();
1878    
1879                            for (int i = 0; i < orderByFields.length; i++) {
1880                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1881                                    query.append(orderByFields[i]);
1882    
1883                                    if ((i + 1) < orderByFields.length) {
1884                                            if (orderByComparator.isAscending() ^ previous) {
1885                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1886                                            }
1887                                            else {
1888                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1889                                            }
1890                                    }
1891                                    else {
1892                                            if (orderByComparator.isAscending() ^ previous) {
1893                                                    query.append(ORDER_BY_ASC);
1894                                            }
1895                                            else {
1896                                                    query.append(ORDER_BY_DESC);
1897                                            }
1898                                    }
1899                            }
1900                    }
1901                    else {
1902                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
1903                    }
1904    
1905                    String sql = query.toString();
1906    
1907                    Query q = session.createQuery(sql);
1908    
1909                    q.setFirstResult(0);
1910                    q.setMaxResults(2);
1911    
1912                    QueryPos qPos = QueryPos.getInstance(q);
1913    
1914                    qPos.add(groupId);
1915    
1916                    if (orderByComparator != null) {
1917                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
1918    
1919                            for (Object value : values) {
1920                                    qPos.add(value);
1921                            }
1922                    }
1923    
1924                    List<BlogsEntry> list = q.list();
1925    
1926                    if (list.size() == 2) {
1927                            return list.get(1);
1928                    }
1929                    else {
1930                            return null;
1931                    }
1932            }
1933    
1934            /**
1935             * Returns all the blogs entries that the user has permission to view where groupId = &#63;.
1936             *
1937             * @param groupId the group ID
1938             * @return the matching blogs entries that the user has permission to view
1939             */
1940            @Override
1941            public List<BlogsEntry> filterFindByGroupId(long groupId) {
1942                    return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1943                            QueryUtil.ALL_POS, null);
1944            }
1945    
1946            /**
1947             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63;.
1948             *
1949             * <p>
1950             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1951             * </p>
1952             *
1953             * @param groupId the group ID
1954             * @param start the lower bound of the range of blogs entries
1955             * @param end the upper bound of the range of blogs entries (not inclusive)
1956             * @return the range of matching blogs entries that the user has permission to view
1957             */
1958            @Override
1959            public List<BlogsEntry> filterFindByGroupId(long groupId, int start, int end) {
1960                    return filterFindByGroupId(groupId, start, end, null);
1961            }
1962    
1963            /**
1964             * Returns an ordered range of all the blogs entries that the user has permissions to view where groupId = &#63;.
1965             *
1966             * <p>
1967             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1968             * </p>
1969             *
1970             * @param groupId the group ID
1971             * @param start the lower bound of the range of blogs entries
1972             * @param end the upper bound of the range of blogs entries (not inclusive)
1973             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1974             * @return the ordered range of matching blogs entries that the user has permission to view
1975             */
1976            @Override
1977            public List<BlogsEntry> filterFindByGroupId(long groupId, int start,
1978                    int end, OrderByComparator<BlogsEntry> orderByComparator) {
1979                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1980                            return findByGroupId(groupId, start, end, orderByComparator);
1981                    }
1982    
1983                    StringBundler query = null;
1984    
1985                    if (orderByComparator != null) {
1986                            query = new StringBundler(3 +
1987                                            (orderByComparator.getOrderByFields().length * 2));
1988                    }
1989                    else {
1990                            query = new StringBundler(4);
1991                    }
1992    
1993                    if (getDB().isSupportsInlineDistinct()) {
1994                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
1995                    }
1996                    else {
1997                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
1998                    }
1999    
2000                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2001    
2002                    if (!getDB().isSupportsInlineDistinct()) {
2003                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
2004                    }
2005    
2006                    if (orderByComparator != null) {
2007                            if (getDB().isSupportsInlineDistinct()) {
2008                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2009                                            orderByComparator, true);
2010                            }
2011                            else {
2012                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2013                                            orderByComparator, true);
2014                            }
2015                    }
2016                    else {
2017                            if (getDB().isSupportsInlineDistinct()) {
2018                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
2019                            }
2020                            else {
2021                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
2022                            }
2023                    }
2024    
2025                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2026                                    BlogsEntry.class.getName(),
2027                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2028    
2029                    Session session = null;
2030    
2031                    try {
2032                            session = openSession();
2033    
2034                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
2035    
2036                            if (getDB().isSupportsInlineDistinct()) {
2037                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
2038                            }
2039                            else {
2040                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
2041                            }
2042    
2043                            QueryPos qPos = QueryPos.getInstance(q);
2044    
2045                            qPos.add(groupId);
2046    
2047                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
2048                    }
2049                    catch (Exception e) {
2050                            throw processException(e);
2051                    }
2052                    finally {
2053                            closeSession(session);
2054                    }
2055            }
2056    
2057            /**
2058             * 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;.
2059             *
2060             * @param entryId the primary key of the current blogs entry
2061             * @param groupId the group ID
2062             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2063             * @return the previous, current, and next blogs entry
2064             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
2065             */
2066            @Override
2067            public BlogsEntry[] filterFindByGroupId_PrevAndNext(long entryId,
2068                    long groupId, OrderByComparator<BlogsEntry> orderByComparator)
2069                    throws NoSuchEntryException {
2070                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2071                            return findByGroupId_PrevAndNext(entryId, groupId, orderByComparator);
2072                    }
2073    
2074                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
2075    
2076                    Session session = null;
2077    
2078                    try {
2079                            session = openSession();
2080    
2081                            BlogsEntry[] array = new BlogsEntryImpl[3];
2082    
2083                            array[0] = filterGetByGroupId_PrevAndNext(session, blogsEntry,
2084                                            groupId, orderByComparator, true);
2085    
2086                            array[1] = blogsEntry;
2087    
2088                            array[2] = filterGetByGroupId_PrevAndNext(session, blogsEntry,
2089                                            groupId, orderByComparator, false);
2090    
2091                            return array;
2092                    }
2093                    catch (Exception e) {
2094                            throw processException(e);
2095                    }
2096                    finally {
2097                            closeSession(session);
2098                    }
2099            }
2100    
2101            protected BlogsEntry filterGetByGroupId_PrevAndNext(Session session,
2102                    BlogsEntry blogsEntry, long groupId,
2103                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
2104                    StringBundler query = null;
2105    
2106                    if (orderByComparator != null) {
2107                            query = new StringBundler(5 +
2108                                            (orderByComparator.getOrderByConditionFields().length * 3) +
2109                                            (orderByComparator.getOrderByFields().length * 3));
2110                    }
2111                    else {
2112                            query = new StringBundler(4);
2113                    }
2114    
2115                    if (getDB().isSupportsInlineDistinct()) {
2116                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
2117                    }
2118                    else {
2119                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
2120                    }
2121    
2122                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2123    
2124                    if (!getDB().isSupportsInlineDistinct()) {
2125                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
2126                    }
2127    
2128                    if (orderByComparator != null) {
2129                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2130    
2131                            if (orderByConditionFields.length > 0) {
2132                                    query.append(WHERE_AND);
2133                            }
2134    
2135                            for (int i = 0; i < orderByConditionFields.length; i++) {
2136                                    if (getDB().isSupportsInlineDistinct()) {
2137                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2138                                    }
2139                                    else {
2140                                            query.append(_ORDER_BY_ENTITY_TABLE);
2141                                    }
2142    
2143                                    query.append(orderByConditionFields[i]);
2144    
2145                                    if ((i + 1) < orderByConditionFields.length) {
2146                                            if (orderByComparator.isAscending() ^ previous) {
2147                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2148                                            }
2149                                            else {
2150                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2151                                            }
2152                                    }
2153                                    else {
2154                                            if (orderByComparator.isAscending() ^ previous) {
2155                                                    query.append(WHERE_GREATER_THAN);
2156                                            }
2157                                            else {
2158                                                    query.append(WHERE_LESSER_THAN);
2159                                            }
2160                                    }
2161                            }
2162    
2163                            query.append(ORDER_BY_CLAUSE);
2164    
2165                            String[] orderByFields = orderByComparator.getOrderByFields();
2166    
2167                            for (int i = 0; i < orderByFields.length; i++) {
2168                                    if (getDB().isSupportsInlineDistinct()) {
2169                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2170                                    }
2171                                    else {
2172                                            query.append(_ORDER_BY_ENTITY_TABLE);
2173                                    }
2174    
2175                                    query.append(orderByFields[i]);
2176    
2177                                    if ((i + 1) < orderByFields.length) {
2178                                            if (orderByComparator.isAscending() ^ previous) {
2179                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2180                                            }
2181                                            else {
2182                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2183                                            }
2184                                    }
2185                                    else {
2186                                            if (orderByComparator.isAscending() ^ previous) {
2187                                                    query.append(ORDER_BY_ASC);
2188                                            }
2189                                            else {
2190                                                    query.append(ORDER_BY_DESC);
2191                                            }
2192                                    }
2193                            }
2194                    }
2195                    else {
2196                            if (getDB().isSupportsInlineDistinct()) {
2197                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
2198                            }
2199                            else {
2200                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
2201                            }
2202                    }
2203    
2204                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2205                                    BlogsEntry.class.getName(),
2206                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2207    
2208                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
2209    
2210                    q.setFirstResult(0);
2211                    q.setMaxResults(2);
2212    
2213                    if (getDB().isSupportsInlineDistinct()) {
2214                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
2215                    }
2216                    else {
2217                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
2218                    }
2219    
2220                    QueryPos qPos = QueryPos.getInstance(q);
2221    
2222                    qPos.add(groupId);
2223    
2224                    if (orderByComparator != null) {
2225                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
2226    
2227                            for (Object value : values) {
2228                                    qPos.add(value);
2229                            }
2230                    }
2231    
2232                    List<BlogsEntry> list = q.list();
2233    
2234                    if (list.size() == 2) {
2235                            return list.get(1);
2236                    }
2237                    else {
2238                            return null;
2239                    }
2240            }
2241    
2242            /**
2243             * Removes all the blogs entries where groupId = &#63; from the database.
2244             *
2245             * @param groupId the group ID
2246             */
2247            @Override
2248            public void removeByGroupId(long groupId) {
2249                    for (BlogsEntry blogsEntry : findByGroupId(groupId, QueryUtil.ALL_POS,
2250                                    QueryUtil.ALL_POS, null)) {
2251                            remove(blogsEntry);
2252                    }
2253            }
2254    
2255            /**
2256             * Returns the number of blogs entries where groupId = &#63;.
2257             *
2258             * @param groupId the group ID
2259             * @return the number of matching blogs entries
2260             */
2261            @Override
2262            public int countByGroupId(long groupId) {
2263                    FinderPath finderPath = FINDER_PATH_COUNT_BY_GROUPID;
2264    
2265                    Object[] finderArgs = new Object[] { groupId };
2266    
2267                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
2268    
2269                    if (count == null) {
2270                            StringBundler query = new StringBundler(2);
2271    
2272                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
2273    
2274                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2275    
2276                            String sql = query.toString();
2277    
2278                            Session session = null;
2279    
2280                            try {
2281                                    session = openSession();
2282    
2283                                    Query q = session.createQuery(sql);
2284    
2285                                    QueryPos qPos = QueryPos.getInstance(q);
2286    
2287                                    qPos.add(groupId);
2288    
2289                                    count = (Long)q.uniqueResult();
2290    
2291                                    finderCache.putResult(finderPath, finderArgs, count);
2292                            }
2293                            catch (Exception e) {
2294                                    finderCache.removeResult(finderPath, finderArgs);
2295    
2296                                    throw processException(e);
2297                            }
2298                            finally {
2299                                    closeSession(session);
2300                            }
2301                    }
2302    
2303                    return count.intValue();
2304            }
2305    
2306            /**
2307             * Returns the number of blogs entries that the user has permission to view where groupId = &#63;.
2308             *
2309             * @param groupId the group ID
2310             * @return the number of matching blogs entries that the user has permission to view
2311             */
2312            @Override
2313            public int filterCountByGroupId(long groupId) {
2314                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2315                            return countByGroupId(groupId);
2316                    }
2317    
2318                    StringBundler query = new StringBundler(2);
2319    
2320                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
2321    
2322                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2323    
2324                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2325                                    BlogsEntry.class.getName(),
2326                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2327    
2328                    Session session = null;
2329    
2330                    try {
2331                            session = openSession();
2332    
2333                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
2334    
2335                            q.addScalar(COUNT_COLUMN_NAME,
2336                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
2337    
2338                            QueryPos qPos = QueryPos.getInstance(q);
2339    
2340                            qPos.add(groupId);
2341    
2342                            Long count = (Long)q.uniqueResult();
2343    
2344                            return count.intValue();
2345                    }
2346                    catch (Exception e) {
2347                            throw processException(e);
2348                    }
2349                    finally {
2350                            closeSession(session);
2351                    }
2352            }
2353    
2354            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "blogsEntry.groupId = ?";
2355            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
2356                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
2357                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
2358                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId",
2359                            new String[] {
2360                                    Long.class.getName(),
2361                                    
2362                            Integer.class.getName(), Integer.class.getName(),
2363                                    OrderByComparator.class.getName()
2364                            });
2365            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
2366                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
2367                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
2368                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
2369                            new String[] { Long.class.getName() },
2370                            BlogsEntryModelImpl.COMPANYID_COLUMN_BITMASK |
2371                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
2372                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
2373            public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
2374                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
2375                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
2376                            new String[] { Long.class.getName() });
2377    
2378            /**
2379             * Returns all the blogs entries where companyId = &#63;.
2380             *
2381             * @param companyId the company ID
2382             * @return the matching blogs entries
2383             */
2384            @Override
2385            public List<BlogsEntry> findByCompanyId(long companyId) {
2386                    return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2387                            null);
2388            }
2389    
2390            /**
2391             * Returns a range of all the blogs entries where companyId = &#63;.
2392             *
2393             * <p>
2394             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2395             * </p>
2396             *
2397             * @param companyId the company ID
2398             * @param start the lower bound of the range of blogs entries
2399             * @param end the upper bound of the range of blogs entries (not inclusive)
2400             * @return the range of matching blogs entries
2401             */
2402            @Override
2403            public List<BlogsEntry> findByCompanyId(long companyId, int start, int end) {
2404                    return findByCompanyId(companyId, start, end, null);
2405            }
2406    
2407            /**
2408             * Returns an ordered range of all the blogs entries where companyId = &#63;.
2409             *
2410             * <p>
2411             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2412             * </p>
2413             *
2414             * @param companyId the company ID
2415             * @param start the lower bound of the range of blogs entries
2416             * @param end the upper bound of the range of blogs entries (not inclusive)
2417             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2418             * @return the ordered range of matching blogs entries
2419             */
2420            @Override
2421            public List<BlogsEntry> findByCompanyId(long companyId, int start, int end,
2422                    OrderByComparator<BlogsEntry> orderByComparator) {
2423                    return findByCompanyId(companyId, start, end, orderByComparator, true);
2424            }
2425    
2426            /**
2427             * Returns an ordered range of all the blogs entries where companyId = &#63;.
2428             *
2429             * <p>
2430             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2431             * </p>
2432             *
2433             * @param companyId the company ID
2434             * @param start the lower bound of the range of blogs entries
2435             * @param end the upper bound of the range of blogs entries (not inclusive)
2436             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2437             * @param retrieveFromCache whether to retrieve from the finder cache
2438             * @return the ordered range of matching blogs entries
2439             */
2440            @Override
2441            public List<BlogsEntry> findByCompanyId(long companyId, int start, int end,
2442                    OrderByComparator<BlogsEntry> orderByComparator,
2443                    boolean retrieveFromCache) {
2444                    boolean pagination = true;
2445                    FinderPath finderPath = null;
2446                    Object[] finderArgs = null;
2447    
2448                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2449                                    (orderByComparator == null)) {
2450                            pagination = false;
2451                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
2452                            finderArgs = new Object[] { companyId };
2453                    }
2454                    else {
2455                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
2456                            finderArgs = new Object[] { companyId, start, end, orderByComparator };
2457                    }
2458    
2459                    List<BlogsEntry> list = null;
2460    
2461                    if (retrieveFromCache) {
2462                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
2463                                            finderArgs, this);
2464    
2465                            if ((list != null) && !list.isEmpty()) {
2466                                    for (BlogsEntry blogsEntry : list) {
2467                                            if ((companyId != blogsEntry.getCompanyId())) {
2468                                                    list = null;
2469    
2470                                                    break;
2471                                            }
2472                                    }
2473                            }
2474                    }
2475    
2476                    if (list == null) {
2477                            StringBundler query = null;
2478    
2479                            if (orderByComparator != null) {
2480                                    query = new StringBundler(3 +
2481                                                    (orderByComparator.getOrderByFields().length * 2));
2482                            }
2483                            else {
2484                                    query = new StringBundler(3);
2485                            }
2486    
2487                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
2488    
2489                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2490    
2491                            if (orderByComparator != null) {
2492                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2493                                            orderByComparator);
2494                            }
2495                            else
2496                             if (pagination) {
2497                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
2498                            }
2499    
2500                            String sql = query.toString();
2501    
2502                            Session session = null;
2503    
2504                            try {
2505                                    session = openSession();
2506    
2507                                    Query q = session.createQuery(sql);
2508    
2509                                    QueryPos qPos = QueryPos.getInstance(q);
2510    
2511                                    qPos.add(companyId);
2512    
2513                                    if (!pagination) {
2514                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
2515                                                            start, end, false);
2516    
2517                                            Collections.sort(list);
2518    
2519                                            list = Collections.unmodifiableList(list);
2520                                    }
2521                                    else {
2522                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
2523                                                            start, end);
2524                                    }
2525    
2526                                    cacheResult(list);
2527    
2528                                    finderCache.putResult(finderPath, finderArgs, list);
2529                            }
2530                            catch (Exception e) {
2531                                    finderCache.removeResult(finderPath, finderArgs);
2532    
2533                                    throw processException(e);
2534                            }
2535                            finally {
2536                                    closeSession(session);
2537                            }
2538                    }
2539    
2540                    return list;
2541            }
2542    
2543            /**
2544             * Returns the first blogs entry in the ordered set where companyId = &#63;.
2545             *
2546             * @param companyId the company ID
2547             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2548             * @return the first matching blogs entry
2549             * @throws NoSuchEntryException if a matching blogs entry could not be found
2550             */
2551            @Override
2552            public BlogsEntry findByCompanyId_First(long companyId,
2553                    OrderByComparator<BlogsEntry> orderByComparator)
2554                    throws NoSuchEntryException {
2555                    BlogsEntry blogsEntry = fetchByCompanyId_First(companyId,
2556                                    orderByComparator);
2557    
2558                    if (blogsEntry != null) {
2559                            return blogsEntry;
2560                    }
2561    
2562                    StringBundler msg = new StringBundler(4);
2563    
2564                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2565    
2566                    msg.append("companyId=");
2567                    msg.append(companyId);
2568    
2569                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2570    
2571                    throw new NoSuchEntryException(msg.toString());
2572            }
2573    
2574            /**
2575             * Returns the first blogs entry in the ordered set where companyId = &#63;.
2576             *
2577             * @param companyId the company ID
2578             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2579             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
2580             */
2581            @Override
2582            public BlogsEntry fetchByCompanyId_First(long companyId,
2583                    OrderByComparator<BlogsEntry> orderByComparator) {
2584                    List<BlogsEntry> list = findByCompanyId(companyId, 0, 1,
2585                                    orderByComparator);
2586    
2587                    if (!list.isEmpty()) {
2588                            return list.get(0);
2589                    }
2590    
2591                    return null;
2592            }
2593    
2594            /**
2595             * Returns the last blogs entry in the ordered set where companyId = &#63;.
2596             *
2597             * @param companyId the company ID
2598             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2599             * @return the last matching blogs entry
2600             * @throws NoSuchEntryException if a matching blogs entry could not be found
2601             */
2602            @Override
2603            public BlogsEntry findByCompanyId_Last(long companyId,
2604                    OrderByComparator<BlogsEntry> orderByComparator)
2605                    throws NoSuchEntryException {
2606                    BlogsEntry blogsEntry = fetchByCompanyId_Last(companyId,
2607                                    orderByComparator);
2608    
2609                    if (blogsEntry != null) {
2610                            return blogsEntry;
2611                    }
2612    
2613                    StringBundler msg = new StringBundler(4);
2614    
2615                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2616    
2617                    msg.append("companyId=");
2618                    msg.append(companyId);
2619    
2620                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2621    
2622                    throw new NoSuchEntryException(msg.toString());
2623            }
2624    
2625            /**
2626             * Returns the last blogs entry in the ordered set where companyId = &#63;.
2627             *
2628             * @param companyId the company ID
2629             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2630             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
2631             */
2632            @Override
2633            public BlogsEntry fetchByCompanyId_Last(long companyId,
2634                    OrderByComparator<BlogsEntry> orderByComparator) {
2635                    int count = countByCompanyId(companyId);
2636    
2637                    if (count == 0) {
2638                            return null;
2639                    }
2640    
2641                    List<BlogsEntry> list = findByCompanyId(companyId, count - 1, count,
2642                                    orderByComparator);
2643    
2644                    if (!list.isEmpty()) {
2645                            return list.get(0);
2646                    }
2647    
2648                    return null;
2649            }
2650    
2651            /**
2652             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63;.
2653             *
2654             * @param entryId the primary key of the current blogs entry
2655             * @param companyId the company ID
2656             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2657             * @return the previous, current, and next blogs entry
2658             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
2659             */
2660            @Override
2661            public BlogsEntry[] findByCompanyId_PrevAndNext(long entryId,
2662                    long companyId, OrderByComparator<BlogsEntry> orderByComparator)
2663                    throws NoSuchEntryException {
2664                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
2665    
2666                    Session session = null;
2667    
2668                    try {
2669                            session = openSession();
2670    
2671                            BlogsEntry[] array = new BlogsEntryImpl[3];
2672    
2673                            array[0] = getByCompanyId_PrevAndNext(session, blogsEntry,
2674                                            companyId, orderByComparator, true);
2675    
2676                            array[1] = blogsEntry;
2677    
2678                            array[2] = getByCompanyId_PrevAndNext(session, blogsEntry,
2679                                            companyId, orderByComparator, false);
2680    
2681                            return array;
2682                    }
2683                    catch (Exception e) {
2684                            throw processException(e);
2685                    }
2686                    finally {
2687                            closeSession(session);
2688                    }
2689            }
2690    
2691            protected BlogsEntry getByCompanyId_PrevAndNext(Session session,
2692                    BlogsEntry blogsEntry, long companyId,
2693                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
2694                    StringBundler query = null;
2695    
2696                    if (orderByComparator != null) {
2697                            query = new StringBundler(4 +
2698                                            (orderByComparator.getOrderByConditionFields().length * 3) +
2699                                            (orderByComparator.getOrderByFields().length * 3));
2700                    }
2701                    else {
2702                            query = new StringBundler(3);
2703                    }
2704    
2705                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
2706    
2707                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2708    
2709                    if (orderByComparator != null) {
2710                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2711    
2712                            if (orderByConditionFields.length > 0) {
2713                                    query.append(WHERE_AND);
2714                            }
2715    
2716                            for (int i = 0; i < orderByConditionFields.length; i++) {
2717                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2718                                    query.append(orderByConditionFields[i]);
2719    
2720                                    if ((i + 1) < orderByConditionFields.length) {
2721                                            if (orderByComparator.isAscending() ^ previous) {
2722                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2723                                            }
2724                                            else {
2725                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2726                                            }
2727                                    }
2728                                    else {
2729                                            if (orderByComparator.isAscending() ^ previous) {
2730                                                    query.append(WHERE_GREATER_THAN);
2731                                            }
2732                                            else {
2733                                                    query.append(WHERE_LESSER_THAN);
2734                                            }
2735                                    }
2736                            }
2737    
2738                            query.append(ORDER_BY_CLAUSE);
2739    
2740                            String[] orderByFields = orderByComparator.getOrderByFields();
2741    
2742                            for (int i = 0; i < orderByFields.length; i++) {
2743                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2744                                    query.append(orderByFields[i]);
2745    
2746                                    if ((i + 1) < orderByFields.length) {
2747                                            if (orderByComparator.isAscending() ^ previous) {
2748                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2749                                            }
2750                                            else {
2751                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2752                                            }
2753                                    }
2754                                    else {
2755                                            if (orderByComparator.isAscending() ^ previous) {
2756                                                    query.append(ORDER_BY_ASC);
2757                                            }
2758                                            else {
2759                                                    query.append(ORDER_BY_DESC);
2760                                            }
2761                                    }
2762                            }
2763                    }
2764                    else {
2765                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
2766                    }
2767    
2768                    String sql = query.toString();
2769    
2770                    Query q = session.createQuery(sql);
2771    
2772                    q.setFirstResult(0);
2773                    q.setMaxResults(2);
2774    
2775                    QueryPos qPos = QueryPos.getInstance(q);
2776    
2777                    qPos.add(companyId);
2778    
2779                    if (orderByComparator != null) {
2780                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
2781    
2782                            for (Object value : values) {
2783                                    qPos.add(value);
2784                            }
2785                    }
2786    
2787                    List<BlogsEntry> list = q.list();
2788    
2789                    if (list.size() == 2) {
2790                            return list.get(1);
2791                    }
2792                    else {
2793                            return null;
2794                    }
2795            }
2796    
2797            /**
2798             * Removes all the blogs entries where companyId = &#63; from the database.
2799             *
2800             * @param companyId the company ID
2801             */
2802            @Override
2803            public void removeByCompanyId(long companyId) {
2804                    for (BlogsEntry blogsEntry : findByCompanyId(companyId,
2805                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2806                            remove(blogsEntry);
2807                    }
2808            }
2809    
2810            /**
2811             * Returns the number of blogs entries where companyId = &#63;.
2812             *
2813             * @param companyId the company ID
2814             * @return the number of matching blogs entries
2815             */
2816            @Override
2817            public int countByCompanyId(long companyId) {
2818                    FinderPath finderPath = FINDER_PATH_COUNT_BY_COMPANYID;
2819    
2820                    Object[] finderArgs = new Object[] { companyId };
2821    
2822                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
2823    
2824                    if (count == null) {
2825                            StringBundler query = new StringBundler(2);
2826    
2827                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
2828    
2829                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2830    
2831                            String sql = query.toString();
2832    
2833                            Session session = null;
2834    
2835                            try {
2836                                    session = openSession();
2837    
2838                                    Query q = session.createQuery(sql);
2839    
2840                                    QueryPos qPos = QueryPos.getInstance(q);
2841    
2842                                    qPos.add(companyId);
2843    
2844                                    count = (Long)q.uniqueResult();
2845    
2846                                    finderCache.putResult(finderPath, finderArgs, count);
2847                            }
2848                            catch (Exception e) {
2849                                    finderCache.removeResult(finderPath, finderArgs);
2850    
2851                                    throw processException(e);
2852                            }
2853                            finally {
2854                                    closeSession(session);
2855                            }
2856                    }
2857    
2858                    return count.intValue();
2859            }
2860    
2861            private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "blogsEntry.companyId = ?";
2862            public static final FinderPath FINDER_PATH_FETCH_BY_G_UT = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
2863                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
2864                            FINDER_CLASS_NAME_ENTITY, "fetchByG_UT",
2865                            new String[] { Long.class.getName(), String.class.getName() },
2866                            BlogsEntryModelImpl.GROUPID_COLUMN_BITMASK |
2867                            BlogsEntryModelImpl.URLTITLE_COLUMN_BITMASK);
2868            public static final FinderPath FINDER_PATH_COUNT_BY_G_UT = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
2869                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
2870                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_UT",
2871                            new String[] { Long.class.getName(), String.class.getName() });
2872    
2873            /**
2874             * Returns the blogs entry where groupId = &#63; and urlTitle = &#63; or throws a {@link NoSuchEntryException} if it could not be found.
2875             *
2876             * @param groupId the group ID
2877             * @param urlTitle the url title
2878             * @return the matching blogs entry
2879             * @throws NoSuchEntryException if a matching blogs entry could not be found
2880             */
2881            @Override
2882            public BlogsEntry findByG_UT(long groupId, String urlTitle)
2883                    throws NoSuchEntryException {
2884                    BlogsEntry blogsEntry = fetchByG_UT(groupId, urlTitle);
2885    
2886                    if (blogsEntry == null) {
2887                            StringBundler msg = new StringBundler(6);
2888    
2889                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2890    
2891                            msg.append("groupId=");
2892                            msg.append(groupId);
2893    
2894                            msg.append(", urlTitle=");
2895                            msg.append(urlTitle);
2896    
2897                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2898    
2899                            if (_log.isDebugEnabled()) {
2900                                    _log.debug(msg.toString());
2901                            }
2902    
2903                            throw new NoSuchEntryException(msg.toString());
2904                    }
2905    
2906                    return blogsEntry;
2907            }
2908    
2909            /**
2910             * 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.
2911             *
2912             * @param groupId the group ID
2913             * @param urlTitle the url title
2914             * @return the matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
2915             */
2916            @Override
2917            public BlogsEntry fetchByG_UT(long groupId, String urlTitle) {
2918                    return fetchByG_UT(groupId, urlTitle, true);
2919            }
2920    
2921            /**
2922             * 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.
2923             *
2924             * @param groupId the group ID
2925             * @param urlTitle the url title
2926             * @param retrieveFromCache whether to retrieve from the finder cache
2927             * @return the matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
2928             */
2929            @Override
2930            public BlogsEntry fetchByG_UT(long groupId, String urlTitle,
2931                    boolean retrieveFromCache) {
2932                    Object[] finderArgs = new Object[] { groupId, urlTitle };
2933    
2934                    Object result = null;
2935    
2936                    if (retrieveFromCache) {
2937                            result = finderCache.getResult(FINDER_PATH_FETCH_BY_G_UT,
2938                                            finderArgs, this);
2939                    }
2940    
2941                    if (result instanceof BlogsEntry) {
2942                            BlogsEntry blogsEntry = (BlogsEntry)result;
2943    
2944                            if ((groupId != blogsEntry.getGroupId()) ||
2945                                            !Objects.equals(urlTitle, blogsEntry.getUrlTitle())) {
2946                                    result = null;
2947                            }
2948                    }
2949    
2950                    if (result == null) {
2951                            StringBundler query = new StringBundler(4);
2952    
2953                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
2954    
2955                            query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
2956    
2957                            boolean bindUrlTitle = false;
2958    
2959                            if (urlTitle == null) {
2960                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
2961                            }
2962                            else if (urlTitle.equals(StringPool.BLANK)) {
2963                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
2964                            }
2965                            else {
2966                                    bindUrlTitle = true;
2967    
2968                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
2969                            }
2970    
2971                            String sql = query.toString();
2972    
2973                            Session session = null;
2974    
2975                            try {
2976                                    session = openSession();
2977    
2978                                    Query q = session.createQuery(sql);
2979    
2980                                    QueryPos qPos = QueryPos.getInstance(q);
2981    
2982                                    qPos.add(groupId);
2983    
2984                                    if (bindUrlTitle) {
2985                                            qPos.add(urlTitle);
2986                                    }
2987    
2988                                    List<BlogsEntry> list = q.list();
2989    
2990                                    if (list.isEmpty()) {
2991                                            finderCache.putResult(FINDER_PATH_FETCH_BY_G_UT,
2992                                                    finderArgs, list);
2993                                    }
2994                                    else {
2995                                            BlogsEntry blogsEntry = list.get(0);
2996    
2997                                            result = blogsEntry;
2998    
2999                                            cacheResult(blogsEntry);
3000    
3001                                            if ((blogsEntry.getGroupId() != groupId) ||
3002                                                            (blogsEntry.getUrlTitle() == null) ||
3003                                                            !blogsEntry.getUrlTitle().equals(urlTitle)) {
3004                                                    finderCache.putResult(FINDER_PATH_FETCH_BY_G_UT,
3005                                                            finderArgs, blogsEntry);
3006                                            }
3007                                    }
3008                            }
3009                            catch (Exception e) {
3010                                    finderCache.removeResult(FINDER_PATH_FETCH_BY_G_UT, finderArgs);
3011    
3012                                    throw processException(e);
3013                            }
3014                            finally {
3015                                    closeSession(session);
3016                            }
3017                    }
3018    
3019                    if (result instanceof List<?>) {
3020                            return null;
3021                    }
3022                    else {
3023                            return (BlogsEntry)result;
3024                    }
3025            }
3026    
3027            /**
3028             * Removes the blogs entry where groupId = &#63; and urlTitle = &#63; from the database.
3029             *
3030             * @param groupId the group ID
3031             * @param urlTitle the url title
3032             * @return the blogs entry that was removed
3033             */
3034            @Override
3035            public BlogsEntry removeByG_UT(long groupId, String urlTitle)
3036                    throws NoSuchEntryException {
3037                    BlogsEntry blogsEntry = findByG_UT(groupId, urlTitle);
3038    
3039                    return remove(blogsEntry);
3040            }
3041    
3042            /**
3043             * Returns the number of blogs entries where groupId = &#63; and urlTitle = &#63;.
3044             *
3045             * @param groupId the group ID
3046             * @param urlTitle the url title
3047             * @return the number of matching blogs entries
3048             */
3049            @Override
3050            public int countByG_UT(long groupId, String urlTitle) {
3051                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_UT;
3052    
3053                    Object[] finderArgs = new Object[] { groupId, urlTitle };
3054    
3055                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
3056    
3057                    if (count == null) {
3058                            StringBundler query = new StringBundler(3);
3059    
3060                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
3061    
3062                            query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
3063    
3064                            boolean bindUrlTitle = false;
3065    
3066                            if (urlTitle == null) {
3067                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
3068                            }
3069                            else if (urlTitle.equals(StringPool.BLANK)) {
3070                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
3071                            }
3072                            else {
3073                                    bindUrlTitle = true;
3074    
3075                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
3076                            }
3077    
3078                            String sql = query.toString();
3079    
3080                            Session session = null;
3081    
3082                            try {
3083                                    session = openSession();
3084    
3085                                    Query q = session.createQuery(sql);
3086    
3087                                    QueryPos qPos = QueryPos.getInstance(q);
3088    
3089                                    qPos.add(groupId);
3090    
3091                                    if (bindUrlTitle) {
3092                                            qPos.add(urlTitle);
3093                                    }
3094    
3095                                    count = (Long)q.uniqueResult();
3096    
3097                                    finderCache.putResult(finderPath, finderArgs, count);
3098                            }
3099                            catch (Exception e) {
3100                                    finderCache.removeResult(finderPath, finderArgs);
3101    
3102                                    throw processException(e);
3103                            }
3104                            finally {
3105                                    closeSession(session);
3106                            }
3107                    }
3108    
3109                    return count.intValue();
3110            }
3111    
3112            private static final String _FINDER_COLUMN_G_UT_GROUPID_2 = "blogsEntry.groupId = ? AND ";
3113            private static final String _FINDER_COLUMN_G_UT_URLTITLE_1 = "blogsEntry.urlTitle IS NULL";
3114            private static final String _FINDER_COLUMN_G_UT_URLTITLE_2 = "blogsEntry.urlTitle = ?";
3115            private static final String _FINDER_COLUMN_G_UT_URLTITLE_3 = "(blogsEntry.urlTitle IS NULL OR blogsEntry.urlTitle = '')";
3116            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
3117                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
3118                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_LtD",
3119                            new String[] {
3120                                    Long.class.getName(), Date.class.getName(),
3121                                    
3122                            Integer.class.getName(), Integer.class.getName(),
3123                                    OrderByComparator.class.getName()
3124                            });
3125            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
3126                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
3127                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_LtD",
3128                            new String[] { Long.class.getName(), Date.class.getName() });
3129    
3130            /**
3131             * Returns all the blogs entries where groupId = &#63; and displayDate &lt; &#63;.
3132             *
3133             * @param groupId the group ID
3134             * @param displayDate the display date
3135             * @return the matching blogs entries
3136             */
3137            @Override
3138            public List<BlogsEntry> findByG_LtD(long groupId, Date displayDate) {
3139                    return findByG_LtD(groupId, displayDate, QueryUtil.ALL_POS,
3140                            QueryUtil.ALL_POS, null);
3141            }
3142    
3143            /**
3144             * Returns a range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63;.
3145             *
3146             * <p>
3147             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3148             * </p>
3149             *
3150             * @param groupId the group ID
3151             * @param displayDate the display date
3152             * @param start the lower bound of the range of blogs entries
3153             * @param end the upper bound of the range of blogs entries (not inclusive)
3154             * @return the range of matching blogs entries
3155             */
3156            @Override
3157            public List<BlogsEntry> findByG_LtD(long groupId, Date displayDate,
3158                    int start, int end) {
3159                    return findByG_LtD(groupId, displayDate, start, end, null);
3160            }
3161    
3162            /**
3163             * Returns an ordered range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63;.
3164             *
3165             * <p>
3166             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3167             * </p>
3168             *
3169             * @param groupId the group ID
3170             * @param displayDate the display date
3171             * @param start the lower bound of the range of blogs entries
3172             * @param end the upper bound of the range of blogs entries (not inclusive)
3173             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3174             * @return the ordered range of matching blogs entries
3175             */
3176            @Override
3177            public List<BlogsEntry> findByG_LtD(long groupId, Date displayDate,
3178                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator) {
3179                    return findByG_LtD(groupId, displayDate, start, end, orderByComparator,
3180                            true);
3181            }
3182    
3183            /**
3184             * Returns an ordered range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63;.
3185             *
3186             * <p>
3187             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3188             * </p>
3189             *
3190             * @param groupId the group ID
3191             * @param displayDate the display date
3192             * @param start the lower bound of the range of blogs entries
3193             * @param end the upper bound of the range of blogs entries (not inclusive)
3194             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3195             * @param retrieveFromCache whether to retrieve from the finder cache
3196             * @return the ordered range of matching blogs entries
3197             */
3198            @Override
3199            public List<BlogsEntry> findByG_LtD(long groupId, Date displayDate,
3200                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator,
3201                    boolean retrieveFromCache) {
3202                    boolean pagination = true;
3203                    FinderPath finderPath = null;
3204                    Object[] finderArgs = null;
3205    
3206                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD;
3207                    finderArgs = new Object[] {
3208                                    groupId, displayDate,
3209                                    
3210                                    start, end, orderByComparator
3211                            };
3212    
3213                    List<BlogsEntry> list = null;
3214    
3215                    if (retrieveFromCache) {
3216                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
3217                                            finderArgs, this);
3218    
3219                            if ((list != null) && !list.isEmpty()) {
3220                                    for (BlogsEntry blogsEntry : list) {
3221                                            if ((groupId != blogsEntry.getGroupId()) ||
3222                                                            (displayDate.getTime() <= blogsEntry.getDisplayDate()
3223                                                                                                                                            .getTime())) {
3224                                                    list = null;
3225    
3226                                                    break;
3227                                            }
3228                                    }
3229                            }
3230                    }
3231    
3232                    if (list == null) {
3233                            StringBundler query = null;
3234    
3235                            if (orderByComparator != null) {
3236                                    query = new StringBundler(4 +
3237                                                    (orderByComparator.getOrderByFields().length * 2));
3238                            }
3239                            else {
3240                                    query = new StringBundler(4);
3241                            }
3242    
3243                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
3244    
3245                            query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
3246    
3247                            boolean bindDisplayDate = false;
3248    
3249                            if (displayDate == null) {
3250                                    query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
3251                            }
3252                            else {
3253                                    bindDisplayDate = true;
3254    
3255                                    query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
3256                            }
3257    
3258                            if (orderByComparator != null) {
3259                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3260                                            orderByComparator);
3261                            }
3262                            else
3263                             if (pagination) {
3264                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
3265                            }
3266    
3267                            String sql = query.toString();
3268    
3269                            Session session = null;
3270    
3271                            try {
3272                                    session = openSession();
3273    
3274                                    Query q = session.createQuery(sql);
3275    
3276                                    QueryPos qPos = QueryPos.getInstance(q);
3277    
3278                                    qPos.add(groupId);
3279    
3280                                    if (bindDisplayDate) {
3281                                            qPos.add(new Timestamp(displayDate.getTime()));
3282                                    }
3283    
3284                                    if (!pagination) {
3285                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
3286                                                            start, end, false);
3287    
3288                                            Collections.sort(list);
3289    
3290                                            list = Collections.unmodifiableList(list);
3291                                    }
3292                                    else {
3293                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
3294                                                            start, end);
3295                                    }
3296    
3297                                    cacheResult(list);
3298    
3299                                    finderCache.putResult(finderPath, finderArgs, list);
3300                            }
3301                            catch (Exception e) {
3302                                    finderCache.removeResult(finderPath, finderArgs);
3303    
3304                                    throw processException(e);
3305                            }
3306                            finally {
3307                                    closeSession(session);
3308                            }
3309                    }
3310    
3311                    return list;
3312            }
3313    
3314            /**
3315             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63;.
3316             *
3317             * @param groupId the group ID
3318             * @param displayDate the display date
3319             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3320             * @return the first matching blogs entry
3321             * @throws NoSuchEntryException if a matching blogs entry could not be found
3322             */
3323            @Override
3324            public BlogsEntry findByG_LtD_First(long groupId, Date displayDate,
3325                    OrderByComparator<BlogsEntry> orderByComparator)
3326                    throws NoSuchEntryException {
3327                    BlogsEntry blogsEntry = fetchByG_LtD_First(groupId, displayDate,
3328                                    orderByComparator);
3329    
3330                    if (blogsEntry != null) {
3331                            return blogsEntry;
3332                    }
3333    
3334                    StringBundler msg = new StringBundler(6);
3335    
3336                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3337    
3338                    msg.append("groupId=");
3339                    msg.append(groupId);
3340    
3341                    msg.append(", displayDate=");
3342                    msg.append(displayDate);
3343    
3344                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3345    
3346                    throw new NoSuchEntryException(msg.toString());
3347            }
3348    
3349            /**
3350             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63;.
3351             *
3352             * @param groupId the group ID
3353             * @param displayDate the display date
3354             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3355             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
3356             */
3357            @Override
3358            public BlogsEntry fetchByG_LtD_First(long groupId, Date displayDate,
3359                    OrderByComparator<BlogsEntry> orderByComparator) {
3360                    List<BlogsEntry> list = findByG_LtD(groupId, displayDate, 0, 1,
3361                                    orderByComparator);
3362    
3363                    if (!list.isEmpty()) {
3364                            return list.get(0);
3365                    }
3366    
3367                    return null;
3368            }
3369    
3370            /**
3371             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63;.
3372             *
3373             * @param groupId the group ID
3374             * @param displayDate the display date
3375             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3376             * @return the last matching blogs entry
3377             * @throws NoSuchEntryException if a matching blogs entry could not be found
3378             */
3379            @Override
3380            public BlogsEntry findByG_LtD_Last(long groupId, Date displayDate,
3381                    OrderByComparator<BlogsEntry> orderByComparator)
3382                    throws NoSuchEntryException {
3383                    BlogsEntry blogsEntry = fetchByG_LtD_Last(groupId, displayDate,
3384                                    orderByComparator);
3385    
3386                    if (blogsEntry != null) {
3387                            return blogsEntry;
3388                    }
3389    
3390                    StringBundler msg = new StringBundler(6);
3391    
3392                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3393    
3394                    msg.append("groupId=");
3395                    msg.append(groupId);
3396    
3397                    msg.append(", displayDate=");
3398                    msg.append(displayDate);
3399    
3400                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3401    
3402                    throw new NoSuchEntryException(msg.toString());
3403            }
3404    
3405            /**
3406             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63;.
3407             *
3408             * @param groupId the group ID
3409             * @param displayDate the display date
3410             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3411             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
3412             */
3413            @Override
3414            public BlogsEntry fetchByG_LtD_Last(long groupId, Date displayDate,
3415                    OrderByComparator<BlogsEntry> orderByComparator) {
3416                    int count = countByG_LtD(groupId, displayDate);
3417    
3418                    if (count == 0) {
3419                            return null;
3420                    }
3421    
3422                    List<BlogsEntry> list = findByG_LtD(groupId, displayDate, count - 1,
3423                                    count, orderByComparator);
3424    
3425                    if (!list.isEmpty()) {
3426                            return list.get(0);
3427                    }
3428    
3429                    return null;
3430            }
3431    
3432            /**
3433             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63;.
3434             *
3435             * @param entryId the primary key of the current blogs entry
3436             * @param groupId the group ID
3437             * @param displayDate the display date
3438             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3439             * @return the previous, current, and next blogs entry
3440             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
3441             */
3442            @Override
3443            public BlogsEntry[] findByG_LtD_PrevAndNext(long entryId, long groupId,
3444                    Date displayDate, OrderByComparator<BlogsEntry> orderByComparator)
3445                    throws NoSuchEntryException {
3446                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
3447    
3448                    Session session = null;
3449    
3450                    try {
3451                            session = openSession();
3452    
3453                            BlogsEntry[] array = new BlogsEntryImpl[3];
3454    
3455                            array[0] = getByG_LtD_PrevAndNext(session, blogsEntry, groupId,
3456                                            displayDate, orderByComparator, true);
3457    
3458                            array[1] = blogsEntry;
3459    
3460                            array[2] = getByG_LtD_PrevAndNext(session, blogsEntry, groupId,
3461                                            displayDate, orderByComparator, false);
3462    
3463                            return array;
3464                    }
3465                    catch (Exception e) {
3466                            throw processException(e);
3467                    }
3468                    finally {
3469                            closeSession(session);
3470                    }
3471            }
3472    
3473            protected BlogsEntry getByG_LtD_PrevAndNext(Session session,
3474                    BlogsEntry blogsEntry, long groupId, Date displayDate,
3475                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
3476                    StringBundler query = null;
3477    
3478                    if (orderByComparator != null) {
3479                            query = new StringBundler(5 +
3480                                            (orderByComparator.getOrderByConditionFields().length * 3) +
3481                                            (orderByComparator.getOrderByFields().length * 3));
3482                    }
3483                    else {
3484                            query = new StringBundler(4);
3485                    }
3486    
3487                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
3488    
3489                    query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
3490    
3491                    boolean bindDisplayDate = false;
3492    
3493                    if (displayDate == null) {
3494                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
3495                    }
3496                    else {
3497                            bindDisplayDate = true;
3498    
3499                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
3500                    }
3501    
3502                    if (orderByComparator != null) {
3503                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3504    
3505                            if (orderByConditionFields.length > 0) {
3506                                    query.append(WHERE_AND);
3507                            }
3508    
3509                            for (int i = 0; i < orderByConditionFields.length; i++) {
3510                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3511                                    query.append(orderByConditionFields[i]);
3512    
3513                                    if ((i + 1) < orderByConditionFields.length) {
3514                                            if (orderByComparator.isAscending() ^ previous) {
3515                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3516                                            }
3517                                            else {
3518                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3519                                            }
3520                                    }
3521                                    else {
3522                                            if (orderByComparator.isAscending() ^ previous) {
3523                                                    query.append(WHERE_GREATER_THAN);
3524                                            }
3525                                            else {
3526                                                    query.append(WHERE_LESSER_THAN);
3527                                            }
3528                                    }
3529                            }
3530    
3531                            query.append(ORDER_BY_CLAUSE);
3532    
3533                            String[] orderByFields = orderByComparator.getOrderByFields();
3534    
3535                            for (int i = 0; i < orderByFields.length; i++) {
3536                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3537                                    query.append(orderByFields[i]);
3538    
3539                                    if ((i + 1) < orderByFields.length) {
3540                                            if (orderByComparator.isAscending() ^ previous) {
3541                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3542                                            }
3543                                            else {
3544                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3545                                            }
3546                                    }
3547                                    else {
3548                                            if (orderByComparator.isAscending() ^ previous) {
3549                                                    query.append(ORDER_BY_ASC);
3550                                            }
3551                                            else {
3552                                                    query.append(ORDER_BY_DESC);
3553                                            }
3554                                    }
3555                            }
3556                    }
3557                    else {
3558                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
3559                    }
3560    
3561                    String sql = query.toString();
3562    
3563                    Query q = session.createQuery(sql);
3564    
3565                    q.setFirstResult(0);
3566                    q.setMaxResults(2);
3567    
3568                    QueryPos qPos = QueryPos.getInstance(q);
3569    
3570                    qPos.add(groupId);
3571    
3572                    if (bindDisplayDate) {
3573                            qPos.add(new Timestamp(displayDate.getTime()));
3574                    }
3575    
3576                    if (orderByComparator != null) {
3577                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
3578    
3579                            for (Object value : values) {
3580                                    qPos.add(value);
3581                            }
3582                    }
3583    
3584                    List<BlogsEntry> list = q.list();
3585    
3586                    if (list.size() == 2) {
3587                            return list.get(1);
3588                    }
3589                    else {
3590                            return null;
3591                    }
3592            }
3593    
3594            /**
3595             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63;.
3596             *
3597             * @param groupId the group ID
3598             * @param displayDate the display date
3599             * @return the matching blogs entries that the user has permission to view
3600             */
3601            @Override
3602            public List<BlogsEntry> filterFindByG_LtD(long groupId, Date displayDate) {
3603                    return filterFindByG_LtD(groupId, displayDate, QueryUtil.ALL_POS,
3604                            QueryUtil.ALL_POS, null);
3605            }
3606    
3607            /**
3608             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63;.
3609             *
3610             * <p>
3611             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3612             * </p>
3613             *
3614             * @param groupId the group ID
3615             * @param displayDate the display date
3616             * @param start the lower bound of the range of blogs entries
3617             * @param end the upper bound of the range of blogs entries (not inclusive)
3618             * @return the range of matching blogs entries that the user has permission to view
3619             */
3620            @Override
3621            public List<BlogsEntry> filterFindByG_LtD(long groupId, Date displayDate,
3622                    int start, int end) {
3623                    return filterFindByG_LtD(groupId, displayDate, start, end, null);
3624            }
3625    
3626            /**
3627             * Returns an ordered range of all the blogs entries that the user has permissions to view where groupId = &#63; and displayDate &lt; &#63;.
3628             *
3629             * <p>
3630             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3631             * </p>
3632             *
3633             * @param groupId the group ID
3634             * @param displayDate the display date
3635             * @param start the lower bound of the range of blogs entries
3636             * @param end the upper bound of the range of blogs entries (not inclusive)
3637             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3638             * @return the ordered range of matching blogs entries that the user has permission to view
3639             */
3640            @Override
3641            public List<BlogsEntry> filterFindByG_LtD(long groupId, Date displayDate,
3642                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator) {
3643                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3644                            return findByG_LtD(groupId, displayDate, start, end,
3645                                    orderByComparator);
3646                    }
3647    
3648                    StringBundler query = null;
3649    
3650                    if (orderByComparator != null) {
3651                            query = new StringBundler(4 +
3652                                            (orderByComparator.getOrderByFields().length * 2));
3653                    }
3654                    else {
3655                            query = new StringBundler(5);
3656                    }
3657    
3658                    if (getDB().isSupportsInlineDistinct()) {
3659                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
3660                    }
3661                    else {
3662                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
3663                    }
3664    
3665                    query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
3666    
3667                    boolean bindDisplayDate = false;
3668    
3669                    if (displayDate == null) {
3670                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
3671                    }
3672                    else {
3673                            bindDisplayDate = true;
3674    
3675                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
3676                    }
3677    
3678                    if (!getDB().isSupportsInlineDistinct()) {
3679                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
3680                    }
3681    
3682                    if (orderByComparator != null) {
3683                            if (getDB().isSupportsInlineDistinct()) {
3684                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3685                                            orderByComparator, true);
3686                            }
3687                            else {
3688                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
3689                                            orderByComparator, true);
3690                            }
3691                    }
3692                    else {
3693                            if (getDB().isSupportsInlineDistinct()) {
3694                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
3695                            }
3696                            else {
3697                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
3698                            }
3699                    }
3700    
3701                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3702                                    BlogsEntry.class.getName(),
3703                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3704    
3705                    Session session = null;
3706    
3707                    try {
3708                            session = openSession();
3709    
3710                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
3711    
3712                            if (getDB().isSupportsInlineDistinct()) {
3713                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
3714                            }
3715                            else {
3716                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
3717                            }
3718    
3719                            QueryPos qPos = QueryPos.getInstance(q);
3720    
3721                            qPos.add(groupId);
3722    
3723                            if (bindDisplayDate) {
3724                                    qPos.add(new Timestamp(displayDate.getTime()));
3725                            }
3726    
3727                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
3728                    }
3729                    catch (Exception e) {
3730                            throw processException(e);
3731                    }
3732                    finally {
3733                            closeSession(session);
3734                    }
3735            }
3736    
3737            /**
3738             * 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;.
3739             *
3740             * @param entryId the primary key of the current blogs entry
3741             * @param groupId the group ID
3742             * @param displayDate the display date
3743             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3744             * @return the previous, current, and next blogs entry
3745             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
3746             */
3747            @Override
3748            public BlogsEntry[] filterFindByG_LtD_PrevAndNext(long entryId,
3749                    long groupId, Date displayDate,
3750                    OrderByComparator<BlogsEntry> orderByComparator)
3751                    throws NoSuchEntryException {
3752                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3753                            return findByG_LtD_PrevAndNext(entryId, groupId, displayDate,
3754                                    orderByComparator);
3755                    }
3756    
3757                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
3758    
3759                    Session session = null;
3760    
3761                    try {
3762                            session = openSession();
3763    
3764                            BlogsEntry[] array = new BlogsEntryImpl[3];
3765    
3766                            array[0] = filterGetByG_LtD_PrevAndNext(session, blogsEntry,
3767                                            groupId, displayDate, orderByComparator, true);
3768    
3769                            array[1] = blogsEntry;
3770    
3771                            array[2] = filterGetByG_LtD_PrevAndNext(session, blogsEntry,
3772                                            groupId, displayDate, orderByComparator, false);
3773    
3774                            return array;
3775                    }
3776                    catch (Exception e) {
3777                            throw processException(e);
3778                    }
3779                    finally {
3780                            closeSession(session);
3781                    }
3782            }
3783    
3784            protected BlogsEntry filterGetByG_LtD_PrevAndNext(Session session,
3785                    BlogsEntry blogsEntry, long groupId, Date displayDate,
3786                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
3787                    StringBundler query = null;
3788    
3789                    if (orderByComparator != null) {
3790                            query = new StringBundler(6 +
3791                                            (orderByComparator.getOrderByConditionFields().length * 3) +
3792                                            (orderByComparator.getOrderByFields().length * 3));
3793                    }
3794                    else {
3795                            query = new StringBundler(5);
3796                    }
3797    
3798                    if (getDB().isSupportsInlineDistinct()) {
3799                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
3800                    }
3801                    else {
3802                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
3803                    }
3804    
3805                    query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
3806    
3807                    boolean bindDisplayDate = false;
3808    
3809                    if (displayDate == null) {
3810                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
3811                    }
3812                    else {
3813                            bindDisplayDate = true;
3814    
3815                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
3816                    }
3817    
3818                    if (!getDB().isSupportsInlineDistinct()) {
3819                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
3820                    }
3821    
3822                    if (orderByComparator != null) {
3823                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3824    
3825                            if (orderByConditionFields.length > 0) {
3826                                    query.append(WHERE_AND);
3827                            }
3828    
3829                            for (int i = 0; i < orderByConditionFields.length; i++) {
3830                                    if (getDB().isSupportsInlineDistinct()) {
3831                                            query.append(_ORDER_BY_ENTITY_ALIAS);
3832                                    }
3833                                    else {
3834                                            query.append(_ORDER_BY_ENTITY_TABLE);
3835                                    }
3836    
3837                                    query.append(orderByConditionFields[i]);
3838    
3839                                    if ((i + 1) < orderByConditionFields.length) {
3840                                            if (orderByComparator.isAscending() ^ previous) {
3841                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3842                                            }
3843                                            else {
3844                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3845                                            }
3846                                    }
3847                                    else {
3848                                            if (orderByComparator.isAscending() ^ previous) {
3849                                                    query.append(WHERE_GREATER_THAN);
3850                                            }
3851                                            else {
3852                                                    query.append(WHERE_LESSER_THAN);
3853                                            }
3854                                    }
3855                            }
3856    
3857                            query.append(ORDER_BY_CLAUSE);
3858    
3859                            String[] orderByFields = orderByComparator.getOrderByFields();
3860    
3861                            for (int i = 0; i < orderByFields.length; i++) {
3862                                    if (getDB().isSupportsInlineDistinct()) {
3863                                            query.append(_ORDER_BY_ENTITY_ALIAS);
3864                                    }
3865                                    else {
3866                                            query.append(_ORDER_BY_ENTITY_TABLE);
3867                                    }
3868    
3869                                    query.append(orderByFields[i]);
3870    
3871                                    if ((i + 1) < orderByFields.length) {
3872                                            if (orderByComparator.isAscending() ^ previous) {
3873                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3874                                            }
3875                                            else {
3876                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3877                                            }
3878                                    }
3879                                    else {
3880                                            if (orderByComparator.isAscending() ^ previous) {
3881                                                    query.append(ORDER_BY_ASC);
3882                                            }
3883                                            else {
3884                                                    query.append(ORDER_BY_DESC);
3885                                            }
3886                                    }
3887                            }
3888                    }
3889                    else {
3890                            if (getDB().isSupportsInlineDistinct()) {
3891                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
3892                            }
3893                            else {
3894                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
3895                            }
3896                    }
3897    
3898                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3899                                    BlogsEntry.class.getName(),
3900                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3901    
3902                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
3903    
3904                    q.setFirstResult(0);
3905                    q.setMaxResults(2);
3906    
3907                    if (getDB().isSupportsInlineDistinct()) {
3908                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
3909                    }
3910                    else {
3911                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
3912                    }
3913    
3914                    QueryPos qPos = QueryPos.getInstance(q);
3915    
3916                    qPos.add(groupId);
3917    
3918                    if (bindDisplayDate) {
3919                            qPos.add(new Timestamp(displayDate.getTime()));
3920                    }
3921    
3922                    if (orderByComparator != null) {
3923                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
3924    
3925                            for (Object value : values) {
3926                                    qPos.add(value);
3927                            }
3928                    }
3929    
3930                    List<BlogsEntry> list = q.list();
3931    
3932                    if (list.size() == 2) {
3933                            return list.get(1);
3934                    }
3935                    else {
3936                            return null;
3937                    }
3938            }
3939    
3940            /**
3941             * Removes all the blogs entries where groupId = &#63; and displayDate &lt; &#63; from the database.
3942             *
3943             * @param groupId the group ID
3944             * @param displayDate the display date
3945             */
3946            @Override
3947            public void removeByG_LtD(long groupId, Date displayDate) {
3948                    for (BlogsEntry blogsEntry : findByG_LtD(groupId, displayDate,
3949                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3950                            remove(blogsEntry);
3951                    }
3952            }
3953    
3954            /**
3955             * Returns the number of blogs entries where groupId = &#63; and displayDate &lt; &#63;.
3956             *
3957             * @param groupId the group ID
3958             * @param displayDate the display date
3959             * @return the number of matching blogs entries
3960             */
3961            @Override
3962            public int countByG_LtD(long groupId, Date displayDate) {
3963                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD;
3964    
3965                    Object[] finderArgs = new Object[] { groupId, displayDate };
3966    
3967                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
3968    
3969                    if (count == null) {
3970                            StringBundler query = new StringBundler(3);
3971    
3972                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
3973    
3974                            query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
3975    
3976                            boolean bindDisplayDate = false;
3977    
3978                            if (displayDate == null) {
3979                                    query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
3980                            }
3981                            else {
3982                                    bindDisplayDate = true;
3983    
3984                                    query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
3985                            }
3986    
3987                            String sql = query.toString();
3988    
3989                            Session session = null;
3990    
3991                            try {
3992                                    session = openSession();
3993    
3994                                    Query q = session.createQuery(sql);
3995    
3996                                    QueryPos qPos = QueryPos.getInstance(q);
3997    
3998                                    qPos.add(groupId);
3999    
4000                                    if (bindDisplayDate) {
4001                                            qPos.add(new Timestamp(displayDate.getTime()));
4002                                    }
4003    
4004                                    count = (Long)q.uniqueResult();
4005    
4006                                    finderCache.putResult(finderPath, finderArgs, count);
4007                            }
4008                            catch (Exception e) {
4009                                    finderCache.removeResult(finderPath, finderArgs);
4010    
4011                                    throw processException(e);
4012                            }
4013                            finally {
4014                                    closeSession(session);
4015                            }
4016                    }
4017    
4018                    return count.intValue();
4019            }
4020    
4021            /**
4022             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63;.
4023             *
4024             * @param groupId the group ID
4025             * @param displayDate the display date
4026             * @return the number of matching blogs entries that the user has permission to view
4027             */
4028            @Override
4029            public int filterCountByG_LtD(long groupId, Date displayDate) {
4030                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4031                            return countByG_LtD(groupId, displayDate);
4032                    }
4033    
4034                    StringBundler query = new StringBundler(3);
4035    
4036                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
4037    
4038                    query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
4039    
4040                    boolean bindDisplayDate = false;
4041    
4042                    if (displayDate == null) {
4043                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
4044                    }
4045                    else {
4046                            bindDisplayDate = true;
4047    
4048                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
4049                    }
4050    
4051                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4052                                    BlogsEntry.class.getName(),
4053                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4054    
4055                    Session session = null;
4056    
4057                    try {
4058                            session = openSession();
4059    
4060                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
4061    
4062                            q.addScalar(COUNT_COLUMN_NAME,
4063                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
4064    
4065                            QueryPos qPos = QueryPos.getInstance(q);
4066    
4067                            qPos.add(groupId);
4068    
4069                            if (bindDisplayDate) {
4070                                    qPos.add(new Timestamp(displayDate.getTime()));
4071                            }
4072    
4073                            Long count = (Long)q.uniqueResult();
4074    
4075                            return count.intValue();
4076                    }
4077                    catch (Exception e) {
4078                            throw processException(e);
4079                    }
4080                    finally {
4081                            closeSession(session);
4082                    }
4083            }
4084    
4085            private static final String _FINDER_COLUMN_G_LTD_GROUPID_2 = "blogsEntry.groupId = ? AND ";
4086            private static final String _FINDER_COLUMN_G_LTD_DISPLAYDATE_1 = "blogsEntry.displayDate IS NULL";
4087            private static final String _FINDER_COLUMN_G_LTD_DISPLAYDATE_2 = "blogsEntry.displayDate < ?";
4088            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
4089                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
4090                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_S",
4091                            new String[] {
4092                                    Long.class.getName(), Integer.class.getName(),
4093                                    
4094                            Integer.class.getName(), Integer.class.getName(),
4095                                    OrderByComparator.class.getName()
4096                            });
4097            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
4098                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
4099                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_S",
4100                            new String[] { Long.class.getName(), Integer.class.getName() },
4101                            BlogsEntryModelImpl.GROUPID_COLUMN_BITMASK |
4102                            BlogsEntryModelImpl.STATUS_COLUMN_BITMASK |
4103                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
4104                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
4105            public static final FinderPath FINDER_PATH_COUNT_BY_G_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
4106                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
4107                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_S",
4108                            new String[] { Long.class.getName(), Integer.class.getName() });
4109    
4110            /**
4111             * Returns all the blogs entries where groupId = &#63; and status = &#63;.
4112             *
4113             * @param groupId the group ID
4114             * @param status the status
4115             * @return the matching blogs entries
4116             */
4117            @Override
4118            public List<BlogsEntry> findByG_S(long groupId, int status) {
4119                    return findByG_S(groupId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
4120                            null);
4121            }
4122    
4123            /**
4124             * Returns a range of all the blogs entries where groupId = &#63; and status = &#63;.
4125             *
4126             * <p>
4127             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4128             * </p>
4129             *
4130             * @param groupId the group ID
4131             * @param status the status
4132             * @param start the lower bound of the range of blogs entries
4133             * @param end the upper bound of the range of blogs entries (not inclusive)
4134             * @return the range of matching blogs entries
4135             */
4136            @Override
4137            public List<BlogsEntry> findByG_S(long groupId, int status, int start,
4138                    int end) {
4139                    return findByG_S(groupId, status, start, end, null);
4140            }
4141    
4142            /**
4143             * Returns an ordered range of all the blogs entries where groupId = &#63; and status = &#63;.
4144             *
4145             * <p>
4146             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4147             * </p>
4148             *
4149             * @param groupId the group ID
4150             * @param status the status
4151             * @param start the lower bound of the range of blogs entries
4152             * @param end the upper bound of the range of blogs entries (not inclusive)
4153             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4154             * @return the ordered range of matching blogs entries
4155             */
4156            @Override
4157            public List<BlogsEntry> findByG_S(long groupId, int status, int start,
4158                    int end, OrderByComparator<BlogsEntry> orderByComparator) {
4159                    return findByG_S(groupId, status, start, end, orderByComparator, true);
4160            }
4161    
4162            /**
4163             * Returns an ordered range of all the blogs entries where groupId = &#63; and status = &#63;.
4164             *
4165             * <p>
4166             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4167             * </p>
4168             *
4169             * @param groupId the group ID
4170             * @param status the status
4171             * @param start the lower bound of the range of blogs entries
4172             * @param end the upper bound of the range of blogs entries (not inclusive)
4173             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4174             * @param retrieveFromCache whether to retrieve from the finder cache
4175             * @return the ordered range of matching blogs entries
4176             */
4177            @Override
4178            public List<BlogsEntry> findByG_S(long groupId, int status, int start,
4179                    int end, OrderByComparator<BlogsEntry> orderByComparator,
4180                    boolean retrieveFromCache) {
4181                    boolean pagination = true;
4182                    FinderPath finderPath = null;
4183                    Object[] finderArgs = null;
4184    
4185                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4186                                    (orderByComparator == null)) {
4187                            pagination = false;
4188                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S;
4189                            finderArgs = new Object[] { groupId, status };
4190                    }
4191                    else {
4192                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S;
4193                            finderArgs = new Object[] {
4194                                            groupId, status,
4195                                            
4196                                            start, end, orderByComparator
4197                                    };
4198                    }
4199    
4200                    List<BlogsEntry> list = null;
4201    
4202                    if (retrieveFromCache) {
4203                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
4204                                            finderArgs, this);
4205    
4206                            if ((list != null) && !list.isEmpty()) {
4207                                    for (BlogsEntry blogsEntry : list) {
4208                                            if ((groupId != blogsEntry.getGroupId()) ||
4209                                                            (status != blogsEntry.getStatus())) {
4210                                                    list = null;
4211    
4212                                                    break;
4213                                            }
4214                                    }
4215                            }
4216                    }
4217    
4218                    if (list == null) {
4219                            StringBundler query = null;
4220    
4221                            if (orderByComparator != null) {
4222                                    query = new StringBundler(4 +
4223                                                    (orderByComparator.getOrderByFields().length * 2));
4224                            }
4225                            else {
4226                                    query = new StringBundler(4);
4227                            }
4228    
4229                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
4230    
4231                            query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4232    
4233                            query.append(_FINDER_COLUMN_G_S_STATUS_2);
4234    
4235                            if (orderByComparator != null) {
4236                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4237                                            orderByComparator);
4238                            }
4239                            else
4240                             if (pagination) {
4241                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
4242                            }
4243    
4244                            String sql = query.toString();
4245    
4246                            Session session = null;
4247    
4248                            try {
4249                                    session = openSession();
4250    
4251                                    Query q = session.createQuery(sql);
4252    
4253                                    QueryPos qPos = QueryPos.getInstance(q);
4254    
4255                                    qPos.add(groupId);
4256    
4257                                    qPos.add(status);
4258    
4259                                    if (!pagination) {
4260                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
4261                                                            start, end, false);
4262    
4263                                            Collections.sort(list);
4264    
4265                                            list = Collections.unmodifiableList(list);
4266                                    }
4267                                    else {
4268                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
4269                                                            start, end);
4270                                    }
4271    
4272                                    cacheResult(list);
4273    
4274                                    finderCache.putResult(finderPath, finderArgs, list);
4275                            }
4276                            catch (Exception e) {
4277                                    finderCache.removeResult(finderPath, finderArgs);
4278    
4279                                    throw processException(e);
4280                            }
4281                            finally {
4282                                    closeSession(session);
4283                            }
4284                    }
4285    
4286                    return list;
4287            }
4288    
4289            /**
4290             * Returns the first blogs entry in the ordered set where groupId = &#63; and status = &#63;.
4291             *
4292             * @param groupId the group ID
4293             * @param status the status
4294             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4295             * @return the first matching blogs entry
4296             * @throws NoSuchEntryException if a matching blogs entry could not be found
4297             */
4298            @Override
4299            public BlogsEntry findByG_S_First(long groupId, int status,
4300                    OrderByComparator<BlogsEntry> orderByComparator)
4301                    throws NoSuchEntryException {
4302                    BlogsEntry blogsEntry = fetchByG_S_First(groupId, status,
4303                                    orderByComparator);
4304    
4305                    if (blogsEntry != null) {
4306                            return blogsEntry;
4307                    }
4308    
4309                    StringBundler msg = new StringBundler(6);
4310    
4311                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4312    
4313                    msg.append("groupId=");
4314                    msg.append(groupId);
4315    
4316                    msg.append(", status=");
4317                    msg.append(status);
4318    
4319                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4320    
4321                    throw new NoSuchEntryException(msg.toString());
4322            }
4323    
4324            /**
4325             * Returns the first blogs entry in the ordered set where groupId = &#63; and status = &#63;.
4326             *
4327             * @param groupId the group ID
4328             * @param status the status
4329             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4330             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
4331             */
4332            @Override
4333            public BlogsEntry fetchByG_S_First(long groupId, int status,
4334                    OrderByComparator<BlogsEntry> orderByComparator) {
4335                    List<BlogsEntry> list = findByG_S(groupId, status, 0, 1,
4336                                    orderByComparator);
4337    
4338                    if (!list.isEmpty()) {
4339                            return list.get(0);
4340                    }
4341    
4342                    return null;
4343            }
4344    
4345            /**
4346             * Returns the last blogs entry in the ordered set where groupId = &#63; and status = &#63;.
4347             *
4348             * @param groupId the group ID
4349             * @param status the status
4350             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4351             * @return the last matching blogs entry
4352             * @throws NoSuchEntryException if a matching blogs entry could not be found
4353             */
4354            @Override
4355            public BlogsEntry findByG_S_Last(long groupId, int status,
4356                    OrderByComparator<BlogsEntry> orderByComparator)
4357                    throws NoSuchEntryException {
4358                    BlogsEntry blogsEntry = fetchByG_S_Last(groupId, status,
4359                                    orderByComparator);
4360    
4361                    if (blogsEntry != null) {
4362                            return blogsEntry;
4363                    }
4364    
4365                    StringBundler msg = new StringBundler(6);
4366    
4367                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4368    
4369                    msg.append("groupId=");
4370                    msg.append(groupId);
4371    
4372                    msg.append(", status=");
4373                    msg.append(status);
4374    
4375                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4376    
4377                    throw new NoSuchEntryException(msg.toString());
4378            }
4379    
4380            /**
4381             * Returns the last blogs entry in the ordered set where groupId = &#63; and status = &#63;.
4382             *
4383             * @param groupId the group ID
4384             * @param status the status
4385             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4386             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
4387             */
4388            @Override
4389            public BlogsEntry fetchByG_S_Last(long groupId, int status,
4390                    OrderByComparator<BlogsEntry> orderByComparator) {
4391                    int count = countByG_S(groupId, status);
4392    
4393                    if (count == 0) {
4394                            return null;
4395                    }
4396    
4397                    List<BlogsEntry> list = findByG_S(groupId, status, count - 1, count,
4398                                    orderByComparator);
4399    
4400                    if (!list.isEmpty()) {
4401                            return list.get(0);
4402                    }
4403    
4404                    return null;
4405            }
4406    
4407            /**
4408             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63; and status = &#63;.
4409             *
4410             * @param entryId the primary key of the current blogs entry
4411             * @param groupId the group ID
4412             * @param status the status
4413             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4414             * @return the previous, current, and next blogs entry
4415             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
4416             */
4417            @Override
4418            public BlogsEntry[] findByG_S_PrevAndNext(long entryId, long groupId,
4419                    int status, OrderByComparator<BlogsEntry> orderByComparator)
4420                    throws NoSuchEntryException {
4421                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
4422    
4423                    Session session = null;
4424    
4425                    try {
4426                            session = openSession();
4427    
4428                            BlogsEntry[] array = new BlogsEntryImpl[3];
4429    
4430                            array[0] = getByG_S_PrevAndNext(session, blogsEntry, groupId,
4431                                            status, orderByComparator, true);
4432    
4433                            array[1] = blogsEntry;
4434    
4435                            array[2] = getByG_S_PrevAndNext(session, blogsEntry, groupId,
4436                                            status, orderByComparator, false);
4437    
4438                            return array;
4439                    }
4440                    catch (Exception e) {
4441                            throw processException(e);
4442                    }
4443                    finally {
4444                            closeSession(session);
4445                    }
4446            }
4447    
4448            protected BlogsEntry getByG_S_PrevAndNext(Session session,
4449                    BlogsEntry blogsEntry, long groupId, int status,
4450                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
4451                    StringBundler query = null;
4452    
4453                    if (orderByComparator != null) {
4454                            query = new StringBundler(5 +
4455                                            (orderByComparator.getOrderByConditionFields().length * 3) +
4456                                            (orderByComparator.getOrderByFields().length * 3));
4457                    }
4458                    else {
4459                            query = new StringBundler(4);
4460                    }
4461    
4462                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
4463    
4464                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4465    
4466                    query.append(_FINDER_COLUMN_G_S_STATUS_2);
4467    
4468                    if (orderByComparator != null) {
4469                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4470    
4471                            if (orderByConditionFields.length > 0) {
4472                                    query.append(WHERE_AND);
4473                            }
4474    
4475                            for (int i = 0; i < orderByConditionFields.length; i++) {
4476                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4477                                    query.append(orderByConditionFields[i]);
4478    
4479                                    if ((i + 1) < orderByConditionFields.length) {
4480                                            if (orderByComparator.isAscending() ^ previous) {
4481                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4482                                            }
4483                                            else {
4484                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4485                                            }
4486                                    }
4487                                    else {
4488                                            if (orderByComparator.isAscending() ^ previous) {
4489                                                    query.append(WHERE_GREATER_THAN);
4490                                            }
4491                                            else {
4492                                                    query.append(WHERE_LESSER_THAN);
4493                                            }
4494                                    }
4495                            }
4496    
4497                            query.append(ORDER_BY_CLAUSE);
4498    
4499                            String[] orderByFields = orderByComparator.getOrderByFields();
4500    
4501                            for (int i = 0; i < orderByFields.length; i++) {
4502                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4503                                    query.append(orderByFields[i]);
4504    
4505                                    if ((i + 1) < orderByFields.length) {
4506                                            if (orderByComparator.isAscending() ^ previous) {
4507                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4508                                            }
4509                                            else {
4510                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4511                                            }
4512                                    }
4513                                    else {
4514                                            if (orderByComparator.isAscending() ^ previous) {
4515                                                    query.append(ORDER_BY_ASC);
4516                                            }
4517                                            else {
4518                                                    query.append(ORDER_BY_DESC);
4519                                            }
4520                                    }
4521                            }
4522                    }
4523                    else {
4524                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
4525                    }
4526    
4527                    String sql = query.toString();
4528    
4529                    Query q = session.createQuery(sql);
4530    
4531                    q.setFirstResult(0);
4532                    q.setMaxResults(2);
4533    
4534                    QueryPos qPos = QueryPos.getInstance(q);
4535    
4536                    qPos.add(groupId);
4537    
4538                    qPos.add(status);
4539    
4540                    if (orderByComparator != null) {
4541                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
4542    
4543                            for (Object value : values) {
4544                                    qPos.add(value);
4545                            }
4546                    }
4547    
4548                    List<BlogsEntry> list = q.list();
4549    
4550                    if (list.size() == 2) {
4551                            return list.get(1);
4552                    }
4553                    else {
4554                            return null;
4555                    }
4556            }
4557    
4558            /**
4559             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and status = &#63;.
4560             *
4561             * @param groupId the group ID
4562             * @param status the status
4563             * @return the matching blogs entries that the user has permission to view
4564             */
4565            @Override
4566            public List<BlogsEntry> filterFindByG_S(long groupId, int status) {
4567                    return filterFindByG_S(groupId, status, QueryUtil.ALL_POS,
4568                            QueryUtil.ALL_POS, null);
4569            }
4570    
4571            /**
4572             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63; and status = &#63;.
4573             *
4574             * <p>
4575             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4576             * </p>
4577             *
4578             * @param groupId the group ID
4579             * @param status the status
4580             * @param start the lower bound of the range of blogs entries
4581             * @param end the upper bound of the range of blogs entries (not inclusive)
4582             * @return the range of matching blogs entries that the user has permission to view
4583             */
4584            @Override
4585            public List<BlogsEntry> filterFindByG_S(long groupId, int status,
4586                    int start, int end) {
4587                    return filterFindByG_S(groupId, status, start, end, null);
4588            }
4589    
4590            /**
4591             * Returns an ordered range of all the blogs entries that the user has permissions to view where groupId = &#63; and status = &#63;.
4592             *
4593             * <p>
4594             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4595             * </p>
4596             *
4597             * @param groupId the group ID
4598             * @param status the status
4599             * @param start the lower bound of the range of blogs entries
4600             * @param end the upper bound of the range of blogs entries (not inclusive)
4601             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4602             * @return the ordered range of matching blogs entries that the user has permission to view
4603             */
4604            @Override
4605            public List<BlogsEntry> filterFindByG_S(long groupId, int status,
4606                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator) {
4607                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4608                            return findByG_S(groupId, status, start, end, orderByComparator);
4609                    }
4610    
4611                    StringBundler query = null;
4612    
4613                    if (orderByComparator != null) {
4614                            query = new StringBundler(4 +
4615                                            (orderByComparator.getOrderByFields().length * 2));
4616                    }
4617                    else {
4618                            query = new StringBundler(5);
4619                    }
4620    
4621                    if (getDB().isSupportsInlineDistinct()) {
4622                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
4623                    }
4624                    else {
4625                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
4626                    }
4627    
4628                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4629    
4630                    query.append(_FINDER_COLUMN_G_S_STATUS_2);
4631    
4632                    if (!getDB().isSupportsInlineDistinct()) {
4633                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
4634                    }
4635    
4636                    if (orderByComparator != null) {
4637                            if (getDB().isSupportsInlineDistinct()) {
4638                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4639                                            orderByComparator, true);
4640                            }
4641                            else {
4642                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
4643                                            orderByComparator, true);
4644                            }
4645                    }
4646                    else {
4647                            if (getDB().isSupportsInlineDistinct()) {
4648                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
4649                            }
4650                            else {
4651                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
4652                            }
4653                    }
4654    
4655                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4656                                    BlogsEntry.class.getName(),
4657                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4658    
4659                    Session session = null;
4660    
4661                    try {
4662                            session = openSession();
4663    
4664                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
4665    
4666                            if (getDB().isSupportsInlineDistinct()) {
4667                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
4668                            }
4669                            else {
4670                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
4671                            }
4672    
4673                            QueryPos qPos = QueryPos.getInstance(q);
4674    
4675                            qPos.add(groupId);
4676    
4677                            qPos.add(status);
4678    
4679                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
4680                    }
4681                    catch (Exception e) {
4682                            throw processException(e);
4683                    }
4684                    finally {
4685                            closeSession(session);
4686                    }
4687            }
4688    
4689            /**
4690             * 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;.
4691             *
4692             * @param entryId the primary key of the current blogs entry
4693             * @param groupId the group ID
4694             * @param status the status
4695             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4696             * @return the previous, current, and next blogs entry
4697             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
4698             */
4699            @Override
4700            public BlogsEntry[] filterFindByG_S_PrevAndNext(long entryId, long groupId,
4701                    int status, OrderByComparator<BlogsEntry> orderByComparator)
4702                    throws NoSuchEntryException {
4703                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4704                            return findByG_S_PrevAndNext(entryId, groupId, status,
4705                                    orderByComparator);
4706                    }
4707    
4708                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
4709    
4710                    Session session = null;
4711    
4712                    try {
4713                            session = openSession();
4714    
4715                            BlogsEntry[] array = new BlogsEntryImpl[3];
4716    
4717                            array[0] = filterGetByG_S_PrevAndNext(session, blogsEntry, groupId,
4718                                            status, orderByComparator, true);
4719    
4720                            array[1] = blogsEntry;
4721    
4722                            array[2] = filterGetByG_S_PrevAndNext(session, blogsEntry, groupId,
4723                                            status, orderByComparator, false);
4724    
4725                            return array;
4726                    }
4727                    catch (Exception e) {
4728                            throw processException(e);
4729                    }
4730                    finally {
4731                            closeSession(session);
4732                    }
4733            }
4734    
4735            protected BlogsEntry filterGetByG_S_PrevAndNext(Session session,
4736                    BlogsEntry blogsEntry, long groupId, int status,
4737                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
4738                    StringBundler query = null;
4739    
4740                    if (orderByComparator != null) {
4741                            query = new StringBundler(6 +
4742                                            (orderByComparator.getOrderByConditionFields().length * 3) +
4743                                            (orderByComparator.getOrderByFields().length * 3));
4744                    }
4745                    else {
4746                            query = new StringBundler(5);
4747                    }
4748    
4749                    if (getDB().isSupportsInlineDistinct()) {
4750                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
4751                    }
4752                    else {
4753                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
4754                    }
4755    
4756                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4757    
4758                    query.append(_FINDER_COLUMN_G_S_STATUS_2);
4759    
4760                    if (!getDB().isSupportsInlineDistinct()) {
4761                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
4762                    }
4763    
4764                    if (orderByComparator != null) {
4765                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4766    
4767                            if (orderByConditionFields.length > 0) {
4768                                    query.append(WHERE_AND);
4769                            }
4770    
4771                            for (int i = 0; i < orderByConditionFields.length; i++) {
4772                                    if (getDB().isSupportsInlineDistinct()) {
4773                                            query.append(_ORDER_BY_ENTITY_ALIAS);
4774                                    }
4775                                    else {
4776                                            query.append(_ORDER_BY_ENTITY_TABLE);
4777                                    }
4778    
4779                                    query.append(orderByConditionFields[i]);
4780    
4781                                    if ((i + 1) < orderByConditionFields.length) {
4782                                            if (orderByComparator.isAscending() ^ previous) {
4783                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4784                                            }
4785                                            else {
4786                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4787                                            }
4788                                    }
4789                                    else {
4790                                            if (orderByComparator.isAscending() ^ previous) {
4791                                                    query.append(WHERE_GREATER_THAN);
4792                                            }
4793                                            else {
4794                                                    query.append(WHERE_LESSER_THAN);
4795                                            }
4796                                    }
4797                            }
4798    
4799                            query.append(ORDER_BY_CLAUSE);
4800    
4801                            String[] orderByFields = orderByComparator.getOrderByFields();
4802    
4803                            for (int i = 0; i < orderByFields.length; i++) {
4804                                    if (getDB().isSupportsInlineDistinct()) {
4805                                            query.append(_ORDER_BY_ENTITY_ALIAS);
4806                                    }
4807                                    else {
4808                                            query.append(_ORDER_BY_ENTITY_TABLE);
4809                                    }
4810    
4811                                    query.append(orderByFields[i]);
4812    
4813                                    if ((i + 1) < orderByFields.length) {
4814                                            if (orderByComparator.isAscending() ^ previous) {
4815                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4816                                            }
4817                                            else {
4818                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4819                                            }
4820                                    }
4821                                    else {
4822                                            if (orderByComparator.isAscending() ^ previous) {
4823                                                    query.append(ORDER_BY_ASC);
4824                                            }
4825                                            else {
4826                                                    query.append(ORDER_BY_DESC);
4827                                            }
4828                                    }
4829                            }
4830                    }
4831                    else {
4832                            if (getDB().isSupportsInlineDistinct()) {
4833                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
4834                            }
4835                            else {
4836                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
4837                            }
4838                    }
4839    
4840                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4841                                    BlogsEntry.class.getName(),
4842                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4843    
4844                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
4845    
4846                    q.setFirstResult(0);
4847                    q.setMaxResults(2);
4848    
4849                    if (getDB().isSupportsInlineDistinct()) {
4850                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
4851                    }
4852                    else {
4853                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
4854                    }
4855    
4856                    QueryPos qPos = QueryPos.getInstance(q);
4857    
4858                    qPos.add(groupId);
4859    
4860                    qPos.add(status);
4861    
4862                    if (orderByComparator != null) {
4863                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
4864    
4865                            for (Object value : values) {
4866                                    qPos.add(value);
4867                            }
4868                    }
4869    
4870                    List<BlogsEntry> list = q.list();
4871    
4872                    if (list.size() == 2) {
4873                            return list.get(1);
4874                    }
4875                    else {
4876                            return null;
4877                    }
4878            }
4879    
4880            /**
4881             * Removes all the blogs entries where groupId = &#63; and status = &#63; from the database.
4882             *
4883             * @param groupId the group ID
4884             * @param status the status
4885             */
4886            @Override
4887            public void removeByG_S(long groupId, int status) {
4888                    for (BlogsEntry blogsEntry : findByG_S(groupId, status,
4889                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
4890                            remove(blogsEntry);
4891                    }
4892            }
4893    
4894            /**
4895             * Returns the number of blogs entries where groupId = &#63; and status = &#63;.
4896             *
4897             * @param groupId the group ID
4898             * @param status the status
4899             * @return the number of matching blogs entries
4900             */
4901            @Override
4902            public int countByG_S(long groupId, int status) {
4903                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_S;
4904    
4905                    Object[] finderArgs = new Object[] { groupId, status };
4906    
4907                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
4908    
4909                    if (count == null) {
4910                            StringBundler query = new StringBundler(3);
4911    
4912                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
4913    
4914                            query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4915    
4916                            query.append(_FINDER_COLUMN_G_S_STATUS_2);
4917    
4918                            String sql = query.toString();
4919    
4920                            Session session = null;
4921    
4922                            try {
4923                                    session = openSession();
4924    
4925                                    Query q = session.createQuery(sql);
4926    
4927                                    QueryPos qPos = QueryPos.getInstance(q);
4928    
4929                                    qPos.add(groupId);
4930    
4931                                    qPos.add(status);
4932    
4933                                    count = (Long)q.uniqueResult();
4934    
4935                                    finderCache.putResult(finderPath, finderArgs, count);
4936                            }
4937                            catch (Exception e) {
4938                                    finderCache.removeResult(finderPath, finderArgs);
4939    
4940                                    throw processException(e);
4941                            }
4942                            finally {
4943                                    closeSession(session);
4944                            }
4945                    }
4946    
4947                    return count.intValue();
4948            }
4949    
4950            /**
4951             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and status = &#63;.
4952             *
4953             * @param groupId the group ID
4954             * @param status the status
4955             * @return the number of matching blogs entries that the user has permission to view
4956             */
4957            @Override
4958            public int filterCountByG_S(long groupId, int status) {
4959                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4960                            return countByG_S(groupId, status);
4961                    }
4962    
4963                    StringBundler query = new StringBundler(3);
4964    
4965                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
4966    
4967                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4968    
4969                    query.append(_FINDER_COLUMN_G_S_STATUS_2);
4970    
4971                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4972                                    BlogsEntry.class.getName(),
4973                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4974    
4975                    Session session = null;
4976    
4977                    try {
4978                            session = openSession();
4979    
4980                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
4981    
4982                            q.addScalar(COUNT_COLUMN_NAME,
4983                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
4984    
4985                            QueryPos qPos = QueryPos.getInstance(q);
4986    
4987                            qPos.add(groupId);
4988    
4989                            qPos.add(status);
4990    
4991                            Long count = (Long)q.uniqueResult();
4992    
4993                            return count.intValue();
4994                    }
4995                    catch (Exception e) {
4996                            throw processException(e);
4997                    }
4998                    finally {
4999                            closeSession(session);
5000                    }
5001            }
5002    
5003            private static final String _FINDER_COLUMN_G_S_GROUPID_2 = "blogsEntry.groupId = ? AND ";
5004            private static final String _FINDER_COLUMN_G_S_STATUS_2 = "blogsEntry.status = ?";
5005            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_NOTS = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
5006                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
5007                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_NotS",
5008                            new String[] {
5009                                    Long.class.getName(), Integer.class.getName(),
5010                                    
5011                            Integer.class.getName(), Integer.class.getName(),
5012                                    OrderByComparator.class.getName()
5013                            });
5014            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_NOTS = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
5015                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
5016                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_NotS",
5017                            new String[] { Long.class.getName(), Integer.class.getName() });
5018    
5019            /**
5020             * Returns all the blogs entries where groupId = &#63; and status &ne; &#63;.
5021             *
5022             * @param groupId the group ID
5023             * @param status the status
5024             * @return the matching blogs entries
5025             */
5026            @Override
5027            public List<BlogsEntry> findByG_NotS(long groupId, int status) {
5028                    return findByG_NotS(groupId, status, QueryUtil.ALL_POS,
5029                            QueryUtil.ALL_POS, null);
5030            }
5031    
5032            /**
5033             * Returns a range of all the blogs entries where groupId = &#63; and status &ne; &#63;.
5034             *
5035             * <p>
5036             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5037             * </p>
5038             *
5039             * @param groupId the group ID
5040             * @param status the status
5041             * @param start the lower bound of the range of blogs entries
5042             * @param end the upper bound of the range of blogs entries (not inclusive)
5043             * @return the range of matching blogs entries
5044             */
5045            @Override
5046            public List<BlogsEntry> findByG_NotS(long groupId, int status, int start,
5047                    int end) {
5048                    return findByG_NotS(groupId, status, start, end, null);
5049            }
5050    
5051            /**
5052             * Returns an ordered range of all the blogs entries where groupId = &#63; and status &ne; &#63;.
5053             *
5054             * <p>
5055             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5056             * </p>
5057             *
5058             * @param groupId the group ID
5059             * @param status the status
5060             * @param start the lower bound of the range of blogs entries
5061             * @param end the upper bound of the range of blogs entries (not inclusive)
5062             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5063             * @return the ordered range of matching blogs entries
5064             */
5065            @Override
5066            public List<BlogsEntry> findByG_NotS(long groupId, int status, int start,
5067                    int end, OrderByComparator<BlogsEntry> orderByComparator) {
5068                    return findByG_NotS(groupId, status, start, end, orderByComparator, true);
5069            }
5070    
5071            /**
5072             * Returns an ordered range of all the blogs entries where groupId = &#63; and status &ne; &#63;.
5073             *
5074             * <p>
5075             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5076             * </p>
5077             *
5078             * @param groupId the group ID
5079             * @param status the status
5080             * @param start the lower bound of the range of blogs entries
5081             * @param end the upper bound of the range of blogs entries (not inclusive)
5082             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5083             * @param retrieveFromCache whether to retrieve from the finder cache
5084             * @return the ordered range of matching blogs entries
5085             */
5086            @Override
5087            public List<BlogsEntry> findByG_NotS(long groupId, int status, int start,
5088                    int end, OrderByComparator<BlogsEntry> orderByComparator,
5089                    boolean retrieveFromCache) {
5090                    boolean pagination = true;
5091                    FinderPath finderPath = null;
5092                    Object[] finderArgs = null;
5093    
5094                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_NOTS;
5095                    finderArgs = new Object[] { groupId, status, start, end, orderByComparator };
5096    
5097                    List<BlogsEntry> list = null;
5098    
5099                    if (retrieveFromCache) {
5100                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
5101                                            finderArgs, this);
5102    
5103                            if ((list != null) && !list.isEmpty()) {
5104                                    for (BlogsEntry blogsEntry : list) {
5105                                            if ((groupId != blogsEntry.getGroupId()) ||
5106                                                            (status == blogsEntry.getStatus())) {
5107                                                    list = null;
5108    
5109                                                    break;
5110                                            }
5111                                    }
5112                            }
5113                    }
5114    
5115                    if (list == null) {
5116                            StringBundler query = null;
5117    
5118                            if (orderByComparator != null) {
5119                                    query = new StringBundler(4 +
5120                                                    (orderByComparator.getOrderByFields().length * 2));
5121                            }
5122                            else {
5123                                    query = new StringBundler(4);
5124                            }
5125    
5126                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
5127    
5128                            query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
5129    
5130                            query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
5131    
5132                            if (orderByComparator != null) {
5133                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5134                                            orderByComparator);
5135                            }
5136                            else
5137                             if (pagination) {
5138                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
5139                            }
5140    
5141                            String sql = query.toString();
5142    
5143                            Session session = null;
5144    
5145                            try {
5146                                    session = openSession();
5147    
5148                                    Query q = session.createQuery(sql);
5149    
5150                                    QueryPos qPos = QueryPos.getInstance(q);
5151    
5152                                    qPos.add(groupId);
5153    
5154                                    qPos.add(status);
5155    
5156                                    if (!pagination) {
5157                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
5158                                                            start, end, false);
5159    
5160                                            Collections.sort(list);
5161    
5162                                            list = Collections.unmodifiableList(list);
5163                                    }
5164                                    else {
5165                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
5166                                                            start, end);
5167                                    }
5168    
5169                                    cacheResult(list);
5170    
5171                                    finderCache.putResult(finderPath, finderArgs, list);
5172                            }
5173                            catch (Exception e) {
5174                                    finderCache.removeResult(finderPath, finderArgs);
5175    
5176                                    throw processException(e);
5177                            }
5178                            finally {
5179                                    closeSession(session);
5180                            }
5181                    }
5182    
5183                    return list;
5184            }
5185    
5186            /**
5187             * Returns the first blogs entry in the ordered set where groupId = &#63; and status &ne; &#63;.
5188             *
5189             * @param groupId the group ID
5190             * @param status the status
5191             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5192             * @return the first matching blogs entry
5193             * @throws NoSuchEntryException if a matching blogs entry could not be found
5194             */
5195            @Override
5196            public BlogsEntry findByG_NotS_First(long groupId, int status,
5197                    OrderByComparator<BlogsEntry> orderByComparator)
5198                    throws NoSuchEntryException {
5199                    BlogsEntry blogsEntry = fetchByG_NotS_First(groupId, status,
5200                                    orderByComparator);
5201    
5202                    if (blogsEntry != null) {
5203                            return blogsEntry;
5204                    }
5205    
5206                    StringBundler msg = new StringBundler(6);
5207    
5208                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5209    
5210                    msg.append("groupId=");
5211                    msg.append(groupId);
5212    
5213                    msg.append(", status=");
5214                    msg.append(status);
5215    
5216                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5217    
5218                    throw new NoSuchEntryException(msg.toString());
5219            }
5220    
5221            /**
5222             * Returns the first blogs entry in the ordered set where groupId = &#63; and status &ne; &#63;.
5223             *
5224             * @param groupId the group ID
5225             * @param status the status
5226             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5227             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
5228             */
5229            @Override
5230            public BlogsEntry fetchByG_NotS_First(long groupId, int status,
5231                    OrderByComparator<BlogsEntry> orderByComparator) {
5232                    List<BlogsEntry> list = findByG_NotS(groupId, status, 0, 1,
5233                                    orderByComparator);
5234    
5235                    if (!list.isEmpty()) {
5236                            return list.get(0);
5237                    }
5238    
5239                    return null;
5240            }
5241    
5242            /**
5243             * Returns the last blogs entry in the ordered set where groupId = &#63; and status &ne; &#63;.
5244             *
5245             * @param groupId the group ID
5246             * @param status the status
5247             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5248             * @return the last matching blogs entry
5249             * @throws NoSuchEntryException if a matching blogs entry could not be found
5250             */
5251            @Override
5252            public BlogsEntry findByG_NotS_Last(long groupId, int status,
5253                    OrderByComparator<BlogsEntry> orderByComparator)
5254                    throws NoSuchEntryException {
5255                    BlogsEntry blogsEntry = fetchByG_NotS_Last(groupId, status,
5256                                    orderByComparator);
5257    
5258                    if (blogsEntry != null) {
5259                            return blogsEntry;
5260                    }
5261    
5262                    StringBundler msg = new StringBundler(6);
5263    
5264                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5265    
5266                    msg.append("groupId=");
5267                    msg.append(groupId);
5268    
5269                    msg.append(", status=");
5270                    msg.append(status);
5271    
5272                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5273    
5274                    throw new NoSuchEntryException(msg.toString());
5275            }
5276    
5277            /**
5278             * Returns the last blogs entry in the ordered set where groupId = &#63; and status &ne; &#63;.
5279             *
5280             * @param groupId the group ID
5281             * @param status the status
5282             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5283             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
5284             */
5285            @Override
5286            public BlogsEntry fetchByG_NotS_Last(long groupId, int status,
5287                    OrderByComparator<BlogsEntry> orderByComparator) {
5288                    int count = countByG_NotS(groupId, status);
5289    
5290                    if (count == 0) {
5291                            return null;
5292                    }
5293    
5294                    List<BlogsEntry> list = findByG_NotS(groupId, status, count - 1, count,
5295                                    orderByComparator);
5296    
5297                    if (!list.isEmpty()) {
5298                            return list.get(0);
5299                    }
5300    
5301                    return null;
5302            }
5303    
5304            /**
5305             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63; and status &ne; &#63;.
5306             *
5307             * @param entryId the primary key of the current blogs entry
5308             * @param groupId the group ID
5309             * @param status the status
5310             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5311             * @return the previous, current, and next blogs entry
5312             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
5313             */
5314            @Override
5315            public BlogsEntry[] findByG_NotS_PrevAndNext(long entryId, long groupId,
5316                    int status, OrderByComparator<BlogsEntry> orderByComparator)
5317                    throws NoSuchEntryException {
5318                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
5319    
5320                    Session session = null;
5321    
5322                    try {
5323                            session = openSession();
5324    
5325                            BlogsEntry[] array = new BlogsEntryImpl[3];
5326    
5327                            array[0] = getByG_NotS_PrevAndNext(session, blogsEntry, groupId,
5328                                            status, orderByComparator, true);
5329    
5330                            array[1] = blogsEntry;
5331    
5332                            array[2] = getByG_NotS_PrevAndNext(session, blogsEntry, groupId,
5333                                            status, orderByComparator, false);
5334    
5335                            return array;
5336                    }
5337                    catch (Exception e) {
5338                            throw processException(e);
5339                    }
5340                    finally {
5341                            closeSession(session);
5342                    }
5343            }
5344    
5345            protected BlogsEntry getByG_NotS_PrevAndNext(Session session,
5346                    BlogsEntry blogsEntry, long groupId, int status,
5347                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
5348                    StringBundler query = null;
5349    
5350                    if (orderByComparator != null) {
5351                            query = new StringBundler(5 +
5352                                            (orderByComparator.getOrderByConditionFields().length * 3) +
5353                                            (orderByComparator.getOrderByFields().length * 3));
5354                    }
5355                    else {
5356                            query = new StringBundler(4);
5357                    }
5358    
5359                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
5360    
5361                    query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
5362    
5363                    query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
5364    
5365                    if (orderByComparator != null) {
5366                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5367    
5368                            if (orderByConditionFields.length > 0) {
5369                                    query.append(WHERE_AND);
5370                            }
5371    
5372                            for (int i = 0; i < orderByConditionFields.length; i++) {
5373                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5374                                    query.append(orderByConditionFields[i]);
5375    
5376                                    if ((i + 1) < orderByConditionFields.length) {
5377                                            if (orderByComparator.isAscending() ^ previous) {
5378                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5379                                            }
5380                                            else {
5381                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5382                                            }
5383                                    }
5384                                    else {
5385                                            if (orderByComparator.isAscending() ^ previous) {
5386                                                    query.append(WHERE_GREATER_THAN);
5387                                            }
5388                                            else {
5389                                                    query.append(WHERE_LESSER_THAN);
5390                                            }
5391                                    }
5392                            }
5393    
5394                            query.append(ORDER_BY_CLAUSE);
5395    
5396                            String[] orderByFields = orderByComparator.getOrderByFields();
5397    
5398                            for (int i = 0; i < orderByFields.length; i++) {
5399                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5400                                    query.append(orderByFields[i]);
5401    
5402                                    if ((i + 1) < orderByFields.length) {
5403                                            if (orderByComparator.isAscending() ^ previous) {
5404                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5405                                            }
5406                                            else {
5407                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5408                                            }
5409                                    }
5410                                    else {
5411                                            if (orderByComparator.isAscending() ^ previous) {
5412                                                    query.append(ORDER_BY_ASC);
5413                                            }
5414                                            else {
5415                                                    query.append(ORDER_BY_DESC);
5416                                            }
5417                                    }
5418                            }
5419                    }
5420                    else {
5421                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
5422                    }
5423    
5424                    String sql = query.toString();
5425    
5426                    Query q = session.createQuery(sql);
5427    
5428                    q.setFirstResult(0);
5429                    q.setMaxResults(2);
5430    
5431                    QueryPos qPos = QueryPos.getInstance(q);
5432    
5433                    qPos.add(groupId);
5434    
5435                    qPos.add(status);
5436    
5437                    if (orderByComparator != null) {
5438                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
5439    
5440                            for (Object value : values) {
5441                                    qPos.add(value);
5442                            }
5443                    }
5444    
5445                    List<BlogsEntry> list = q.list();
5446    
5447                    if (list.size() == 2) {
5448                            return list.get(1);
5449                    }
5450                    else {
5451                            return null;
5452                    }
5453            }
5454    
5455            /**
5456             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and status &ne; &#63;.
5457             *
5458             * @param groupId the group ID
5459             * @param status the status
5460             * @return the matching blogs entries that the user has permission to view
5461             */
5462            @Override
5463            public List<BlogsEntry> filterFindByG_NotS(long groupId, int status) {
5464                    return filterFindByG_NotS(groupId, status, QueryUtil.ALL_POS,
5465                            QueryUtil.ALL_POS, null);
5466            }
5467    
5468            /**
5469             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63; and status &ne; &#63;.
5470             *
5471             * <p>
5472             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5473             * </p>
5474             *
5475             * @param groupId the group ID
5476             * @param status the status
5477             * @param start the lower bound of the range of blogs entries
5478             * @param end the upper bound of the range of blogs entries (not inclusive)
5479             * @return the range of matching blogs entries that the user has permission to view
5480             */
5481            @Override
5482            public List<BlogsEntry> filterFindByG_NotS(long groupId, int status,
5483                    int start, int end) {
5484                    return filterFindByG_NotS(groupId, status, start, end, null);
5485            }
5486    
5487            /**
5488             * Returns an ordered range of all the blogs entries that the user has permissions to view where groupId = &#63; and status &ne; &#63;.
5489             *
5490             * <p>
5491             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5492             * </p>
5493             *
5494             * @param groupId the group ID
5495             * @param status the status
5496             * @param start the lower bound of the range of blogs entries
5497             * @param end the upper bound of the range of blogs entries (not inclusive)
5498             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5499             * @return the ordered range of matching blogs entries that the user has permission to view
5500             */
5501            @Override
5502            public List<BlogsEntry> filterFindByG_NotS(long groupId, int status,
5503                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator) {
5504                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5505                            return findByG_NotS(groupId, status, start, end, orderByComparator);
5506                    }
5507    
5508                    StringBundler query = null;
5509    
5510                    if (orderByComparator != null) {
5511                            query = new StringBundler(4 +
5512                                            (orderByComparator.getOrderByFields().length * 2));
5513                    }
5514                    else {
5515                            query = new StringBundler(5);
5516                    }
5517    
5518                    if (getDB().isSupportsInlineDistinct()) {
5519                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
5520                    }
5521                    else {
5522                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
5523                    }
5524    
5525                    query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
5526    
5527                    query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
5528    
5529                    if (!getDB().isSupportsInlineDistinct()) {
5530                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
5531                    }
5532    
5533                    if (orderByComparator != null) {
5534                            if (getDB().isSupportsInlineDistinct()) {
5535                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5536                                            orderByComparator, true);
5537                            }
5538                            else {
5539                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
5540                                            orderByComparator, true);
5541                            }
5542                    }
5543                    else {
5544                            if (getDB().isSupportsInlineDistinct()) {
5545                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
5546                            }
5547                            else {
5548                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
5549                            }
5550                    }
5551    
5552                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5553                                    BlogsEntry.class.getName(),
5554                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5555    
5556                    Session session = null;
5557    
5558                    try {
5559                            session = openSession();
5560    
5561                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
5562    
5563                            if (getDB().isSupportsInlineDistinct()) {
5564                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
5565                            }
5566                            else {
5567                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
5568                            }
5569    
5570                            QueryPos qPos = QueryPos.getInstance(q);
5571    
5572                            qPos.add(groupId);
5573    
5574                            qPos.add(status);
5575    
5576                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
5577                    }
5578                    catch (Exception e) {
5579                            throw processException(e);
5580                    }
5581                    finally {
5582                            closeSession(session);
5583                    }
5584            }
5585    
5586            /**
5587             * 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;.
5588             *
5589             * @param entryId the primary key of the current blogs entry
5590             * @param groupId the group ID
5591             * @param status the status
5592             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5593             * @return the previous, current, and next blogs entry
5594             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
5595             */
5596            @Override
5597            public BlogsEntry[] filterFindByG_NotS_PrevAndNext(long entryId,
5598                    long groupId, int status,
5599                    OrderByComparator<BlogsEntry> orderByComparator)
5600                    throws NoSuchEntryException {
5601                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5602                            return findByG_NotS_PrevAndNext(entryId, groupId, status,
5603                                    orderByComparator);
5604                    }
5605    
5606                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
5607    
5608                    Session session = null;
5609    
5610                    try {
5611                            session = openSession();
5612    
5613                            BlogsEntry[] array = new BlogsEntryImpl[3];
5614    
5615                            array[0] = filterGetByG_NotS_PrevAndNext(session, blogsEntry,
5616                                            groupId, status, orderByComparator, true);
5617    
5618                            array[1] = blogsEntry;
5619    
5620                            array[2] = filterGetByG_NotS_PrevAndNext(session, blogsEntry,
5621                                            groupId, status, orderByComparator, false);
5622    
5623                            return array;
5624                    }
5625                    catch (Exception e) {
5626                            throw processException(e);
5627                    }
5628                    finally {
5629                            closeSession(session);
5630                    }
5631            }
5632    
5633            protected BlogsEntry filterGetByG_NotS_PrevAndNext(Session session,
5634                    BlogsEntry blogsEntry, long groupId, int status,
5635                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
5636                    StringBundler query = null;
5637    
5638                    if (orderByComparator != null) {
5639                            query = new StringBundler(6 +
5640                                            (orderByComparator.getOrderByConditionFields().length * 3) +
5641                                            (orderByComparator.getOrderByFields().length * 3));
5642                    }
5643                    else {
5644                            query = new StringBundler(5);
5645                    }
5646    
5647                    if (getDB().isSupportsInlineDistinct()) {
5648                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
5649                    }
5650                    else {
5651                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
5652                    }
5653    
5654                    query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
5655    
5656                    query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
5657    
5658                    if (!getDB().isSupportsInlineDistinct()) {
5659                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
5660                    }
5661    
5662                    if (orderByComparator != null) {
5663                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5664    
5665                            if (orderByConditionFields.length > 0) {
5666                                    query.append(WHERE_AND);
5667                            }
5668    
5669                            for (int i = 0; i < orderByConditionFields.length; i++) {
5670                                    if (getDB().isSupportsInlineDistinct()) {
5671                                            query.append(_ORDER_BY_ENTITY_ALIAS);
5672                                    }
5673                                    else {
5674                                            query.append(_ORDER_BY_ENTITY_TABLE);
5675                                    }
5676    
5677                                    query.append(orderByConditionFields[i]);
5678    
5679                                    if ((i + 1) < orderByConditionFields.length) {
5680                                            if (orderByComparator.isAscending() ^ previous) {
5681                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5682                                            }
5683                                            else {
5684                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5685                                            }
5686                                    }
5687                                    else {
5688                                            if (orderByComparator.isAscending() ^ previous) {
5689                                                    query.append(WHERE_GREATER_THAN);
5690                                            }
5691                                            else {
5692                                                    query.append(WHERE_LESSER_THAN);
5693                                            }
5694                                    }
5695                            }
5696    
5697                            query.append(ORDER_BY_CLAUSE);
5698    
5699                            String[] orderByFields = orderByComparator.getOrderByFields();
5700    
5701                            for (int i = 0; i < orderByFields.length; i++) {
5702                                    if (getDB().isSupportsInlineDistinct()) {
5703                                            query.append(_ORDER_BY_ENTITY_ALIAS);
5704                                    }
5705                                    else {
5706                                            query.append(_ORDER_BY_ENTITY_TABLE);
5707                                    }
5708    
5709                                    query.append(orderByFields[i]);
5710    
5711                                    if ((i + 1) < orderByFields.length) {
5712                                            if (orderByComparator.isAscending() ^ previous) {
5713                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5714                                            }
5715                                            else {
5716                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5717                                            }
5718                                    }
5719                                    else {
5720                                            if (orderByComparator.isAscending() ^ previous) {
5721                                                    query.append(ORDER_BY_ASC);
5722                                            }
5723                                            else {
5724                                                    query.append(ORDER_BY_DESC);
5725                                            }
5726                                    }
5727                            }
5728                    }
5729                    else {
5730                            if (getDB().isSupportsInlineDistinct()) {
5731                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
5732                            }
5733                            else {
5734                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
5735                            }
5736                    }
5737    
5738                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5739                                    BlogsEntry.class.getName(),
5740                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5741    
5742                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
5743    
5744                    q.setFirstResult(0);
5745                    q.setMaxResults(2);
5746    
5747                    if (getDB().isSupportsInlineDistinct()) {
5748                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
5749                    }
5750                    else {
5751                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
5752                    }
5753    
5754                    QueryPos qPos = QueryPos.getInstance(q);
5755    
5756                    qPos.add(groupId);
5757    
5758                    qPos.add(status);
5759    
5760                    if (orderByComparator != null) {
5761                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
5762    
5763                            for (Object value : values) {
5764                                    qPos.add(value);
5765                            }
5766                    }
5767    
5768                    List<BlogsEntry> list = q.list();
5769    
5770                    if (list.size() == 2) {
5771                            return list.get(1);
5772                    }
5773                    else {
5774                            return null;
5775                    }
5776            }
5777    
5778            /**
5779             * Removes all the blogs entries where groupId = &#63; and status &ne; &#63; from the database.
5780             *
5781             * @param groupId the group ID
5782             * @param status the status
5783             */
5784            @Override
5785            public void removeByG_NotS(long groupId, int status) {
5786                    for (BlogsEntry blogsEntry : findByG_NotS(groupId, status,
5787                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
5788                            remove(blogsEntry);
5789                    }
5790            }
5791    
5792            /**
5793             * Returns the number of blogs entries where groupId = &#63; and status &ne; &#63;.
5794             *
5795             * @param groupId the group ID
5796             * @param status the status
5797             * @return the number of matching blogs entries
5798             */
5799            @Override
5800            public int countByG_NotS(long groupId, int status) {
5801                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_NOTS;
5802    
5803                    Object[] finderArgs = new Object[] { groupId, status };
5804    
5805                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
5806    
5807                    if (count == null) {
5808                            StringBundler query = new StringBundler(3);
5809    
5810                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
5811    
5812                            query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
5813    
5814                            query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
5815    
5816                            String sql = query.toString();
5817    
5818                            Session session = null;
5819    
5820                            try {
5821                                    session = openSession();
5822    
5823                                    Query q = session.createQuery(sql);
5824    
5825                                    QueryPos qPos = QueryPos.getInstance(q);
5826    
5827                                    qPos.add(groupId);
5828    
5829                                    qPos.add(status);
5830    
5831                                    count = (Long)q.uniqueResult();
5832    
5833                                    finderCache.putResult(finderPath, finderArgs, count);
5834                            }
5835                            catch (Exception e) {
5836                                    finderCache.removeResult(finderPath, finderArgs);
5837    
5838                                    throw processException(e);
5839                            }
5840                            finally {
5841                                    closeSession(session);
5842                            }
5843                    }
5844    
5845                    return count.intValue();
5846            }
5847    
5848            /**
5849             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and status &ne; &#63;.
5850             *
5851             * @param groupId the group ID
5852             * @param status the status
5853             * @return the number of matching blogs entries that the user has permission to view
5854             */
5855            @Override
5856            public int filterCountByG_NotS(long groupId, int status) {
5857                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5858                            return countByG_NotS(groupId, status);
5859                    }
5860    
5861                    StringBundler query = new StringBundler(3);
5862    
5863                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
5864    
5865                    query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
5866    
5867                    query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
5868    
5869                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5870                                    BlogsEntry.class.getName(),
5871                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5872    
5873                    Session session = null;
5874    
5875                    try {
5876                            session = openSession();
5877    
5878                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
5879    
5880                            q.addScalar(COUNT_COLUMN_NAME,
5881                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
5882    
5883                            QueryPos qPos = QueryPos.getInstance(q);
5884    
5885                            qPos.add(groupId);
5886    
5887                            qPos.add(status);
5888    
5889                            Long count = (Long)q.uniqueResult();
5890    
5891                            return count.intValue();
5892                    }
5893                    catch (Exception e) {
5894                            throw processException(e);
5895                    }
5896                    finally {
5897                            closeSession(session);
5898                    }
5899            }
5900    
5901            private static final String _FINDER_COLUMN_G_NOTS_GROUPID_2 = "blogsEntry.groupId = ? AND ";
5902            private static final String _FINDER_COLUMN_G_NOTS_STATUS_2 = "blogsEntry.status != ?";
5903            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
5904                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
5905                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_U",
5906                            new String[] {
5907                                    Long.class.getName(), Long.class.getName(),
5908                                    
5909                            Integer.class.getName(), Integer.class.getName(),
5910                                    OrderByComparator.class.getName()
5911                            });
5912            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
5913                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
5914                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_U",
5915                            new String[] { Long.class.getName(), Long.class.getName() },
5916                            BlogsEntryModelImpl.COMPANYID_COLUMN_BITMASK |
5917                            BlogsEntryModelImpl.USERID_COLUMN_BITMASK |
5918                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
5919                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
5920            public static final FinderPath FINDER_PATH_COUNT_BY_C_U = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
5921                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
5922                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_U",
5923                            new String[] { Long.class.getName(), Long.class.getName() });
5924    
5925            /**
5926             * Returns all the blogs entries where companyId = &#63; and userId = &#63;.
5927             *
5928             * @param companyId the company ID
5929             * @param userId the user ID
5930             * @return the matching blogs entries
5931             */
5932            @Override
5933            public List<BlogsEntry> findByC_U(long companyId, long userId) {
5934                    return findByC_U(companyId, userId, QueryUtil.ALL_POS,
5935                            QueryUtil.ALL_POS, null);
5936            }
5937    
5938            /**
5939             * Returns a range of all the blogs entries where companyId = &#63; and userId = &#63;.
5940             *
5941             * <p>
5942             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5943             * </p>
5944             *
5945             * @param companyId the company ID
5946             * @param userId the user ID
5947             * @param start the lower bound of the range of blogs entries
5948             * @param end the upper bound of the range of blogs entries (not inclusive)
5949             * @return the range of matching blogs entries
5950             */
5951            @Override
5952            public List<BlogsEntry> findByC_U(long companyId, long userId, int start,
5953                    int end) {
5954                    return findByC_U(companyId, userId, start, end, null);
5955            }
5956    
5957            /**
5958             * Returns an ordered range of all the blogs entries where companyId = &#63; and userId = &#63;.
5959             *
5960             * <p>
5961             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5962             * </p>
5963             *
5964             * @param companyId the company ID
5965             * @param userId the user ID
5966             * @param start the lower bound of the range of blogs entries
5967             * @param end the upper bound of the range of blogs entries (not inclusive)
5968             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5969             * @return the ordered range of matching blogs entries
5970             */
5971            @Override
5972            public List<BlogsEntry> findByC_U(long companyId, long userId, int start,
5973                    int end, OrderByComparator<BlogsEntry> orderByComparator) {
5974                    return findByC_U(companyId, userId, start, end, orderByComparator, true);
5975            }
5976    
5977            /**
5978             * Returns an ordered range of all the blogs entries where companyId = &#63; and userId = &#63;.
5979             *
5980             * <p>
5981             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5982             * </p>
5983             *
5984             * @param companyId the company ID
5985             * @param userId the user ID
5986             * @param start the lower bound of the range of blogs entries
5987             * @param end the upper bound of the range of blogs entries (not inclusive)
5988             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5989             * @param retrieveFromCache whether to retrieve from the finder cache
5990             * @return the ordered range of matching blogs entries
5991             */
5992            @Override
5993            public List<BlogsEntry> findByC_U(long companyId, long userId, int start,
5994                    int end, OrderByComparator<BlogsEntry> orderByComparator,
5995                    boolean retrieveFromCache) {
5996                    boolean pagination = true;
5997                    FinderPath finderPath = null;
5998                    Object[] finderArgs = null;
5999    
6000                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6001                                    (orderByComparator == null)) {
6002                            pagination = false;
6003                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U;
6004                            finderArgs = new Object[] { companyId, userId };
6005                    }
6006                    else {
6007                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U;
6008                            finderArgs = new Object[] {
6009                                            companyId, userId,
6010                                            
6011                                            start, end, orderByComparator
6012                                    };
6013                    }
6014    
6015                    List<BlogsEntry> list = null;
6016    
6017                    if (retrieveFromCache) {
6018                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
6019                                            finderArgs, this);
6020    
6021                            if ((list != null) && !list.isEmpty()) {
6022                                    for (BlogsEntry blogsEntry : list) {
6023                                            if ((companyId != blogsEntry.getCompanyId()) ||
6024                                                            (userId != blogsEntry.getUserId())) {
6025                                                    list = null;
6026    
6027                                                    break;
6028                                            }
6029                                    }
6030                            }
6031                    }
6032    
6033                    if (list == null) {
6034                            StringBundler query = null;
6035    
6036                            if (orderByComparator != null) {
6037                                    query = new StringBundler(4 +
6038                                                    (orderByComparator.getOrderByFields().length * 2));
6039                            }
6040                            else {
6041                                    query = new StringBundler(4);
6042                            }
6043    
6044                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
6045    
6046                            query.append(_FINDER_COLUMN_C_U_COMPANYID_2);
6047    
6048                            query.append(_FINDER_COLUMN_C_U_USERID_2);
6049    
6050                            if (orderByComparator != null) {
6051                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6052                                            orderByComparator);
6053                            }
6054                            else
6055                             if (pagination) {
6056                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
6057                            }
6058    
6059                            String sql = query.toString();
6060    
6061                            Session session = null;
6062    
6063                            try {
6064                                    session = openSession();
6065    
6066                                    Query q = session.createQuery(sql);
6067    
6068                                    QueryPos qPos = QueryPos.getInstance(q);
6069    
6070                                    qPos.add(companyId);
6071    
6072                                    qPos.add(userId);
6073    
6074                                    if (!pagination) {
6075                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
6076                                                            start, end, false);
6077    
6078                                            Collections.sort(list);
6079    
6080                                            list = Collections.unmodifiableList(list);
6081                                    }
6082                                    else {
6083                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
6084                                                            start, end);
6085                                    }
6086    
6087                                    cacheResult(list);
6088    
6089                                    finderCache.putResult(finderPath, finderArgs, list);
6090                            }
6091                            catch (Exception e) {
6092                                    finderCache.removeResult(finderPath, finderArgs);
6093    
6094                                    throw processException(e);
6095                            }
6096                            finally {
6097                                    closeSession(session);
6098                            }
6099                    }
6100    
6101                    return list;
6102            }
6103    
6104            /**
6105             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63;.
6106             *
6107             * @param companyId the company ID
6108             * @param userId the user ID
6109             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6110             * @return the first matching blogs entry
6111             * @throws NoSuchEntryException if a matching blogs entry could not be found
6112             */
6113            @Override
6114            public BlogsEntry findByC_U_First(long companyId, long userId,
6115                    OrderByComparator<BlogsEntry> orderByComparator)
6116                    throws NoSuchEntryException {
6117                    BlogsEntry blogsEntry = fetchByC_U_First(companyId, userId,
6118                                    orderByComparator);
6119    
6120                    if (blogsEntry != null) {
6121                            return blogsEntry;
6122                    }
6123    
6124                    StringBundler msg = new StringBundler(6);
6125    
6126                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6127    
6128                    msg.append("companyId=");
6129                    msg.append(companyId);
6130    
6131                    msg.append(", userId=");
6132                    msg.append(userId);
6133    
6134                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6135    
6136                    throw new NoSuchEntryException(msg.toString());
6137            }
6138    
6139            /**
6140             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63;.
6141             *
6142             * @param companyId the company ID
6143             * @param userId the user ID
6144             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6145             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
6146             */
6147            @Override
6148            public BlogsEntry fetchByC_U_First(long companyId, long userId,
6149                    OrderByComparator<BlogsEntry> orderByComparator) {
6150                    List<BlogsEntry> list = findByC_U(companyId, userId, 0, 1,
6151                                    orderByComparator);
6152    
6153                    if (!list.isEmpty()) {
6154                            return list.get(0);
6155                    }
6156    
6157                    return null;
6158            }
6159    
6160            /**
6161             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63;.
6162             *
6163             * @param companyId the company ID
6164             * @param userId the user ID
6165             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6166             * @return the last matching blogs entry
6167             * @throws NoSuchEntryException if a matching blogs entry could not be found
6168             */
6169            @Override
6170            public BlogsEntry findByC_U_Last(long companyId, long userId,
6171                    OrderByComparator<BlogsEntry> orderByComparator)
6172                    throws NoSuchEntryException {
6173                    BlogsEntry blogsEntry = fetchByC_U_Last(companyId, userId,
6174                                    orderByComparator);
6175    
6176                    if (blogsEntry != null) {
6177                            return blogsEntry;
6178                    }
6179    
6180                    StringBundler msg = new StringBundler(6);
6181    
6182                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6183    
6184                    msg.append("companyId=");
6185                    msg.append(companyId);
6186    
6187                    msg.append(", userId=");
6188                    msg.append(userId);
6189    
6190                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6191    
6192                    throw new NoSuchEntryException(msg.toString());
6193            }
6194    
6195            /**
6196             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63;.
6197             *
6198             * @param companyId the company ID
6199             * @param userId the user ID
6200             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6201             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
6202             */
6203            @Override
6204            public BlogsEntry fetchByC_U_Last(long companyId, long userId,
6205                    OrderByComparator<BlogsEntry> orderByComparator) {
6206                    int count = countByC_U(companyId, userId);
6207    
6208                    if (count == 0) {
6209                            return null;
6210                    }
6211    
6212                    List<BlogsEntry> list = findByC_U(companyId, userId, count - 1, count,
6213                                    orderByComparator);
6214    
6215                    if (!list.isEmpty()) {
6216                            return list.get(0);
6217                    }
6218    
6219                    return null;
6220            }
6221    
6222            /**
6223             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63; and userId = &#63;.
6224             *
6225             * @param entryId the primary key of the current blogs entry
6226             * @param companyId the company ID
6227             * @param userId the user ID
6228             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6229             * @return the previous, current, and next blogs entry
6230             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
6231             */
6232            @Override
6233            public BlogsEntry[] findByC_U_PrevAndNext(long entryId, long companyId,
6234                    long userId, OrderByComparator<BlogsEntry> orderByComparator)
6235                    throws NoSuchEntryException {
6236                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
6237    
6238                    Session session = null;
6239    
6240                    try {
6241                            session = openSession();
6242    
6243                            BlogsEntry[] array = new BlogsEntryImpl[3];
6244    
6245                            array[0] = getByC_U_PrevAndNext(session, blogsEntry, companyId,
6246                                            userId, orderByComparator, true);
6247    
6248                            array[1] = blogsEntry;
6249    
6250                            array[2] = getByC_U_PrevAndNext(session, blogsEntry, companyId,
6251                                            userId, orderByComparator, false);
6252    
6253                            return array;
6254                    }
6255                    catch (Exception e) {
6256                            throw processException(e);
6257                    }
6258                    finally {
6259                            closeSession(session);
6260                    }
6261            }
6262    
6263            protected BlogsEntry getByC_U_PrevAndNext(Session session,
6264                    BlogsEntry blogsEntry, long companyId, long userId,
6265                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
6266                    StringBundler query = null;
6267    
6268                    if (orderByComparator != null) {
6269                            query = new StringBundler(5 +
6270                                            (orderByComparator.getOrderByConditionFields().length * 3) +
6271                                            (orderByComparator.getOrderByFields().length * 3));
6272                    }
6273                    else {
6274                            query = new StringBundler(4);
6275                    }
6276    
6277                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
6278    
6279                    query.append(_FINDER_COLUMN_C_U_COMPANYID_2);
6280    
6281                    query.append(_FINDER_COLUMN_C_U_USERID_2);
6282    
6283                    if (orderByComparator != null) {
6284                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6285    
6286                            if (orderByConditionFields.length > 0) {
6287                                    query.append(WHERE_AND);
6288                            }
6289    
6290                            for (int i = 0; i < orderByConditionFields.length; i++) {
6291                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6292                                    query.append(orderByConditionFields[i]);
6293    
6294                                    if ((i + 1) < orderByConditionFields.length) {
6295                                            if (orderByComparator.isAscending() ^ previous) {
6296                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6297                                            }
6298                                            else {
6299                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6300                                            }
6301                                    }
6302                                    else {
6303                                            if (orderByComparator.isAscending() ^ previous) {
6304                                                    query.append(WHERE_GREATER_THAN);
6305                                            }
6306                                            else {
6307                                                    query.append(WHERE_LESSER_THAN);
6308                                            }
6309                                    }
6310                            }
6311    
6312                            query.append(ORDER_BY_CLAUSE);
6313    
6314                            String[] orderByFields = orderByComparator.getOrderByFields();
6315    
6316                            for (int i = 0; i < orderByFields.length; i++) {
6317                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6318                                    query.append(orderByFields[i]);
6319    
6320                                    if ((i + 1) < orderByFields.length) {
6321                                            if (orderByComparator.isAscending() ^ previous) {
6322                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6323                                            }
6324                                            else {
6325                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6326                                            }
6327                                    }
6328                                    else {
6329                                            if (orderByComparator.isAscending() ^ previous) {
6330                                                    query.append(ORDER_BY_ASC);
6331                                            }
6332                                            else {
6333                                                    query.append(ORDER_BY_DESC);
6334                                            }
6335                                    }
6336                            }
6337                    }
6338                    else {
6339                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
6340                    }
6341    
6342                    String sql = query.toString();
6343    
6344                    Query q = session.createQuery(sql);
6345    
6346                    q.setFirstResult(0);
6347                    q.setMaxResults(2);
6348    
6349                    QueryPos qPos = QueryPos.getInstance(q);
6350    
6351                    qPos.add(companyId);
6352    
6353                    qPos.add(userId);
6354    
6355                    if (orderByComparator != null) {
6356                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
6357    
6358                            for (Object value : values) {
6359                                    qPos.add(value);
6360                            }
6361                    }
6362    
6363                    List<BlogsEntry> list = q.list();
6364    
6365                    if (list.size() == 2) {
6366                            return list.get(1);
6367                    }
6368                    else {
6369                            return null;
6370                    }
6371            }
6372    
6373            /**
6374             * Removes all the blogs entries where companyId = &#63; and userId = &#63; from the database.
6375             *
6376             * @param companyId the company ID
6377             * @param userId the user ID
6378             */
6379            @Override
6380            public void removeByC_U(long companyId, long userId) {
6381                    for (BlogsEntry blogsEntry : findByC_U(companyId, userId,
6382                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
6383                            remove(blogsEntry);
6384                    }
6385            }
6386    
6387            /**
6388             * Returns the number of blogs entries where companyId = &#63; and userId = &#63;.
6389             *
6390             * @param companyId the company ID
6391             * @param userId the user ID
6392             * @return the number of matching blogs entries
6393             */
6394            @Override
6395            public int countByC_U(long companyId, long userId) {
6396                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_U;
6397    
6398                    Object[] finderArgs = new Object[] { companyId, userId };
6399    
6400                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
6401    
6402                    if (count == null) {
6403                            StringBundler query = new StringBundler(3);
6404    
6405                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
6406    
6407                            query.append(_FINDER_COLUMN_C_U_COMPANYID_2);
6408    
6409                            query.append(_FINDER_COLUMN_C_U_USERID_2);
6410    
6411                            String sql = query.toString();
6412    
6413                            Session session = null;
6414    
6415                            try {
6416                                    session = openSession();
6417    
6418                                    Query q = session.createQuery(sql);
6419    
6420                                    QueryPos qPos = QueryPos.getInstance(q);
6421    
6422                                    qPos.add(companyId);
6423    
6424                                    qPos.add(userId);
6425    
6426                                    count = (Long)q.uniqueResult();
6427    
6428                                    finderCache.putResult(finderPath, finderArgs, count);
6429                            }
6430                            catch (Exception e) {
6431                                    finderCache.removeResult(finderPath, finderArgs);
6432    
6433                                    throw processException(e);
6434                            }
6435                            finally {
6436                                    closeSession(session);
6437                            }
6438                    }
6439    
6440                    return count.intValue();
6441            }
6442    
6443            private static final String _FINDER_COLUMN_C_U_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
6444            private static final String _FINDER_COLUMN_C_U_USERID_2 = "blogsEntry.userId = ?";
6445            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
6446                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
6447                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_LtD",
6448                            new String[] {
6449                                    Long.class.getName(), Date.class.getName(),
6450                                    
6451                            Integer.class.getName(), Integer.class.getName(),
6452                                    OrderByComparator.class.getName()
6453                            });
6454            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
6455                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
6456                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_LtD",
6457                            new String[] { Long.class.getName(), Date.class.getName() });
6458    
6459            /**
6460             * Returns all the blogs entries where companyId = &#63; and displayDate &lt; &#63;.
6461             *
6462             * @param companyId the company ID
6463             * @param displayDate the display date
6464             * @return the matching blogs entries
6465             */
6466            @Override
6467            public List<BlogsEntry> findByC_LtD(long companyId, Date displayDate) {
6468                    return findByC_LtD(companyId, displayDate, QueryUtil.ALL_POS,
6469                            QueryUtil.ALL_POS, null);
6470            }
6471    
6472            /**
6473             * Returns a range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63;.
6474             *
6475             * <p>
6476             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6477             * </p>
6478             *
6479             * @param companyId the company ID
6480             * @param displayDate the display date
6481             * @param start the lower bound of the range of blogs entries
6482             * @param end the upper bound of the range of blogs entries (not inclusive)
6483             * @return the range of matching blogs entries
6484             */
6485            @Override
6486            public List<BlogsEntry> findByC_LtD(long companyId, Date displayDate,
6487                    int start, int end) {
6488                    return findByC_LtD(companyId, displayDate, start, end, null);
6489            }
6490    
6491            /**
6492             * Returns an ordered range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63;.
6493             *
6494             * <p>
6495             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6496             * </p>
6497             *
6498             * @param companyId the company ID
6499             * @param displayDate the display date
6500             * @param start the lower bound of the range of blogs entries
6501             * @param end the upper bound of the range of blogs entries (not inclusive)
6502             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6503             * @return the ordered range of matching blogs entries
6504             */
6505            @Override
6506            public List<BlogsEntry> findByC_LtD(long companyId, Date displayDate,
6507                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator) {
6508                    return findByC_LtD(companyId, displayDate, start, end,
6509                            orderByComparator, true);
6510            }
6511    
6512            /**
6513             * Returns an ordered range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63;.
6514             *
6515             * <p>
6516             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6517             * </p>
6518             *
6519             * @param companyId the company ID
6520             * @param displayDate the display date
6521             * @param start the lower bound of the range of blogs entries
6522             * @param end the upper bound of the range of blogs entries (not inclusive)
6523             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6524             * @param retrieveFromCache whether to retrieve from the finder cache
6525             * @return the ordered range of matching blogs entries
6526             */
6527            @Override
6528            public List<BlogsEntry> findByC_LtD(long companyId, Date displayDate,
6529                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator,
6530                    boolean retrieveFromCache) {
6531                    boolean pagination = true;
6532                    FinderPath finderPath = null;
6533                    Object[] finderArgs = null;
6534    
6535                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD;
6536                    finderArgs = new Object[] {
6537                                    companyId, displayDate,
6538                                    
6539                                    start, end, orderByComparator
6540                            };
6541    
6542                    List<BlogsEntry> list = null;
6543    
6544                    if (retrieveFromCache) {
6545                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
6546                                            finderArgs, this);
6547    
6548                            if ((list != null) && !list.isEmpty()) {
6549                                    for (BlogsEntry blogsEntry : list) {
6550                                            if ((companyId != blogsEntry.getCompanyId()) ||
6551                                                            (displayDate.getTime() <= blogsEntry.getDisplayDate()
6552                                                                                                                                            .getTime())) {
6553                                                    list = null;
6554    
6555                                                    break;
6556                                            }
6557                                    }
6558                            }
6559                    }
6560    
6561                    if (list == null) {
6562                            StringBundler query = null;
6563    
6564                            if (orderByComparator != null) {
6565                                    query = new StringBundler(4 +
6566                                                    (orderByComparator.getOrderByFields().length * 2));
6567                            }
6568                            else {
6569                                    query = new StringBundler(4);
6570                            }
6571    
6572                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
6573    
6574                            query.append(_FINDER_COLUMN_C_LTD_COMPANYID_2);
6575    
6576                            boolean bindDisplayDate = false;
6577    
6578                            if (displayDate == null) {
6579                                    query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_1);
6580                            }
6581                            else {
6582                                    bindDisplayDate = true;
6583    
6584                                    query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_2);
6585                            }
6586    
6587                            if (orderByComparator != null) {
6588                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6589                                            orderByComparator);
6590                            }
6591                            else
6592                             if (pagination) {
6593                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
6594                            }
6595    
6596                            String sql = query.toString();
6597    
6598                            Session session = null;
6599    
6600                            try {
6601                                    session = openSession();
6602    
6603                                    Query q = session.createQuery(sql);
6604    
6605                                    QueryPos qPos = QueryPos.getInstance(q);
6606    
6607                                    qPos.add(companyId);
6608    
6609                                    if (bindDisplayDate) {
6610                                            qPos.add(new Timestamp(displayDate.getTime()));
6611                                    }
6612    
6613                                    if (!pagination) {
6614                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
6615                                                            start, end, false);
6616    
6617                                            Collections.sort(list);
6618    
6619                                            list = Collections.unmodifiableList(list);
6620                                    }
6621                                    else {
6622                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
6623                                                            start, end);
6624                                    }
6625    
6626                                    cacheResult(list);
6627    
6628                                    finderCache.putResult(finderPath, finderArgs, list);
6629                            }
6630                            catch (Exception e) {
6631                                    finderCache.removeResult(finderPath, finderArgs);
6632    
6633                                    throw processException(e);
6634                            }
6635                            finally {
6636                                    closeSession(session);
6637                            }
6638                    }
6639    
6640                    return list;
6641            }
6642    
6643            /**
6644             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63;.
6645             *
6646             * @param companyId the company ID
6647             * @param displayDate the display date
6648             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6649             * @return the first matching blogs entry
6650             * @throws NoSuchEntryException if a matching blogs entry could not be found
6651             */
6652            @Override
6653            public BlogsEntry findByC_LtD_First(long companyId, Date displayDate,
6654                    OrderByComparator<BlogsEntry> orderByComparator)
6655                    throws NoSuchEntryException {
6656                    BlogsEntry blogsEntry = fetchByC_LtD_First(companyId, displayDate,
6657                                    orderByComparator);
6658    
6659                    if (blogsEntry != null) {
6660                            return blogsEntry;
6661                    }
6662    
6663                    StringBundler msg = new StringBundler(6);
6664    
6665                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6666    
6667                    msg.append("companyId=");
6668                    msg.append(companyId);
6669    
6670                    msg.append(", displayDate=");
6671                    msg.append(displayDate);
6672    
6673                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6674    
6675                    throw new NoSuchEntryException(msg.toString());
6676            }
6677    
6678            /**
6679             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63;.
6680             *
6681             * @param companyId the company ID
6682             * @param displayDate the display date
6683             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6684             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
6685             */
6686            @Override
6687            public BlogsEntry fetchByC_LtD_First(long companyId, Date displayDate,
6688                    OrderByComparator<BlogsEntry> orderByComparator) {
6689                    List<BlogsEntry> list = findByC_LtD(companyId, displayDate, 0, 1,
6690                                    orderByComparator);
6691    
6692                    if (!list.isEmpty()) {
6693                            return list.get(0);
6694                    }
6695    
6696                    return null;
6697            }
6698    
6699            /**
6700             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63;.
6701             *
6702             * @param companyId the company ID
6703             * @param displayDate the display date
6704             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6705             * @return the last matching blogs entry
6706             * @throws NoSuchEntryException if a matching blogs entry could not be found
6707             */
6708            @Override
6709            public BlogsEntry findByC_LtD_Last(long companyId, Date displayDate,
6710                    OrderByComparator<BlogsEntry> orderByComparator)
6711                    throws NoSuchEntryException {
6712                    BlogsEntry blogsEntry = fetchByC_LtD_Last(companyId, displayDate,
6713                                    orderByComparator);
6714    
6715                    if (blogsEntry != null) {
6716                            return blogsEntry;
6717                    }
6718    
6719                    StringBundler msg = new StringBundler(6);
6720    
6721                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6722    
6723                    msg.append("companyId=");
6724                    msg.append(companyId);
6725    
6726                    msg.append(", displayDate=");
6727                    msg.append(displayDate);
6728    
6729                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6730    
6731                    throw new NoSuchEntryException(msg.toString());
6732            }
6733    
6734            /**
6735             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63;.
6736             *
6737             * @param companyId the company ID
6738             * @param displayDate the display date
6739             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6740             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
6741             */
6742            @Override
6743            public BlogsEntry fetchByC_LtD_Last(long companyId, Date displayDate,
6744                    OrderByComparator<BlogsEntry> orderByComparator) {
6745                    int count = countByC_LtD(companyId, displayDate);
6746    
6747                    if (count == 0) {
6748                            return null;
6749                    }
6750    
6751                    List<BlogsEntry> list = findByC_LtD(companyId, displayDate, count - 1,
6752                                    count, orderByComparator);
6753    
6754                    if (!list.isEmpty()) {
6755                            return list.get(0);
6756                    }
6757    
6758                    return null;
6759            }
6760    
6761            /**
6762             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63;.
6763             *
6764             * @param entryId the primary key of the current blogs entry
6765             * @param companyId the company ID
6766             * @param displayDate the display date
6767             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6768             * @return the previous, current, and next blogs entry
6769             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
6770             */
6771            @Override
6772            public BlogsEntry[] findByC_LtD_PrevAndNext(long entryId, long companyId,
6773                    Date displayDate, OrderByComparator<BlogsEntry> orderByComparator)
6774                    throws NoSuchEntryException {
6775                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
6776    
6777                    Session session = null;
6778    
6779                    try {
6780                            session = openSession();
6781    
6782                            BlogsEntry[] array = new BlogsEntryImpl[3];
6783    
6784                            array[0] = getByC_LtD_PrevAndNext(session, blogsEntry, companyId,
6785                                            displayDate, orderByComparator, true);
6786    
6787                            array[1] = blogsEntry;
6788    
6789                            array[2] = getByC_LtD_PrevAndNext(session, blogsEntry, companyId,
6790                                            displayDate, orderByComparator, false);
6791    
6792                            return array;
6793                    }
6794                    catch (Exception e) {
6795                            throw processException(e);
6796                    }
6797                    finally {
6798                            closeSession(session);
6799                    }
6800            }
6801    
6802            protected BlogsEntry getByC_LtD_PrevAndNext(Session session,
6803                    BlogsEntry blogsEntry, long companyId, Date displayDate,
6804                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
6805                    StringBundler query = null;
6806    
6807                    if (orderByComparator != null) {
6808                            query = new StringBundler(5 +
6809                                            (orderByComparator.getOrderByConditionFields().length * 3) +
6810                                            (orderByComparator.getOrderByFields().length * 3));
6811                    }
6812                    else {
6813                            query = new StringBundler(4);
6814                    }
6815    
6816                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
6817    
6818                    query.append(_FINDER_COLUMN_C_LTD_COMPANYID_2);
6819    
6820                    boolean bindDisplayDate = false;
6821    
6822                    if (displayDate == null) {
6823                            query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_1);
6824                    }
6825                    else {
6826                            bindDisplayDate = true;
6827    
6828                            query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_2);
6829                    }
6830    
6831                    if (orderByComparator != null) {
6832                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6833    
6834                            if (orderByConditionFields.length > 0) {
6835                                    query.append(WHERE_AND);
6836                            }
6837    
6838                            for (int i = 0; i < orderByConditionFields.length; i++) {
6839                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6840                                    query.append(orderByConditionFields[i]);
6841    
6842                                    if ((i + 1) < orderByConditionFields.length) {
6843                                            if (orderByComparator.isAscending() ^ previous) {
6844                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6845                                            }
6846                                            else {
6847                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6848                                            }
6849                                    }
6850                                    else {
6851                                            if (orderByComparator.isAscending() ^ previous) {
6852                                                    query.append(WHERE_GREATER_THAN);
6853                                            }
6854                                            else {
6855                                                    query.append(WHERE_LESSER_THAN);
6856                                            }
6857                                    }
6858                            }
6859    
6860                            query.append(ORDER_BY_CLAUSE);
6861    
6862                            String[] orderByFields = orderByComparator.getOrderByFields();
6863    
6864                            for (int i = 0; i < orderByFields.length; i++) {
6865                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6866                                    query.append(orderByFields[i]);
6867    
6868                                    if ((i + 1) < orderByFields.length) {
6869                                            if (orderByComparator.isAscending() ^ previous) {
6870                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6871                                            }
6872                                            else {
6873                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6874                                            }
6875                                    }
6876                                    else {
6877                                            if (orderByComparator.isAscending() ^ previous) {
6878                                                    query.append(ORDER_BY_ASC);
6879                                            }
6880                                            else {
6881                                                    query.append(ORDER_BY_DESC);
6882                                            }
6883                                    }
6884                            }
6885                    }
6886                    else {
6887                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
6888                    }
6889    
6890                    String sql = query.toString();
6891    
6892                    Query q = session.createQuery(sql);
6893    
6894                    q.setFirstResult(0);
6895                    q.setMaxResults(2);
6896    
6897                    QueryPos qPos = QueryPos.getInstance(q);
6898    
6899                    qPos.add(companyId);
6900    
6901                    if (bindDisplayDate) {
6902                            qPos.add(new Timestamp(displayDate.getTime()));
6903                    }
6904    
6905                    if (orderByComparator != null) {
6906                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
6907    
6908                            for (Object value : values) {
6909                                    qPos.add(value);
6910                            }
6911                    }
6912    
6913                    List<BlogsEntry> list = q.list();
6914    
6915                    if (list.size() == 2) {
6916                            return list.get(1);
6917                    }
6918                    else {
6919                            return null;
6920                    }
6921            }
6922    
6923            /**
6924             * Removes all the blogs entries where companyId = &#63; and displayDate &lt; &#63; from the database.
6925             *
6926             * @param companyId the company ID
6927             * @param displayDate the display date
6928             */
6929            @Override
6930            public void removeByC_LtD(long companyId, Date displayDate) {
6931                    for (BlogsEntry blogsEntry : findByC_LtD(companyId, displayDate,
6932                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
6933                            remove(blogsEntry);
6934                    }
6935            }
6936    
6937            /**
6938             * Returns the number of blogs entries where companyId = &#63; and displayDate &lt; &#63;.
6939             *
6940             * @param companyId the company ID
6941             * @param displayDate the display date
6942             * @return the number of matching blogs entries
6943             */
6944            @Override
6945            public int countByC_LtD(long companyId, Date displayDate) {
6946                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD;
6947    
6948                    Object[] finderArgs = new Object[] { companyId, displayDate };
6949    
6950                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
6951    
6952                    if (count == null) {
6953                            StringBundler query = new StringBundler(3);
6954    
6955                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
6956    
6957                            query.append(_FINDER_COLUMN_C_LTD_COMPANYID_2);
6958    
6959                            boolean bindDisplayDate = false;
6960    
6961                            if (displayDate == null) {
6962                                    query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_1);
6963                            }
6964                            else {
6965                                    bindDisplayDate = true;
6966    
6967                                    query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_2);
6968                            }
6969    
6970                            String sql = query.toString();
6971    
6972                            Session session = null;
6973    
6974                            try {
6975                                    session = openSession();
6976    
6977                                    Query q = session.createQuery(sql);
6978    
6979                                    QueryPos qPos = QueryPos.getInstance(q);
6980    
6981                                    qPos.add(companyId);
6982    
6983                                    if (bindDisplayDate) {
6984                                            qPos.add(new Timestamp(displayDate.getTime()));
6985                                    }
6986    
6987                                    count = (Long)q.uniqueResult();
6988    
6989                                    finderCache.putResult(finderPath, finderArgs, count);
6990                            }
6991                            catch (Exception e) {
6992                                    finderCache.removeResult(finderPath, finderArgs);
6993    
6994                                    throw processException(e);
6995                            }
6996                            finally {
6997                                    closeSession(session);
6998                            }
6999                    }
7000    
7001                    return count.intValue();
7002            }
7003    
7004            private static final String _FINDER_COLUMN_C_LTD_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
7005            private static final String _FINDER_COLUMN_C_LTD_DISPLAYDATE_1 = "blogsEntry.displayDate IS NULL";
7006            private static final String _FINDER_COLUMN_C_LTD_DISPLAYDATE_2 = "blogsEntry.displayDate < ?";
7007            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
7008                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
7009                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_S",
7010                            new String[] {
7011                                    Long.class.getName(), Integer.class.getName(),
7012                                    
7013                            Integer.class.getName(), Integer.class.getName(),
7014                                    OrderByComparator.class.getName()
7015                            });
7016            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
7017                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
7018                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_S",
7019                            new String[] { Long.class.getName(), Integer.class.getName() },
7020                            BlogsEntryModelImpl.COMPANYID_COLUMN_BITMASK |
7021                            BlogsEntryModelImpl.STATUS_COLUMN_BITMASK |
7022                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
7023                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
7024            public static final FinderPath FINDER_PATH_COUNT_BY_C_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
7025                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
7026                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_S",
7027                            new String[] { Long.class.getName(), Integer.class.getName() });
7028    
7029            /**
7030             * Returns all the blogs entries where companyId = &#63; and status = &#63;.
7031             *
7032             * @param companyId the company ID
7033             * @param status the status
7034             * @return the matching blogs entries
7035             */
7036            @Override
7037            public List<BlogsEntry> findByC_S(long companyId, int status) {
7038                    return findByC_S(companyId, status, QueryUtil.ALL_POS,
7039                            QueryUtil.ALL_POS, null);
7040            }
7041    
7042            /**
7043             * Returns a 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             * @return the range of matching blogs entries
7054             */
7055            @Override
7056            public List<BlogsEntry> findByC_S(long companyId, int status, int start,
7057                    int end) {
7058                    return findByC_S(companyId, status, start, end, null);
7059            }
7060    
7061            /**
7062             * Returns an ordered range of all the blogs entries where companyId = &#63; and status = &#63;.
7063             *
7064             * <p>
7065             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7066             * </p>
7067             *
7068             * @param companyId the company ID
7069             * @param status the status
7070             * @param start the lower bound of the range of blogs entries
7071             * @param end the upper bound of the range of blogs entries (not inclusive)
7072             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7073             * @return the ordered range of matching blogs entries
7074             */
7075            @Override
7076            public List<BlogsEntry> findByC_S(long companyId, int status, int start,
7077                    int end, OrderByComparator<BlogsEntry> orderByComparator) {
7078                    return findByC_S(companyId, status, start, end, orderByComparator, true);
7079            }
7080    
7081            /**
7082             * Returns an ordered range of all the blogs entries where companyId = &#63; and status = &#63;.
7083             *
7084             * <p>
7085             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7086             * </p>
7087             *
7088             * @param companyId the company ID
7089             * @param status the status
7090             * @param start the lower bound of the range of blogs entries
7091             * @param end the upper bound of the range of blogs entries (not inclusive)
7092             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7093             * @param retrieveFromCache whether to retrieve from the finder cache
7094             * @return the ordered range of matching blogs entries
7095             */
7096            @Override
7097            public List<BlogsEntry> findByC_S(long companyId, int status, int start,
7098                    int end, OrderByComparator<BlogsEntry> orderByComparator,
7099                    boolean retrieveFromCache) {
7100                    boolean pagination = true;
7101                    FinderPath finderPath = null;
7102                    Object[] finderArgs = null;
7103    
7104                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
7105                                    (orderByComparator == null)) {
7106                            pagination = false;
7107                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S;
7108                            finderArgs = new Object[] { companyId, status };
7109                    }
7110                    else {
7111                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_S;
7112                            finderArgs = new Object[] {
7113                                            companyId, status,
7114                                            
7115                                            start, end, orderByComparator
7116                                    };
7117                    }
7118    
7119                    List<BlogsEntry> list = null;
7120    
7121                    if (retrieveFromCache) {
7122                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
7123                                            finderArgs, this);
7124    
7125                            if ((list != null) && !list.isEmpty()) {
7126                                    for (BlogsEntry blogsEntry : list) {
7127                                            if ((companyId != blogsEntry.getCompanyId()) ||
7128                                                            (status != blogsEntry.getStatus())) {
7129                                                    list = null;
7130    
7131                                                    break;
7132                                            }
7133                                    }
7134                            }
7135                    }
7136    
7137                    if (list == null) {
7138                            StringBundler query = null;
7139    
7140                            if (orderByComparator != null) {
7141                                    query = new StringBundler(4 +
7142                                                    (orderByComparator.getOrderByFields().length * 2));
7143                            }
7144                            else {
7145                                    query = new StringBundler(4);
7146                            }
7147    
7148                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
7149    
7150                            query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
7151    
7152                            query.append(_FINDER_COLUMN_C_S_STATUS_2);
7153    
7154                            if (orderByComparator != null) {
7155                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7156                                            orderByComparator);
7157                            }
7158                            else
7159                             if (pagination) {
7160                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
7161                            }
7162    
7163                            String sql = query.toString();
7164    
7165                            Session session = null;
7166    
7167                            try {
7168                                    session = openSession();
7169    
7170                                    Query q = session.createQuery(sql);
7171    
7172                                    QueryPos qPos = QueryPos.getInstance(q);
7173    
7174                                    qPos.add(companyId);
7175    
7176                                    qPos.add(status);
7177    
7178                                    if (!pagination) {
7179                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
7180                                                            start, end, false);
7181    
7182                                            Collections.sort(list);
7183    
7184                                            list = Collections.unmodifiableList(list);
7185                                    }
7186                                    else {
7187                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
7188                                                            start, end);
7189                                    }
7190    
7191                                    cacheResult(list);
7192    
7193                                    finderCache.putResult(finderPath, finderArgs, list);
7194                            }
7195                            catch (Exception e) {
7196                                    finderCache.removeResult(finderPath, finderArgs);
7197    
7198                                    throw processException(e);
7199                            }
7200                            finally {
7201                                    closeSession(session);
7202                            }
7203                    }
7204    
7205                    return list;
7206            }
7207    
7208            /**
7209             * Returns the first blogs entry in the ordered set where companyId = &#63; and status = &#63;.
7210             *
7211             * @param companyId the company ID
7212             * @param status the status
7213             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7214             * @return the first matching blogs entry
7215             * @throws NoSuchEntryException if a matching blogs entry could not be found
7216             */
7217            @Override
7218            public BlogsEntry findByC_S_First(long companyId, int status,
7219                    OrderByComparator<BlogsEntry> orderByComparator)
7220                    throws NoSuchEntryException {
7221                    BlogsEntry blogsEntry = fetchByC_S_First(companyId, status,
7222                                    orderByComparator);
7223    
7224                    if (blogsEntry != null) {
7225                            return blogsEntry;
7226                    }
7227    
7228                    StringBundler msg = new StringBundler(6);
7229    
7230                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7231    
7232                    msg.append("companyId=");
7233                    msg.append(companyId);
7234    
7235                    msg.append(", status=");
7236                    msg.append(status);
7237    
7238                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7239    
7240                    throw new NoSuchEntryException(msg.toString());
7241            }
7242    
7243            /**
7244             * Returns the first blogs entry in the ordered set where companyId = &#63; and status = &#63;.
7245             *
7246             * @param companyId the company ID
7247             * @param status the status
7248             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7249             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
7250             */
7251            @Override
7252            public BlogsEntry fetchByC_S_First(long companyId, int status,
7253                    OrderByComparator<BlogsEntry> orderByComparator) {
7254                    List<BlogsEntry> list = findByC_S(companyId, status, 0, 1,
7255                                    orderByComparator);
7256    
7257                    if (!list.isEmpty()) {
7258                            return list.get(0);
7259                    }
7260    
7261                    return null;
7262            }
7263    
7264            /**
7265             * Returns the last blogs entry in the ordered set where companyId = &#63; and status = &#63;.
7266             *
7267             * @param companyId the company ID
7268             * @param status the status
7269             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7270             * @return the last matching blogs entry
7271             * @throws NoSuchEntryException if a matching blogs entry could not be found
7272             */
7273            @Override
7274            public BlogsEntry findByC_S_Last(long companyId, int status,
7275                    OrderByComparator<BlogsEntry> orderByComparator)
7276                    throws NoSuchEntryException {
7277                    BlogsEntry blogsEntry = fetchByC_S_Last(companyId, status,
7278                                    orderByComparator);
7279    
7280                    if (blogsEntry != null) {
7281                            return blogsEntry;
7282                    }
7283    
7284                    StringBundler msg = new StringBundler(6);
7285    
7286                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7287    
7288                    msg.append("companyId=");
7289                    msg.append(companyId);
7290    
7291                    msg.append(", status=");
7292                    msg.append(status);
7293    
7294                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7295    
7296                    throw new NoSuchEntryException(msg.toString());
7297            }
7298    
7299            /**
7300             * Returns the last blogs entry in the ordered set where companyId = &#63; and status = &#63;.
7301             *
7302             * @param companyId the company ID
7303             * @param status the status
7304             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7305             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
7306             */
7307            @Override
7308            public BlogsEntry fetchByC_S_Last(long companyId, int status,
7309                    OrderByComparator<BlogsEntry> orderByComparator) {
7310                    int count = countByC_S(companyId, status);
7311    
7312                    if (count == 0) {
7313                            return null;
7314                    }
7315    
7316                    List<BlogsEntry> list = findByC_S(companyId, status, count - 1, count,
7317                                    orderByComparator);
7318    
7319                    if (!list.isEmpty()) {
7320                            return list.get(0);
7321                    }
7322    
7323                    return null;
7324            }
7325    
7326            /**
7327             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63; and status = &#63;.
7328             *
7329             * @param entryId the primary key of the current blogs entry
7330             * @param companyId the company ID
7331             * @param status the status
7332             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7333             * @return the previous, current, and next blogs entry
7334             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
7335             */
7336            @Override
7337            public BlogsEntry[] findByC_S_PrevAndNext(long entryId, long companyId,
7338                    int status, OrderByComparator<BlogsEntry> orderByComparator)
7339                    throws NoSuchEntryException {
7340                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
7341    
7342                    Session session = null;
7343    
7344                    try {
7345                            session = openSession();
7346    
7347                            BlogsEntry[] array = new BlogsEntryImpl[3];
7348    
7349                            array[0] = getByC_S_PrevAndNext(session, blogsEntry, companyId,
7350                                            status, orderByComparator, true);
7351    
7352                            array[1] = blogsEntry;
7353    
7354                            array[2] = getByC_S_PrevAndNext(session, blogsEntry, companyId,
7355                                            status, orderByComparator, false);
7356    
7357                            return array;
7358                    }
7359                    catch (Exception e) {
7360                            throw processException(e);
7361                    }
7362                    finally {
7363                            closeSession(session);
7364                    }
7365            }
7366    
7367            protected BlogsEntry getByC_S_PrevAndNext(Session session,
7368                    BlogsEntry blogsEntry, long companyId, int status,
7369                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
7370                    StringBundler query = null;
7371    
7372                    if (orderByComparator != null) {
7373                            query = new StringBundler(5 +
7374                                            (orderByComparator.getOrderByConditionFields().length * 3) +
7375                                            (orderByComparator.getOrderByFields().length * 3));
7376                    }
7377                    else {
7378                            query = new StringBundler(4);
7379                    }
7380    
7381                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
7382    
7383                    query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
7384    
7385                    query.append(_FINDER_COLUMN_C_S_STATUS_2);
7386    
7387                    if (orderByComparator != null) {
7388                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7389    
7390                            if (orderByConditionFields.length > 0) {
7391                                    query.append(WHERE_AND);
7392                            }
7393    
7394                            for (int i = 0; i < orderByConditionFields.length; i++) {
7395                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7396                                    query.append(orderByConditionFields[i]);
7397    
7398                                    if ((i + 1) < orderByConditionFields.length) {
7399                                            if (orderByComparator.isAscending() ^ previous) {
7400                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7401                                            }
7402                                            else {
7403                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7404                                            }
7405                                    }
7406                                    else {
7407                                            if (orderByComparator.isAscending() ^ previous) {
7408                                                    query.append(WHERE_GREATER_THAN);
7409                                            }
7410                                            else {
7411                                                    query.append(WHERE_LESSER_THAN);
7412                                            }
7413                                    }
7414                            }
7415    
7416                            query.append(ORDER_BY_CLAUSE);
7417    
7418                            String[] orderByFields = orderByComparator.getOrderByFields();
7419    
7420                            for (int i = 0; i < orderByFields.length; i++) {
7421                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7422                                    query.append(orderByFields[i]);
7423    
7424                                    if ((i + 1) < orderByFields.length) {
7425                                            if (orderByComparator.isAscending() ^ previous) {
7426                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7427                                            }
7428                                            else {
7429                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7430                                            }
7431                                    }
7432                                    else {
7433                                            if (orderByComparator.isAscending() ^ previous) {
7434                                                    query.append(ORDER_BY_ASC);
7435                                            }
7436                                            else {
7437                                                    query.append(ORDER_BY_DESC);
7438                                            }
7439                                    }
7440                            }
7441                    }
7442                    else {
7443                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
7444                    }
7445    
7446                    String sql = query.toString();
7447    
7448                    Query q = session.createQuery(sql);
7449    
7450                    q.setFirstResult(0);
7451                    q.setMaxResults(2);
7452    
7453                    QueryPos qPos = QueryPos.getInstance(q);
7454    
7455                    qPos.add(companyId);
7456    
7457                    qPos.add(status);
7458    
7459                    if (orderByComparator != null) {
7460                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
7461    
7462                            for (Object value : values) {
7463                                    qPos.add(value);
7464                            }
7465                    }
7466    
7467                    List<BlogsEntry> list = q.list();
7468    
7469                    if (list.size() == 2) {
7470                            return list.get(1);
7471                    }
7472                    else {
7473                            return null;
7474                    }
7475            }
7476    
7477            /**
7478             * Removes all the blogs entries where companyId = &#63; and status = &#63; from the database.
7479             *
7480             * @param companyId the company ID
7481             * @param status the status
7482             */
7483            @Override
7484            public void removeByC_S(long companyId, int status) {
7485                    for (BlogsEntry blogsEntry : findByC_S(companyId, status,
7486                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
7487                            remove(blogsEntry);
7488                    }
7489            }
7490    
7491            /**
7492             * Returns the number of blogs entries where companyId = &#63; and status = &#63;.
7493             *
7494             * @param companyId the company ID
7495             * @param status the status
7496             * @return the number of matching blogs entries
7497             */
7498            @Override
7499            public int countByC_S(long companyId, int status) {
7500                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_S;
7501    
7502                    Object[] finderArgs = new Object[] { companyId, status };
7503    
7504                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
7505    
7506                    if (count == null) {
7507                            StringBundler query = new StringBundler(3);
7508    
7509                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
7510    
7511                            query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
7512    
7513                            query.append(_FINDER_COLUMN_C_S_STATUS_2);
7514    
7515                            String sql = query.toString();
7516    
7517                            Session session = null;
7518    
7519                            try {
7520                                    session = openSession();
7521    
7522                                    Query q = session.createQuery(sql);
7523    
7524                                    QueryPos qPos = QueryPos.getInstance(q);
7525    
7526                                    qPos.add(companyId);
7527    
7528                                    qPos.add(status);
7529    
7530                                    count = (Long)q.uniqueResult();
7531    
7532                                    finderCache.putResult(finderPath, finderArgs, count);
7533                            }
7534                            catch (Exception e) {
7535                                    finderCache.removeResult(finderPath, finderArgs);
7536    
7537                                    throw processException(e);
7538                            }
7539                            finally {
7540                                    closeSession(session);
7541                            }
7542                    }
7543    
7544                    return count.intValue();
7545            }
7546    
7547            private static final String _FINDER_COLUMN_C_S_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
7548            private static final String _FINDER_COLUMN_C_S_STATUS_2 = "blogsEntry.status = ?";
7549            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_NOTS = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
7550                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
7551                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_NotS",
7552                            new String[] {
7553                                    Long.class.getName(), Integer.class.getName(),
7554                                    
7555                            Integer.class.getName(), Integer.class.getName(),
7556                                    OrderByComparator.class.getName()
7557                            });
7558            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_NOTS = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
7559                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
7560                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_NotS",
7561                            new String[] { Long.class.getName(), Integer.class.getName() });
7562    
7563            /**
7564             * Returns all the blogs entries where companyId = &#63; and status &ne; &#63;.
7565             *
7566             * @param companyId the company ID
7567             * @param status the status
7568             * @return the matching blogs entries
7569             */
7570            @Override
7571            public List<BlogsEntry> findByC_NotS(long companyId, int status) {
7572                    return findByC_NotS(companyId, status, QueryUtil.ALL_POS,
7573                            QueryUtil.ALL_POS, null);
7574            }
7575    
7576            /**
7577             * Returns a range of all the blogs entries where companyId = &#63; and status &ne; &#63;.
7578             *
7579             * <p>
7580             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7581             * </p>
7582             *
7583             * @param companyId the company ID
7584             * @param status the status
7585             * @param start the lower bound of the range of blogs entries
7586             * @param end the upper bound of the range of blogs entries (not inclusive)
7587             * @return the range of matching blogs entries
7588             */
7589            @Override
7590            public List<BlogsEntry> findByC_NotS(long companyId, int status, int start,
7591                    int end) {
7592                    return findByC_NotS(companyId, status, start, end, null);
7593            }
7594    
7595            /**
7596             * Returns an ordered range of all the blogs entries where companyId = &#63; and status &ne; &#63;.
7597             *
7598             * <p>
7599             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7600             * </p>
7601             *
7602             * @param companyId the company ID
7603             * @param status the status
7604             * @param start the lower bound of the range of blogs entries
7605             * @param end the upper bound of the range of blogs entries (not inclusive)
7606             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7607             * @return the ordered range of matching blogs entries
7608             */
7609            @Override
7610            public List<BlogsEntry> findByC_NotS(long companyId, int status, int start,
7611                    int end, OrderByComparator<BlogsEntry> orderByComparator) {
7612                    return findByC_NotS(companyId, status, start, end, orderByComparator,
7613                            true);
7614            }
7615    
7616            /**
7617             * Returns an ordered range of all the blogs entries where companyId = &#63; and status &ne; &#63;.
7618             *
7619             * <p>
7620             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7621             * </p>
7622             *
7623             * @param companyId the company ID
7624             * @param status the status
7625             * @param start the lower bound of the range of blogs entries
7626             * @param end the upper bound of the range of blogs entries (not inclusive)
7627             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7628             * @param retrieveFromCache whether to retrieve from the finder cache
7629             * @return the ordered range of matching blogs entries
7630             */
7631            @Override
7632            public List<BlogsEntry> findByC_NotS(long companyId, int status, int start,
7633                    int end, OrderByComparator<BlogsEntry> orderByComparator,
7634                    boolean retrieveFromCache) {
7635                    boolean pagination = true;
7636                    FinderPath finderPath = null;
7637                    Object[] finderArgs = null;
7638    
7639                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_NOTS;
7640                    finderArgs = new Object[] {
7641                                    companyId, status,
7642                                    
7643                                    start, end, orderByComparator
7644                            };
7645    
7646                    List<BlogsEntry> list = null;
7647    
7648                    if (retrieveFromCache) {
7649                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
7650                                            finderArgs, this);
7651    
7652                            if ((list != null) && !list.isEmpty()) {
7653                                    for (BlogsEntry blogsEntry : list) {
7654                                            if ((companyId != blogsEntry.getCompanyId()) ||
7655                                                            (status == blogsEntry.getStatus())) {
7656                                                    list = null;
7657    
7658                                                    break;
7659                                            }
7660                                    }
7661                            }
7662                    }
7663    
7664                    if (list == null) {
7665                            StringBundler query = null;
7666    
7667                            if (orderByComparator != null) {
7668                                    query = new StringBundler(4 +
7669                                                    (orderByComparator.getOrderByFields().length * 2));
7670                            }
7671                            else {
7672                                    query = new StringBundler(4);
7673                            }
7674    
7675                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
7676    
7677                            query.append(_FINDER_COLUMN_C_NOTS_COMPANYID_2);
7678    
7679                            query.append(_FINDER_COLUMN_C_NOTS_STATUS_2);
7680    
7681                            if (orderByComparator != null) {
7682                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7683                                            orderByComparator);
7684                            }
7685                            else
7686                             if (pagination) {
7687                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
7688                            }
7689    
7690                            String sql = query.toString();
7691    
7692                            Session session = null;
7693    
7694                            try {
7695                                    session = openSession();
7696    
7697                                    Query q = session.createQuery(sql);
7698    
7699                                    QueryPos qPos = QueryPos.getInstance(q);
7700    
7701                                    qPos.add(companyId);
7702    
7703                                    qPos.add(status);
7704    
7705                                    if (!pagination) {
7706                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
7707                                                            start, end, false);
7708    
7709                                            Collections.sort(list);
7710    
7711                                            list = Collections.unmodifiableList(list);
7712                                    }
7713                                    else {
7714                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
7715                                                            start, end);
7716                                    }
7717    
7718                                    cacheResult(list);
7719    
7720                                    finderCache.putResult(finderPath, finderArgs, list);
7721                            }
7722                            catch (Exception e) {
7723                                    finderCache.removeResult(finderPath, finderArgs);
7724    
7725                                    throw processException(e);
7726                            }
7727                            finally {
7728                                    closeSession(session);
7729                            }
7730                    }
7731    
7732                    return list;
7733            }
7734    
7735            /**
7736             * Returns the first blogs entry in the ordered set where companyId = &#63; and status &ne; &#63;.
7737             *
7738             * @param companyId the company ID
7739             * @param status the status
7740             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7741             * @return the first matching blogs entry
7742             * @throws NoSuchEntryException if a matching blogs entry could not be found
7743             */
7744            @Override
7745            public BlogsEntry findByC_NotS_First(long companyId, int status,
7746                    OrderByComparator<BlogsEntry> orderByComparator)
7747                    throws NoSuchEntryException {
7748                    BlogsEntry blogsEntry = fetchByC_NotS_First(companyId, status,
7749                                    orderByComparator);
7750    
7751                    if (blogsEntry != null) {
7752                            return blogsEntry;
7753                    }
7754    
7755                    StringBundler msg = new StringBundler(6);
7756    
7757                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7758    
7759                    msg.append("companyId=");
7760                    msg.append(companyId);
7761    
7762                    msg.append(", status=");
7763                    msg.append(status);
7764    
7765                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7766    
7767                    throw new NoSuchEntryException(msg.toString());
7768            }
7769    
7770            /**
7771             * Returns the first blogs entry in the ordered set where companyId = &#63; and status &ne; &#63;.
7772             *
7773             * @param companyId the company ID
7774             * @param status the status
7775             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7776             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
7777             */
7778            @Override
7779            public BlogsEntry fetchByC_NotS_First(long companyId, int status,
7780                    OrderByComparator<BlogsEntry> orderByComparator) {
7781                    List<BlogsEntry> list = findByC_NotS(companyId, status, 0, 1,
7782                                    orderByComparator);
7783    
7784                    if (!list.isEmpty()) {
7785                            return list.get(0);
7786                    }
7787    
7788                    return null;
7789            }
7790    
7791            /**
7792             * Returns the last blogs entry in the ordered set where companyId = &#63; and status &ne; &#63;.
7793             *
7794             * @param companyId the company ID
7795             * @param status the status
7796             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7797             * @return the last matching blogs entry
7798             * @throws NoSuchEntryException if a matching blogs entry could not be found
7799             */
7800            @Override
7801            public BlogsEntry findByC_NotS_Last(long companyId, int status,
7802                    OrderByComparator<BlogsEntry> orderByComparator)
7803                    throws NoSuchEntryException {
7804                    BlogsEntry blogsEntry = fetchByC_NotS_Last(companyId, status,
7805                                    orderByComparator);
7806    
7807                    if (blogsEntry != null) {
7808                            return blogsEntry;
7809                    }
7810    
7811                    StringBundler msg = new StringBundler(6);
7812    
7813                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7814    
7815                    msg.append("companyId=");
7816                    msg.append(companyId);
7817    
7818                    msg.append(", status=");
7819                    msg.append(status);
7820    
7821                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7822    
7823                    throw new NoSuchEntryException(msg.toString());
7824            }
7825    
7826            /**
7827             * Returns the last blogs entry in the ordered set where companyId = &#63; and status &ne; &#63;.
7828             *
7829             * @param companyId the company ID
7830             * @param status the status
7831             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7832             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
7833             */
7834            @Override
7835            public BlogsEntry fetchByC_NotS_Last(long companyId, int status,
7836                    OrderByComparator<BlogsEntry> orderByComparator) {
7837                    int count = countByC_NotS(companyId, status);
7838    
7839                    if (count == 0) {
7840                            return null;
7841                    }
7842    
7843                    List<BlogsEntry> list = findByC_NotS(companyId, status, count - 1,
7844                                    count, orderByComparator);
7845    
7846                    if (!list.isEmpty()) {
7847                            return list.get(0);
7848                    }
7849    
7850                    return null;
7851            }
7852    
7853            /**
7854             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63; and status &ne; &#63;.
7855             *
7856             * @param entryId the primary key of the current blogs entry
7857             * @param companyId the company ID
7858             * @param status the status
7859             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7860             * @return the previous, current, and next blogs entry
7861             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
7862             */
7863            @Override
7864            public BlogsEntry[] findByC_NotS_PrevAndNext(long entryId, long companyId,
7865                    int status, OrderByComparator<BlogsEntry> orderByComparator)
7866                    throws NoSuchEntryException {
7867                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
7868    
7869                    Session session = null;
7870    
7871                    try {
7872                            session = openSession();
7873    
7874                            BlogsEntry[] array = new BlogsEntryImpl[3];
7875    
7876                            array[0] = getByC_NotS_PrevAndNext(session, blogsEntry, companyId,
7877                                            status, orderByComparator, true);
7878    
7879                            array[1] = blogsEntry;
7880    
7881                            array[2] = getByC_NotS_PrevAndNext(session, blogsEntry, companyId,
7882                                            status, orderByComparator, false);
7883    
7884                            return array;
7885                    }
7886                    catch (Exception e) {
7887                            throw processException(e);
7888                    }
7889                    finally {
7890                            closeSession(session);
7891                    }
7892            }
7893    
7894            protected BlogsEntry getByC_NotS_PrevAndNext(Session session,
7895                    BlogsEntry blogsEntry, long companyId, int status,
7896                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
7897                    StringBundler query = null;
7898    
7899                    if (orderByComparator != null) {
7900                            query = new StringBundler(5 +
7901                                            (orderByComparator.getOrderByConditionFields().length * 3) +
7902                                            (orderByComparator.getOrderByFields().length * 3));
7903                    }
7904                    else {
7905                            query = new StringBundler(4);
7906                    }
7907    
7908                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
7909    
7910                    query.append(_FINDER_COLUMN_C_NOTS_COMPANYID_2);
7911    
7912                    query.append(_FINDER_COLUMN_C_NOTS_STATUS_2);
7913    
7914                    if (orderByComparator != null) {
7915                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7916    
7917                            if (orderByConditionFields.length > 0) {
7918                                    query.append(WHERE_AND);
7919                            }
7920    
7921                            for (int i = 0; i < orderByConditionFields.length; i++) {
7922                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7923                                    query.append(orderByConditionFields[i]);
7924    
7925                                    if ((i + 1) < orderByConditionFields.length) {
7926                                            if (orderByComparator.isAscending() ^ previous) {
7927                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7928                                            }
7929                                            else {
7930                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7931                                            }
7932                                    }
7933                                    else {
7934                                            if (orderByComparator.isAscending() ^ previous) {
7935                                                    query.append(WHERE_GREATER_THAN);
7936                                            }
7937                                            else {
7938                                                    query.append(WHERE_LESSER_THAN);
7939                                            }
7940                                    }
7941                            }
7942    
7943                            query.append(ORDER_BY_CLAUSE);
7944    
7945                            String[] orderByFields = orderByComparator.getOrderByFields();
7946    
7947                            for (int i = 0; i < orderByFields.length; i++) {
7948                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7949                                    query.append(orderByFields[i]);
7950    
7951                                    if ((i + 1) < orderByFields.length) {
7952                                            if (orderByComparator.isAscending() ^ previous) {
7953                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7954                                            }
7955                                            else {
7956                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7957                                            }
7958                                    }
7959                                    else {
7960                                            if (orderByComparator.isAscending() ^ previous) {
7961                                                    query.append(ORDER_BY_ASC);
7962                                            }
7963                                            else {
7964                                                    query.append(ORDER_BY_DESC);
7965                                            }
7966                                    }
7967                            }
7968                    }
7969                    else {
7970                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
7971                    }
7972    
7973                    String sql = query.toString();
7974    
7975                    Query q = session.createQuery(sql);
7976    
7977                    q.setFirstResult(0);
7978                    q.setMaxResults(2);
7979    
7980                    QueryPos qPos = QueryPos.getInstance(q);
7981    
7982                    qPos.add(companyId);
7983    
7984                    qPos.add(status);
7985    
7986                    if (orderByComparator != null) {
7987                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
7988    
7989                            for (Object value : values) {
7990                                    qPos.add(value);
7991                            }
7992                    }
7993    
7994                    List<BlogsEntry> list = q.list();
7995    
7996                    if (list.size() == 2) {
7997                            return list.get(1);
7998                    }
7999                    else {
8000                            return null;
8001                    }
8002            }
8003    
8004            /**
8005             * Removes all the blogs entries where companyId = &#63; and status &ne; &#63; from the database.
8006             *
8007             * @param companyId the company ID
8008             * @param status the status
8009             */
8010            @Override
8011            public void removeByC_NotS(long companyId, int status) {
8012                    for (BlogsEntry blogsEntry : findByC_NotS(companyId, status,
8013                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
8014                            remove(blogsEntry);
8015                    }
8016            }
8017    
8018            /**
8019             * Returns the number of blogs entries where companyId = &#63; and status &ne; &#63;.
8020             *
8021             * @param companyId the company ID
8022             * @param status the status
8023             * @return the number of matching blogs entries
8024             */
8025            @Override
8026            public int countByC_NotS(long companyId, int status) {
8027                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_NOTS;
8028    
8029                    Object[] finderArgs = new Object[] { companyId, status };
8030    
8031                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
8032    
8033                    if (count == null) {
8034                            StringBundler query = new StringBundler(3);
8035    
8036                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
8037    
8038                            query.append(_FINDER_COLUMN_C_NOTS_COMPANYID_2);
8039    
8040                            query.append(_FINDER_COLUMN_C_NOTS_STATUS_2);
8041    
8042                            String sql = query.toString();
8043    
8044                            Session session = null;
8045    
8046                            try {
8047                                    session = openSession();
8048    
8049                                    Query q = session.createQuery(sql);
8050    
8051                                    QueryPos qPos = QueryPos.getInstance(q);
8052    
8053                                    qPos.add(companyId);
8054    
8055                                    qPos.add(status);
8056    
8057                                    count = (Long)q.uniqueResult();
8058    
8059                                    finderCache.putResult(finderPath, finderArgs, count);
8060                            }
8061                            catch (Exception e) {
8062                                    finderCache.removeResult(finderPath, finderArgs);
8063    
8064                                    throw processException(e);
8065                            }
8066                            finally {
8067                                    closeSession(session);
8068                            }
8069                    }
8070    
8071                    return count.intValue();
8072            }
8073    
8074            private static final String _FINDER_COLUMN_C_NOTS_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
8075            private static final String _FINDER_COLUMN_C_NOTS_STATUS_2 = "blogsEntry.status != ?";
8076            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
8077                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
8078                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByLtD_S",
8079                            new String[] {
8080                                    Date.class.getName(), Integer.class.getName(),
8081                                    
8082                            Integer.class.getName(), Integer.class.getName(),
8083                                    OrderByComparator.class.getName()
8084                            });
8085            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
8086                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
8087                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByLtD_S",
8088                            new String[] { Date.class.getName(), Integer.class.getName() });
8089    
8090            /**
8091             * Returns all the blogs entries where displayDate &lt; &#63; and status = &#63;.
8092             *
8093             * @param displayDate the display date
8094             * @param status the status
8095             * @return the matching blogs entries
8096             */
8097            @Override
8098            public List<BlogsEntry> findByLtD_S(Date displayDate, int status) {
8099                    return findByLtD_S(displayDate, status, QueryUtil.ALL_POS,
8100                            QueryUtil.ALL_POS, null);
8101            }
8102    
8103            /**
8104             * Returns a range of all the blogs entries where displayDate &lt; &#63; and status = &#63;.
8105             *
8106             * <p>
8107             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8108             * </p>
8109             *
8110             * @param displayDate the display date
8111             * @param status the status
8112             * @param start the lower bound of the range of blogs entries
8113             * @param end the upper bound of the range of blogs entries (not inclusive)
8114             * @return the range of matching blogs entries
8115             */
8116            @Override
8117            public List<BlogsEntry> findByLtD_S(Date displayDate, int status,
8118                    int start, int end) {
8119                    return findByLtD_S(displayDate, status, start, end, null);
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             * @return the ordered range of matching blogs entries
8135             */
8136            @Override
8137            public List<BlogsEntry> findByLtD_S(Date displayDate, int status,
8138                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator) {
8139                    return findByLtD_S(displayDate, status, start, end, orderByComparator,
8140                            true);
8141            }
8142    
8143            /**
8144             * Returns an ordered range of all the blogs entries where displayDate &lt; &#63; and status = &#63;.
8145             *
8146             * <p>
8147             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8148             * </p>
8149             *
8150             * @param displayDate the display date
8151             * @param status the status
8152             * @param start the lower bound of the range of blogs entries
8153             * @param end the upper bound of the range of blogs entries (not inclusive)
8154             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8155             * @param retrieveFromCache whether to retrieve from the finder cache
8156             * @return the ordered range of matching blogs entries
8157             */
8158            @Override
8159            public List<BlogsEntry> findByLtD_S(Date displayDate, int status,
8160                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator,
8161                    boolean retrieveFromCache) {
8162                    boolean pagination = true;
8163                    FinderPath finderPath = null;
8164                    Object[] finderArgs = null;
8165    
8166                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_LTD_S;
8167                    finderArgs = new Object[] {
8168                                    displayDate, status,
8169                                    
8170                                    start, end, orderByComparator
8171                            };
8172    
8173                    List<BlogsEntry> list = null;
8174    
8175                    if (retrieveFromCache) {
8176                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
8177                                            finderArgs, this);
8178    
8179                            if ((list != null) && !list.isEmpty()) {
8180                                    for (BlogsEntry blogsEntry : list) {
8181                                            if ((displayDate.getTime() <= blogsEntry.getDisplayDate()
8182                                                                                                                                    .getTime()) ||
8183                                                            (status != blogsEntry.getStatus())) {
8184                                                    list = null;
8185    
8186                                                    break;
8187                                            }
8188                                    }
8189                            }
8190                    }
8191    
8192                    if (list == null) {
8193                            StringBundler query = null;
8194    
8195                            if (orderByComparator != null) {
8196                                    query = new StringBundler(4 +
8197                                                    (orderByComparator.getOrderByFields().length * 2));
8198                            }
8199                            else {
8200                                    query = new StringBundler(4);
8201                            }
8202    
8203                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
8204    
8205                            boolean bindDisplayDate = false;
8206    
8207                            if (displayDate == null) {
8208                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_1);
8209                            }
8210                            else {
8211                                    bindDisplayDate = true;
8212    
8213                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_2);
8214                            }
8215    
8216                            query.append(_FINDER_COLUMN_LTD_S_STATUS_2);
8217    
8218                            if (orderByComparator != null) {
8219                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8220                                            orderByComparator);
8221                            }
8222                            else
8223                             if (pagination) {
8224                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
8225                            }
8226    
8227                            String sql = query.toString();
8228    
8229                            Session session = null;
8230    
8231                            try {
8232                                    session = openSession();
8233    
8234                                    Query q = session.createQuery(sql);
8235    
8236                                    QueryPos qPos = QueryPos.getInstance(q);
8237    
8238                                    if (bindDisplayDate) {
8239                                            qPos.add(new Timestamp(displayDate.getTime()));
8240                                    }
8241    
8242                                    qPos.add(status);
8243    
8244                                    if (!pagination) {
8245                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
8246                                                            start, end, false);
8247    
8248                                            Collections.sort(list);
8249    
8250                                            list = Collections.unmodifiableList(list);
8251                                    }
8252                                    else {
8253                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
8254                                                            start, end);
8255                                    }
8256    
8257                                    cacheResult(list);
8258    
8259                                    finderCache.putResult(finderPath, finderArgs, list);
8260                            }
8261                            catch (Exception e) {
8262                                    finderCache.removeResult(finderPath, finderArgs);
8263    
8264                                    throw processException(e);
8265                            }
8266                            finally {
8267                                    closeSession(session);
8268                            }
8269                    }
8270    
8271                    return list;
8272            }
8273    
8274            /**
8275             * Returns the first blogs entry in the ordered set where displayDate &lt; &#63; and status = &#63;.
8276             *
8277             * @param displayDate the display date
8278             * @param status the status
8279             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8280             * @return the first matching blogs entry
8281             * @throws NoSuchEntryException if a matching blogs entry could not be found
8282             */
8283            @Override
8284            public BlogsEntry findByLtD_S_First(Date displayDate, int status,
8285                    OrderByComparator<BlogsEntry> orderByComparator)
8286                    throws NoSuchEntryException {
8287                    BlogsEntry blogsEntry = fetchByLtD_S_First(displayDate, status,
8288                                    orderByComparator);
8289    
8290                    if (blogsEntry != null) {
8291                            return blogsEntry;
8292                    }
8293    
8294                    StringBundler msg = new StringBundler(6);
8295    
8296                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8297    
8298                    msg.append("displayDate=");
8299                    msg.append(displayDate);
8300    
8301                    msg.append(", status=");
8302                    msg.append(status);
8303    
8304                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8305    
8306                    throw new NoSuchEntryException(msg.toString());
8307            }
8308    
8309            /**
8310             * Returns the first 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 first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
8316             */
8317            @Override
8318            public BlogsEntry fetchByLtD_S_First(Date displayDate, int status,
8319                    OrderByComparator<BlogsEntry> orderByComparator) {
8320                    List<BlogsEntry> list = findByLtD_S(displayDate, status, 0, 1,
8321                                    orderByComparator);
8322    
8323                    if (!list.isEmpty()) {
8324                            return list.get(0);
8325                    }
8326    
8327                    return null;
8328            }
8329    
8330            /**
8331             * Returns the last blogs entry in the ordered set where displayDate &lt; &#63; and status = &#63;.
8332             *
8333             * @param displayDate the display date
8334             * @param status the status
8335             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8336             * @return the last matching blogs entry
8337             * @throws NoSuchEntryException if a matching blogs entry could not be found
8338             */
8339            @Override
8340            public BlogsEntry findByLtD_S_Last(Date displayDate, int status,
8341                    OrderByComparator<BlogsEntry> orderByComparator)
8342                    throws NoSuchEntryException {
8343                    BlogsEntry blogsEntry = fetchByLtD_S_Last(displayDate, status,
8344                                    orderByComparator);
8345    
8346                    if (blogsEntry != null) {
8347                            return blogsEntry;
8348                    }
8349    
8350                    StringBundler msg = new StringBundler(6);
8351    
8352                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8353    
8354                    msg.append("displayDate=");
8355                    msg.append(displayDate);
8356    
8357                    msg.append(", status=");
8358                    msg.append(status);
8359    
8360                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8361    
8362                    throw new NoSuchEntryException(msg.toString());
8363            }
8364    
8365            /**
8366             * Returns the last blogs entry in the ordered set where displayDate &lt; &#63; and status = &#63;.
8367             *
8368             * @param displayDate the display date
8369             * @param status the status
8370             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8371             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
8372             */
8373            @Override
8374            public BlogsEntry fetchByLtD_S_Last(Date displayDate, int status,
8375                    OrderByComparator<BlogsEntry> orderByComparator) {
8376                    int count = countByLtD_S(displayDate, status);
8377    
8378                    if (count == 0) {
8379                            return null;
8380                    }
8381    
8382                    List<BlogsEntry> list = findByLtD_S(displayDate, status, count - 1,
8383                                    count, orderByComparator);
8384    
8385                    if (!list.isEmpty()) {
8386                            return list.get(0);
8387                    }
8388    
8389                    return null;
8390            }
8391    
8392            /**
8393             * Returns the blogs entries before and after the current blogs entry in the ordered set where displayDate &lt; &#63; and status = &#63;.
8394             *
8395             * @param entryId the primary key of the current blogs entry
8396             * @param displayDate the display date
8397             * @param status the status
8398             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8399             * @return the previous, current, and next blogs entry
8400             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
8401             */
8402            @Override
8403            public BlogsEntry[] findByLtD_S_PrevAndNext(long entryId, Date displayDate,
8404                    int status, OrderByComparator<BlogsEntry> orderByComparator)
8405                    throws NoSuchEntryException {
8406                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
8407    
8408                    Session session = null;
8409    
8410                    try {
8411                            session = openSession();
8412    
8413                            BlogsEntry[] array = new BlogsEntryImpl[3];
8414    
8415                            array[0] = getByLtD_S_PrevAndNext(session, blogsEntry, displayDate,
8416                                            status, orderByComparator, true);
8417    
8418                            array[1] = blogsEntry;
8419    
8420                            array[2] = getByLtD_S_PrevAndNext(session, blogsEntry, displayDate,
8421                                            status, orderByComparator, false);
8422    
8423                            return array;
8424                    }
8425                    catch (Exception e) {
8426                            throw processException(e);
8427                    }
8428                    finally {
8429                            closeSession(session);
8430                    }
8431            }
8432    
8433            protected BlogsEntry getByLtD_S_PrevAndNext(Session session,
8434                    BlogsEntry blogsEntry, Date displayDate, int status,
8435                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
8436                    StringBundler query = null;
8437    
8438                    if (orderByComparator != null) {
8439                            query = new StringBundler(5 +
8440                                            (orderByComparator.getOrderByConditionFields().length * 3) +
8441                                            (orderByComparator.getOrderByFields().length * 3));
8442                    }
8443                    else {
8444                            query = new StringBundler(4);
8445                    }
8446    
8447                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
8448    
8449                    boolean bindDisplayDate = false;
8450    
8451                    if (displayDate == null) {
8452                            query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_1);
8453                    }
8454                    else {
8455                            bindDisplayDate = true;
8456    
8457                            query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_2);
8458                    }
8459    
8460                    query.append(_FINDER_COLUMN_LTD_S_STATUS_2);
8461    
8462                    if (orderByComparator != null) {
8463                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8464    
8465                            if (orderByConditionFields.length > 0) {
8466                                    query.append(WHERE_AND);
8467                            }
8468    
8469                            for (int i = 0; i < orderByConditionFields.length; i++) {
8470                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8471                                    query.append(orderByConditionFields[i]);
8472    
8473                                    if ((i + 1) < orderByConditionFields.length) {
8474                                            if (orderByComparator.isAscending() ^ previous) {
8475                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8476                                            }
8477                                            else {
8478                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8479                                            }
8480                                    }
8481                                    else {
8482                                            if (orderByComparator.isAscending() ^ previous) {
8483                                                    query.append(WHERE_GREATER_THAN);
8484                                            }
8485                                            else {
8486                                                    query.append(WHERE_LESSER_THAN);
8487                                            }
8488                                    }
8489                            }
8490    
8491                            query.append(ORDER_BY_CLAUSE);
8492    
8493                            String[] orderByFields = orderByComparator.getOrderByFields();
8494    
8495                            for (int i = 0; i < orderByFields.length; i++) {
8496                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8497                                    query.append(orderByFields[i]);
8498    
8499                                    if ((i + 1) < orderByFields.length) {
8500                                            if (orderByComparator.isAscending() ^ previous) {
8501                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8502                                            }
8503                                            else {
8504                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8505                                            }
8506                                    }
8507                                    else {
8508                                            if (orderByComparator.isAscending() ^ previous) {
8509                                                    query.append(ORDER_BY_ASC);
8510                                            }
8511                                            else {
8512                                                    query.append(ORDER_BY_DESC);
8513                                            }
8514                                    }
8515                            }
8516                    }
8517                    else {
8518                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
8519                    }
8520    
8521                    String sql = query.toString();
8522    
8523                    Query q = session.createQuery(sql);
8524    
8525                    q.setFirstResult(0);
8526                    q.setMaxResults(2);
8527    
8528                    QueryPos qPos = QueryPos.getInstance(q);
8529    
8530                    if (bindDisplayDate) {
8531                            qPos.add(new Timestamp(displayDate.getTime()));
8532                    }
8533    
8534                    qPos.add(status);
8535    
8536                    if (orderByComparator != null) {
8537                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
8538    
8539                            for (Object value : values) {
8540                                    qPos.add(value);
8541                            }
8542                    }
8543    
8544                    List<BlogsEntry> list = q.list();
8545    
8546                    if (list.size() == 2) {
8547                            return list.get(1);
8548                    }
8549                    else {
8550                            return null;
8551                    }
8552            }
8553    
8554            /**
8555             * Removes all the blogs entries where displayDate &lt; &#63; and status = &#63; from the database.
8556             *
8557             * @param displayDate the display date
8558             * @param status the status
8559             */
8560            @Override
8561            public void removeByLtD_S(Date displayDate, int status) {
8562                    for (BlogsEntry blogsEntry : findByLtD_S(displayDate, status,
8563                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
8564                            remove(blogsEntry);
8565                    }
8566            }
8567    
8568            /**
8569             * Returns the number of blogs entries where displayDate &lt; &#63; and status = &#63;.
8570             *
8571             * @param displayDate the display date
8572             * @param status the status
8573             * @return the number of matching blogs entries
8574             */
8575            @Override
8576            public int countByLtD_S(Date displayDate, int status) {
8577                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_LTD_S;
8578    
8579                    Object[] finderArgs = new Object[] { displayDate, status };
8580    
8581                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
8582    
8583                    if (count == null) {
8584                            StringBundler query = new StringBundler(3);
8585    
8586                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
8587    
8588                            boolean bindDisplayDate = false;
8589    
8590                            if (displayDate == null) {
8591                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_1);
8592                            }
8593                            else {
8594                                    bindDisplayDate = true;
8595    
8596                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_2);
8597                            }
8598    
8599                            query.append(_FINDER_COLUMN_LTD_S_STATUS_2);
8600    
8601                            String sql = query.toString();
8602    
8603                            Session session = null;
8604    
8605                            try {
8606                                    session = openSession();
8607    
8608                                    Query q = session.createQuery(sql);
8609    
8610                                    QueryPos qPos = QueryPos.getInstance(q);
8611    
8612                                    if (bindDisplayDate) {
8613                                            qPos.add(new Timestamp(displayDate.getTime()));
8614                                    }
8615    
8616                                    qPos.add(status);
8617    
8618                                    count = (Long)q.uniqueResult();
8619    
8620                                    finderCache.putResult(finderPath, finderArgs, count);
8621                            }
8622                            catch (Exception e) {
8623                                    finderCache.removeResult(finderPath, finderArgs);
8624    
8625                                    throw processException(e);
8626                            }
8627                            finally {
8628                                    closeSession(session);
8629                            }
8630                    }
8631    
8632                    return count.intValue();
8633            }
8634    
8635            private static final String _FINDER_COLUMN_LTD_S_DISPLAYDATE_1 = "blogsEntry.displayDate IS NULL AND ";
8636            private static final String _FINDER_COLUMN_LTD_S_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
8637            private static final String _FINDER_COLUMN_LTD_S_STATUS_2 = "blogsEntry.status = ?";
8638            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
8639                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
8640                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_LtD",
8641                            new String[] {
8642                                    Long.class.getName(), Long.class.getName(), Date.class.getName(),
8643                                    
8644                            Integer.class.getName(), Integer.class.getName(),
8645                                    OrderByComparator.class.getName()
8646                            });
8647            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
8648                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
8649                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_U_LtD",
8650                            new String[] {
8651                                    Long.class.getName(), Long.class.getName(), Date.class.getName()
8652                            });
8653    
8654            /**
8655             * Returns all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
8656             *
8657             * @param groupId the group ID
8658             * @param userId the user ID
8659             * @param displayDate the display date
8660             * @return the matching blogs entries
8661             */
8662            @Override
8663            public List<BlogsEntry> findByG_U_LtD(long groupId, long userId,
8664                    Date displayDate) {
8665                    return findByG_U_LtD(groupId, userId, displayDate, QueryUtil.ALL_POS,
8666                            QueryUtil.ALL_POS, null);
8667            }
8668    
8669            /**
8670             * Returns a range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
8671             *
8672             * <p>
8673             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8674             * </p>
8675             *
8676             * @param groupId the group ID
8677             * @param userId the user ID
8678             * @param displayDate the display date
8679             * @param start the lower bound of the range of blogs entries
8680             * @param end the upper bound of the range of blogs entries (not inclusive)
8681             * @return the range of matching blogs entries
8682             */
8683            @Override
8684            public List<BlogsEntry> findByG_U_LtD(long groupId, long userId,
8685                    Date displayDate, int start, int end) {
8686                    return findByG_U_LtD(groupId, userId, displayDate, start, end, null);
8687            }
8688    
8689            /**
8690             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
8691             *
8692             * <p>
8693             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8694             * </p>
8695             *
8696             * @param groupId the group ID
8697             * @param userId the user ID
8698             * @param displayDate the display date
8699             * @param start the lower bound of the range of blogs entries
8700             * @param end the upper bound of the range of blogs entries (not inclusive)
8701             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8702             * @return the ordered range of matching blogs entries
8703             */
8704            @Override
8705            public List<BlogsEntry> findByG_U_LtD(long groupId, long userId,
8706                    Date displayDate, int start, int end,
8707                    OrderByComparator<BlogsEntry> orderByComparator) {
8708                    return findByG_U_LtD(groupId, userId, displayDate, start, end,
8709                            orderByComparator, true);
8710            }
8711    
8712            /**
8713             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
8714             *
8715             * <p>
8716             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8717             * </p>
8718             *
8719             * @param groupId the group ID
8720             * @param userId the user ID
8721             * @param displayDate the display date
8722             * @param start the lower bound of the range of blogs entries
8723             * @param end the upper bound of the range of blogs entries (not inclusive)
8724             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8725             * @param retrieveFromCache whether to retrieve from the finder cache
8726             * @return the ordered range of matching blogs entries
8727             */
8728            @Override
8729            public List<BlogsEntry> findByG_U_LtD(long groupId, long userId,
8730                    Date displayDate, int start, int end,
8731                    OrderByComparator<BlogsEntry> orderByComparator,
8732                    boolean retrieveFromCache) {
8733                    boolean pagination = true;
8734                    FinderPath finderPath = null;
8735                    Object[] finderArgs = null;
8736    
8737                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD;
8738                    finderArgs = new Object[] {
8739                                    groupId, userId, displayDate,
8740                                    
8741                                    start, end, orderByComparator
8742                            };
8743    
8744                    List<BlogsEntry> list = null;
8745    
8746                    if (retrieveFromCache) {
8747                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
8748                                            finderArgs, this);
8749    
8750                            if ((list != null) && !list.isEmpty()) {
8751                                    for (BlogsEntry blogsEntry : list) {
8752                                            if ((groupId != blogsEntry.getGroupId()) ||
8753                                                            (userId != blogsEntry.getUserId()) ||
8754                                                            (displayDate.getTime() <= blogsEntry.getDisplayDate()
8755                                                                                                                                            .getTime())) {
8756                                                    list = null;
8757    
8758                                                    break;
8759                                            }
8760                                    }
8761                            }
8762                    }
8763    
8764                    if (list == null) {
8765                            StringBundler query = null;
8766    
8767                            if (orderByComparator != null) {
8768                                    query = new StringBundler(5 +
8769                                                    (orderByComparator.getOrderByFields().length * 2));
8770                            }
8771                            else {
8772                                    query = new StringBundler(5);
8773                            }
8774    
8775                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
8776    
8777                            query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
8778    
8779                            query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
8780    
8781                            boolean bindDisplayDate = false;
8782    
8783                            if (displayDate == null) {
8784                                    query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
8785                            }
8786                            else {
8787                                    bindDisplayDate = true;
8788    
8789                                    query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
8790                            }
8791    
8792                            if (orderByComparator != null) {
8793                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8794                                            orderByComparator);
8795                            }
8796                            else
8797                             if (pagination) {
8798                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
8799                            }
8800    
8801                            String sql = query.toString();
8802    
8803                            Session session = null;
8804    
8805                            try {
8806                                    session = openSession();
8807    
8808                                    Query q = session.createQuery(sql);
8809    
8810                                    QueryPos qPos = QueryPos.getInstance(q);
8811    
8812                                    qPos.add(groupId);
8813    
8814                                    qPos.add(userId);
8815    
8816                                    if (bindDisplayDate) {
8817                                            qPos.add(new Timestamp(displayDate.getTime()));
8818                                    }
8819    
8820                                    if (!pagination) {
8821                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
8822                                                            start, end, false);
8823    
8824                                            Collections.sort(list);
8825    
8826                                            list = Collections.unmodifiableList(list);
8827                                    }
8828                                    else {
8829                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
8830                                                            start, end);
8831                                    }
8832    
8833                                    cacheResult(list);
8834    
8835                                    finderCache.putResult(finderPath, finderArgs, list);
8836                            }
8837                            catch (Exception e) {
8838                                    finderCache.removeResult(finderPath, finderArgs);
8839    
8840                                    throw processException(e);
8841                            }
8842                            finally {
8843                                    closeSession(session);
8844                            }
8845                    }
8846    
8847                    return list;
8848            }
8849    
8850            /**
8851             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
8852             *
8853             * @param groupId the group ID
8854             * @param userId the user ID
8855             * @param displayDate the display date
8856             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8857             * @return the first matching blogs entry
8858             * @throws NoSuchEntryException if a matching blogs entry could not be found
8859             */
8860            @Override
8861            public BlogsEntry findByG_U_LtD_First(long groupId, long userId,
8862                    Date displayDate, OrderByComparator<BlogsEntry> orderByComparator)
8863                    throws NoSuchEntryException {
8864                    BlogsEntry blogsEntry = fetchByG_U_LtD_First(groupId, userId,
8865                                    displayDate, orderByComparator);
8866    
8867                    if (blogsEntry != null) {
8868                            return blogsEntry;
8869                    }
8870    
8871                    StringBundler msg = new StringBundler(8);
8872    
8873                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8874    
8875                    msg.append("groupId=");
8876                    msg.append(groupId);
8877    
8878                    msg.append(", userId=");
8879                    msg.append(userId);
8880    
8881                    msg.append(", displayDate=");
8882                    msg.append(displayDate);
8883    
8884                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8885    
8886                    throw new NoSuchEntryException(msg.toString());
8887            }
8888    
8889            /**
8890             * Returns the first 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 first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
8897             */
8898            @Override
8899            public BlogsEntry fetchByG_U_LtD_First(long groupId, long userId,
8900                    Date displayDate, OrderByComparator<BlogsEntry> orderByComparator) {
8901                    List<BlogsEntry> list = findByG_U_LtD(groupId, userId, displayDate, 0,
8902                                    1, orderByComparator);
8903    
8904                    if (!list.isEmpty()) {
8905                            return list.get(0);
8906                    }
8907    
8908                    return null;
8909            }
8910    
8911            /**
8912             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
8913             *
8914             * @param groupId the group ID
8915             * @param userId the user ID
8916             * @param displayDate the display date
8917             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8918             * @return the last matching blogs entry
8919             * @throws NoSuchEntryException if a matching blogs entry could not be found
8920             */
8921            @Override
8922            public BlogsEntry findByG_U_LtD_Last(long groupId, long userId,
8923                    Date displayDate, OrderByComparator<BlogsEntry> orderByComparator)
8924                    throws NoSuchEntryException {
8925                    BlogsEntry blogsEntry = fetchByG_U_LtD_Last(groupId, userId,
8926                                    displayDate, orderByComparator);
8927    
8928                    if (blogsEntry != null) {
8929                            return blogsEntry;
8930                    }
8931    
8932                    StringBundler msg = new StringBundler(8);
8933    
8934                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8935    
8936                    msg.append("groupId=");
8937                    msg.append(groupId);
8938    
8939                    msg.append(", userId=");
8940                    msg.append(userId);
8941    
8942                    msg.append(", displayDate=");
8943                    msg.append(displayDate);
8944    
8945                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8946    
8947                    throw new NoSuchEntryException(msg.toString());
8948            }
8949    
8950            /**
8951             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
8952             *
8953             * @param groupId the group ID
8954             * @param userId the user ID
8955             * @param displayDate the display date
8956             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8957             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
8958             */
8959            @Override
8960            public BlogsEntry fetchByG_U_LtD_Last(long groupId, long userId,
8961                    Date displayDate, OrderByComparator<BlogsEntry> orderByComparator) {
8962                    int count = countByG_U_LtD(groupId, userId, displayDate);
8963    
8964                    if (count == 0) {
8965                            return null;
8966                    }
8967    
8968                    List<BlogsEntry> list = findByG_U_LtD(groupId, userId, displayDate,
8969                                    count - 1, count, orderByComparator);
8970    
8971                    if (!list.isEmpty()) {
8972                            return list.get(0);
8973                    }
8974    
8975                    return null;
8976            }
8977    
8978            /**
8979             * 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;.
8980             *
8981             * @param entryId the primary key of the current blogs entry
8982             * @param groupId the group ID
8983             * @param userId the user ID
8984             * @param displayDate the display date
8985             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8986             * @return the previous, current, and next blogs entry
8987             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
8988             */
8989            @Override
8990            public BlogsEntry[] findByG_U_LtD_PrevAndNext(long entryId, long groupId,
8991                    long userId, Date displayDate,
8992                    OrderByComparator<BlogsEntry> orderByComparator)
8993                    throws NoSuchEntryException {
8994                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
8995    
8996                    Session session = null;
8997    
8998                    try {
8999                            session = openSession();
9000    
9001                            BlogsEntry[] array = new BlogsEntryImpl[3];
9002    
9003                            array[0] = getByG_U_LtD_PrevAndNext(session, blogsEntry, groupId,
9004                                            userId, displayDate, orderByComparator, true);
9005    
9006                            array[1] = blogsEntry;
9007    
9008                            array[2] = getByG_U_LtD_PrevAndNext(session, blogsEntry, groupId,
9009                                            userId, displayDate, orderByComparator, false);
9010    
9011                            return array;
9012                    }
9013                    catch (Exception e) {
9014                            throw processException(e);
9015                    }
9016                    finally {
9017                            closeSession(session);
9018                    }
9019            }
9020    
9021            protected BlogsEntry getByG_U_LtD_PrevAndNext(Session session,
9022                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
9023                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
9024                    StringBundler query = null;
9025    
9026                    if (orderByComparator != null) {
9027                            query = new StringBundler(6 +
9028                                            (orderByComparator.getOrderByConditionFields().length * 3) +
9029                                            (orderByComparator.getOrderByFields().length * 3));
9030                    }
9031                    else {
9032                            query = new StringBundler(5);
9033                    }
9034    
9035                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
9036    
9037                    query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
9038    
9039                    query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
9040    
9041                    boolean bindDisplayDate = false;
9042    
9043                    if (displayDate == null) {
9044                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
9045                    }
9046                    else {
9047                            bindDisplayDate = true;
9048    
9049                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
9050                    }
9051    
9052                    if (orderByComparator != null) {
9053                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9054    
9055                            if (orderByConditionFields.length > 0) {
9056                                    query.append(WHERE_AND);
9057                            }
9058    
9059                            for (int i = 0; i < orderByConditionFields.length; i++) {
9060                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9061                                    query.append(orderByConditionFields[i]);
9062    
9063                                    if ((i + 1) < orderByConditionFields.length) {
9064                                            if (orderByComparator.isAscending() ^ previous) {
9065                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9066                                            }
9067                                            else {
9068                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
9069                                            }
9070                                    }
9071                                    else {
9072                                            if (orderByComparator.isAscending() ^ previous) {
9073                                                    query.append(WHERE_GREATER_THAN);
9074                                            }
9075                                            else {
9076                                                    query.append(WHERE_LESSER_THAN);
9077                                            }
9078                                    }
9079                            }
9080    
9081                            query.append(ORDER_BY_CLAUSE);
9082    
9083                            String[] orderByFields = orderByComparator.getOrderByFields();
9084    
9085                            for (int i = 0; i < orderByFields.length; i++) {
9086                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9087                                    query.append(orderByFields[i]);
9088    
9089                                    if ((i + 1) < orderByFields.length) {
9090                                            if (orderByComparator.isAscending() ^ previous) {
9091                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
9092                                            }
9093                                            else {
9094                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
9095                                            }
9096                                    }
9097                                    else {
9098                                            if (orderByComparator.isAscending() ^ previous) {
9099                                                    query.append(ORDER_BY_ASC);
9100                                            }
9101                                            else {
9102                                                    query.append(ORDER_BY_DESC);
9103                                            }
9104                                    }
9105                            }
9106                    }
9107                    else {
9108                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
9109                    }
9110    
9111                    String sql = query.toString();
9112    
9113                    Query q = session.createQuery(sql);
9114    
9115                    q.setFirstResult(0);
9116                    q.setMaxResults(2);
9117    
9118                    QueryPos qPos = QueryPos.getInstance(q);
9119    
9120                    qPos.add(groupId);
9121    
9122                    qPos.add(userId);
9123    
9124                    if (bindDisplayDate) {
9125                            qPos.add(new Timestamp(displayDate.getTime()));
9126                    }
9127    
9128                    if (orderByComparator != null) {
9129                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
9130    
9131                            for (Object value : values) {
9132                                    qPos.add(value);
9133                            }
9134                    }
9135    
9136                    List<BlogsEntry> list = q.list();
9137    
9138                    if (list.size() == 2) {
9139                            return list.get(1);
9140                    }
9141                    else {
9142                            return null;
9143                    }
9144            }
9145    
9146            /**
9147             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
9148             *
9149             * @param groupId the group ID
9150             * @param userId the user ID
9151             * @param displayDate the display date
9152             * @return the matching blogs entries that the user has permission to view
9153             */
9154            @Override
9155            public List<BlogsEntry> filterFindByG_U_LtD(long groupId, long userId,
9156                    Date displayDate) {
9157                    return filterFindByG_U_LtD(groupId, userId, displayDate,
9158                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
9159            }
9160    
9161            /**
9162             * 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;.
9163             *
9164             * <p>
9165             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9166             * </p>
9167             *
9168             * @param groupId the group ID
9169             * @param userId the user ID
9170             * @param displayDate the display date
9171             * @param start the lower bound of the range of blogs entries
9172             * @param end the upper bound of the range of blogs entries (not inclusive)
9173             * @return the range of matching blogs entries that the user has permission to view
9174             */
9175            @Override
9176            public List<BlogsEntry> filterFindByG_U_LtD(long groupId, long userId,
9177                    Date displayDate, int start, int end) {
9178                    return filterFindByG_U_LtD(groupId, userId, displayDate, start, end,
9179                            null);
9180            }
9181    
9182            /**
9183             * 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;.
9184             *
9185             * <p>
9186             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9187             * </p>
9188             *
9189             * @param groupId the group ID
9190             * @param userId the user ID
9191             * @param displayDate the display date
9192             * @param start the lower bound of the range of blogs entries
9193             * @param end the upper bound of the range of blogs entries (not inclusive)
9194             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9195             * @return the ordered range of matching blogs entries that the user has permission to view
9196             */
9197            @Override
9198            public List<BlogsEntry> filterFindByG_U_LtD(long groupId, long userId,
9199                    Date displayDate, int start, int end,
9200                    OrderByComparator<BlogsEntry> orderByComparator) {
9201                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9202                            return findByG_U_LtD(groupId, userId, displayDate, start, end,
9203                                    orderByComparator);
9204                    }
9205    
9206                    StringBundler query = null;
9207    
9208                    if (orderByComparator != null) {
9209                            query = new StringBundler(5 +
9210                                            (orderByComparator.getOrderByFields().length * 2));
9211                    }
9212                    else {
9213                            query = new StringBundler(6);
9214                    }
9215    
9216                    if (getDB().isSupportsInlineDistinct()) {
9217                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
9218                    }
9219                    else {
9220                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
9221                    }
9222    
9223                    query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
9224    
9225                    query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
9226    
9227                    boolean bindDisplayDate = false;
9228    
9229                    if (displayDate == null) {
9230                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
9231                    }
9232                    else {
9233                            bindDisplayDate = true;
9234    
9235                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
9236                    }
9237    
9238                    if (!getDB().isSupportsInlineDistinct()) {
9239                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
9240                    }
9241    
9242                    if (orderByComparator != null) {
9243                            if (getDB().isSupportsInlineDistinct()) {
9244                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9245                                            orderByComparator, true);
9246                            }
9247                            else {
9248                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
9249                                            orderByComparator, true);
9250                            }
9251                    }
9252                    else {
9253                            if (getDB().isSupportsInlineDistinct()) {
9254                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
9255                            }
9256                            else {
9257                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
9258                            }
9259                    }
9260    
9261                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9262                                    BlogsEntry.class.getName(),
9263                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9264    
9265                    Session session = null;
9266    
9267                    try {
9268                            session = openSession();
9269    
9270                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
9271    
9272                            if (getDB().isSupportsInlineDistinct()) {
9273                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
9274                            }
9275                            else {
9276                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
9277                            }
9278    
9279                            QueryPos qPos = QueryPos.getInstance(q);
9280    
9281                            qPos.add(groupId);
9282    
9283                            qPos.add(userId);
9284    
9285                            if (bindDisplayDate) {
9286                                    qPos.add(new Timestamp(displayDate.getTime()));
9287                            }
9288    
9289                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
9290                    }
9291                    catch (Exception e) {
9292                            throw processException(e);
9293                    }
9294                    finally {
9295                            closeSession(session);
9296                    }
9297            }
9298    
9299            /**
9300             * 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;.
9301             *
9302             * @param entryId the primary key of the current blogs entry
9303             * @param groupId the group ID
9304             * @param userId the user ID
9305             * @param displayDate the display date
9306             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9307             * @return the previous, current, and next blogs entry
9308             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
9309             */
9310            @Override
9311            public BlogsEntry[] filterFindByG_U_LtD_PrevAndNext(long entryId,
9312                    long groupId, long userId, Date displayDate,
9313                    OrderByComparator<BlogsEntry> orderByComparator)
9314                    throws NoSuchEntryException {
9315                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9316                            return findByG_U_LtD_PrevAndNext(entryId, groupId, userId,
9317                                    displayDate, orderByComparator);
9318                    }
9319    
9320                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
9321    
9322                    Session session = null;
9323    
9324                    try {
9325                            session = openSession();
9326    
9327                            BlogsEntry[] array = new BlogsEntryImpl[3];
9328    
9329                            array[0] = filterGetByG_U_LtD_PrevAndNext(session, blogsEntry,
9330                                            groupId, userId, displayDate, orderByComparator, true);
9331    
9332                            array[1] = blogsEntry;
9333    
9334                            array[2] = filterGetByG_U_LtD_PrevAndNext(session, blogsEntry,
9335                                            groupId, userId, displayDate, orderByComparator, false);
9336    
9337                            return array;
9338                    }
9339                    catch (Exception e) {
9340                            throw processException(e);
9341                    }
9342                    finally {
9343                            closeSession(session);
9344                    }
9345            }
9346    
9347            protected BlogsEntry filterGetByG_U_LtD_PrevAndNext(Session session,
9348                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
9349                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
9350                    StringBundler query = null;
9351    
9352                    if (orderByComparator != null) {
9353                            query = new StringBundler(7 +
9354                                            (orderByComparator.getOrderByConditionFields().length * 3) +
9355                                            (orderByComparator.getOrderByFields().length * 3));
9356                    }
9357                    else {
9358                            query = new StringBundler(6);
9359                    }
9360    
9361                    if (getDB().isSupportsInlineDistinct()) {
9362                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
9363                    }
9364                    else {
9365                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
9366                    }
9367    
9368                    query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
9369    
9370                    query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
9371    
9372                    boolean bindDisplayDate = false;
9373    
9374                    if (displayDate == null) {
9375                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
9376                    }
9377                    else {
9378                            bindDisplayDate = true;
9379    
9380                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
9381                    }
9382    
9383                    if (!getDB().isSupportsInlineDistinct()) {
9384                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
9385                    }
9386    
9387                    if (orderByComparator != null) {
9388                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9389    
9390                            if (orderByConditionFields.length > 0) {
9391                                    query.append(WHERE_AND);
9392                            }
9393    
9394                            for (int i = 0; i < orderByConditionFields.length; i++) {
9395                                    if (getDB().isSupportsInlineDistinct()) {
9396                                            query.append(_ORDER_BY_ENTITY_ALIAS);
9397                                    }
9398                                    else {
9399                                            query.append(_ORDER_BY_ENTITY_TABLE);
9400                                    }
9401    
9402                                    query.append(orderByConditionFields[i]);
9403    
9404                                    if ((i + 1) < orderByConditionFields.length) {
9405                                            if (orderByComparator.isAscending() ^ previous) {
9406                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9407                                            }
9408                                            else {
9409                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
9410                                            }
9411                                    }
9412                                    else {
9413                                            if (orderByComparator.isAscending() ^ previous) {
9414                                                    query.append(WHERE_GREATER_THAN);
9415                                            }
9416                                            else {
9417                                                    query.append(WHERE_LESSER_THAN);
9418                                            }
9419                                    }
9420                            }
9421    
9422                            query.append(ORDER_BY_CLAUSE);
9423    
9424                            String[] orderByFields = orderByComparator.getOrderByFields();
9425    
9426                            for (int i = 0; i < orderByFields.length; i++) {
9427                                    if (getDB().isSupportsInlineDistinct()) {
9428                                            query.append(_ORDER_BY_ENTITY_ALIAS);
9429                                    }
9430                                    else {
9431                                            query.append(_ORDER_BY_ENTITY_TABLE);
9432                                    }
9433    
9434                                    query.append(orderByFields[i]);
9435    
9436                                    if ((i + 1) < orderByFields.length) {
9437                                            if (orderByComparator.isAscending() ^ previous) {
9438                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
9439                                            }
9440                                            else {
9441                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
9442                                            }
9443                                    }
9444                                    else {
9445                                            if (orderByComparator.isAscending() ^ previous) {
9446                                                    query.append(ORDER_BY_ASC);
9447                                            }
9448                                            else {
9449                                                    query.append(ORDER_BY_DESC);
9450                                            }
9451                                    }
9452                            }
9453                    }
9454                    else {
9455                            if (getDB().isSupportsInlineDistinct()) {
9456                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
9457                            }
9458                            else {
9459                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
9460                            }
9461                    }
9462    
9463                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9464                                    BlogsEntry.class.getName(),
9465                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9466    
9467                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
9468    
9469                    q.setFirstResult(0);
9470                    q.setMaxResults(2);
9471    
9472                    if (getDB().isSupportsInlineDistinct()) {
9473                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
9474                    }
9475                    else {
9476                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
9477                    }
9478    
9479                    QueryPos qPos = QueryPos.getInstance(q);
9480    
9481                    qPos.add(groupId);
9482    
9483                    qPos.add(userId);
9484    
9485                    if (bindDisplayDate) {
9486                            qPos.add(new Timestamp(displayDate.getTime()));
9487                    }
9488    
9489                    if (orderByComparator != null) {
9490                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
9491    
9492                            for (Object value : values) {
9493                                    qPos.add(value);
9494                            }
9495                    }
9496    
9497                    List<BlogsEntry> list = q.list();
9498    
9499                    if (list.size() == 2) {
9500                            return list.get(1);
9501                    }
9502                    else {
9503                            return null;
9504                    }
9505            }
9506    
9507            /**
9508             * Removes all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; from the database.
9509             *
9510             * @param groupId the group ID
9511             * @param userId the user ID
9512             * @param displayDate the display date
9513             */
9514            @Override
9515            public void removeByG_U_LtD(long groupId, long userId, Date displayDate) {
9516                    for (BlogsEntry blogsEntry : findByG_U_LtD(groupId, userId,
9517                                    displayDate, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
9518                            remove(blogsEntry);
9519                    }
9520            }
9521    
9522            /**
9523             * Returns the number of blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
9524             *
9525             * @param groupId the group ID
9526             * @param userId the user ID
9527             * @param displayDate the display date
9528             * @return the number of matching blogs entries
9529             */
9530            @Override
9531            public int countByG_U_LtD(long groupId, long userId, Date displayDate) {
9532                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD;
9533    
9534                    Object[] finderArgs = new Object[] { groupId, userId, displayDate };
9535    
9536                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
9537    
9538                    if (count == null) {
9539                            StringBundler query = new StringBundler(4);
9540    
9541                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
9542    
9543                            query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
9544    
9545                            query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
9546    
9547                            boolean bindDisplayDate = false;
9548    
9549                            if (displayDate == null) {
9550                                    query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
9551                            }
9552                            else {
9553                                    bindDisplayDate = true;
9554    
9555                                    query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
9556                            }
9557    
9558                            String sql = query.toString();
9559    
9560                            Session session = null;
9561    
9562                            try {
9563                                    session = openSession();
9564    
9565                                    Query q = session.createQuery(sql);
9566    
9567                                    QueryPos qPos = QueryPos.getInstance(q);
9568    
9569                                    qPos.add(groupId);
9570    
9571                                    qPos.add(userId);
9572    
9573                                    if (bindDisplayDate) {
9574                                            qPos.add(new Timestamp(displayDate.getTime()));
9575                                    }
9576    
9577                                    count = (Long)q.uniqueResult();
9578    
9579                                    finderCache.putResult(finderPath, finderArgs, count);
9580                            }
9581                            catch (Exception e) {
9582                                    finderCache.removeResult(finderPath, finderArgs);
9583    
9584                                    throw processException(e);
9585                            }
9586                            finally {
9587                                    closeSession(session);
9588                            }
9589                    }
9590    
9591                    return count.intValue();
9592            }
9593    
9594            /**
9595             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
9596             *
9597             * @param groupId the group ID
9598             * @param userId the user ID
9599             * @param displayDate the display date
9600             * @return the number of matching blogs entries that the user has permission to view
9601             */
9602            @Override
9603            public int filterCountByG_U_LtD(long groupId, long userId, Date displayDate) {
9604                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9605                            return countByG_U_LtD(groupId, userId, displayDate);
9606                    }
9607    
9608                    StringBundler query = new StringBundler(4);
9609    
9610                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
9611    
9612                    query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
9613    
9614                    query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
9615    
9616                    boolean bindDisplayDate = false;
9617    
9618                    if (displayDate == null) {
9619                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
9620                    }
9621                    else {
9622                            bindDisplayDate = true;
9623    
9624                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
9625                    }
9626    
9627                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9628                                    BlogsEntry.class.getName(),
9629                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9630    
9631                    Session session = null;
9632    
9633                    try {
9634                            session = openSession();
9635    
9636                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
9637    
9638                            q.addScalar(COUNT_COLUMN_NAME,
9639                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
9640    
9641                            QueryPos qPos = QueryPos.getInstance(q);
9642    
9643                            qPos.add(groupId);
9644    
9645                            qPos.add(userId);
9646    
9647                            if (bindDisplayDate) {
9648                                    qPos.add(new Timestamp(displayDate.getTime()));
9649                            }
9650    
9651                            Long count = (Long)q.uniqueResult();
9652    
9653                            return count.intValue();
9654                    }
9655                    catch (Exception e) {
9656                            throw processException(e);
9657                    }
9658                    finally {
9659                            closeSession(session);
9660                    }
9661            }
9662    
9663            private static final String _FINDER_COLUMN_G_U_LTD_GROUPID_2 = "blogsEntry.groupId = ? AND ";
9664            private static final String _FINDER_COLUMN_G_U_LTD_USERID_2 = "blogsEntry.userId = ? AND ";
9665            private static final String _FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1 = "blogsEntry.displayDate IS NULL";
9666            private static final String _FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2 = "blogsEntry.displayDate < ?";
9667            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
9668                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
9669                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_S",
9670                            new String[] {
9671                                    Long.class.getName(), Long.class.getName(),
9672                                    Integer.class.getName(),
9673                                    
9674                            Integer.class.getName(), Integer.class.getName(),
9675                                    OrderByComparator.class.getName()
9676                            });
9677            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
9678                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
9679                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U_S",
9680                            new String[] {
9681                                    Long.class.getName(), Long.class.getName(),
9682                                    Integer.class.getName()
9683                            },
9684                            BlogsEntryModelImpl.GROUPID_COLUMN_BITMASK |
9685                            BlogsEntryModelImpl.USERID_COLUMN_BITMASK |
9686                            BlogsEntryModelImpl.STATUS_COLUMN_BITMASK |
9687                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
9688                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
9689            public static final FinderPath FINDER_PATH_COUNT_BY_G_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
9690                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
9691                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U_S",
9692                            new String[] {
9693                                    Long.class.getName(), Long.class.getName(),
9694                                    Integer.class.getName()
9695                            });
9696            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
9697                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
9698                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_U_S",
9699                            new String[] {
9700                                    Long.class.getName(), Long.class.getName(),
9701                                    Integer.class.getName()
9702                            });
9703    
9704            /**
9705             * Returns all the blogs entries where groupId = &#63; and userId = &#63; and status = &#63;.
9706             *
9707             * @param groupId the group ID
9708             * @param userId the user ID
9709             * @param status the status
9710             * @return the matching blogs entries
9711             */
9712            @Override
9713            public List<BlogsEntry> findByG_U_S(long groupId, long userId, int status) {
9714                    return findByG_U_S(groupId, userId, status, QueryUtil.ALL_POS,
9715                            QueryUtil.ALL_POS, null);
9716            }
9717    
9718            /**
9719             * Returns a range of all the blogs entries where groupId = &#63; and userId = &#63; and status = &#63;.
9720             *
9721             * <p>
9722             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9723             * </p>
9724             *
9725             * @param groupId the group ID
9726             * @param userId the user ID
9727             * @param status the status
9728             * @param start the lower bound of the range of blogs entries
9729             * @param end the upper bound of the range of blogs entries (not inclusive)
9730             * @return the range of matching blogs entries
9731             */
9732            @Override
9733            public List<BlogsEntry> findByG_U_S(long groupId, long userId, int status,
9734                    int start, int end) {
9735                    return findByG_U_S(groupId, userId, status, start, end, null);
9736            }
9737    
9738            /**
9739             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and status = &#63;.
9740             *
9741             * <p>
9742             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9743             * </p>
9744             *
9745             * @param groupId the group ID
9746             * @param userId the user ID
9747             * @param status the status
9748             * @param start the lower bound of the range of blogs entries
9749             * @param end the upper bound of the range of blogs entries (not inclusive)
9750             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9751             * @return the ordered range of matching blogs entries
9752             */
9753            @Override
9754            public List<BlogsEntry> findByG_U_S(long groupId, long userId, int status,
9755                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator) {
9756                    return findByG_U_S(groupId, userId, status, start, end,
9757                            orderByComparator, true);
9758            }
9759    
9760            /**
9761             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and status = &#63;.
9762             *
9763             * <p>
9764             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9765             * </p>
9766             *
9767             * @param groupId the group ID
9768             * @param userId the user ID
9769             * @param status the status
9770             * @param start the lower bound of the range of blogs entries
9771             * @param end the upper bound of the range of blogs entries (not inclusive)
9772             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9773             * @param retrieveFromCache whether to retrieve from the finder cache
9774             * @return the ordered range of matching blogs entries
9775             */
9776            @Override
9777            public List<BlogsEntry> findByG_U_S(long groupId, long userId, int status,
9778                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator,
9779                    boolean retrieveFromCache) {
9780                    boolean pagination = true;
9781                    FinderPath finderPath = null;
9782                    Object[] finderArgs = null;
9783    
9784                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
9785                                    (orderByComparator == null)) {
9786                            pagination = false;
9787                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S;
9788                            finderArgs = new Object[] { groupId, userId, status };
9789                    }
9790                    else {
9791                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_S;
9792                            finderArgs = new Object[] {
9793                                            groupId, userId, status,
9794                                            
9795                                            start, end, orderByComparator
9796                                    };
9797                    }
9798    
9799                    List<BlogsEntry> list = null;
9800    
9801                    if (retrieveFromCache) {
9802                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
9803                                            finderArgs, this);
9804    
9805                            if ((list != null) && !list.isEmpty()) {
9806                                    for (BlogsEntry blogsEntry : list) {
9807                                            if ((groupId != blogsEntry.getGroupId()) ||
9808                                                            (userId != blogsEntry.getUserId()) ||
9809                                                            (status != blogsEntry.getStatus())) {
9810                                                    list = null;
9811    
9812                                                    break;
9813                                            }
9814                                    }
9815                            }
9816                    }
9817    
9818                    if (list == null) {
9819                            StringBundler query = null;
9820    
9821                            if (orderByComparator != null) {
9822                                    query = new StringBundler(5 +
9823                                                    (orderByComparator.getOrderByFields().length * 2));
9824                            }
9825                            else {
9826                                    query = new StringBundler(5);
9827                            }
9828    
9829                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
9830    
9831                            query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
9832    
9833                            query.append(_FINDER_COLUMN_G_U_S_USERID_2);
9834    
9835                            query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
9836    
9837                            if (orderByComparator != null) {
9838                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9839                                            orderByComparator);
9840                            }
9841                            else
9842                             if (pagination) {
9843                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
9844                            }
9845    
9846                            String sql = query.toString();
9847    
9848                            Session session = null;
9849    
9850                            try {
9851                                    session = openSession();
9852    
9853                                    Query q = session.createQuery(sql);
9854    
9855                                    QueryPos qPos = QueryPos.getInstance(q);
9856    
9857                                    qPos.add(groupId);
9858    
9859                                    qPos.add(userId);
9860    
9861                                    qPos.add(status);
9862    
9863                                    if (!pagination) {
9864                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
9865                                                            start, end, false);
9866    
9867                                            Collections.sort(list);
9868    
9869                                            list = Collections.unmodifiableList(list);
9870                                    }
9871                                    else {
9872                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
9873                                                            start, end);
9874                                    }
9875    
9876                                    cacheResult(list);
9877    
9878                                    finderCache.putResult(finderPath, finderArgs, list);
9879                            }
9880                            catch (Exception e) {
9881                                    finderCache.removeResult(finderPath, finderArgs);
9882    
9883                                    throw processException(e);
9884                            }
9885                            finally {
9886                                    closeSession(session);
9887                            }
9888                    }
9889    
9890                    return list;
9891            }
9892    
9893            /**
9894             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
9895             *
9896             * @param groupId the group ID
9897             * @param userId the user ID
9898             * @param status the status
9899             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9900             * @return the first matching blogs entry
9901             * @throws NoSuchEntryException if a matching blogs entry could not be found
9902             */
9903            @Override
9904            public BlogsEntry findByG_U_S_First(long groupId, long userId, int status,
9905                    OrderByComparator<BlogsEntry> orderByComparator)
9906                    throws NoSuchEntryException {
9907                    BlogsEntry blogsEntry = fetchByG_U_S_First(groupId, userId, status,
9908                                    orderByComparator);
9909    
9910                    if (blogsEntry != null) {
9911                            return blogsEntry;
9912                    }
9913    
9914                    StringBundler msg = new StringBundler(8);
9915    
9916                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9917    
9918                    msg.append("groupId=");
9919                    msg.append(groupId);
9920    
9921                    msg.append(", userId=");
9922                    msg.append(userId);
9923    
9924                    msg.append(", status=");
9925                    msg.append(status);
9926    
9927                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9928    
9929                    throw new NoSuchEntryException(msg.toString());
9930            }
9931    
9932            /**
9933             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
9934             *
9935             * @param groupId the group ID
9936             * @param userId the user ID
9937             * @param status the status
9938             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9939             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
9940             */
9941            @Override
9942            public BlogsEntry fetchByG_U_S_First(long groupId, long userId, int status,
9943                    OrderByComparator<BlogsEntry> orderByComparator) {
9944                    List<BlogsEntry> list = findByG_U_S(groupId, userId, status, 0, 1,
9945                                    orderByComparator);
9946    
9947                    if (!list.isEmpty()) {
9948                            return list.get(0);
9949                    }
9950    
9951                    return null;
9952            }
9953    
9954            /**
9955             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
9956             *
9957             * @param groupId the group ID
9958             * @param userId the user ID
9959             * @param status the status
9960             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9961             * @return the last matching blogs entry
9962             * @throws NoSuchEntryException if a matching blogs entry could not be found
9963             */
9964            @Override
9965            public BlogsEntry findByG_U_S_Last(long groupId, long userId, int status,
9966                    OrderByComparator<BlogsEntry> orderByComparator)
9967                    throws NoSuchEntryException {
9968                    BlogsEntry blogsEntry = fetchByG_U_S_Last(groupId, userId, status,
9969                                    orderByComparator);
9970    
9971                    if (blogsEntry != null) {
9972                            return blogsEntry;
9973                    }
9974    
9975                    StringBundler msg = new StringBundler(8);
9976    
9977                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9978    
9979                    msg.append("groupId=");
9980                    msg.append(groupId);
9981    
9982                    msg.append(", userId=");
9983                    msg.append(userId);
9984    
9985                    msg.append(", status=");
9986                    msg.append(status);
9987    
9988                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9989    
9990                    throw new NoSuchEntryException(msg.toString());
9991            }
9992    
9993            /**
9994             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
9995             *
9996             * @param groupId the group ID
9997             * @param userId the user ID
9998             * @param status the status
9999             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10000             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
10001             */
10002            @Override
10003            public BlogsEntry fetchByG_U_S_Last(long groupId, long userId, int status,
10004                    OrderByComparator<BlogsEntry> orderByComparator) {
10005                    int count = countByG_U_S(groupId, userId, status);
10006    
10007                    if (count == 0) {
10008                            return null;
10009                    }
10010    
10011                    List<BlogsEntry> list = findByG_U_S(groupId, userId, status, count - 1,
10012                                    count, orderByComparator);
10013    
10014                    if (!list.isEmpty()) {
10015                            return list.get(0);
10016                    }
10017    
10018                    return null;
10019            }
10020    
10021            /**
10022             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
10023             *
10024             * @param entryId the primary key of the current blogs entry
10025             * @param groupId the group ID
10026             * @param userId the user ID
10027             * @param status the status
10028             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10029             * @return the previous, current, and next blogs entry
10030             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
10031             */
10032            @Override
10033            public BlogsEntry[] findByG_U_S_PrevAndNext(long entryId, long groupId,
10034                    long userId, int status, OrderByComparator<BlogsEntry> orderByComparator)
10035                    throws NoSuchEntryException {
10036                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
10037    
10038                    Session session = null;
10039    
10040                    try {
10041                            session = openSession();
10042    
10043                            BlogsEntry[] array = new BlogsEntryImpl[3];
10044    
10045                            array[0] = getByG_U_S_PrevAndNext(session, blogsEntry, groupId,
10046                                            userId, status, orderByComparator, true);
10047    
10048                            array[1] = blogsEntry;
10049    
10050                            array[2] = getByG_U_S_PrevAndNext(session, blogsEntry, groupId,
10051                                            userId, status, orderByComparator, false);
10052    
10053                            return array;
10054                    }
10055                    catch (Exception e) {
10056                            throw processException(e);
10057                    }
10058                    finally {
10059                            closeSession(session);
10060                    }
10061            }
10062    
10063            protected BlogsEntry getByG_U_S_PrevAndNext(Session session,
10064                    BlogsEntry blogsEntry, long groupId, long userId, int status,
10065                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
10066                    StringBundler query = null;
10067    
10068                    if (orderByComparator != null) {
10069                            query = new StringBundler(6 +
10070                                            (orderByComparator.getOrderByConditionFields().length * 3) +
10071                                            (orderByComparator.getOrderByFields().length * 3));
10072                    }
10073                    else {
10074                            query = new StringBundler(5);
10075                    }
10076    
10077                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
10078    
10079                    query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
10080    
10081                    query.append(_FINDER_COLUMN_G_U_S_USERID_2);
10082    
10083                    query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
10084    
10085                    if (orderByComparator != null) {
10086                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10087    
10088                            if (orderByConditionFields.length > 0) {
10089                                    query.append(WHERE_AND);
10090                            }
10091    
10092                            for (int i = 0; i < orderByConditionFields.length; i++) {
10093                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10094                                    query.append(orderByConditionFields[i]);
10095    
10096                                    if ((i + 1) < orderByConditionFields.length) {
10097                                            if (orderByComparator.isAscending() ^ previous) {
10098                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10099                                            }
10100                                            else {
10101                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10102                                            }
10103                                    }
10104                                    else {
10105                                            if (orderByComparator.isAscending() ^ previous) {
10106                                                    query.append(WHERE_GREATER_THAN);
10107                                            }
10108                                            else {
10109                                                    query.append(WHERE_LESSER_THAN);
10110                                            }
10111                                    }
10112                            }
10113    
10114                            query.append(ORDER_BY_CLAUSE);
10115    
10116                            String[] orderByFields = orderByComparator.getOrderByFields();
10117    
10118                            for (int i = 0; i < orderByFields.length; i++) {
10119                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10120                                    query.append(orderByFields[i]);
10121    
10122                                    if ((i + 1) < orderByFields.length) {
10123                                            if (orderByComparator.isAscending() ^ previous) {
10124                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10125                                            }
10126                                            else {
10127                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10128                                            }
10129                                    }
10130                                    else {
10131                                            if (orderByComparator.isAscending() ^ previous) {
10132                                                    query.append(ORDER_BY_ASC);
10133                                            }
10134                                            else {
10135                                                    query.append(ORDER_BY_DESC);
10136                                            }
10137                                    }
10138                            }
10139                    }
10140                    else {
10141                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
10142                    }
10143    
10144                    String sql = query.toString();
10145    
10146                    Query q = session.createQuery(sql);
10147    
10148                    q.setFirstResult(0);
10149                    q.setMaxResults(2);
10150    
10151                    QueryPos qPos = QueryPos.getInstance(q);
10152    
10153                    qPos.add(groupId);
10154    
10155                    qPos.add(userId);
10156    
10157                    qPos.add(status);
10158    
10159                    if (orderByComparator != null) {
10160                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
10161    
10162                            for (Object value : values) {
10163                                    qPos.add(value);
10164                            }
10165                    }
10166    
10167                    List<BlogsEntry> list = q.list();
10168    
10169                    if (list.size() == 2) {
10170                            return list.get(1);
10171                    }
10172                    else {
10173                            return null;
10174                    }
10175            }
10176    
10177            /**
10178             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status = &#63;.
10179             *
10180             * @param groupId the group ID
10181             * @param userId the user ID
10182             * @param status the status
10183             * @return the matching blogs entries that the user has permission to view
10184             */
10185            @Override
10186            public List<BlogsEntry> filterFindByG_U_S(long groupId, long userId,
10187                    int status) {
10188                    return filterFindByG_U_S(groupId, userId, status, QueryUtil.ALL_POS,
10189                            QueryUtil.ALL_POS, null);
10190            }
10191    
10192            /**
10193             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status = &#63;.
10194             *
10195             * <p>
10196             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10197             * </p>
10198             *
10199             * @param groupId the group ID
10200             * @param userId the user ID
10201             * @param status the status
10202             * @param start the lower bound of the range of blogs entries
10203             * @param end the upper bound of the range of blogs entries (not inclusive)
10204             * @return the range of matching blogs entries that the user has permission to view
10205             */
10206            @Override
10207            public List<BlogsEntry> filterFindByG_U_S(long groupId, long userId,
10208                    int status, int start, int end) {
10209                    return filterFindByG_U_S(groupId, userId, status, start, end, null);
10210            }
10211    
10212            /**
10213             * 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;.
10214             *
10215             * <p>
10216             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10217             * </p>
10218             *
10219             * @param groupId the group ID
10220             * @param userId the user ID
10221             * @param status the status
10222             * @param start the lower bound of the range of blogs entries
10223             * @param end the upper bound of the range of blogs entries (not inclusive)
10224             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10225             * @return the ordered range of matching blogs entries that the user has permission to view
10226             */
10227            @Override
10228            public List<BlogsEntry> filterFindByG_U_S(long groupId, long userId,
10229                    int status, int start, int end,
10230                    OrderByComparator<BlogsEntry> orderByComparator) {
10231                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10232                            return findByG_U_S(groupId, userId, status, start, end,
10233                                    orderByComparator);
10234                    }
10235    
10236                    StringBundler query = null;
10237    
10238                    if (orderByComparator != null) {
10239                            query = new StringBundler(5 +
10240                                            (orderByComparator.getOrderByFields().length * 2));
10241                    }
10242                    else {
10243                            query = new StringBundler(6);
10244                    }
10245    
10246                    if (getDB().isSupportsInlineDistinct()) {
10247                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
10248                    }
10249                    else {
10250                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
10251                    }
10252    
10253                    query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
10254    
10255                    query.append(_FINDER_COLUMN_G_U_S_USERID_2);
10256    
10257                    query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
10258    
10259                    if (!getDB().isSupportsInlineDistinct()) {
10260                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
10261                    }
10262    
10263                    if (orderByComparator != null) {
10264                            if (getDB().isSupportsInlineDistinct()) {
10265                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10266                                            orderByComparator, true);
10267                            }
10268                            else {
10269                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
10270                                            orderByComparator, true);
10271                            }
10272                    }
10273                    else {
10274                            if (getDB().isSupportsInlineDistinct()) {
10275                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
10276                            }
10277                            else {
10278                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
10279                            }
10280                    }
10281    
10282                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10283                                    BlogsEntry.class.getName(),
10284                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10285    
10286                    Session session = null;
10287    
10288                    try {
10289                            session = openSession();
10290    
10291                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
10292    
10293                            if (getDB().isSupportsInlineDistinct()) {
10294                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
10295                            }
10296                            else {
10297                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
10298                            }
10299    
10300                            QueryPos qPos = QueryPos.getInstance(q);
10301    
10302                            qPos.add(groupId);
10303    
10304                            qPos.add(userId);
10305    
10306                            qPos.add(status);
10307    
10308                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
10309                    }
10310                    catch (Exception e) {
10311                            throw processException(e);
10312                    }
10313                    finally {
10314                            closeSession(session);
10315                    }
10316            }
10317    
10318            /**
10319             * 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;.
10320             *
10321             * @param entryId the primary key of the current blogs entry
10322             * @param groupId the group ID
10323             * @param userId the user ID
10324             * @param status the status
10325             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10326             * @return the previous, current, and next blogs entry
10327             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
10328             */
10329            @Override
10330            public BlogsEntry[] filterFindByG_U_S_PrevAndNext(long entryId,
10331                    long groupId, long userId, int status,
10332                    OrderByComparator<BlogsEntry> orderByComparator)
10333                    throws NoSuchEntryException {
10334                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10335                            return findByG_U_S_PrevAndNext(entryId, groupId, userId, status,
10336                                    orderByComparator);
10337                    }
10338    
10339                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
10340    
10341                    Session session = null;
10342    
10343                    try {
10344                            session = openSession();
10345    
10346                            BlogsEntry[] array = new BlogsEntryImpl[3];
10347    
10348                            array[0] = filterGetByG_U_S_PrevAndNext(session, blogsEntry,
10349                                            groupId, userId, status, orderByComparator, true);
10350    
10351                            array[1] = blogsEntry;
10352    
10353                            array[2] = filterGetByG_U_S_PrevAndNext(session, blogsEntry,
10354                                            groupId, userId, status, orderByComparator, false);
10355    
10356                            return array;
10357                    }
10358                    catch (Exception e) {
10359                            throw processException(e);
10360                    }
10361                    finally {
10362                            closeSession(session);
10363                    }
10364            }
10365    
10366            protected BlogsEntry filterGetByG_U_S_PrevAndNext(Session session,
10367                    BlogsEntry blogsEntry, long groupId, long userId, int status,
10368                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
10369                    StringBundler query = null;
10370    
10371                    if (orderByComparator != null) {
10372                            query = new StringBundler(7 +
10373                                            (orderByComparator.getOrderByConditionFields().length * 3) +
10374                                            (orderByComparator.getOrderByFields().length * 3));
10375                    }
10376                    else {
10377                            query = new StringBundler(6);
10378                    }
10379    
10380                    if (getDB().isSupportsInlineDistinct()) {
10381                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
10382                    }
10383                    else {
10384                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
10385                    }
10386    
10387                    query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
10388    
10389                    query.append(_FINDER_COLUMN_G_U_S_USERID_2);
10390    
10391                    query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
10392    
10393                    if (!getDB().isSupportsInlineDistinct()) {
10394                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
10395                    }
10396    
10397                    if (orderByComparator != null) {
10398                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10399    
10400                            if (orderByConditionFields.length > 0) {
10401                                    query.append(WHERE_AND);
10402                            }
10403    
10404                            for (int i = 0; i < orderByConditionFields.length; i++) {
10405                                    if (getDB().isSupportsInlineDistinct()) {
10406                                            query.append(_ORDER_BY_ENTITY_ALIAS);
10407                                    }
10408                                    else {
10409                                            query.append(_ORDER_BY_ENTITY_TABLE);
10410                                    }
10411    
10412                                    query.append(orderByConditionFields[i]);
10413    
10414                                    if ((i + 1) < orderByConditionFields.length) {
10415                                            if (orderByComparator.isAscending() ^ previous) {
10416                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10417                                            }
10418                                            else {
10419                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10420                                            }
10421                                    }
10422                                    else {
10423                                            if (orderByComparator.isAscending() ^ previous) {
10424                                                    query.append(WHERE_GREATER_THAN);
10425                                            }
10426                                            else {
10427                                                    query.append(WHERE_LESSER_THAN);
10428                                            }
10429                                    }
10430                            }
10431    
10432                            query.append(ORDER_BY_CLAUSE);
10433    
10434                            String[] orderByFields = orderByComparator.getOrderByFields();
10435    
10436                            for (int i = 0; i < orderByFields.length; i++) {
10437                                    if (getDB().isSupportsInlineDistinct()) {
10438                                            query.append(_ORDER_BY_ENTITY_ALIAS);
10439                                    }
10440                                    else {
10441                                            query.append(_ORDER_BY_ENTITY_TABLE);
10442                                    }
10443    
10444                                    query.append(orderByFields[i]);
10445    
10446                                    if ((i + 1) < orderByFields.length) {
10447                                            if (orderByComparator.isAscending() ^ previous) {
10448                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10449                                            }
10450                                            else {
10451                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10452                                            }
10453                                    }
10454                                    else {
10455                                            if (orderByComparator.isAscending() ^ previous) {
10456                                                    query.append(ORDER_BY_ASC);
10457                                            }
10458                                            else {
10459                                                    query.append(ORDER_BY_DESC);
10460                                            }
10461                                    }
10462                            }
10463                    }
10464                    else {
10465                            if (getDB().isSupportsInlineDistinct()) {
10466                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
10467                            }
10468                            else {
10469                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
10470                            }
10471                    }
10472    
10473                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10474                                    BlogsEntry.class.getName(),
10475                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10476    
10477                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
10478    
10479                    q.setFirstResult(0);
10480                    q.setMaxResults(2);
10481    
10482                    if (getDB().isSupportsInlineDistinct()) {
10483                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
10484                    }
10485                    else {
10486                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
10487                    }
10488    
10489                    QueryPos qPos = QueryPos.getInstance(q);
10490    
10491                    qPos.add(groupId);
10492    
10493                    qPos.add(userId);
10494    
10495                    qPos.add(status);
10496    
10497                    if (orderByComparator != null) {
10498                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
10499    
10500                            for (Object value : values) {
10501                                    qPos.add(value);
10502                            }
10503                    }
10504    
10505                    List<BlogsEntry> list = q.list();
10506    
10507                    if (list.size() == 2) {
10508                            return list.get(1);
10509                    }
10510                    else {
10511                            return null;
10512                    }
10513            }
10514    
10515            /**
10516             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status = any &#63;.
10517             *
10518             * @param groupId the group ID
10519             * @param userId the user ID
10520             * @param statuses the statuses
10521             * @return the matching blogs entries that the user has permission to view
10522             */
10523            @Override
10524            public List<BlogsEntry> filterFindByG_U_S(long groupId, long userId,
10525                    int[] statuses) {
10526                    return filterFindByG_U_S(groupId, userId, statuses, QueryUtil.ALL_POS,
10527                            QueryUtil.ALL_POS, null);
10528            }
10529    
10530            /**
10531             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status = any &#63;.
10532             *
10533             * <p>
10534             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10535             * </p>
10536             *
10537             * @param groupId the group ID
10538             * @param userId the user ID
10539             * @param statuses the statuses
10540             * @param start the lower bound of the range of blogs entries
10541             * @param end the upper bound of the range of blogs entries (not inclusive)
10542             * @return the range of matching blogs entries that the user has permission to view
10543             */
10544            @Override
10545            public List<BlogsEntry> filterFindByG_U_S(long groupId, long userId,
10546                    int[] statuses, int start, int end) {
10547                    return filterFindByG_U_S(groupId, userId, statuses, start, end, null);
10548            }
10549    
10550            /**
10551             * Returns an ordered range of all the blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status = any &#63;.
10552             *
10553             * <p>
10554             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10555             * </p>
10556             *
10557             * @param groupId the group ID
10558             * @param userId the user ID
10559             * @param statuses the statuses
10560             * @param start the lower bound of the range of blogs entries
10561             * @param end the upper bound of the range of blogs entries (not inclusive)
10562             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10563             * @return the ordered range of matching blogs entries that the user has permission to view
10564             */
10565            @Override
10566            public List<BlogsEntry> filterFindByG_U_S(long groupId, long userId,
10567                    int[] statuses, int start, int end,
10568                    OrderByComparator<BlogsEntry> orderByComparator) {
10569                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10570                            return findByG_U_S(groupId, userId, statuses, start, end,
10571                                    orderByComparator);
10572                    }
10573    
10574                    if (statuses == null) {
10575                            statuses = new int[0];
10576                    }
10577                    else if (statuses.length > 1) {
10578                            statuses = ArrayUtil.unique(statuses);
10579    
10580                            Arrays.sort(statuses);
10581                    }
10582    
10583                    StringBundler query = new StringBundler();
10584    
10585                    if (getDB().isSupportsInlineDistinct()) {
10586                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
10587                    }
10588                    else {
10589                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
10590                    }
10591    
10592                    query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
10593    
10594                    query.append(_FINDER_COLUMN_G_U_S_USERID_2);
10595    
10596                    if (statuses.length > 0) {
10597                            query.append(StringPool.OPEN_PARENTHESIS);
10598    
10599                            query.append(_FINDER_COLUMN_G_U_S_STATUS_7);
10600    
10601                            query.append(StringUtil.merge(statuses));
10602    
10603                            query.append(StringPool.CLOSE_PARENTHESIS);
10604    
10605                            query.append(StringPool.CLOSE_PARENTHESIS);
10606                    }
10607    
10608                    query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
10609                            query.index() - 1);
10610    
10611                    if (!getDB().isSupportsInlineDistinct()) {
10612                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
10613                    }
10614    
10615                    if (orderByComparator != null) {
10616                            if (getDB().isSupportsInlineDistinct()) {
10617                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10618                                            orderByComparator, true);
10619                            }
10620                            else {
10621                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
10622                                            orderByComparator, true);
10623                            }
10624                    }
10625                    else {
10626                            if (getDB().isSupportsInlineDistinct()) {
10627                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
10628                            }
10629                            else {
10630                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
10631                            }
10632                    }
10633    
10634                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10635                                    BlogsEntry.class.getName(),
10636                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10637    
10638                    Session session = null;
10639    
10640                    try {
10641                            session = openSession();
10642    
10643                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
10644    
10645                            if (getDB().isSupportsInlineDistinct()) {
10646                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
10647                            }
10648                            else {
10649                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
10650                            }
10651    
10652                            QueryPos qPos = QueryPos.getInstance(q);
10653    
10654                            qPos.add(groupId);
10655    
10656                            qPos.add(userId);
10657    
10658                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
10659                    }
10660                    catch (Exception e) {
10661                            throw processException(e);
10662                    }
10663                    finally {
10664                            closeSession(session);
10665                    }
10666            }
10667    
10668            /**
10669             * Returns all the blogs entries where groupId = &#63; and userId = &#63; and status = any &#63;.
10670             *
10671             * <p>
10672             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10673             * </p>
10674             *
10675             * @param groupId the group ID
10676             * @param userId the user ID
10677             * @param statuses the statuses
10678             * @return the matching blogs entries
10679             */
10680            @Override
10681            public List<BlogsEntry> findByG_U_S(long groupId, long userId,
10682                    int[] statuses) {
10683                    return findByG_U_S(groupId, userId, statuses, QueryUtil.ALL_POS,
10684                            QueryUtil.ALL_POS, null);
10685            }
10686    
10687            /**
10688             * Returns a range of all the blogs entries where groupId = &#63; and userId = &#63; and status = any &#63;.
10689             *
10690             * <p>
10691             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10692             * </p>
10693             *
10694             * @param groupId the group ID
10695             * @param userId the user ID
10696             * @param statuses the statuses
10697             * @param start the lower bound of the range of blogs entries
10698             * @param end the upper bound of the range of blogs entries (not inclusive)
10699             * @return the range of matching blogs entries
10700             */
10701            @Override
10702            public List<BlogsEntry> findByG_U_S(long groupId, long userId,
10703                    int[] statuses, int start, int end) {
10704                    return findByG_U_S(groupId, userId, statuses, start, end, null);
10705            }
10706    
10707            /**
10708             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and status = any &#63;.
10709             *
10710             * <p>
10711             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10712             * </p>
10713             *
10714             * @param groupId the group ID
10715             * @param userId the user ID
10716             * @param statuses the statuses
10717             * @param start the lower bound of the range of blogs entries
10718             * @param end the upper bound of the range of blogs entries (not inclusive)
10719             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10720             * @return the ordered range of matching blogs entries
10721             */
10722            @Override
10723            public List<BlogsEntry> findByG_U_S(long groupId, long userId,
10724                    int[] statuses, int start, int end,
10725                    OrderByComparator<BlogsEntry> orderByComparator) {
10726                    return findByG_U_S(groupId, userId, statuses, start, end,
10727                            orderByComparator, true);
10728            }
10729    
10730            /**
10731             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and status = &#63;, optionally using the finder cache.
10732             *
10733             * <p>
10734             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10735             * </p>
10736             *
10737             * @param groupId the group ID
10738             * @param userId the user ID
10739             * @param status the status
10740             * @param start the lower bound of the range of blogs entries
10741             * @param end the upper bound of the range of blogs entries (not inclusive)
10742             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10743             * @param retrieveFromCache whether to retrieve from the finder cache
10744             * @return the ordered range of matching blogs entries
10745             */
10746            @Override
10747            public List<BlogsEntry> findByG_U_S(long groupId, long userId,
10748                    int[] statuses, int start, int end,
10749                    OrderByComparator<BlogsEntry> orderByComparator,
10750                    boolean retrieveFromCache) {
10751                    if (statuses == null) {
10752                            statuses = new int[0];
10753                    }
10754                    else if (statuses.length > 1) {
10755                            statuses = ArrayUtil.unique(statuses);
10756    
10757                            Arrays.sort(statuses);
10758                    }
10759    
10760                    if (statuses.length == 1) {
10761                            return findByG_U_S(groupId, userId, statuses[0], start, end,
10762                                    orderByComparator);
10763                    }
10764    
10765                    boolean pagination = true;
10766                    Object[] finderArgs = null;
10767    
10768                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
10769                                    (orderByComparator == null)) {
10770                            pagination = false;
10771                            finderArgs = new Object[] {
10772                                            groupId, userId, StringUtil.merge(statuses)
10773                                    };
10774                    }
10775                    else {
10776                            finderArgs = new Object[] {
10777                                            groupId, userId, StringUtil.merge(statuses),
10778                                            
10779                                            start, end, orderByComparator
10780                                    };
10781                    }
10782    
10783                    List<BlogsEntry> list = null;
10784    
10785                    if (retrieveFromCache) {
10786                            list = (List<BlogsEntry>)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_S,
10787                                            finderArgs, this);
10788    
10789                            if ((list != null) && !list.isEmpty()) {
10790                                    for (BlogsEntry blogsEntry : list) {
10791                                            if ((groupId != blogsEntry.getGroupId()) ||
10792                                                            (userId != blogsEntry.getUserId()) ||
10793                                                            !ArrayUtil.contains(statuses, blogsEntry.getStatus())) {
10794                                                    list = null;
10795    
10796                                                    break;
10797                                            }
10798                                    }
10799                            }
10800                    }
10801    
10802                    if (list == null) {
10803                            StringBundler query = new StringBundler();
10804    
10805                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
10806    
10807                            query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
10808    
10809                            query.append(_FINDER_COLUMN_G_U_S_USERID_2);
10810    
10811                            if (statuses.length > 0) {
10812                                    query.append(StringPool.OPEN_PARENTHESIS);
10813    
10814                                    query.append(_FINDER_COLUMN_G_U_S_STATUS_7);
10815    
10816                                    query.append(StringUtil.merge(statuses));
10817    
10818                                    query.append(StringPool.CLOSE_PARENTHESIS);
10819    
10820                                    query.append(StringPool.CLOSE_PARENTHESIS);
10821                            }
10822    
10823                            query.setStringAt(removeConjunction(query.stringAt(query.index() -
10824                                                    1)), query.index() - 1);
10825    
10826                            if (orderByComparator != null) {
10827                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10828                                            orderByComparator);
10829                            }
10830                            else
10831                             if (pagination) {
10832                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
10833                            }
10834    
10835                            String sql = query.toString();
10836    
10837                            Session session = null;
10838    
10839                            try {
10840                                    session = openSession();
10841    
10842                                    Query q = session.createQuery(sql);
10843    
10844                                    QueryPos qPos = QueryPos.getInstance(q);
10845    
10846                                    qPos.add(groupId);
10847    
10848                                    qPos.add(userId);
10849    
10850                                    if (!pagination) {
10851                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
10852                                                            start, end, false);
10853    
10854                                            Collections.sort(list);
10855    
10856                                            list = Collections.unmodifiableList(list);
10857                                    }
10858                                    else {
10859                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
10860                                                            start, end);
10861                                    }
10862    
10863                                    cacheResult(list);
10864    
10865                                    finderCache.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_S,
10866                                            finderArgs, list);
10867                            }
10868                            catch (Exception e) {
10869                                    finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_S,
10870                                            finderArgs);
10871    
10872                                    throw processException(e);
10873                            }
10874                            finally {
10875                                    closeSession(session);
10876                            }
10877                    }
10878    
10879                    return list;
10880            }
10881    
10882            /**
10883             * Removes all the blogs entries where groupId = &#63; and userId = &#63; and status = &#63; from the database.
10884             *
10885             * @param groupId the group ID
10886             * @param userId the user ID
10887             * @param status the status
10888             */
10889            @Override
10890            public void removeByG_U_S(long groupId, long userId, int status) {
10891                    for (BlogsEntry blogsEntry : findByG_U_S(groupId, userId, status,
10892                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
10893                            remove(blogsEntry);
10894                    }
10895            }
10896    
10897            /**
10898             * Returns the number of blogs entries where groupId = &#63; and userId = &#63; and status = &#63;.
10899             *
10900             * @param groupId the group ID
10901             * @param userId the user ID
10902             * @param status the status
10903             * @return the number of matching blogs entries
10904             */
10905            @Override
10906            public int countByG_U_S(long groupId, long userId, int status) {
10907                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_U_S;
10908    
10909                    Object[] finderArgs = new Object[] { groupId, userId, status };
10910    
10911                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
10912    
10913                    if (count == null) {
10914                            StringBundler query = new StringBundler(4);
10915    
10916                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
10917    
10918                            query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
10919    
10920                            query.append(_FINDER_COLUMN_G_U_S_USERID_2);
10921    
10922                            query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
10923    
10924                            String sql = query.toString();
10925    
10926                            Session session = null;
10927    
10928                            try {
10929                                    session = openSession();
10930    
10931                                    Query q = session.createQuery(sql);
10932    
10933                                    QueryPos qPos = QueryPos.getInstance(q);
10934    
10935                                    qPos.add(groupId);
10936    
10937                                    qPos.add(userId);
10938    
10939                                    qPos.add(status);
10940    
10941                                    count = (Long)q.uniqueResult();
10942    
10943                                    finderCache.putResult(finderPath, finderArgs, count);
10944                            }
10945                            catch (Exception e) {
10946                                    finderCache.removeResult(finderPath, finderArgs);
10947    
10948                                    throw processException(e);
10949                            }
10950                            finally {
10951                                    closeSession(session);
10952                            }
10953                    }
10954    
10955                    return count.intValue();
10956            }
10957    
10958            /**
10959             * Returns the number of blogs entries where groupId = &#63; and userId = &#63; and status = any &#63;.
10960             *
10961             * @param groupId the group ID
10962             * @param userId the user ID
10963             * @param statuses the statuses
10964             * @return the number of matching blogs entries
10965             */
10966            @Override
10967            public int countByG_U_S(long groupId, long userId, int[] statuses) {
10968                    if (statuses == null) {
10969                            statuses = new int[0];
10970                    }
10971                    else if (statuses.length > 1) {
10972                            statuses = ArrayUtil.unique(statuses);
10973    
10974                            Arrays.sort(statuses);
10975                    }
10976    
10977                    Object[] finderArgs = new Object[] {
10978                                    groupId, userId, StringUtil.merge(statuses)
10979                            };
10980    
10981                    Long count = (Long)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_S,
10982                                    finderArgs, this);
10983    
10984                    if (count == null) {
10985                            StringBundler query = new StringBundler();
10986    
10987                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
10988    
10989                            query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
10990    
10991                            query.append(_FINDER_COLUMN_G_U_S_USERID_2);
10992    
10993                            if (statuses.length > 0) {
10994                                    query.append(StringPool.OPEN_PARENTHESIS);
10995    
10996                                    query.append(_FINDER_COLUMN_G_U_S_STATUS_7);
10997    
10998                                    query.append(StringUtil.merge(statuses));
10999    
11000                                    query.append(StringPool.CLOSE_PARENTHESIS);
11001    
11002                                    query.append(StringPool.CLOSE_PARENTHESIS);
11003                            }
11004    
11005                            query.setStringAt(removeConjunction(query.stringAt(query.index() -
11006                                                    1)), query.index() - 1);
11007    
11008                            String sql = query.toString();
11009    
11010                            Session session = null;
11011    
11012                            try {
11013                                    session = openSession();
11014    
11015                                    Query q = session.createQuery(sql);
11016    
11017                                    QueryPos qPos = QueryPos.getInstance(q);
11018    
11019                                    qPos.add(groupId);
11020    
11021                                    qPos.add(userId);
11022    
11023                                    count = (Long)q.uniqueResult();
11024    
11025                                    finderCache.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_S,
11026                                            finderArgs, count);
11027                            }
11028                            catch (Exception e) {
11029                                    finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_S,
11030                                            finderArgs);
11031    
11032                                    throw processException(e);
11033                            }
11034                            finally {
11035                                    closeSession(session);
11036                            }
11037                    }
11038    
11039                    return count.intValue();
11040            }
11041    
11042            /**
11043             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status = &#63;.
11044             *
11045             * @param groupId the group ID
11046             * @param userId the user ID
11047             * @param status the status
11048             * @return the number of matching blogs entries that the user has permission to view
11049             */
11050            @Override
11051            public int filterCountByG_U_S(long groupId, long userId, int status) {
11052                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11053                            return countByG_U_S(groupId, userId, status);
11054                    }
11055    
11056                    StringBundler query = new StringBundler(4);
11057    
11058                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
11059    
11060                    query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
11061    
11062                    query.append(_FINDER_COLUMN_G_U_S_USERID_2);
11063    
11064                    query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
11065    
11066                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11067                                    BlogsEntry.class.getName(),
11068                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11069    
11070                    Session session = null;
11071    
11072                    try {
11073                            session = openSession();
11074    
11075                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
11076    
11077                            q.addScalar(COUNT_COLUMN_NAME,
11078                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
11079    
11080                            QueryPos qPos = QueryPos.getInstance(q);
11081    
11082                            qPos.add(groupId);
11083    
11084                            qPos.add(userId);
11085    
11086                            qPos.add(status);
11087    
11088                            Long count = (Long)q.uniqueResult();
11089    
11090                            return count.intValue();
11091                    }
11092                    catch (Exception e) {
11093                            throw processException(e);
11094                    }
11095                    finally {
11096                            closeSession(session);
11097                    }
11098            }
11099    
11100            /**
11101             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status = any &#63;.
11102             *
11103             * @param groupId the group ID
11104             * @param userId the user ID
11105             * @param statuses the statuses
11106             * @return the number of matching blogs entries that the user has permission to view
11107             */
11108            @Override
11109            public int filterCountByG_U_S(long groupId, long userId, int[] statuses) {
11110                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11111                            return countByG_U_S(groupId, userId, statuses);
11112                    }
11113    
11114                    if (statuses == null) {
11115                            statuses = new int[0];
11116                    }
11117                    else if (statuses.length > 1) {
11118                            statuses = ArrayUtil.unique(statuses);
11119    
11120                            Arrays.sort(statuses);
11121                    }
11122    
11123                    StringBundler query = new StringBundler();
11124    
11125                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
11126    
11127                    query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
11128    
11129                    query.append(_FINDER_COLUMN_G_U_S_USERID_2);
11130    
11131                    if (statuses.length > 0) {
11132                            query.append(StringPool.OPEN_PARENTHESIS);
11133    
11134                            query.append(_FINDER_COLUMN_G_U_S_STATUS_7);
11135    
11136                            query.append(StringUtil.merge(statuses));
11137    
11138                            query.append(StringPool.CLOSE_PARENTHESIS);
11139    
11140                            query.append(StringPool.CLOSE_PARENTHESIS);
11141                    }
11142    
11143                    query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
11144                            query.index() - 1);
11145    
11146                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11147                                    BlogsEntry.class.getName(),
11148                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11149    
11150                    Session session = null;
11151    
11152                    try {
11153                            session = openSession();
11154    
11155                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
11156    
11157                            q.addScalar(COUNT_COLUMN_NAME,
11158                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
11159    
11160                            QueryPos qPos = QueryPos.getInstance(q);
11161    
11162                            qPos.add(groupId);
11163    
11164                            qPos.add(userId);
11165    
11166                            Long count = (Long)q.uniqueResult();
11167    
11168                            return count.intValue();
11169                    }
11170                    catch (Exception e) {
11171                            throw processException(e);
11172                    }
11173                    finally {
11174                            closeSession(session);
11175                    }
11176            }
11177    
11178            private static final String _FINDER_COLUMN_G_U_S_GROUPID_2 = "blogsEntry.groupId = ? AND ";
11179            private static final String _FINDER_COLUMN_G_U_S_USERID_2 = "blogsEntry.userId = ? AND ";
11180            private static final String _FINDER_COLUMN_G_U_S_STATUS_2 = "blogsEntry.status = ?";
11181            private static final String _FINDER_COLUMN_G_U_S_STATUS_7 = "blogsEntry.status IN (";
11182            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_NOTS = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
11183                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
11184                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_NotS",
11185                            new String[] {
11186                                    Long.class.getName(), Long.class.getName(),
11187                                    Integer.class.getName(),
11188                                    
11189                            Integer.class.getName(), Integer.class.getName(),
11190                                    OrderByComparator.class.getName()
11191                            });
11192            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_NOTS =
11193                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
11194                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
11195                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_U_NotS",
11196                            new String[] {
11197                                    Long.class.getName(), Long.class.getName(),
11198                                    Integer.class.getName()
11199                            });
11200    
11201            /**
11202             * Returns all the blogs entries where groupId = &#63; and userId = &#63; and status &ne; &#63;.
11203             *
11204             * @param groupId the group ID
11205             * @param userId the user ID
11206             * @param status the status
11207             * @return the matching blogs entries
11208             */
11209            @Override
11210            public List<BlogsEntry> findByG_U_NotS(long groupId, long userId, int status) {
11211                    return findByG_U_NotS(groupId, userId, status, QueryUtil.ALL_POS,
11212                            QueryUtil.ALL_POS, null);
11213            }
11214    
11215            /**
11216             * Returns a range of all the blogs entries where groupId = &#63; and userId = &#63; and status &ne; &#63;.
11217             *
11218             * <p>
11219             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11220             * </p>
11221             *
11222             * @param groupId the group ID
11223             * @param userId the user ID
11224             * @param status the status
11225             * @param start the lower bound of the range of blogs entries
11226             * @param end the upper bound of the range of blogs entries (not inclusive)
11227             * @return the range of matching blogs entries
11228             */
11229            @Override
11230            public List<BlogsEntry> findByG_U_NotS(long groupId, long userId,
11231                    int status, int start, int end) {
11232                    return findByG_U_NotS(groupId, userId, status, start, end, null);
11233            }
11234    
11235            /**
11236             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and status &ne; &#63;.
11237             *
11238             * <p>
11239             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11240             * </p>
11241             *
11242             * @param groupId the group ID
11243             * @param userId the user ID
11244             * @param status the status
11245             * @param start the lower bound of the range of blogs entries
11246             * @param end the upper bound of the range of blogs entries (not inclusive)
11247             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11248             * @return the ordered range of matching blogs entries
11249             */
11250            @Override
11251            public List<BlogsEntry> findByG_U_NotS(long groupId, long userId,
11252                    int status, int start, int end,
11253                    OrderByComparator<BlogsEntry> orderByComparator) {
11254                    return findByG_U_NotS(groupId, userId, status, start, end,
11255                            orderByComparator, true);
11256            }
11257    
11258            /**
11259             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and status &ne; &#63;.
11260             *
11261             * <p>
11262             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11263             * </p>
11264             *
11265             * @param groupId the group ID
11266             * @param userId the user ID
11267             * @param status the status
11268             * @param start the lower bound of the range of blogs entries
11269             * @param end the upper bound of the range of blogs entries (not inclusive)
11270             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11271             * @param retrieveFromCache whether to retrieve from the finder cache
11272             * @return the ordered range of matching blogs entries
11273             */
11274            @Override
11275            public List<BlogsEntry> findByG_U_NotS(long groupId, long userId,
11276                    int status, int start, int end,
11277                    OrderByComparator<BlogsEntry> orderByComparator,
11278                    boolean retrieveFromCache) {
11279                    boolean pagination = true;
11280                    FinderPath finderPath = null;
11281                    Object[] finderArgs = null;
11282    
11283                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_NOTS;
11284                    finderArgs = new Object[] {
11285                                    groupId, userId, status,
11286                                    
11287                                    start, end, orderByComparator
11288                            };
11289    
11290                    List<BlogsEntry> list = null;
11291    
11292                    if (retrieveFromCache) {
11293                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
11294                                            finderArgs, this);
11295    
11296                            if ((list != null) && !list.isEmpty()) {
11297                                    for (BlogsEntry blogsEntry : list) {
11298                                            if ((groupId != blogsEntry.getGroupId()) ||
11299                                                            (userId != blogsEntry.getUserId()) ||
11300                                                            (status == blogsEntry.getStatus())) {
11301                                                    list = null;
11302    
11303                                                    break;
11304                                            }
11305                                    }
11306                            }
11307                    }
11308    
11309                    if (list == null) {
11310                            StringBundler query = null;
11311    
11312                            if (orderByComparator != null) {
11313                                    query = new StringBundler(5 +
11314                                                    (orderByComparator.getOrderByFields().length * 2));
11315                            }
11316                            else {
11317                                    query = new StringBundler(5);
11318                            }
11319    
11320                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
11321    
11322                            query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
11323    
11324                            query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
11325    
11326                            query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
11327    
11328                            if (orderByComparator != null) {
11329                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11330                                            orderByComparator);
11331                            }
11332                            else
11333                             if (pagination) {
11334                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
11335                            }
11336    
11337                            String sql = query.toString();
11338    
11339                            Session session = null;
11340    
11341                            try {
11342                                    session = openSession();
11343    
11344                                    Query q = session.createQuery(sql);
11345    
11346                                    QueryPos qPos = QueryPos.getInstance(q);
11347    
11348                                    qPos.add(groupId);
11349    
11350                                    qPos.add(userId);
11351    
11352                                    qPos.add(status);
11353    
11354                                    if (!pagination) {
11355                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
11356                                                            start, end, false);
11357    
11358                                            Collections.sort(list);
11359    
11360                                            list = Collections.unmodifiableList(list);
11361                                    }
11362                                    else {
11363                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
11364                                                            start, end);
11365                                    }
11366    
11367                                    cacheResult(list);
11368    
11369                                    finderCache.putResult(finderPath, finderArgs, list);
11370                            }
11371                            catch (Exception e) {
11372                                    finderCache.removeResult(finderPath, finderArgs);
11373    
11374                                    throw processException(e);
11375                            }
11376                            finally {
11377                                    closeSession(session);
11378                            }
11379                    }
11380    
11381                    return list;
11382            }
11383    
11384            /**
11385             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status &ne; &#63;.
11386             *
11387             * @param groupId the group ID
11388             * @param userId the user ID
11389             * @param status the status
11390             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11391             * @return the first matching blogs entry
11392             * @throws NoSuchEntryException if a matching blogs entry could not be found
11393             */
11394            @Override
11395            public BlogsEntry findByG_U_NotS_First(long groupId, long userId,
11396                    int status, OrderByComparator<BlogsEntry> orderByComparator)
11397                    throws NoSuchEntryException {
11398                    BlogsEntry blogsEntry = fetchByG_U_NotS_First(groupId, userId, status,
11399                                    orderByComparator);
11400    
11401                    if (blogsEntry != null) {
11402                            return blogsEntry;
11403                    }
11404    
11405                    StringBundler msg = new StringBundler(8);
11406    
11407                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11408    
11409                    msg.append("groupId=");
11410                    msg.append(groupId);
11411    
11412                    msg.append(", userId=");
11413                    msg.append(userId);
11414    
11415                    msg.append(", status=");
11416                    msg.append(status);
11417    
11418                    msg.append(StringPool.CLOSE_CURLY_BRACE);
11419    
11420                    throw new NoSuchEntryException(msg.toString());
11421            }
11422    
11423            /**
11424             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status &ne; &#63;.
11425             *
11426             * @param groupId the group ID
11427             * @param userId the user ID
11428             * @param status the status
11429             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11430             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
11431             */
11432            @Override
11433            public BlogsEntry fetchByG_U_NotS_First(long groupId, long userId,
11434                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
11435                    List<BlogsEntry> list = findByG_U_NotS(groupId, userId, status, 0, 1,
11436                                    orderByComparator);
11437    
11438                    if (!list.isEmpty()) {
11439                            return list.get(0);
11440                    }
11441    
11442                    return null;
11443            }
11444    
11445            /**
11446             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status &ne; &#63;.
11447             *
11448             * @param groupId the group ID
11449             * @param userId the user ID
11450             * @param status the status
11451             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11452             * @return the last matching blogs entry
11453             * @throws NoSuchEntryException if a matching blogs entry could not be found
11454             */
11455            @Override
11456            public BlogsEntry findByG_U_NotS_Last(long groupId, long userId,
11457                    int status, OrderByComparator<BlogsEntry> orderByComparator)
11458                    throws NoSuchEntryException {
11459                    BlogsEntry blogsEntry = fetchByG_U_NotS_Last(groupId, userId, status,
11460                                    orderByComparator);
11461    
11462                    if (blogsEntry != null) {
11463                            return blogsEntry;
11464                    }
11465    
11466                    StringBundler msg = new StringBundler(8);
11467    
11468                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11469    
11470                    msg.append("groupId=");
11471                    msg.append(groupId);
11472    
11473                    msg.append(", userId=");
11474                    msg.append(userId);
11475    
11476                    msg.append(", status=");
11477                    msg.append(status);
11478    
11479                    msg.append(StringPool.CLOSE_CURLY_BRACE);
11480    
11481                    throw new NoSuchEntryException(msg.toString());
11482            }
11483    
11484            /**
11485             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status &ne; &#63;.
11486             *
11487             * @param groupId the group ID
11488             * @param userId the user ID
11489             * @param status the status
11490             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11491             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
11492             */
11493            @Override
11494            public BlogsEntry fetchByG_U_NotS_Last(long groupId, long userId,
11495                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
11496                    int count = countByG_U_NotS(groupId, userId, status);
11497    
11498                    if (count == 0) {
11499                            return null;
11500                    }
11501    
11502                    List<BlogsEntry> list = findByG_U_NotS(groupId, userId, status,
11503                                    count - 1, count, orderByComparator);
11504    
11505                    if (!list.isEmpty()) {
11506                            return list.get(0);
11507                    }
11508    
11509                    return null;
11510            }
11511    
11512            /**
11513             * 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;.
11514             *
11515             * @param entryId the primary key of the current blogs entry
11516             * @param groupId the group ID
11517             * @param userId the user ID
11518             * @param status the status
11519             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11520             * @return the previous, current, and next blogs entry
11521             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
11522             */
11523            @Override
11524            public BlogsEntry[] findByG_U_NotS_PrevAndNext(long entryId, long groupId,
11525                    long userId, int status, OrderByComparator<BlogsEntry> orderByComparator)
11526                    throws NoSuchEntryException {
11527                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
11528    
11529                    Session session = null;
11530    
11531                    try {
11532                            session = openSession();
11533    
11534                            BlogsEntry[] array = new BlogsEntryImpl[3];
11535    
11536                            array[0] = getByG_U_NotS_PrevAndNext(session, blogsEntry, groupId,
11537                                            userId, status, orderByComparator, true);
11538    
11539                            array[1] = blogsEntry;
11540    
11541                            array[2] = getByG_U_NotS_PrevAndNext(session, blogsEntry, groupId,
11542                                            userId, status, orderByComparator, false);
11543    
11544                            return array;
11545                    }
11546                    catch (Exception e) {
11547                            throw processException(e);
11548                    }
11549                    finally {
11550                            closeSession(session);
11551                    }
11552            }
11553    
11554            protected BlogsEntry getByG_U_NotS_PrevAndNext(Session session,
11555                    BlogsEntry blogsEntry, long groupId, long userId, int status,
11556                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
11557                    StringBundler query = null;
11558    
11559                    if (orderByComparator != null) {
11560                            query = new StringBundler(6 +
11561                                            (orderByComparator.getOrderByConditionFields().length * 3) +
11562                                            (orderByComparator.getOrderByFields().length * 3));
11563                    }
11564                    else {
11565                            query = new StringBundler(5);
11566                    }
11567    
11568                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
11569    
11570                    query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
11571    
11572                    query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
11573    
11574                    query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
11575    
11576                    if (orderByComparator != null) {
11577                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11578    
11579                            if (orderByConditionFields.length > 0) {
11580                                    query.append(WHERE_AND);
11581                            }
11582    
11583                            for (int i = 0; i < orderByConditionFields.length; i++) {
11584                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11585                                    query.append(orderByConditionFields[i]);
11586    
11587                                    if ((i + 1) < orderByConditionFields.length) {
11588                                            if (orderByComparator.isAscending() ^ previous) {
11589                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
11590                                            }
11591                                            else {
11592                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
11593                                            }
11594                                    }
11595                                    else {
11596                                            if (orderByComparator.isAscending() ^ previous) {
11597                                                    query.append(WHERE_GREATER_THAN);
11598                                            }
11599                                            else {
11600                                                    query.append(WHERE_LESSER_THAN);
11601                                            }
11602                                    }
11603                            }
11604    
11605                            query.append(ORDER_BY_CLAUSE);
11606    
11607                            String[] orderByFields = orderByComparator.getOrderByFields();
11608    
11609                            for (int i = 0; i < orderByFields.length; i++) {
11610                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11611                                    query.append(orderByFields[i]);
11612    
11613                                    if ((i + 1) < orderByFields.length) {
11614                                            if (orderByComparator.isAscending() ^ previous) {
11615                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
11616                                            }
11617                                            else {
11618                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
11619                                            }
11620                                    }
11621                                    else {
11622                                            if (orderByComparator.isAscending() ^ previous) {
11623                                                    query.append(ORDER_BY_ASC);
11624                                            }
11625                                            else {
11626                                                    query.append(ORDER_BY_DESC);
11627                                            }
11628                                    }
11629                            }
11630                    }
11631                    else {
11632                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
11633                    }
11634    
11635                    String sql = query.toString();
11636    
11637                    Query q = session.createQuery(sql);
11638    
11639                    q.setFirstResult(0);
11640                    q.setMaxResults(2);
11641    
11642                    QueryPos qPos = QueryPos.getInstance(q);
11643    
11644                    qPos.add(groupId);
11645    
11646                    qPos.add(userId);
11647    
11648                    qPos.add(status);
11649    
11650                    if (orderByComparator != null) {
11651                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
11652    
11653                            for (Object value : values) {
11654                                    qPos.add(value);
11655                            }
11656                    }
11657    
11658                    List<BlogsEntry> list = q.list();
11659    
11660                    if (list.size() == 2) {
11661                            return list.get(1);
11662                    }
11663                    else {
11664                            return null;
11665                    }
11666            }
11667    
11668            /**
11669             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status &ne; &#63;.
11670             *
11671             * @param groupId the group ID
11672             * @param userId the user ID
11673             * @param status the status
11674             * @return the matching blogs entries that the user has permission to view
11675             */
11676            @Override
11677            public List<BlogsEntry> filterFindByG_U_NotS(long groupId, long userId,
11678                    int status) {
11679                    return filterFindByG_U_NotS(groupId, userId, status, QueryUtil.ALL_POS,
11680                            QueryUtil.ALL_POS, null);
11681            }
11682    
11683            /**
11684             * 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;.
11685             *
11686             * <p>
11687             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11688             * </p>
11689             *
11690             * @param groupId the group ID
11691             * @param userId the user ID
11692             * @param status the status
11693             * @param start the lower bound of the range of blogs entries
11694             * @param end the upper bound of the range of blogs entries (not inclusive)
11695             * @return the range of matching blogs entries that the user has permission to view
11696             */
11697            @Override
11698            public List<BlogsEntry> filterFindByG_U_NotS(long groupId, long userId,
11699                    int status, int start, int end) {
11700                    return filterFindByG_U_NotS(groupId, userId, status, start, end, null);
11701            }
11702    
11703            /**
11704             * 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;.
11705             *
11706             * <p>
11707             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11708             * </p>
11709             *
11710             * @param groupId the group ID
11711             * @param userId the user ID
11712             * @param status the status
11713             * @param start the lower bound of the range of blogs entries
11714             * @param end the upper bound of the range of blogs entries (not inclusive)
11715             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11716             * @return the ordered range of matching blogs entries that the user has permission to view
11717             */
11718            @Override
11719            public List<BlogsEntry> filterFindByG_U_NotS(long groupId, long userId,
11720                    int status, int start, int end,
11721                    OrderByComparator<BlogsEntry> orderByComparator) {
11722                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11723                            return findByG_U_NotS(groupId, userId, status, start, end,
11724                                    orderByComparator);
11725                    }
11726    
11727                    StringBundler query = null;
11728    
11729                    if (orderByComparator != null) {
11730                            query = new StringBundler(5 +
11731                                            (orderByComparator.getOrderByFields().length * 2));
11732                    }
11733                    else {
11734                            query = new StringBundler(6);
11735                    }
11736    
11737                    if (getDB().isSupportsInlineDistinct()) {
11738                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
11739                    }
11740                    else {
11741                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
11742                    }
11743    
11744                    query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
11745    
11746                    query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
11747    
11748                    query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
11749    
11750                    if (!getDB().isSupportsInlineDistinct()) {
11751                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
11752                    }
11753    
11754                    if (orderByComparator != null) {
11755                            if (getDB().isSupportsInlineDistinct()) {
11756                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11757                                            orderByComparator, true);
11758                            }
11759                            else {
11760                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
11761                                            orderByComparator, true);
11762                            }
11763                    }
11764                    else {
11765                            if (getDB().isSupportsInlineDistinct()) {
11766                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
11767                            }
11768                            else {
11769                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
11770                            }
11771                    }
11772    
11773                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11774                                    BlogsEntry.class.getName(),
11775                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11776    
11777                    Session session = null;
11778    
11779                    try {
11780                            session = openSession();
11781    
11782                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
11783    
11784                            if (getDB().isSupportsInlineDistinct()) {
11785                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
11786                            }
11787                            else {
11788                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
11789                            }
11790    
11791                            QueryPos qPos = QueryPos.getInstance(q);
11792    
11793                            qPos.add(groupId);
11794    
11795                            qPos.add(userId);
11796    
11797                            qPos.add(status);
11798    
11799                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
11800                    }
11801                    catch (Exception e) {
11802                            throw processException(e);
11803                    }
11804                    finally {
11805                            closeSession(session);
11806                    }
11807            }
11808    
11809            /**
11810             * 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;.
11811             *
11812             * @param entryId the primary key of the current blogs entry
11813             * @param groupId the group ID
11814             * @param userId the user ID
11815             * @param status the status
11816             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11817             * @return the previous, current, and next blogs entry
11818             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
11819             */
11820            @Override
11821            public BlogsEntry[] filterFindByG_U_NotS_PrevAndNext(long entryId,
11822                    long groupId, long userId, int status,
11823                    OrderByComparator<BlogsEntry> orderByComparator)
11824                    throws NoSuchEntryException {
11825                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11826                            return findByG_U_NotS_PrevAndNext(entryId, groupId, userId, status,
11827                                    orderByComparator);
11828                    }
11829    
11830                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
11831    
11832                    Session session = null;
11833    
11834                    try {
11835                            session = openSession();
11836    
11837                            BlogsEntry[] array = new BlogsEntryImpl[3];
11838    
11839                            array[0] = filterGetByG_U_NotS_PrevAndNext(session, blogsEntry,
11840                                            groupId, userId, status, orderByComparator, true);
11841    
11842                            array[1] = blogsEntry;
11843    
11844                            array[2] = filterGetByG_U_NotS_PrevAndNext(session, blogsEntry,
11845                                            groupId, userId, status, orderByComparator, false);
11846    
11847                            return array;
11848                    }
11849                    catch (Exception e) {
11850                            throw processException(e);
11851                    }
11852                    finally {
11853                            closeSession(session);
11854                    }
11855            }
11856    
11857            protected BlogsEntry filterGetByG_U_NotS_PrevAndNext(Session session,
11858                    BlogsEntry blogsEntry, long groupId, long userId, int status,
11859                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
11860                    StringBundler query = null;
11861    
11862                    if (orderByComparator != null) {
11863                            query = new StringBundler(7 +
11864                                            (orderByComparator.getOrderByConditionFields().length * 3) +
11865                                            (orderByComparator.getOrderByFields().length * 3));
11866                    }
11867                    else {
11868                            query = new StringBundler(6);
11869                    }
11870    
11871                    if (getDB().isSupportsInlineDistinct()) {
11872                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
11873                    }
11874                    else {
11875                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
11876                    }
11877    
11878                    query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
11879    
11880                    query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
11881    
11882                    query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
11883    
11884                    if (!getDB().isSupportsInlineDistinct()) {
11885                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
11886                    }
11887    
11888                    if (orderByComparator != null) {
11889                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11890    
11891                            if (orderByConditionFields.length > 0) {
11892                                    query.append(WHERE_AND);
11893                            }
11894    
11895                            for (int i = 0; i < orderByConditionFields.length; i++) {
11896                                    if (getDB().isSupportsInlineDistinct()) {
11897                                            query.append(_ORDER_BY_ENTITY_ALIAS);
11898                                    }
11899                                    else {
11900                                            query.append(_ORDER_BY_ENTITY_TABLE);
11901                                    }
11902    
11903                                    query.append(orderByConditionFields[i]);
11904    
11905                                    if ((i + 1) < orderByConditionFields.length) {
11906                                            if (orderByComparator.isAscending() ^ previous) {
11907                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
11908                                            }
11909                                            else {
11910                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
11911                                            }
11912                                    }
11913                                    else {
11914                                            if (orderByComparator.isAscending() ^ previous) {
11915                                                    query.append(WHERE_GREATER_THAN);
11916                                            }
11917                                            else {
11918                                                    query.append(WHERE_LESSER_THAN);
11919                                            }
11920                                    }
11921                            }
11922    
11923                            query.append(ORDER_BY_CLAUSE);
11924    
11925                            String[] orderByFields = orderByComparator.getOrderByFields();
11926    
11927                            for (int i = 0; i < orderByFields.length; i++) {
11928                                    if (getDB().isSupportsInlineDistinct()) {
11929                                            query.append(_ORDER_BY_ENTITY_ALIAS);
11930                                    }
11931                                    else {
11932                                            query.append(_ORDER_BY_ENTITY_TABLE);
11933                                    }
11934    
11935                                    query.append(orderByFields[i]);
11936    
11937                                    if ((i + 1) < orderByFields.length) {
11938                                            if (orderByComparator.isAscending() ^ previous) {
11939                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
11940                                            }
11941                                            else {
11942                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
11943                                            }
11944                                    }
11945                                    else {
11946                                            if (orderByComparator.isAscending() ^ previous) {
11947                                                    query.append(ORDER_BY_ASC);
11948                                            }
11949                                            else {
11950                                                    query.append(ORDER_BY_DESC);
11951                                            }
11952                                    }
11953                            }
11954                    }
11955                    else {
11956                            if (getDB().isSupportsInlineDistinct()) {
11957                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
11958                            }
11959                            else {
11960                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
11961                            }
11962                    }
11963    
11964                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11965                                    BlogsEntry.class.getName(),
11966                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11967    
11968                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
11969    
11970                    q.setFirstResult(0);
11971                    q.setMaxResults(2);
11972    
11973                    if (getDB().isSupportsInlineDistinct()) {
11974                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
11975                    }
11976                    else {
11977                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
11978                    }
11979    
11980                    QueryPos qPos = QueryPos.getInstance(q);
11981    
11982                    qPos.add(groupId);
11983    
11984                    qPos.add(userId);
11985    
11986                    qPos.add(status);
11987    
11988                    if (orderByComparator != null) {
11989                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
11990    
11991                            for (Object value : values) {
11992                                    qPos.add(value);
11993                            }
11994                    }
11995    
11996                    List<BlogsEntry> list = q.list();
11997    
11998                    if (list.size() == 2) {
11999                            return list.get(1);
12000                    }
12001                    else {
12002                            return null;
12003                    }
12004            }
12005    
12006            /**
12007             * Removes all the blogs entries where groupId = &#63; and userId = &#63; and status &ne; &#63; from the database.
12008             *
12009             * @param groupId the group ID
12010             * @param userId the user ID
12011             * @param status the status
12012             */
12013            @Override
12014            public void removeByG_U_NotS(long groupId, long userId, int status) {
12015                    for (BlogsEntry blogsEntry : findByG_U_NotS(groupId, userId, status,
12016                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
12017                            remove(blogsEntry);
12018                    }
12019            }
12020    
12021            /**
12022             * Returns the number of blogs entries where groupId = &#63; and userId = &#63; and status &ne; &#63;.
12023             *
12024             * @param groupId the group ID
12025             * @param userId the user ID
12026             * @param status the status
12027             * @return the number of matching blogs entries
12028             */
12029            @Override
12030            public int countByG_U_NotS(long groupId, long userId, int status) {
12031                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_NOTS;
12032    
12033                    Object[] finderArgs = new Object[] { groupId, userId, status };
12034    
12035                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
12036    
12037                    if (count == null) {
12038                            StringBundler query = new StringBundler(4);
12039    
12040                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
12041    
12042                            query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
12043    
12044                            query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
12045    
12046                            query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
12047    
12048                            String sql = query.toString();
12049    
12050                            Session session = null;
12051    
12052                            try {
12053                                    session = openSession();
12054    
12055                                    Query q = session.createQuery(sql);
12056    
12057                                    QueryPos qPos = QueryPos.getInstance(q);
12058    
12059                                    qPos.add(groupId);
12060    
12061                                    qPos.add(userId);
12062    
12063                                    qPos.add(status);
12064    
12065                                    count = (Long)q.uniqueResult();
12066    
12067                                    finderCache.putResult(finderPath, finderArgs, count);
12068                            }
12069                            catch (Exception e) {
12070                                    finderCache.removeResult(finderPath, finderArgs);
12071    
12072                                    throw processException(e);
12073                            }
12074                            finally {
12075                                    closeSession(session);
12076                            }
12077                    }
12078    
12079                    return count.intValue();
12080            }
12081    
12082            /**
12083             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status &ne; &#63;.
12084             *
12085             * @param groupId the group ID
12086             * @param userId the user ID
12087             * @param status the status
12088             * @return the number of matching blogs entries that the user has permission to view
12089             */
12090            @Override
12091            public int filterCountByG_U_NotS(long groupId, long userId, int status) {
12092                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12093                            return countByG_U_NotS(groupId, userId, status);
12094                    }
12095    
12096                    StringBundler query = new StringBundler(4);
12097    
12098                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
12099    
12100                    query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
12101    
12102                    query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
12103    
12104                    query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
12105    
12106                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12107                                    BlogsEntry.class.getName(),
12108                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12109    
12110                    Session session = null;
12111    
12112                    try {
12113                            session = openSession();
12114    
12115                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
12116    
12117                            q.addScalar(COUNT_COLUMN_NAME,
12118                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
12119    
12120                            QueryPos qPos = QueryPos.getInstance(q);
12121    
12122                            qPos.add(groupId);
12123    
12124                            qPos.add(userId);
12125    
12126                            qPos.add(status);
12127    
12128                            Long count = (Long)q.uniqueResult();
12129    
12130                            return count.intValue();
12131                    }
12132                    catch (Exception e) {
12133                            throw processException(e);
12134                    }
12135                    finally {
12136                            closeSession(session);
12137                    }
12138            }
12139    
12140            private static final String _FINDER_COLUMN_G_U_NOTS_GROUPID_2 = "blogsEntry.groupId = ? AND ";
12141            private static final String _FINDER_COLUMN_G_U_NOTS_USERID_2 = "blogsEntry.userId = ? AND ";
12142            private static final String _FINDER_COLUMN_G_U_NOTS_STATUS_2 = "blogsEntry.status != ?";
12143            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
12144                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
12145                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_LtD_S",
12146                            new String[] {
12147                                    Long.class.getName(), Date.class.getName(),
12148                                    Integer.class.getName(),
12149                                    
12150                            Integer.class.getName(), Integer.class.getName(),
12151                                    OrderByComparator.class.getName()
12152                            });
12153            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
12154                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
12155                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_LtD_S",
12156                            new String[] {
12157                                    Long.class.getName(), Date.class.getName(),
12158                                    Integer.class.getName()
12159                            });
12160    
12161            /**
12162             * Returns all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
12163             *
12164             * @param groupId the group ID
12165             * @param displayDate the display date
12166             * @param status the status
12167             * @return the matching blogs entries
12168             */
12169            @Override
12170            public List<BlogsEntry> findByG_LtD_S(long groupId, Date displayDate,
12171                    int status) {
12172                    return findByG_LtD_S(groupId, displayDate, status, QueryUtil.ALL_POS,
12173                            QueryUtil.ALL_POS, null);
12174            }
12175    
12176            /**
12177             * Returns a range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
12178             *
12179             * <p>
12180             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
12181             * </p>
12182             *
12183             * @param groupId the group ID
12184             * @param displayDate the display date
12185             * @param status the status
12186             * @param start the lower bound of the range of blogs entries
12187             * @param end the upper bound of the range of blogs entries (not inclusive)
12188             * @return the range of matching blogs entries
12189             */
12190            @Override
12191            public List<BlogsEntry> findByG_LtD_S(long groupId, Date displayDate,
12192                    int status, int start, int end) {
12193                    return findByG_LtD_S(groupId, displayDate, status, start, end, null);
12194            }
12195    
12196            /**
12197             * Returns an ordered range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
12198             *
12199             * <p>
12200             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
12201             * </p>
12202             *
12203             * @param groupId the group ID
12204             * @param displayDate the display date
12205             * @param status the status
12206             * @param start the lower bound of the range of blogs entries
12207             * @param end the upper bound of the range of blogs entries (not inclusive)
12208             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12209             * @return the ordered range of matching blogs entries
12210             */
12211            @Override
12212            public List<BlogsEntry> findByG_LtD_S(long groupId, Date displayDate,
12213                    int status, int start, int end,
12214                    OrderByComparator<BlogsEntry> orderByComparator) {
12215                    return findByG_LtD_S(groupId, displayDate, status, start, end,
12216                            orderByComparator, true);
12217            }
12218    
12219            /**
12220             * Returns an ordered range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
12221             *
12222             * <p>
12223             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
12224             * </p>
12225             *
12226             * @param groupId the group ID
12227             * @param displayDate the display date
12228             * @param status the status
12229             * @param start the lower bound of the range of blogs entries
12230             * @param end the upper bound of the range of blogs entries (not inclusive)
12231             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12232             * @param retrieveFromCache whether to retrieve from the finder cache
12233             * @return the ordered range of matching blogs entries
12234             */
12235            @Override
12236            public List<BlogsEntry> findByG_LtD_S(long groupId, Date displayDate,
12237                    int status, int start, int end,
12238                    OrderByComparator<BlogsEntry> orderByComparator,
12239                    boolean retrieveFromCache) {
12240                    boolean pagination = true;
12241                    FinderPath finderPath = null;
12242                    Object[] finderArgs = null;
12243    
12244                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD_S;
12245                    finderArgs = new Object[] {
12246                                    groupId, displayDate, status,
12247                                    
12248                                    start, end, orderByComparator
12249                            };
12250    
12251                    List<BlogsEntry> list = null;
12252    
12253                    if (retrieveFromCache) {
12254                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
12255                                            finderArgs, this);
12256    
12257                            if ((list != null) && !list.isEmpty()) {
12258                                    for (BlogsEntry blogsEntry : list) {
12259                                            if ((groupId != blogsEntry.getGroupId()) ||
12260                                                            (displayDate.getTime() <= blogsEntry.getDisplayDate()
12261                                                                                                                                            .getTime()) ||
12262                                                            (status != blogsEntry.getStatus())) {
12263                                                    list = null;
12264    
12265                                                    break;
12266                                            }
12267                                    }
12268                            }
12269                    }
12270    
12271                    if (list == null) {
12272                            StringBundler query = null;
12273    
12274                            if (orderByComparator != null) {
12275                                    query = new StringBundler(5 +
12276                                                    (orderByComparator.getOrderByFields().length * 2));
12277                            }
12278                            else {
12279                                    query = new StringBundler(5);
12280                            }
12281    
12282                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
12283    
12284                            query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
12285    
12286                            boolean bindDisplayDate = false;
12287    
12288                            if (displayDate == null) {
12289                                    query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
12290                            }
12291                            else {
12292                                    bindDisplayDate = true;
12293    
12294                                    query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
12295                            }
12296    
12297                            query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
12298    
12299                            if (orderByComparator != null) {
12300                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12301                                            orderByComparator);
12302                            }
12303                            else
12304                             if (pagination) {
12305                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
12306                            }
12307    
12308                            String sql = query.toString();
12309    
12310                            Session session = null;
12311    
12312                            try {
12313                                    session = openSession();
12314    
12315                                    Query q = session.createQuery(sql);
12316    
12317                                    QueryPos qPos = QueryPos.getInstance(q);
12318    
12319                                    qPos.add(groupId);
12320    
12321                                    if (bindDisplayDate) {
12322                                            qPos.add(new Timestamp(displayDate.getTime()));
12323                                    }
12324    
12325                                    qPos.add(status);
12326    
12327                                    if (!pagination) {
12328                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
12329                                                            start, end, false);
12330    
12331                                            Collections.sort(list);
12332    
12333                                            list = Collections.unmodifiableList(list);
12334                                    }
12335                                    else {
12336                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
12337                                                            start, end);
12338                                    }
12339    
12340                                    cacheResult(list);
12341    
12342                                    finderCache.putResult(finderPath, finderArgs, list);
12343                            }
12344                            catch (Exception e) {
12345                                    finderCache.removeResult(finderPath, finderArgs);
12346    
12347                                    throw processException(e);
12348                            }
12349                            finally {
12350                                    closeSession(session);
12351                            }
12352                    }
12353    
12354                    return list;
12355            }
12356    
12357            /**
12358             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
12359             *
12360             * @param groupId the group ID
12361             * @param displayDate the display date
12362             * @param status the status
12363             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12364             * @return the first matching blogs entry
12365             * @throws NoSuchEntryException if a matching blogs entry could not be found
12366             */
12367            @Override
12368            public BlogsEntry findByG_LtD_S_First(long groupId, Date displayDate,
12369                    int status, OrderByComparator<BlogsEntry> orderByComparator)
12370                    throws NoSuchEntryException {
12371                    BlogsEntry blogsEntry = fetchByG_LtD_S_First(groupId, displayDate,
12372                                    status, orderByComparator);
12373    
12374                    if (blogsEntry != null) {
12375                            return blogsEntry;
12376                    }
12377    
12378                    StringBundler msg = new StringBundler(8);
12379    
12380                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12381    
12382                    msg.append("groupId=");
12383                    msg.append(groupId);
12384    
12385                    msg.append(", displayDate=");
12386                    msg.append(displayDate);
12387    
12388                    msg.append(", status=");
12389                    msg.append(status);
12390    
12391                    msg.append(StringPool.CLOSE_CURLY_BRACE);
12392    
12393                    throw new NoSuchEntryException(msg.toString());
12394            }
12395    
12396            /**
12397             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
12398             *
12399             * @param groupId the group ID
12400             * @param displayDate the display date
12401             * @param status the status
12402             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12403             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
12404             */
12405            @Override
12406            public BlogsEntry fetchByG_LtD_S_First(long groupId, Date displayDate,
12407                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
12408                    List<BlogsEntry> list = findByG_LtD_S(groupId, displayDate, status, 0,
12409                                    1, orderByComparator);
12410    
12411                    if (!list.isEmpty()) {
12412                            return list.get(0);
12413                    }
12414    
12415                    return null;
12416            }
12417    
12418            /**
12419             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
12420             *
12421             * @param groupId the group ID
12422             * @param displayDate the display date
12423             * @param status the status
12424             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12425             * @return the last matching blogs entry
12426             * @throws NoSuchEntryException if a matching blogs entry could not be found
12427             */
12428            @Override
12429            public BlogsEntry findByG_LtD_S_Last(long groupId, Date displayDate,
12430                    int status, OrderByComparator<BlogsEntry> orderByComparator)
12431                    throws NoSuchEntryException {
12432                    BlogsEntry blogsEntry = fetchByG_LtD_S_Last(groupId, displayDate,
12433                                    status, orderByComparator);
12434    
12435                    if (blogsEntry != null) {
12436                            return blogsEntry;
12437                    }
12438    
12439                    StringBundler msg = new StringBundler(8);
12440    
12441                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12442    
12443                    msg.append("groupId=");
12444                    msg.append(groupId);
12445    
12446                    msg.append(", displayDate=");
12447                    msg.append(displayDate);
12448    
12449                    msg.append(", status=");
12450                    msg.append(status);
12451    
12452                    msg.append(StringPool.CLOSE_CURLY_BRACE);
12453    
12454                    throw new NoSuchEntryException(msg.toString());
12455            }
12456    
12457            /**
12458             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
12459             *
12460             * @param groupId the group ID
12461             * @param displayDate the display date
12462             * @param status the status
12463             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12464             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
12465             */
12466            @Override
12467            public BlogsEntry fetchByG_LtD_S_Last(long groupId, Date displayDate,
12468                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
12469                    int count = countByG_LtD_S(groupId, displayDate, status);
12470    
12471                    if (count == 0) {
12472                            return null;
12473                    }
12474    
12475                    List<BlogsEntry> list = findByG_LtD_S(groupId, displayDate, status,
12476                                    count - 1, count, orderByComparator);
12477    
12478                    if (!list.isEmpty()) {
12479                            return list.get(0);
12480                    }
12481    
12482                    return null;
12483            }
12484    
12485            /**
12486             * 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;.
12487             *
12488             * @param entryId the primary key of the current blogs entry
12489             * @param groupId the group ID
12490             * @param displayDate the display date
12491             * @param status the status
12492             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12493             * @return the previous, current, and next blogs entry
12494             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
12495             */
12496            @Override
12497            public BlogsEntry[] findByG_LtD_S_PrevAndNext(long entryId, long groupId,
12498                    Date displayDate, int status,
12499                    OrderByComparator<BlogsEntry> orderByComparator)
12500                    throws NoSuchEntryException {
12501                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
12502    
12503                    Session session = null;
12504    
12505                    try {
12506                            session = openSession();
12507    
12508                            BlogsEntry[] array = new BlogsEntryImpl[3];
12509    
12510                            array[0] = getByG_LtD_S_PrevAndNext(session, blogsEntry, groupId,
12511                                            displayDate, status, orderByComparator, true);
12512    
12513                            array[1] = blogsEntry;
12514    
12515                            array[2] = getByG_LtD_S_PrevAndNext(session, blogsEntry, groupId,
12516                                            displayDate, status, orderByComparator, false);
12517    
12518                            return array;
12519                    }
12520                    catch (Exception e) {
12521                            throw processException(e);
12522                    }
12523                    finally {
12524                            closeSession(session);
12525                    }
12526            }
12527    
12528            protected BlogsEntry getByG_LtD_S_PrevAndNext(Session session,
12529                    BlogsEntry blogsEntry, long groupId, Date displayDate, int status,
12530                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
12531                    StringBundler query = null;
12532    
12533                    if (orderByComparator != null) {
12534                            query = new StringBundler(6 +
12535                                            (orderByComparator.getOrderByConditionFields().length * 3) +
12536                                            (orderByComparator.getOrderByFields().length * 3));
12537                    }
12538                    else {
12539                            query = new StringBundler(5);
12540                    }
12541    
12542                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
12543    
12544                    query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
12545    
12546                    boolean bindDisplayDate = false;
12547    
12548                    if (displayDate == null) {
12549                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
12550                    }
12551                    else {
12552                            bindDisplayDate = true;
12553    
12554                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
12555                    }
12556    
12557                    query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
12558    
12559                    if (orderByComparator != null) {
12560                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
12561    
12562                            if (orderByConditionFields.length > 0) {
12563                                    query.append(WHERE_AND);
12564                            }
12565    
12566                            for (int i = 0; i < orderByConditionFields.length; i++) {
12567                                    query.append(_ORDER_BY_ENTITY_ALIAS);
12568                                    query.append(orderByConditionFields[i]);
12569    
12570                                    if ((i + 1) < orderByConditionFields.length) {
12571                                            if (orderByComparator.isAscending() ^ previous) {
12572                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
12573                                            }
12574                                            else {
12575                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
12576                                            }
12577                                    }
12578                                    else {
12579                                            if (orderByComparator.isAscending() ^ previous) {
12580                                                    query.append(WHERE_GREATER_THAN);
12581                                            }
12582                                            else {
12583                                                    query.append(WHERE_LESSER_THAN);
12584                                            }
12585                                    }
12586                            }
12587    
12588                            query.append(ORDER_BY_CLAUSE);
12589    
12590                            String[] orderByFields = orderByComparator.getOrderByFields();
12591    
12592                            for (int i = 0; i < orderByFields.length; i++) {
12593                                    query.append(_ORDER_BY_ENTITY_ALIAS);
12594                                    query.append(orderByFields[i]);
12595    
12596                                    if ((i + 1) < orderByFields.length) {
12597                                            if (orderByComparator.isAscending() ^ previous) {
12598                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
12599                                            }
12600                                            else {
12601                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
12602                                            }
12603                                    }
12604                                    else {
12605                                            if (orderByComparator.isAscending() ^ previous) {
12606                                                    query.append(ORDER_BY_ASC);
12607                                            }
12608                                            else {
12609                                                    query.append(ORDER_BY_DESC);
12610                                            }
12611                                    }
12612                            }
12613                    }
12614                    else {
12615                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
12616                    }
12617    
12618                    String sql = query.toString();
12619    
12620                    Query q = session.createQuery(sql);
12621    
12622                    q.setFirstResult(0);
12623                    q.setMaxResults(2);
12624    
12625                    QueryPos qPos = QueryPos.getInstance(q);
12626    
12627                    qPos.add(groupId);
12628    
12629                    if (bindDisplayDate) {
12630                            qPos.add(new Timestamp(displayDate.getTime()));
12631                    }
12632    
12633                    qPos.add(status);
12634    
12635                    if (orderByComparator != null) {
12636                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
12637    
12638                            for (Object value : values) {
12639                                    qPos.add(value);
12640                            }
12641                    }
12642    
12643                    List<BlogsEntry> list = q.list();
12644    
12645                    if (list.size() == 2) {
12646                            return list.get(1);
12647                    }
12648                    else {
12649                            return null;
12650                    }
12651            }
12652    
12653            /**
12654             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
12655             *
12656             * @param groupId the group ID
12657             * @param displayDate the display date
12658             * @param status the status
12659             * @return the matching blogs entries that the user has permission to view
12660             */
12661            @Override
12662            public List<BlogsEntry> filterFindByG_LtD_S(long groupId, Date displayDate,
12663                    int status) {
12664                    return filterFindByG_LtD_S(groupId, displayDate, status,
12665                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
12666            }
12667    
12668            /**
12669             * 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;.
12670             *
12671             * <p>
12672             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
12673             * </p>
12674             *
12675             * @param groupId the group ID
12676             * @param displayDate the display date
12677             * @param status the status
12678             * @param start the lower bound of the range of blogs entries
12679             * @param end the upper bound of the range of blogs entries (not inclusive)
12680             * @return the range of matching blogs entries that the user has permission to view
12681             */
12682            @Override
12683            public List<BlogsEntry> filterFindByG_LtD_S(long groupId, Date displayDate,
12684                    int status, int start, int end) {
12685                    return filterFindByG_LtD_S(groupId, displayDate, status, start, end,
12686                            null);
12687            }
12688    
12689            /**
12690             * 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;.
12691             *
12692             * <p>
12693             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
12694             * </p>
12695             *
12696             * @param groupId the group ID
12697             * @param displayDate the display date
12698             * @param status the status
12699             * @param start the lower bound of the range of blogs entries
12700             * @param end the upper bound of the range of blogs entries (not inclusive)
12701             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12702             * @return the ordered range of matching blogs entries that the user has permission to view
12703             */
12704            @Override
12705            public List<BlogsEntry> filterFindByG_LtD_S(long groupId, Date displayDate,
12706                    int status, int start, int end,
12707                    OrderByComparator<BlogsEntry> orderByComparator) {
12708                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12709                            return findByG_LtD_S(groupId, displayDate, status, start, end,
12710                                    orderByComparator);
12711                    }
12712    
12713                    StringBundler query = null;
12714    
12715                    if (orderByComparator != null) {
12716                            query = new StringBundler(5 +
12717                                            (orderByComparator.getOrderByFields().length * 2));
12718                    }
12719                    else {
12720                            query = new StringBundler(6);
12721                    }
12722    
12723                    if (getDB().isSupportsInlineDistinct()) {
12724                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
12725                    }
12726                    else {
12727                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
12728                    }
12729    
12730                    query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
12731    
12732                    boolean bindDisplayDate = false;
12733    
12734                    if (displayDate == null) {
12735                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
12736                    }
12737                    else {
12738                            bindDisplayDate = true;
12739    
12740                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
12741                    }
12742    
12743                    query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
12744    
12745                    if (!getDB().isSupportsInlineDistinct()) {
12746                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
12747                    }
12748    
12749                    if (orderByComparator != null) {
12750                            if (getDB().isSupportsInlineDistinct()) {
12751                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12752                                            orderByComparator, true);
12753                            }
12754                            else {
12755                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
12756                                            orderByComparator, true);
12757                            }
12758                    }
12759                    else {
12760                            if (getDB().isSupportsInlineDistinct()) {
12761                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
12762                            }
12763                            else {
12764                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
12765                            }
12766                    }
12767    
12768                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12769                                    BlogsEntry.class.getName(),
12770                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12771    
12772                    Session session = null;
12773    
12774                    try {
12775                            session = openSession();
12776    
12777                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
12778    
12779                            if (getDB().isSupportsInlineDistinct()) {
12780                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
12781                            }
12782                            else {
12783                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
12784                            }
12785    
12786                            QueryPos qPos = QueryPos.getInstance(q);
12787    
12788                            qPos.add(groupId);
12789    
12790                            if (bindDisplayDate) {
12791                                    qPos.add(new Timestamp(displayDate.getTime()));
12792                            }
12793    
12794                            qPos.add(status);
12795    
12796                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
12797                    }
12798                    catch (Exception e) {
12799                            throw processException(e);
12800                    }
12801                    finally {
12802                            closeSession(session);
12803                    }
12804            }
12805    
12806            /**
12807             * 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;.
12808             *
12809             * @param entryId the primary key of the current blogs entry
12810             * @param groupId the group ID
12811             * @param displayDate the display date
12812             * @param status the status
12813             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12814             * @return the previous, current, and next blogs entry
12815             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
12816             */
12817            @Override
12818            public BlogsEntry[] filterFindByG_LtD_S_PrevAndNext(long entryId,
12819                    long groupId, Date displayDate, int status,
12820                    OrderByComparator<BlogsEntry> orderByComparator)
12821                    throws NoSuchEntryException {
12822                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12823                            return findByG_LtD_S_PrevAndNext(entryId, groupId, displayDate,
12824                                    status, orderByComparator);
12825                    }
12826    
12827                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
12828    
12829                    Session session = null;
12830    
12831                    try {
12832                            session = openSession();
12833    
12834                            BlogsEntry[] array = new BlogsEntryImpl[3];
12835    
12836                            array[0] = filterGetByG_LtD_S_PrevAndNext(session, blogsEntry,
12837                                            groupId, displayDate, status, orderByComparator, true);
12838    
12839                            array[1] = blogsEntry;
12840    
12841                            array[2] = filterGetByG_LtD_S_PrevAndNext(session, blogsEntry,
12842                                            groupId, displayDate, status, orderByComparator, false);
12843    
12844                            return array;
12845                    }
12846                    catch (Exception e) {
12847                            throw processException(e);
12848                    }
12849                    finally {
12850                            closeSession(session);
12851                    }
12852            }
12853    
12854            protected BlogsEntry filterGetByG_LtD_S_PrevAndNext(Session session,
12855                    BlogsEntry blogsEntry, long groupId, Date displayDate, int status,
12856                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
12857                    StringBundler query = null;
12858    
12859                    if (orderByComparator != null) {
12860                            query = new StringBundler(7 +
12861                                            (orderByComparator.getOrderByConditionFields().length * 3) +
12862                                            (orderByComparator.getOrderByFields().length * 3));
12863                    }
12864                    else {
12865                            query = new StringBundler(6);
12866                    }
12867    
12868                    if (getDB().isSupportsInlineDistinct()) {
12869                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
12870                    }
12871                    else {
12872                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
12873                    }
12874    
12875                    query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
12876    
12877                    boolean bindDisplayDate = false;
12878    
12879                    if (displayDate == null) {
12880                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
12881                    }
12882                    else {
12883                            bindDisplayDate = true;
12884    
12885                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
12886                    }
12887    
12888                    query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
12889    
12890                    if (!getDB().isSupportsInlineDistinct()) {
12891                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
12892                    }
12893    
12894                    if (orderByComparator != null) {
12895                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
12896    
12897                            if (orderByConditionFields.length > 0) {
12898                                    query.append(WHERE_AND);
12899                            }
12900    
12901                            for (int i = 0; i < orderByConditionFields.length; i++) {
12902                                    if (getDB().isSupportsInlineDistinct()) {
12903                                            query.append(_ORDER_BY_ENTITY_ALIAS);
12904                                    }
12905                                    else {
12906                                            query.append(_ORDER_BY_ENTITY_TABLE);
12907                                    }
12908    
12909                                    query.append(orderByConditionFields[i]);
12910    
12911                                    if ((i + 1) < orderByConditionFields.length) {
12912                                            if (orderByComparator.isAscending() ^ previous) {
12913                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
12914                                            }
12915                                            else {
12916                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
12917                                            }
12918                                    }
12919                                    else {
12920                                            if (orderByComparator.isAscending() ^ previous) {
12921                                                    query.append(WHERE_GREATER_THAN);
12922                                            }
12923                                            else {
12924                                                    query.append(WHERE_LESSER_THAN);
12925                                            }
12926                                    }
12927                            }
12928    
12929                            query.append(ORDER_BY_CLAUSE);
12930    
12931                            String[] orderByFields = orderByComparator.getOrderByFields();
12932    
12933                            for (int i = 0; i < orderByFields.length; i++) {
12934                                    if (getDB().isSupportsInlineDistinct()) {
12935                                            query.append(_ORDER_BY_ENTITY_ALIAS);
12936                                    }
12937                                    else {
12938                                            query.append(_ORDER_BY_ENTITY_TABLE);
12939                                    }
12940    
12941                                    query.append(orderByFields[i]);
12942    
12943                                    if ((i + 1) < orderByFields.length) {
12944                                            if (orderByComparator.isAscending() ^ previous) {
12945                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
12946                                            }
12947                                            else {
12948                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
12949                                            }
12950                                    }
12951                                    else {
12952                                            if (orderByComparator.isAscending() ^ previous) {
12953                                                    query.append(ORDER_BY_ASC);
12954                                            }
12955                                            else {
12956                                                    query.append(ORDER_BY_DESC);
12957                                            }
12958                                    }
12959                            }
12960                    }
12961                    else {
12962                            if (getDB().isSupportsInlineDistinct()) {
12963                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
12964                            }
12965                            else {
12966                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
12967                            }
12968                    }
12969    
12970                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12971                                    BlogsEntry.class.getName(),
12972                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12973    
12974                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
12975    
12976                    q.setFirstResult(0);
12977                    q.setMaxResults(2);
12978    
12979                    if (getDB().isSupportsInlineDistinct()) {
12980                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
12981                    }
12982                    else {
12983                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
12984                    }
12985    
12986                    QueryPos qPos = QueryPos.getInstance(q);
12987    
12988                    qPos.add(groupId);
12989    
12990                    if (bindDisplayDate) {
12991                            qPos.add(new Timestamp(displayDate.getTime()));
12992                    }
12993    
12994                    qPos.add(status);
12995    
12996                    if (orderByComparator != null) {
12997                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
12998    
12999                            for (Object value : values) {
13000                                    qPos.add(value);
13001                            }
13002                    }
13003    
13004                    List<BlogsEntry> list = q.list();
13005    
13006                    if (list.size() == 2) {
13007                            return list.get(1);
13008                    }
13009                    else {
13010                            return null;
13011                    }
13012            }
13013    
13014            /**
13015             * Removes all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63; from the database.
13016             *
13017             * @param groupId the group ID
13018             * @param displayDate the display date
13019             * @param status the status
13020             */
13021            @Override
13022            public void removeByG_LtD_S(long groupId, Date displayDate, int status) {
13023                    for (BlogsEntry blogsEntry : findByG_LtD_S(groupId, displayDate,
13024                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
13025                            remove(blogsEntry);
13026                    }
13027            }
13028    
13029            /**
13030             * Returns the number of blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
13031             *
13032             * @param groupId the group ID
13033             * @param displayDate the display date
13034             * @param status the status
13035             * @return the number of matching blogs entries
13036             */
13037            @Override
13038            public int countByG_LtD_S(long groupId, Date displayDate, int status) {
13039                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD_S;
13040    
13041                    Object[] finderArgs = new Object[] { groupId, displayDate, status };
13042    
13043                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
13044    
13045                    if (count == null) {
13046                            StringBundler query = new StringBundler(4);
13047    
13048                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
13049    
13050                            query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
13051    
13052                            boolean bindDisplayDate = false;
13053    
13054                            if (displayDate == null) {
13055                                    query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
13056                            }
13057                            else {
13058                                    bindDisplayDate = true;
13059    
13060                                    query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
13061                            }
13062    
13063                            query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
13064    
13065                            String sql = query.toString();
13066    
13067                            Session session = null;
13068    
13069                            try {
13070                                    session = openSession();
13071    
13072                                    Query q = session.createQuery(sql);
13073    
13074                                    QueryPos qPos = QueryPos.getInstance(q);
13075    
13076                                    qPos.add(groupId);
13077    
13078                                    if (bindDisplayDate) {
13079                                            qPos.add(new Timestamp(displayDate.getTime()));
13080                                    }
13081    
13082                                    qPos.add(status);
13083    
13084                                    count = (Long)q.uniqueResult();
13085    
13086                                    finderCache.putResult(finderPath, finderArgs, count);
13087                            }
13088                            catch (Exception e) {
13089                                    finderCache.removeResult(finderPath, finderArgs);
13090    
13091                                    throw processException(e);
13092                            }
13093                            finally {
13094                                    closeSession(session);
13095                            }
13096                    }
13097    
13098                    return count.intValue();
13099            }
13100    
13101            /**
13102             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
13103             *
13104             * @param groupId the group ID
13105             * @param displayDate the display date
13106             * @param status the status
13107             * @return the number of matching blogs entries that the user has permission to view
13108             */
13109            @Override
13110            public int filterCountByG_LtD_S(long groupId, Date displayDate, int status) {
13111                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13112                            return countByG_LtD_S(groupId, displayDate, status);
13113                    }
13114    
13115                    StringBundler query = new StringBundler(4);
13116    
13117                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
13118    
13119                    query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
13120    
13121                    boolean bindDisplayDate = false;
13122    
13123                    if (displayDate == null) {
13124                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
13125                    }
13126                    else {
13127                            bindDisplayDate = true;
13128    
13129                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
13130                    }
13131    
13132                    query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
13133    
13134                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13135                                    BlogsEntry.class.getName(),
13136                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13137    
13138                    Session session = null;
13139    
13140                    try {
13141                            session = openSession();
13142    
13143                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
13144    
13145                            q.addScalar(COUNT_COLUMN_NAME,
13146                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
13147    
13148                            QueryPos qPos = QueryPos.getInstance(q);
13149    
13150                            qPos.add(groupId);
13151    
13152                            if (bindDisplayDate) {
13153                                    qPos.add(new Timestamp(displayDate.getTime()));
13154                            }
13155    
13156                            qPos.add(status);
13157    
13158                            Long count = (Long)q.uniqueResult();
13159    
13160                            return count.intValue();
13161                    }
13162                    catch (Exception e) {
13163                            throw processException(e);
13164                    }
13165                    finally {
13166                            closeSession(session);
13167                    }
13168            }
13169    
13170            private static final String _FINDER_COLUMN_G_LTD_S_GROUPID_2 = "blogsEntry.groupId = ? AND ";
13171            private static final String _FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1 = "blogsEntry.displayDate IS NULL AND ";
13172            private static final String _FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
13173            private static final String _FINDER_COLUMN_G_LTD_S_STATUS_2 = "blogsEntry.status = ?";
13174            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD_NOTS =
13175                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
13176                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
13177                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_LtD_NotS",
13178                            new String[] {
13179                                    Long.class.getName(), Date.class.getName(),
13180                                    Integer.class.getName(),
13181                                    
13182                            Integer.class.getName(), Integer.class.getName(),
13183                                    OrderByComparator.class.getName()
13184                            });
13185            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD_NOTS =
13186                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
13187                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
13188                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_LtD_NotS",
13189                            new String[] {
13190                                    Long.class.getName(), Date.class.getName(),
13191                                    Integer.class.getName()
13192                            });
13193    
13194            /**
13195             * Returns all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13196             *
13197             * @param groupId the group ID
13198             * @param displayDate the display date
13199             * @param status the status
13200             * @return the matching blogs entries
13201             */
13202            @Override
13203            public List<BlogsEntry> findByG_LtD_NotS(long groupId, Date displayDate,
13204                    int status) {
13205                    return findByG_LtD_NotS(groupId, displayDate, status,
13206                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
13207            }
13208    
13209            /**
13210             * Returns a range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13211             *
13212             * <p>
13213             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
13214             * </p>
13215             *
13216             * @param groupId the group ID
13217             * @param displayDate the display date
13218             * @param status the status
13219             * @param start the lower bound of the range of blogs entries
13220             * @param end the upper bound of the range of blogs entries (not inclusive)
13221             * @return the range of matching blogs entries
13222             */
13223            @Override
13224            public List<BlogsEntry> findByG_LtD_NotS(long groupId, Date displayDate,
13225                    int status, int start, int end) {
13226                    return findByG_LtD_NotS(groupId, displayDate, status, start, end, null);
13227            }
13228    
13229            /**
13230             * Returns an ordered range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13231             *
13232             * <p>
13233             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
13234             * </p>
13235             *
13236             * @param groupId the group ID
13237             * @param displayDate the display date
13238             * @param status the status
13239             * @param start the lower bound of the range of blogs entries
13240             * @param end the upper bound of the range of blogs entries (not inclusive)
13241             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13242             * @return the ordered range of matching blogs entries
13243             */
13244            @Override
13245            public List<BlogsEntry> findByG_LtD_NotS(long groupId, Date displayDate,
13246                    int status, int start, int end,
13247                    OrderByComparator<BlogsEntry> orderByComparator) {
13248                    return findByG_LtD_NotS(groupId, displayDate, status, start, end,
13249                            orderByComparator, true);
13250            }
13251    
13252            /**
13253             * Returns an ordered range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13254             *
13255             * <p>
13256             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
13257             * </p>
13258             *
13259             * @param groupId the group ID
13260             * @param displayDate the display date
13261             * @param status the status
13262             * @param start the lower bound of the range of blogs entries
13263             * @param end the upper bound of the range of blogs entries (not inclusive)
13264             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13265             * @param retrieveFromCache whether to retrieve from the finder cache
13266             * @return the ordered range of matching blogs entries
13267             */
13268            @Override
13269            public List<BlogsEntry> findByG_LtD_NotS(long groupId, Date displayDate,
13270                    int status, int start, int end,
13271                    OrderByComparator<BlogsEntry> orderByComparator,
13272                    boolean retrieveFromCache) {
13273                    boolean pagination = true;
13274                    FinderPath finderPath = null;
13275                    Object[] finderArgs = null;
13276    
13277                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD_NOTS;
13278                    finderArgs = new Object[] {
13279                                    groupId, displayDate, status,
13280                                    
13281                                    start, end, orderByComparator
13282                            };
13283    
13284                    List<BlogsEntry> list = null;
13285    
13286                    if (retrieveFromCache) {
13287                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
13288                                            finderArgs, this);
13289    
13290                            if ((list != null) && !list.isEmpty()) {
13291                                    for (BlogsEntry blogsEntry : list) {
13292                                            if ((groupId != blogsEntry.getGroupId()) ||
13293                                                            (displayDate.getTime() <= blogsEntry.getDisplayDate()
13294                                                                                                                                            .getTime()) ||
13295                                                            (status == blogsEntry.getStatus())) {
13296                                                    list = null;
13297    
13298                                                    break;
13299                                            }
13300                                    }
13301                            }
13302                    }
13303    
13304                    if (list == null) {
13305                            StringBundler query = null;
13306    
13307                            if (orderByComparator != null) {
13308                                    query = new StringBundler(5 +
13309                                                    (orderByComparator.getOrderByFields().length * 2));
13310                            }
13311                            else {
13312                                    query = new StringBundler(5);
13313                            }
13314    
13315                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
13316    
13317                            query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
13318    
13319                            boolean bindDisplayDate = false;
13320    
13321                            if (displayDate == null) {
13322                                    query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
13323                            }
13324                            else {
13325                                    bindDisplayDate = true;
13326    
13327                                    query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
13328                            }
13329    
13330                            query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
13331    
13332                            if (orderByComparator != null) {
13333                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13334                                            orderByComparator);
13335                            }
13336                            else
13337                             if (pagination) {
13338                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
13339                            }
13340    
13341                            String sql = query.toString();
13342    
13343                            Session session = null;
13344    
13345                            try {
13346                                    session = openSession();
13347    
13348                                    Query q = session.createQuery(sql);
13349    
13350                                    QueryPos qPos = QueryPos.getInstance(q);
13351    
13352                                    qPos.add(groupId);
13353    
13354                                    if (bindDisplayDate) {
13355                                            qPos.add(new Timestamp(displayDate.getTime()));
13356                                    }
13357    
13358                                    qPos.add(status);
13359    
13360                                    if (!pagination) {
13361                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
13362                                                            start, end, false);
13363    
13364                                            Collections.sort(list);
13365    
13366                                            list = Collections.unmodifiableList(list);
13367                                    }
13368                                    else {
13369                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
13370                                                            start, end);
13371                                    }
13372    
13373                                    cacheResult(list);
13374    
13375                                    finderCache.putResult(finderPath, finderArgs, list);
13376                            }
13377                            catch (Exception e) {
13378                                    finderCache.removeResult(finderPath, finderArgs);
13379    
13380                                    throw processException(e);
13381                            }
13382                            finally {
13383                                    closeSession(session);
13384                            }
13385                    }
13386    
13387                    return list;
13388            }
13389    
13390            /**
13391             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13392             *
13393             * @param groupId the group ID
13394             * @param displayDate the display date
13395             * @param status the status
13396             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13397             * @return the first matching blogs entry
13398             * @throws NoSuchEntryException if a matching blogs entry could not be found
13399             */
13400            @Override
13401            public BlogsEntry findByG_LtD_NotS_First(long groupId, Date displayDate,
13402                    int status, OrderByComparator<BlogsEntry> orderByComparator)
13403                    throws NoSuchEntryException {
13404                    BlogsEntry blogsEntry = fetchByG_LtD_NotS_First(groupId, displayDate,
13405                                    status, orderByComparator);
13406    
13407                    if (blogsEntry != null) {
13408                            return blogsEntry;
13409                    }
13410    
13411                    StringBundler msg = new StringBundler(8);
13412    
13413                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13414    
13415                    msg.append("groupId=");
13416                    msg.append(groupId);
13417    
13418                    msg.append(", displayDate=");
13419                    msg.append(displayDate);
13420    
13421                    msg.append(", status=");
13422                    msg.append(status);
13423    
13424                    msg.append(StringPool.CLOSE_CURLY_BRACE);
13425    
13426                    throw new NoSuchEntryException(msg.toString());
13427            }
13428    
13429            /**
13430             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13431             *
13432             * @param groupId the group ID
13433             * @param displayDate the display date
13434             * @param status the status
13435             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13436             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
13437             */
13438            @Override
13439            public BlogsEntry fetchByG_LtD_NotS_First(long groupId, Date displayDate,
13440                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
13441                    List<BlogsEntry> list = findByG_LtD_NotS(groupId, displayDate, status,
13442                                    0, 1, orderByComparator);
13443    
13444                    if (!list.isEmpty()) {
13445                            return list.get(0);
13446                    }
13447    
13448                    return null;
13449            }
13450    
13451            /**
13452             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13453             *
13454             * @param groupId the group ID
13455             * @param displayDate the display date
13456             * @param status the status
13457             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13458             * @return the last matching blogs entry
13459             * @throws NoSuchEntryException if a matching blogs entry could not be found
13460             */
13461            @Override
13462            public BlogsEntry findByG_LtD_NotS_Last(long groupId, Date displayDate,
13463                    int status, OrderByComparator<BlogsEntry> orderByComparator)
13464                    throws NoSuchEntryException {
13465                    BlogsEntry blogsEntry = fetchByG_LtD_NotS_Last(groupId, displayDate,
13466                                    status, orderByComparator);
13467    
13468                    if (blogsEntry != null) {
13469                            return blogsEntry;
13470                    }
13471    
13472                    StringBundler msg = new StringBundler(8);
13473    
13474                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13475    
13476                    msg.append("groupId=");
13477                    msg.append(groupId);
13478    
13479                    msg.append(", displayDate=");
13480                    msg.append(displayDate);
13481    
13482                    msg.append(", status=");
13483                    msg.append(status);
13484    
13485                    msg.append(StringPool.CLOSE_CURLY_BRACE);
13486    
13487                    throw new NoSuchEntryException(msg.toString());
13488            }
13489    
13490            /**
13491             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13492             *
13493             * @param groupId the group ID
13494             * @param displayDate the display date
13495             * @param status the status
13496             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13497             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
13498             */
13499            @Override
13500            public BlogsEntry fetchByG_LtD_NotS_Last(long groupId, Date displayDate,
13501                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
13502                    int count = countByG_LtD_NotS(groupId, displayDate, status);
13503    
13504                    if (count == 0) {
13505                            return null;
13506                    }
13507    
13508                    List<BlogsEntry> list = findByG_LtD_NotS(groupId, displayDate, status,
13509                                    count - 1, count, orderByComparator);
13510    
13511                    if (!list.isEmpty()) {
13512                            return list.get(0);
13513                    }
13514    
13515                    return null;
13516            }
13517    
13518            /**
13519             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13520             *
13521             * @param entryId the primary key of the current blogs entry
13522             * @param groupId the group ID
13523             * @param displayDate the display date
13524             * @param status the status
13525             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13526             * @return the previous, current, and next blogs entry
13527             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
13528             */
13529            @Override
13530            public BlogsEntry[] findByG_LtD_NotS_PrevAndNext(long entryId,
13531                    long groupId, Date displayDate, int status,
13532                    OrderByComparator<BlogsEntry> orderByComparator)
13533                    throws NoSuchEntryException {
13534                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
13535    
13536                    Session session = null;
13537    
13538                    try {
13539                            session = openSession();
13540    
13541                            BlogsEntry[] array = new BlogsEntryImpl[3];
13542    
13543                            array[0] = getByG_LtD_NotS_PrevAndNext(session, blogsEntry,
13544                                            groupId, displayDate, status, orderByComparator, true);
13545    
13546                            array[1] = blogsEntry;
13547    
13548                            array[2] = getByG_LtD_NotS_PrevAndNext(session, blogsEntry,
13549                                            groupId, displayDate, status, orderByComparator, false);
13550    
13551                            return array;
13552                    }
13553                    catch (Exception e) {
13554                            throw processException(e);
13555                    }
13556                    finally {
13557                            closeSession(session);
13558                    }
13559            }
13560    
13561            protected BlogsEntry getByG_LtD_NotS_PrevAndNext(Session session,
13562                    BlogsEntry blogsEntry, long groupId, Date displayDate, int status,
13563                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
13564                    StringBundler query = null;
13565    
13566                    if (orderByComparator != null) {
13567                            query = new StringBundler(6 +
13568                                            (orderByComparator.getOrderByConditionFields().length * 3) +
13569                                            (orderByComparator.getOrderByFields().length * 3));
13570                    }
13571                    else {
13572                            query = new StringBundler(5);
13573                    }
13574    
13575                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
13576    
13577                    query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
13578    
13579                    boolean bindDisplayDate = false;
13580    
13581                    if (displayDate == null) {
13582                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
13583                    }
13584                    else {
13585                            bindDisplayDate = true;
13586    
13587                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
13588                    }
13589    
13590                    query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
13591    
13592                    if (orderByComparator != null) {
13593                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
13594    
13595                            if (orderByConditionFields.length > 0) {
13596                                    query.append(WHERE_AND);
13597                            }
13598    
13599                            for (int i = 0; i < orderByConditionFields.length; i++) {
13600                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13601                                    query.append(orderByConditionFields[i]);
13602    
13603                                    if ((i + 1) < orderByConditionFields.length) {
13604                                            if (orderByComparator.isAscending() ^ previous) {
13605                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
13606                                            }
13607                                            else {
13608                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
13609                                            }
13610                                    }
13611                                    else {
13612                                            if (orderByComparator.isAscending() ^ previous) {
13613                                                    query.append(WHERE_GREATER_THAN);
13614                                            }
13615                                            else {
13616                                                    query.append(WHERE_LESSER_THAN);
13617                                            }
13618                                    }
13619                            }
13620    
13621                            query.append(ORDER_BY_CLAUSE);
13622    
13623                            String[] orderByFields = orderByComparator.getOrderByFields();
13624    
13625                            for (int i = 0; i < orderByFields.length; i++) {
13626                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13627                                    query.append(orderByFields[i]);
13628    
13629                                    if ((i + 1) < orderByFields.length) {
13630                                            if (orderByComparator.isAscending() ^ previous) {
13631                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
13632                                            }
13633                                            else {
13634                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
13635                                            }
13636                                    }
13637                                    else {
13638                                            if (orderByComparator.isAscending() ^ previous) {
13639                                                    query.append(ORDER_BY_ASC);
13640                                            }
13641                                            else {
13642                                                    query.append(ORDER_BY_DESC);
13643                                            }
13644                                    }
13645                            }
13646                    }
13647                    else {
13648                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
13649                    }
13650    
13651                    String sql = query.toString();
13652    
13653                    Query q = session.createQuery(sql);
13654    
13655                    q.setFirstResult(0);
13656                    q.setMaxResults(2);
13657    
13658                    QueryPos qPos = QueryPos.getInstance(q);
13659    
13660                    qPos.add(groupId);
13661    
13662                    if (bindDisplayDate) {
13663                            qPos.add(new Timestamp(displayDate.getTime()));
13664                    }
13665    
13666                    qPos.add(status);
13667    
13668                    if (orderByComparator != null) {
13669                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
13670    
13671                            for (Object value : values) {
13672                                    qPos.add(value);
13673                            }
13674                    }
13675    
13676                    List<BlogsEntry> list = q.list();
13677    
13678                    if (list.size() == 2) {
13679                            return list.get(1);
13680                    }
13681                    else {
13682                            return null;
13683                    }
13684            }
13685    
13686            /**
13687             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13688             *
13689             * @param groupId the group ID
13690             * @param displayDate the display date
13691             * @param status the status
13692             * @return the matching blogs entries that the user has permission to view
13693             */
13694            @Override
13695            public List<BlogsEntry> filterFindByG_LtD_NotS(long groupId,
13696                    Date displayDate, int status) {
13697                    return filterFindByG_LtD_NotS(groupId, displayDate, status,
13698                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
13699            }
13700    
13701            /**
13702             * 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;.
13703             *
13704             * <p>
13705             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
13706             * </p>
13707             *
13708             * @param groupId the group ID
13709             * @param displayDate the display date
13710             * @param status the status
13711             * @param start the lower bound of the range of blogs entries
13712             * @param end the upper bound of the range of blogs entries (not inclusive)
13713             * @return the range of matching blogs entries that the user has permission to view
13714             */
13715            @Override
13716            public List<BlogsEntry> filterFindByG_LtD_NotS(long groupId,
13717                    Date displayDate, int status, int start, int end) {
13718                    return filterFindByG_LtD_NotS(groupId, displayDate, status, start, end,
13719                            null);
13720            }
13721    
13722            /**
13723             * 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;.
13724             *
13725             * <p>
13726             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
13727             * </p>
13728             *
13729             * @param groupId the group ID
13730             * @param displayDate the display date
13731             * @param status the status
13732             * @param start the lower bound of the range of blogs entries
13733             * @param end the upper bound of the range of blogs entries (not inclusive)
13734             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13735             * @return the ordered range of matching blogs entries that the user has permission to view
13736             */
13737            @Override
13738            public List<BlogsEntry> filterFindByG_LtD_NotS(long groupId,
13739                    Date displayDate, int status, int start, int end,
13740                    OrderByComparator<BlogsEntry> orderByComparator) {
13741                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13742                            return findByG_LtD_NotS(groupId, displayDate, status, start, end,
13743                                    orderByComparator);
13744                    }
13745    
13746                    StringBundler query = null;
13747    
13748                    if (orderByComparator != null) {
13749                            query = new StringBundler(5 +
13750                                            (orderByComparator.getOrderByFields().length * 2));
13751                    }
13752                    else {
13753                            query = new StringBundler(6);
13754                    }
13755    
13756                    if (getDB().isSupportsInlineDistinct()) {
13757                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
13758                    }
13759                    else {
13760                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
13761                    }
13762    
13763                    query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
13764    
13765                    boolean bindDisplayDate = false;
13766    
13767                    if (displayDate == null) {
13768                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
13769                    }
13770                    else {
13771                            bindDisplayDate = true;
13772    
13773                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
13774                    }
13775    
13776                    query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
13777    
13778                    if (!getDB().isSupportsInlineDistinct()) {
13779                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
13780                    }
13781    
13782                    if (orderByComparator != null) {
13783                            if (getDB().isSupportsInlineDistinct()) {
13784                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13785                                            orderByComparator, true);
13786                            }
13787                            else {
13788                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
13789                                            orderByComparator, true);
13790                            }
13791                    }
13792                    else {
13793                            if (getDB().isSupportsInlineDistinct()) {
13794                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
13795                            }
13796                            else {
13797                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
13798                            }
13799                    }
13800    
13801                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13802                                    BlogsEntry.class.getName(),
13803                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13804    
13805                    Session session = null;
13806    
13807                    try {
13808                            session = openSession();
13809    
13810                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
13811    
13812                            if (getDB().isSupportsInlineDistinct()) {
13813                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
13814                            }
13815                            else {
13816                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
13817                            }
13818    
13819                            QueryPos qPos = QueryPos.getInstance(q);
13820    
13821                            qPos.add(groupId);
13822    
13823                            if (bindDisplayDate) {
13824                                    qPos.add(new Timestamp(displayDate.getTime()));
13825                            }
13826    
13827                            qPos.add(status);
13828    
13829                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
13830                    }
13831                    catch (Exception e) {
13832                            throw processException(e);
13833                    }
13834                    finally {
13835                            closeSession(session);
13836                    }
13837            }
13838    
13839            /**
13840             * 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;.
13841             *
13842             * @param entryId the primary key of the current blogs entry
13843             * @param groupId the group ID
13844             * @param displayDate the display date
13845             * @param status the status
13846             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13847             * @return the previous, current, and next blogs entry
13848             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
13849             */
13850            @Override
13851            public BlogsEntry[] filterFindByG_LtD_NotS_PrevAndNext(long entryId,
13852                    long groupId, Date displayDate, int status,
13853                    OrderByComparator<BlogsEntry> orderByComparator)
13854                    throws NoSuchEntryException {
13855                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13856                            return findByG_LtD_NotS_PrevAndNext(entryId, groupId, displayDate,
13857                                    status, orderByComparator);
13858                    }
13859    
13860                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
13861    
13862                    Session session = null;
13863    
13864                    try {
13865                            session = openSession();
13866    
13867                            BlogsEntry[] array = new BlogsEntryImpl[3];
13868    
13869                            array[0] = filterGetByG_LtD_NotS_PrevAndNext(session, blogsEntry,
13870                                            groupId, displayDate, status, orderByComparator, true);
13871    
13872                            array[1] = blogsEntry;
13873    
13874                            array[2] = filterGetByG_LtD_NotS_PrevAndNext(session, blogsEntry,
13875                                            groupId, displayDate, status, orderByComparator, false);
13876    
13877                            return array;
13878                    }
13879                    catch (Exception e) {
13880                            throw processException(e);
13881                    }
13882                    finally {
13883                            closeSession(session);
13884                    }
13885            }
13886    
13887            protected BlogsEntry filterGetByG_LtD_NotS_PrevAndNext(Session session,
13888                    BlogsEntry blogsEntry, long groupId, Date displayDate, int status,
13889                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
13890                    StringBundler query = null;
13891    
13892                    if (orderByComparator != null) {
13893                            query = new StringBundler(7 +
13894                                            (orderByComparator.getOrderByConditionFields().length * 3) +
13895                                            (orderByComparator.getOrderByFields().length * 3));
13896                    }
13897                    else {
13898                            query = new StringBundler(6);
13899                    }
13900    
13901                    if (getDB().isSupportsInlineDistinct()) {
13902                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
13903                    }
13904                    else {
13905                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
13906                    }
13907    
13908                    query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
13909    
13910                    boolean bindDisplayDate = false;
13911    
13912                    if (displayDate == null) {
13913                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
13914                    }
13915                    else {
13916                            bindDisplayDate = true;
13917    
13918                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
13919                    }
13920    
13921                    query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
13922    
13923                    if (!getDB().isSupportsInlineDistinct()) {
13924                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
13925                    }
13926    
13927                    if (orderByComparator != null) {
13928                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
13929    
13930                            if (orderByConditionFields.length > 0) {
13931                                    query.append(WHERE_AND);
13932                            }
13933    
13934                            for (int i = 0; i < orderByConditionFields.length; i++) {
13935                                    if (getDB().isSupportsInlineDistinct()) {
13936                                            query.append(_ORDER_BY_ENTITY_ALIAS);
13937                                    }
13938                                    else {
13939                                            query.append(_ORDER_BY_ENTITY_TABLE);
13940                                    }
13941    
13942                                    query.append(orderByConditionFields[i]);
13943    
13944                                    if ((i + 1) < orderByConditionFields.length) {
13945                                            if (orderByComparator.isAscending() ^ previous) {
13946                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
13947                                            }
13948                                            else {
13949                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
13950                                            }
13951                                    }
13952                                    else {
13953                                            if (orderByComparator.isAscending() ^ previous) {
13954                                                    query.append(WHERE_GREATER_THAN);
13955                                            }
13956                                            else {
13957                                                    query.append(WHERE_LESSER_THAN);
13958                                            }
13959                                    }
13960                            }
13961    
13962                            query.append(ORDER_BY_CLAUSE);
13963    
13964                            String[] orderByFields = orderByComparator.getOrderByFields();
13965    
13966                            for (int i = 0; i < orderByFields.length; i++) {
13967                                    if (getDB().isSupportsInlineDistinct()) {
13968                                            query.append(_ORDER_BY_ENTITY_ALIAS);
13969                                    }
13970                                    else {
13971                                            query.append(_ORDER_BY_ENTITY_TABLE);
13972                                    }
13973    
13974                                    query.append(orderByFields[i]);
13975    
13976                                    if ((i + 1) < orderByFields.length) {
13977                                            if (orderByComparator.isAscending() ^ previous) {
13978                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
13979                                            }
13980                                            else {
13981                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
13982                                            }
13983                                    }
13984                                    else {
13985                                            if (orderByComparator.isAscending() ^ previous) {
13986                                                    query.append(ORDER_BY_ASC);
13987                                            }
13988                                            else {
13989                                                    query.append(ORDER_BY_DESC);
13990                                            }
13991                                    }
13992                            }
13993                    }
13994                    else {
13995                            if (getDB().isSupportsInlineDistinct()) {
13996                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
13997                            }
13998                            else {
13999                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
14000                            }
14001                    }
14002    
14003                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
14004                                    BlogsEntry.class.getName(),
14005                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
14006    
14007                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
14008    
14009                    q.setFirstResult(0);
14010                    q.setMaxResults(2);
14011    
14012                    if (getDB().isSupportsInlineDistinct()) {
14013                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
14014                    }
14015                    else {
14016                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
14017                    }
14018    
14019                    QueryPos qPos = QueryPos.getInstance(q);
14020    
14021                    qPos.add(groupId);
14022    
14023                    if (bindDisplayDate) {
14024                            qPos.add(new Timestamp(displayDate.getTime()));
14025                    }
14026    
14027                    qPos.add(status);
14028    
14029                    if (orderByComparator != null) {
14030                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
14031    
14032                            for (Object value : values) {
14033                                    qPos.add(value);
14034                            }
14035                    }
14036    
14037                    List<BlogsEntry> list = q.list();
14038    
14039                    if (list.size() == 2) {
14040                            return list.get(1);
14041                    }
14042                    else {
14043                            return null;
14044                    }
14045            }
14046    
14047            /**
14048             * Removes all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63; from the database.
14049             *
14050             * @param groupId the group ID
14051             * @param displayDate the display date
14052             * @param status the status
14053             */
14054            @Override
14055            public void removeByG_LtD_NotS(long groupId, Date displayDate, int status) {
14056                    for (BlogsEntry blogsEntry : findByG_LtD_NotS(groupId, displayDate,
14057                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
14058                            remove(blogsEntry);
14059                    }
14060            }
14061    
14062            /**
14063             * Returns the number of blogs entries where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
14064             *
14065             * @param groupId the group ID
14066             * @param displayDate the display date
14067             * @param status the status
14068             * @return the number of matching blogs entries
14069             */
14070            @Override
14071            public int countByG_LtD_NotS(long groupId, Date displayDate, int status) {
14072                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD_NOTS;
14073    
14074                    Object[] finderArgs = new Object[] { groupId, displayDate, status };
14075    
14076                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
14077    
14078                    if (count == null) {
14079                            StringBundler query = new StringBundler(4);
14080    
14081                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
14082    
14083                            query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
14084    
14085                            boolean bindDisplayDate = false;
14086    
14087                            if (displayDate == null) {
14088                                    query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
14089                            }
14090                            else {
14091                                    bindDisplayDate = true;
14092    
14093                                    query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
14094                            }
14095    
14096                            query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
14097    
14098                            String sql = query.toString();
14099    
14100                            Session session = null;
14101    
14102                            try {
14103                                    session = openSession();
14104    
14105                                    Query q = session.createQuery(sql);
14106    
14107                                    QueryPos qPos = QueryPos.getInstance(q);
14108    
14109                                    qPos.add(groupId);
14110    
14111                                    if (bindDisplayDate) {
14112                                            qPos.add(new Timestamp(displayDate.getTime()));
14113                                    }
14114    
14115                                    qPos.add(status);
14116    
14117                                    count = (Long)q.uniqueResult();
14118    
14119                                    finderCache.putResult(finderPath, finderArgs, count);
14120                            }
14121                            catch (Exception e) {
14122                                    finderCache.removeResult(finderPath, finderArgs);
14123    
14124                                    throw processException(e);
14125                            }
14126                            finally {
14127                                    closeSession(session);
14128                            }
14129                    }
14130    
14131                    return count.intValue();
14132            }
14133    
14134            /**
14135             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
14136             *
14137             * @param groupId the group ID
14138             * @param displayDate the display date
14139             * @param status the status
14140             * @return the number of matching blogs entries that the user has permission to view
14141             */
14142            @Override
14143            public int filterCountByG_LtD_NotS(long groupId, Date displayDate,
14144                    int status) {
14145                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
14146                            return countByG_LtD_NotS(groupId, displayDate, status);
14147                    }
14148    
14149                    StringBundler query = new StringBundler(4);
14150    
14151                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
14152    
14153                    query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
14154    
14155                    boolean bindDisplayDate = false;
14156    
14157                    if (displayDate == null) {
14158                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
14159                    }
14160                    else {
14161                            bindDisplayDate = true;
14162    
14163                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
14164                    }
14165    
14166                    query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
14167    
14168                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
14169                                    BlogsEntry.class.getName(),
14170                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
14171    
14172                    Session session = null;
14173    
14174                    try {
14175                            session = openSession();
14176    
14177                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
14178    
14179                            q.addScalar(COUNT_COLUMN_NAME,
14180                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
14181    
14182                            QueryPos qPos = QueryPos.getInstance(q);
14183    
14184                            qPos.add(groupId);
14185    
14186                            if (bindDisplayDate) {
14187                                    qPos.add(new Timestamp(displayDate.getTime()));
14188                            }
14189    
14190                            qPos.add(status);
14191    
14192                            Long count = (Long)q.uniqueResult();
14193    
14194                            return count.intValue();
14195                    }
14196                    catch (Exception e) {
14197                            throw processException(e);
14198                    }
14199                    finally {
14200                            closeSession(session);
14201                    }
14202            }
14203    
14204            private static final String _FINDER_COLUMN_G_LTD_NOTS_GROUPID_2 = "blogsEntry.groupId = ? AND ";
14205            private static final String _FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1 = "blogsEntry.displayDate IS NULL AND ";
14206            private static final String _FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
14207            private static final String _FINDER_COLUMN_G_LTD_NOTS_STATUS_2 = "blogsEntry.status != ?";
14208            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
14209                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
14210                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_U_S",
14211                            new String[] {
14212                                    Long.class.getName(), Long.class.getName(),
14213                                    Integer.class.getName(),
14214                                    
14215                            Integer.class.getName(), Integer.class.getName(),
14216                                    OrderByComparator.class.getName()
14217                            });
14218            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
14219                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
14220                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_U_S",
14221                            new String[] {
14222                                    Long.class.getName(), Long.class.getName(),
14223                                    Integer.class.getName()
14224                            },
14225                            BlogsEntryModelImpl.COMPANYID_COLUMN_BITMASK |
14226                            BlogsEntryModelImpl.USERID_COLUMN_BITMASK |
14227                            BlogsEntryModelImpl.STATUS_COLUMN_BITMASK |
14228                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
14229                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
14230            public static final FinderPath FINDER_PATH_COUNT_BY_C_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
14231                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
14232                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_U_S",
14233                            new String[] {
14234                                    Long.class.getName(), Long.class.getName(),
14235                                    Integer.class.getName()
14236                            });
14237    
14238            /**
14239             * Returns all the blogs entries where companyId = &#63; and userId = &#63; and status = &#63;.
14240             *
14241             * @param companyId the company ID
14242             * @param userId the user ID
14243             * @param status the status
14244             * @return the matching blogs entries
14245             */
14246            @Override
14247            public List<BlogsEntry> findByC_U_S(long companyId, long userId, int status) {
14248                    return findByC_U_S(companyId, userId, status, QueryUtil.ALL_POS,
14249                            QueryUtil.ALL_POS, null);
14250            }
14251    
14252            /**
14253             * Returns a range of all the blogs entries where companyId = &#63; and userId = &#63; and status = &#63;.
14254             *
14255             * <p>
14256             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
14257             * </p>
14258             *
14259             * @param companyId the company ID
14260             * @param userId the user ID
14261             * @param status the status
14262             * @param start the lower bound of the range of blogs entries
14263             * @param end the upper bound of the range of blogs entries (not inclusive)
14264             * @return the range of matching blogs entries
14265             */
14266            @Override
14267            public List<BlogsEntry> findByC_U_S(long companyId, long userId,
14268                    int status, int start, int end) {
14269                    return findByC_U_S(companyId, userId, status, start, end, null);
14270            }
14271    
14272            /**
14273             * Returns an ordered range of all the blogs entries where companyId = &#63; and userId = &#63; and status = &#63;.
14274             *
14275             * <p>
14276             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
14277             * </p>
14278             *
14279             * @param companyId the company ID
14280             * @param userId the user ID
14281             * @param status the status
14282             * @param start the lower bound of the range of blogs entries
14283             * @param end the upper bound of the range of blogs entries (not inclusive)
14284             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14285             * @return the ordered range of matching blogs entries
14286             */
14287            @Override
14288            public List<BlogsEntry> findByC_U_S(long companyId, long userId,
14289                    int status, int start, int end,
14290                    OrderByComparator<BlogsEntry> orderByComparator) {
14291                    return findByC_U_S(companyId, userId, status, start, end,
14292                            orderByComparator, true);
14293            }
14294    
14295            /**
14296             * Returns an ordered range of all the blogs entries where companyId = &#63; and userId = &#63; and status = &#63;.
14297             *
14298             * <p>
14299             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
14300             * </p>
14301             *
14302             * @param companyId the company ID
14303             * @param userId the user ID
14304             * @param status the status
14305             * @param start the lower bound of the range of blogs entries
14306             * @param end the upper bound of the range of blogs entries (not inclusive)
14307             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14308             * @param retrieveFromCache whether to retrieve from the finder cache
14309             * @return the ordered range of matching blogs entries
14310             */
14311            @Override
14312            public List<BlogsEntry> findByC_U_S(long companyId, long userId,
14313                    int status, int start, int end,
14314                    OrderByComparator<BlogsEntry> orderByComparator,
14315                    boolean retrieveFromCache) {
14316                    boolean pagination = true;
14317                    FinderPath finderPath = null;
14318                    Object[] finderArgs = null;
14319    
14320                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
14321                                    (orderByComparator == null)) {
14322                            pagination = false;
14323                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U_S;
14324                            finderArgs = new Object[] { companyId, userId, status };
14325                    }
14326                    else {
14327                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U_S;
14328                            finderArgs = new Object[] {
14329                                            companyId, userId, status,
14330                                            
14331                                            start, end, orderByComparator
14332                                    };
14333                    }
14334    
14335                    List<BlogsEntry> list = null;
14336    
14337                    if (retrieveFromCache) {
14338                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
14339                                            finderArgs, this);
14340    
14341                            if ((list != null) && !list.isEmpty()) {
14342                                    for (BlogsEntry blogsEntry : list) {
14343                                            if ((companyId != blogsEntry.getCompanyId()) ||
14344                                                            (userId != blogsEntry.getUserId()) ||
14345                                                            (status != blogsEntry.getStatus())) {
14346                                                    list = null;
14347    
14348                                                    break;
14349                                            }
14350                                    }
14351                            }
14352                    }
14353    
14354                    if (list == null) {
14355                            StringBundler query = null;
14356    
14357                            if (orderByComparator != null) {
14358                                    query = new StringBundler(5 +
14359                                                    (orderByComparator.getOrderByFields().length * 2));
14360                            }
14361                            else {
14362                                    query = new StringBundler(5);
14363                            }
14364    
14365                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
14366    
14367                            query.append(_FINDER_COLUMN_C_U_S_COMPANYID_2);
14368    
14369                            query.append(_FINDER_COLUMN_C_U_S_USERID_2);
14370    
14371                            query.append(_FINDER_COLUMN_C_U_S_STATUS_2);
14372    
14373                            if (orderByComparator != null) {
14374                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
14375                                            orderByComparator);
14376                            }
14377                            else
14378                             if (pagination) {
14379                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
14380                            }
14381    
14382                            String sql = query.toString();
14383    
14384                            Session session = null;
14385    
14386                            try {
14387                                    session = openSession();
14388    
14389                                    Query q = session.createQuery(sql);
14390    
14391                                    QueryPos qPos = QueryPos.getInstance(q);
14392    
14393                                    qPos.add(companyId);
14394    
14395                                    qPos.add(userId);
14396    
14397                                    qPos.add(status);
14398    
14399                                    if (!pagination) {
14400                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
14401                                                            start, end, false);
14402    
14403                                            Collections.sort(list);
14404    
14405                                            list = Collections.unmodifiableList(list);
14406                                    }
14407                                    else {
14408                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
14409                                                            start, end);
14410                                    }
14411    
14412                                    cacheResult(list);
14413    
14414                                    finderCache.putResult(finderPath, finderArgs, list);
14415                            }
14416                            catch (Exception e) {
14417                                    finderCache.removeResult(finderPath, finderArgs);
14418    
14419                                    throw processException(e);
14420                            }
14421                            finally {
14422                                    closeSession(session);
14423                            }
14424                    }
14425    
14426                    return list;
14427            }
14428    
14429            /**
14430             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status = &#63;.
14431             *
14432             * @param companyId the company ID
14433             * @param userId the user ID
14434             * @param status the status
14435             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14436             * @return the first matching blogs entry
14437             * @throws NoSuchEntryException if a matching blogs entry could not be found
14438             */
14439            @Override
14440            public BlogsEntry findByC_U_S_First(long companyId, long userId,
14441                    int status, OrderByComparator<BlogsEntry> orderByComparator)
14442                    throws NoSuchEntryException {
14443                    BlogsEntry blogsEntry = fetchByC_U_S_First(companyId, userId, status,
14444                                    orderByComparator);
14445    
14446                    if (blogsEntry != null) {
14447                            return blogsEntry;
14448                    }
14449    
14450                    StringBundler msg = new StringBundler(8);
14451    
14452                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
14453    
14454                    msg.append("companyId=");
14455                    msg.append(companyId);
14456    
14457                    msg.append(", userId=");
14458                    msg.append(userId);
14459    
14460                    msg.append(", status=");
14461                    msg.append(status);
14462    
14463                    msg.append(StringPool.CLOSE_CURLY_BRACE);
14464    
14465                    throw new NoSuchEntryException(msg.toString());
14466            }
14467    
14468            /**
14469             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status = &#63;.
14470             *
14471             * @param companyId the company ID
14472             * @param userId the user ID
14473             * @param status the status
14474             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14475             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
14476             */
14477            @Override
14478            public BlogsEntry fetchByC_U_S_First(long companyId, long userId,
14479                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
14480                    List<BlogsEntry> list = findByC_U_S(companyId, userId, status, 0, 1,
14481                                    orderByComparator);
14482    
14483                    if (!list.isEmpty()) {
14484                            return list.get(0);
14485                    }
14486    
14487                    return null;
14488            }
14489    
14490            /**
14491             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status = &#63;.
14492             *
14493             * @param companyId the company ID
14494             * @param userId the user ID
14495             * @param status the status
14496             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14497             * @return the last matching blogs entry
14498             * @throws NoSuchEntryException if a matching blogs entry could not be found
14499             */
14500            @Override
14501            public BlogsEntry findByC_U_S_Last(long companyId, long userId, int status,
14502                    OrderByComparator<BlogsEntry> orderByComparator)
14503                    throws NoSuchEntryException {
14504                    BlogsEntry blogsEntry = fetchByC_U_S_Last(companyId, userId, status,
14505                                    orderByComparator);
14506    
14507                    if (blogsEntry != null) {
14508                            return blogsEntry;
14509                    }
14510    
14511                    StringBundler msg = new StringBundler(8);
14512    
14513                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
14514    
14515                    msg.append("companyId=");
14516                    msg.append(companyId);
14517    
14518                    msg.append(", userId=");
14519                    msg.append(userId);
14520    
14521                    msg.append(", status=");
14522                    msg.append(status);
14523    
14524                    msg.append(StringPool.CLOSE_CURLY_BRACE);
14525    
14526                    throw new NoSuchEntryException(msg.toString());
14527            }
14528    
14529            /**
14530             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status = &#63;.
14531             *
14532             * @param companyId the company ID
14533             * @param userId the user ID
14534             * @param status the status
14535             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14536             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
14537             */
14538            @Override
14539            public BlogsEntry fetchByC_U_S_Last(long companyId, long userId,
14540                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
14541                    int count = countByC_U_S(companyId, userId, status);
14542    
14543                    if (count == 0) {
14544                            return null;
14545                    }
14546    
14547                    List<BlogsEntry> list = findByC_U_S(companyId, userId, status,
14548                                    count - 1, count, orderByComparator);
14549    
14550                    if (!list.isEmpty()) {
14551                            return list.get(0);
14552                    }
14553    
14554                    return null;
14555            }
14556    
14557            /**
14558             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status = &#63;.
14559             *
14560             * @param entryId the primary key of the current blogs entry
14561             * @param companyId the company ID
14562             * @param userId the user ID
14563             * @param status the status
14564             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14565             * @return the previous, current, and next blogs entry
14566             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
14567             */
14568            @Override
14569            public BlogsEntry[] findByC_U_S_PrevAndNext(long entryId, long companyId,
14570                    long userId, int status, OrderByComparator<BlogsEntry> orderByComparator)
14571                    throws NoSuchEntryException {
14572                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
14573    
14574                    Session session = null;
14575    
14576                    try {
14577                            session = openSession();
14578    
14579                            BlogsEntry[] array = new BlogsEntryImpl[3];
14580    
14581                            array[0] = getByC_U_S_PrevAndNext(session, blogsEntry, companyId,
14582                                            userId, status, orderByComparator, true);
14583    
14584                            array[1] = blogsEntry;
14585    
14586                            array[2] = getByC_U_S_PrevAndNext(session, blogsEntry, companyId,
14587                                            userId, status, orderByComparator, false);
14588    
14589                            return array;
14590                    }
14591                    catch (Exception e) {
14592                            throw processException(e);
14593                    }
14594                    finally {
14595                            closeSession(session);
14596                    }
14597            }
14598    
14599            protected BlogsEntry getByC_U_S_PrevAndNext(Session session,
14600                    BlogsEntry blogsEntry, long companyId, long userId, int status,
14601                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
14602                    StringBundler query = null;
14603    
14604                    if (orderByComparator != null) {
14605                            query = new StringBundler(6 +
14606                                            (orderByComparator.getOrderByConditionFields().length * 3) +
14607                                            (orderByComparator.getOrderByFields().length * 3));
14608                    }
14609                    else {
14610                            query = new StringBundler(5);
14611                    }
14612    
14613                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
14614    
14615                    query.append(_FINDER_COLUMN_C_U_S_COMPANYID_2);
14616    
14617                    query.append(_FINDER_COLUMN_C_U_S_USERID_2);
14618    
14619                    query.append(_FINDER_COLUMN_C_U_S_STATUS_2);
14620    
14621                    if (orderByComparator != null) {
14622                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
14623    
14624                            if (orderByConditionFields.length > 0) {
14625                                    query.append(WHERE_AND);
14626                            }
14627    
14628                            for (int i = 0; i < orderByConditionFields.length; i++) {
14629                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14630                                    query.append(orderByConditionFields[i]);
14631    
14632                                    if ((i + 1) < orderByConditionFields.length) {
14633                                            if (orderByComparator.isAscending() ^ previous) {
14634                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
14635                                            }
14636                                            else {
14637                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
14638                                            }
14639                                    }
14640                                    else {
14641                                            if (orderByComparator.isAscending() ^ previous) {
14642                                                    query.append(WHERE_GREATER_THAN);
14643                                            }
14644                                            else {
14645                                                    query.append(WHERE_LESSER_THAN);
14646                                            }
14647                                    }
14648                            }
14649    
14650                            query.append(ORDER_BY_CLAUSE);
14651    
14652                            String[] orderByFields = orderByComparator.getOrderByFields();
14653    
14654                            for (int i = 0; i < orderByFields.length; i++) {
14655                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14656                                    query.append(orderByFields[i]);
14657    
14658                                    if ((i + 1) < orderByFields.length) {
14659                                            if (orderByComparator.isAscending() ^ previous) {
14660                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
14661                                            }
14662                                            else {
14663                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
14664                                            }
14665                                    }
14666                                    else {
14667                                            if (orderByComparator.isAscending() ^ previous) {
14668                                                    query.append(ORDER_BY_ASC);
14669                                            }
14670                                            else {
14671                                                    query.append(ORDER_BY_DESC);
14672                                            }
14673                                    }
14674                            }
14675                    }
14676                    else {
14677                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
14678                    }
14679    
14680                    String sql = query.toString();
14681    
14682                    Query q = session.createQuery(sql);
14683    
14684                    q.setFirstResult(0);
14685                    q.setMaxResults(2);
14686    
14687                    QueryPos qPos = QueryPos.getInstance(q);
14688    
14689                    qPos.add(companyId);
14690    
14691                    qPos.add(userId);
14692    
14693                    qPos.add(status);
14694    
14695                    if (orderByComparator != null) {
14696                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
14697    
14698                            for (Object value : values) {
14699                                    qPos.add(value);
14700                            }
14701                    }
14702    
14703                    List<BlogsEntry> list = q.list();
14704    
14705                    if (list.size() == 2) {
14706                            return list.get(1);
14707                    }
14708                    else {
14709                            return null;
14710                    }
14711            }
14712    
14713            /**
14714             * Removes all the blogs entries where companyId = &#63; and userId = &#63; and status = &#63; from the database.
14715             *
14716             * @param companyId the company ID
14717             * @param userId the user ID
14718             * @param status the status
14719             */
14720            @Override
14721            public void removeByC_U_S(long companyId, long userId, int status) {
14722                    for (BlogsEntry blogsEntry : findByC_U_S(companyId, userId, status,
14723                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
14724                            remove(blogsEntry);
14725                    }
14726            }
14727    
14728            /**
14729             * Returns the number of blogs entries where companyId = &#63; and userId = &#63; and status = &#63;.
14730             *
14731             * @param companyId the company ID
14732             * @param userId the user ID
14733             * @param status the status
14734             * @return the number of matching blogs entries
14735             */
14736            @Override
14737            public int countByC_U_S(long companyId, long userId, int status) {
14738                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_U_S;
14739    
14740                    Object[] finderArgs = new Object[] { companyId, userId, status };
14741    
14742                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
14743    
14744                    if (count == null) {
14745                            StringBundler query = new StringBundler(4);
14746    
14747                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
14748    
14749                            query.append(_FINDER_COLUMN_C_U_S_COMPANYID_2);
14750    
14751                            query.append(_FINDER_COLUMN_C_U_S_USERID_2);
14752    
14753                            query.append(_FINDER_COLUMN_C_U_S_STATUS_2);
14754    
14755                            String sql = query.toString();
14756    
14757                            Session session = null;
14758    
14759                            try {
14760                                    session = openSession();
14761    
14762                                    Query q = session.createQuery(sql);
14763    
14764                                    QueryPos qPos = QueryPos.getInstance(q);
14765    
14766                                    qPos.add(companyId);
14767    
14768                                    qPos.add(userId);
14769    
14770                                    qPos.add(status);
14771    
14772                                    count = (Long)q.uniqueResult();
14773    
14774                                    finderCache.putResult(finderPath, finderArgs, count);
14775                            }
14776                            catch (Exception e) {
14777                                    finderCache.removeResult(finderPath, finderArgs);
14778    
14779                                    throw processException(e);
14780                            }
14781                            finally {
14782                                    closeSession(session);
14783                            }
14784                    }
14785    
14786                    return count.intValue();
14787            }
14788    
14789            private static final String _FINDER_COLUMN_C_U_S_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
14790            private static final String _FINDER_COLUMN_C_U_S_USERID_2 = "blogsEntry.userId = ? AND ";
14791            private static final String _FINDER_COLUMN_C_U_S_STATUS_2 = "blogsEntry.status = ?";
14792            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U_NOTS = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
14793                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
14794                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_U_NotS",
14795                            new String[] {
14796                                    Long.class.getName(), Long.class.getName(),
14797                                    Integer.class.getName(),
14798                                    
14799                            Integer.class.getName(), Integer.class.getName(),
14800                                    OrderByComparator.class.getName()
14801                            });
14802            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_U_NOTS =
14803                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
14804                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
14805                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_U_NotS",
14806                            new String[] {
14807                                    Long.class.getName(), Long.class.getName(),
14808                                    Integer.class.getName()
14809                            });
14810    
14811            /**
14812             * Returns all the blogs entries where companyId = &#63; and userId = &#63; and status &ne; &#63;.
14813             *
14814             * @param companyId the company ID
14815             * @param userId the user ID
14816             * @param status the status
14817             * @return the matching blogs entries
14818             */
14819            @Override
14820            public List<BlogsEntry> findByC_U_NotS(long companyId, long userId,
14821                    int status) {
14822                    return findByC_U_NotS(companyId, userId, status, QueryUtil.ALL_POS,
14823                            QueryUtil.ALL_POS, null);
14824            }
14825    
14826            /**
14827             * Returns a range of all the blogs entries where companyId = &#63; and userId = &#63; and status &ne; &#63;.
14828             *
14829             * <p>
14830             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
14831             * </p>
14832             *
14833             * @param companyId the company ID
14834             * @param userId the user ID
14835             * @param status the status
14836             * @param start the lower bound of the range of blogs entries
14837             * @param end the upper bound of the range of blogs entries (not inclusive)
14838             * @return the range of matching blogs entries
14839             */
14840            @Override
14841            public List<BlogsEntry> findByC_U_NotS(long companyId, long userId,
14842                    int status, int start, int end) {
14843                    return findByC_U_NotS(companyId, userId, status, start, end, null);
14844            }
14845    
14846            /**
14847             * Returns an ordered range of all the blogs entries where companyId = &#63; and userId = &#63; and status &ne; &#63;.
14848             *
14849             * <p>
14850             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
14851             * </p>
14852             *
14853             * @param companyId the company ID
14854             * @param userId the user ID
14855             * @param status the status
14856             * @param start the lower bound of the range of blogs entries
14857             * @param end the upper bound of the range of blogs entries (not inclusive)
14858             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14859             * @return the ordered range of matching blogs entries
14860             */
14861            @Override
14862            public List<BlogsEntry> findByC_U_NotS(long companyId, long userId,
14863                    int status, int start, int end,
14864                    OrderByComparator<BlogsEntry> orderByComparator) {
14865                    return findByC_U_NotS(companyId, userId, status, start, end,
14866                            orderByComparator, true);
14867            }
14868    
14869            /**
14870             * Returns an ordered range of all the blogs entries where companyId = &#63; and userId = &#63; and status &ne; &#63;.
14871             *
14872             * <p>
14873             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
14874             * </p>
14875             *
14876             * @param companyId the company ID
14877             * @param userId the user ID
14878             * @param status the status
14879             * @param start the lower bound of the range of blogs entries
14880             * @param end the upper bound of the range of blogs entries (not inclusive)
14881             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14882             * @param retrieveFromCache whether to retrieve from the finder cache
14883             * @return the ordered range of matching blogs entries
14884             */
14885            @Override
14886            public List<BlogsEntry> findByC_U_NotS(long companyId, long userId,
14887                    int status, int start, int end,
14888                    OrderByComparator<BlogsEntry> orderByComparator,
14889                    boolean retrieveFromCache) {
14890                    boolean pagination = true;
14891                    FinderPath finderPath = null;
14892                    Object[] finderArgs = null;
14893    
14894                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U_NOTS;
14895                    finderArgs = new Object[] {
14896                                    companyId, userId, status,
14897                                    
14898                                    start, end, orderByComparator
14899                            };
14900    
14901                    List<BlogsEntry> list = null;
14902    
14903                    if (retrieveFromCache) {
14904                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
14905                                            finderArgs, this);
14906    
14907                            if ((list != null) && !list.isEmpty()) {
14908                                    for (BlogsEntry blogsEntry : list) {
14909                                            if ((companyId != blogsEntry.getCompanyId()) ||
14910                                                            (userId != blogsEntry.getUserId()) ||
14911                                                            (status == blogsEntry.getStatus())) {
14912                                                    list = null;
14913    
14914                                                    break;
14915                                            }
14916                                    }
14917                            }
14918                    }
14919    
14920                    if (list == null) {
14921                            StringBundler query = null;
14922    
14923                            if (orderByComparator != null) {
14924                                    query = new StringBundler(5 +
14925                                                    (orderByComparator.getOrderByFields().length * 2));
14926                            }
14927                            else {
14928                                    query = new StringBundler(5);
14929                            }
14930    
14931                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
14932    
14933                            query.append(_FINDER_COLUMN_C_U_NOTS_COMPANYID_2);
14934    
14935                            query.append(_FINDER_COLUMN_C_U_NOTS_USERID_2);
14936    
14937                            query.append(_FINDER_COLUMN_C_U_NOTS_STATUS_2);
14938    
14939                            if (orderByComparator != null) {
14940                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
14941                                            orderByComparator);
14942                            }
14943                            else
14944                             if (pagination) {
14945                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
14946                            }
14947    
14948                            String sql = query.toString();
14949    
14950                            Session session = null;
14951    
14952                            try {
14953                                    session = openSession();
14954    
14955                                    Query q = session.createQuery(sql);
14956    
14957                                    QueryPos qPos = QueryPos.getInstance(q);
14958    
14959                                    qPos.add(companyId);
14960    
14961                                    qPos.add(userId);
14962    
14963                                    qPos.add(status);
14964    
14965                                    if (!pagination) {
14966                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
14967                                                            start, end, false);
14968    
14969                                            Collections.sort(list);
14970    
14971                                            list = Collections.unmodifiableList(list);
14972                                    }
14973                                    else {
14974                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
14975                                                            start, end);
14976                                    }
14977    
14978                                    cacheResult(list);
14979    
14980                                    finderCache.putResult(finderPath, finderArgs, list);
14981                            }
14982                            catch (Exception e) {
14983                                    finderCache.removeResult(finderPath, finderArgs);
14984    
14985                                    throw processException(e);
14986                            }
14987                            finally {
14988                                    closeSession(session);
14989                            }
14990                    }
14991    
14992                    return list;
14993            }
14994    
14995            /**
14996             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status &ne; &#63;.
14997             *
14998             * @param companyId the company ID
14999             * @param userId the user ID
15000             * @param status the status
15001             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15002             * @return the first matching blogs entry
15003             * @throws NoSuchEntryException if a matching blogs entry could not be found
15004             */
15005            @Override
15006            public BlogsEntry findByC_U_NotS_First(long companyId, long userId,
15007                    int status, OrderByComparator<BlogsEntry> orderByComparator)
15008                    throws NoSuchEntryException {
15009                    BlogsEntry blogsEntry = fetchByC_U_NotS_First(companyId, userId,
15010                                    status, orderByComparator);
15011    
15012                    if (blogsEntry != null) {
15013                            return blogsEntry;
15014                    }
15015    
15016                    StringBundler msg = new StringBundler(8);
15017    
15018                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15019    
15020                    msg.append("companyId=");
15021                    msg.append(companyId);
15022    
15023                    msg.append(", userId=");
15024                    msg.append(userId);
15025    
15026                    msg.append(", status=");
15027                    msg.append(status);
15028    
15029                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15030    
15031                    throw new NoSuchEntryException(msg.toString());
15032            }
15033    
15034            /**
15035             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status &ne; &#63;.
15036             *
15037             * @param companyId the company ID
15038             * @param userId the user ID
15039             * @param status the status
15040             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15041             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
15042             */
15043            @Override
15044            public BlogsEntry fetchByC_U_NotS_First(long companyId, long userId,
15045                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
15046                    List<BlogsEntry> list = findByC_U_NotS(companyId, userId, status, 0, 1,
15047                                    orderByComparator);
15048    
15049                    if (!list.isEmpty()) {
15050                            return list.get(0);
15051                    }
15052    
15053                    return null;
15054            }
15055    
15056            /**
15057             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status &ne; &#63;.
15058             *
15059             * @param companyId the company ID
15060             * @param userId the user ID
15061             * @param status the status
15062             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15063             * @return the last matching blogs entry
15064             * @throws NoSuchEntryException if a matching blogs entry could not be found
15065             */
15066            @Override
15067            public BlogsEntry findByC_U_NotS_Last(long companyId, long userId,
15068                    int status, OrderByComparator<BlogsEntry> orderByComparator)
15069                    throws NoSuchEntryException {
15070                    BlogsEntry blogsEntry = fetchByC_U_NotS_Last(companyId, userId, status,
15071                                    orderByComparator);
15072    
15073                    if (blogsEntry != null) {
15074                            return blogsEntry;
15075                    }
15076    
15077                    StringBundler msg = new StringBundler(8);
15078    
15079                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15080    
15081                    msg.append("companyId=");
15082                    msg.append(companyId);
15083    
15084                    msg.append(", userId=");
15085                    msg.append(userId);
15086    
15087                    msg.append(", status=");
15088                    msg.append(status);
15089    
15090                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15091    
15092                    throw new NoSuchEntryException(msg.toString());
15093            }
15094    
15095            /**
15096             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status &ne; &#63;.
15097             *
15098             * @param companyId the company ID
15099             * @param userId the user ID
15100             * @param status the status
15101             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15102             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
15103             */
15104            @Override
15105            public BlogsEntry fetchByC_U_NotS_Last(long companyId, long userId,
15106                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
15107                    int count = countByC_U_NotS(companyId, userId, status);
15108    
15109                    if (count == 0) {
15110                            return null;
15111                    }
15112    
15113                    List<BlogsEntry> list = findByC_U_NotS(companyId, userId, status,
15114                                    count - 1, count, orderByComparator);
15115    
15116                    if (!list.isEmpty()) {
15117                            return list.get(0);
15118                    }
15119    
15120                    return null;
15121            }
15122    
15123            /**
15124             * 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;.
15125             *
15126             * @param entryId the primary key of the current blogs entry
15127             * @param companyId the company ID
15128             * @param userId the user ID
15129             * @param status the status
15130             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15131             * @return the previous, current, and next blogs entry
15132             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
15133             */
15134            @Override
15135            public BlogsEntry[] findByC_U_NotS_PrevAndNext(long entryId,
15136                    long companyId, long userId, int status,
15137                    OrderByComparator<BlogsEntry> orderByComparator)
15138                    throws NoSuchEntryException {
15139                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
15140    
15141                    Session session = null;
15142    
15143                    try {
15144                            session = openSession();
15145    
15146                            BlogsEntry[] array = new BlogsEntryImpl[3];
15147    
15148                            array[0] = getByC_U_NotS_PrevAndNext(session, blogsEntry,
15149                                            companyId, userId, status, orderByComparator, true);
15150    
15151                            array[1] = blogsEntry;
15152    
15153                            array[2] = getByC_U_NotS_PrevAndNext(session, blogsEntry,
15154                                            companyId, userId, status, orderByComparator, false);
15155    
15156                            return array;
15157                    }
15158                    catch (Exception e) {
15159                            throw processException(e);
15160                    }
15161                    finally {
15162                            closeSession(session);
15163                    }
15164            }
15165    
15166            protected BlogsEntry getByC_U_NotS_PrevAndNext(Session session,
15167                    BlogsEntry blogsEntry, long companyId, long userId, int status,
15168                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
15169                    StringBundler query = null;
15170    
15171                    if (orderByComparator != null) {
15172                            query = new StringBundler(6 +
15173                                            (orderByComparator.getOrderByConditionFields().length * 3) +
15174                                            (orderByComparator.getOrderByFields().length * 3));
15175                    }
15176                    else {
15177                            query = new StringBundler(5);
15178                    }
15179    
15180                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
15181    
15182                    query.append(_FINDER_COLUMN_C_U_NOTS_COMPANYID_2);
15183    
15184                    query.append(_FINDER_COLUMN_C_U_NOTS_USERID_2);
15185    
15186                    query.append(_FINDER_COLUMN_C_U_NOTS_STATUS_2);
15187    
15188                    if (orderByComparator != null) {
15189                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
15190    
15191                            if (orderByConditionFields.length > 0) {
15192                                    query.append(WHERE_AND);
15193                            }
15194    
15195                            for (int i = 0; i < orderByConditionFields.length; i++) {
15196                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15197                                    query.append(orderByConditionFields[i]);
15198    
15199                                    if ((i + 1) < orderByConditionFields.length) {
15200                                            if (orderByComparator.isAscending() ^ previous) {
15201                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
15202                                            }
15203                                            else {
15204                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
15205                                            }
15206                                    }
15207                                    else {
15208                                            if (orderByComparator.isAscending() ^ previous) {
15209                                                    query.append(WHERE_GREATER_THAN);
15210                                            }
15211                                            else {
15212                                                    query.append(WHERE_LESSER_THAN);
15213                                            }
15214                                    }
15215                            }
15216    
15217                            query.append(ORDER_BY_CLAUSE);
15218    
15219                            String[] orderByFields = orderByComparator.getOrderByFields();
15220    
15221                            for (int i = 0; i < orderByFields.length; i++) {
15222                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15223                                    query.append(orderByFields[i]);
15224    
15225                                    if ((i + 1) < orderByFields.length) {
15226                                            if (orderByComparator.isAscending() ^ previous) {
15227                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
15228                                            }
15229                                            else {
15230                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
15231                                            }
15232                                    }
15233                                    else {
15234                                            if (orderByComparator.isAscending() ^ previous) {
15235                                                    query.append(ORDER_BY_ASC);
15236                                            }
15237                                            else {
15238                                                    query.append(ORDER_BY_DESC);
15239                                            }
15240                                    }
15241                            }
15242                    }
15243                    else {
15244                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
15245                    }
15246    
15247                    String sql = query.toString();
15248    
15249                    Query q = session.createQuery(sql);
15250    
15251                    q.setFirstResult(0);
15252                    q.setMaxResults(2);
15253    
15254                    QueryPos qPos = QueryPos.getInstance(q);
15255    
15256                    qPos.add(companyId);
15257    
15258                    qPos.add(userId);
15259    
15260                    qPos.add(status);
15261    
15262                    if (orderByComparator != null) {
15263                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
15264    
15265                            for (Object value : values) {
15266                                    qPos.add(value);
15267                            }
15268                    }
15269    
15270                    List<BlogsEntry> list = q.list();
15271    
15272                    if (list.size() == 2) {
15273                            return list.get(1);
15274                    }
15275                    else {
15276                            return null;
15277                    }
15278            }
15279    
15280            /**
15281             * Removes all the blogs entries where companyId = &#63; and userId = &#63; and status &ne; &#63; from the database.
15282             *
15283             * @param companyId the company ID
15284             * @param userId the user ID
15285             * @param status the status
15286             */
15287            @Override
15288            public void removeByC_U_NotS(long companyId, long userId, int status) {
15289                    for (BlogsEntry blogsEntry : findByC_U_NotS(companyId, userId, status,
15290                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
15291                            remove(blogsEntry);
15292                    }
15293            }
15294    
15295            /**
15296             * Returns the number of blogs entries where companyId = &#63; and userId = &#63; and status &ne; &#63;.
15297             *
15298             * @param companyId the company ID
15299             * @param userId the user ID
15300             * @param status the status
15301             * @return the number of matching blogs entries
15302             */
15303            @Override
15304            public int countByC_U_NotS(long companyId, long userId, int status) {
15305                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_U_NOTS;
15306    
15307                    Object[] finderArgs = new Object[] { companyId, userId, status };
15308    
15309                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
15310    
15311                    if (count == null) {
15312                            StringBundler query = new StringBundler(4);
15313    
15314                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
15315    
15316                            query.append(_FINDER_COLUMN_C_U_NOTS_COMPANYID_2);
15317    
15318                            query.append(_FINDER_COLUMN_C_U_NOTS_USERID_2);
15319    
15320                            query.append(_FINDER_COLUMN_C_U_NOTS_STATUS_2);
15321    
15322                            String sql = query.toString();
15323    
15324                            Session session = null;
15325    
15326                            try {
15327                                    session = openSession();
15328    
15329                                    Query q = session.createQuery(sql);
15330    
15331                                    QueryPos qPos = QueryPos.getInstance(q);
15332    
15333                                    qPos.add(companyId);
15334    
15335                                    qPos.add(userId);
15336    
15337                                    qPos.add(status);
15338    
15339                                    count = (Long)q.uniqueResult();
15340    
15341                                    finderCache.putResult(finderPath, finderArgs, count);
15342                            }
15343                            catch (Exception e) {
15344                                    finderCache.removeResult(finderPath, finderArgs);
15345    
15346                                    throw processException(e);
15347                            }
15348                            finally {
15349                                    closeSession(session);
15350                            }
15351                    }
15352    
15353                    return count.intValue();
15354            }
15355    
15356            private static final String _FINDER_COLUMN_C_U_NOTS_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
15357            private static final String _FINDER_COLUMN_C_U_NOTS_USERID_2 = "blogsEntry.userId = ? AND ";
15358            private static final String _FINDER_COLUMN_C_U_NOTS_STATUS_2 = "blogsEntry.status != ?";
15359            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
15360                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
15361                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_LtD_S",
15362                            new String[] {
15363                                    Long.class.getName(), Date.class.getName(),
15364                                    Integer.class.getName(),
15365                                    
15366                            Integer.class.getName(), Integer.class.getName(),
15367                                    OrderByComparator.class.getName()
15368                            });
15369            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
15370                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
15371                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_LtD_S",
15372                            new String[] {
15373                                    Long.class.getName(), Date.class.getName(),
15374                                    Integer.class.getName()
15375                            });
15376    
15377            /**
15378             * Returns all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
15379             *
15380             * @param companyId the company ID
15381             * @param displayDate the display date
15382             * @param status the status
15383             * @return the matching blogs entries
15384             */
15385            @Override
15386            public List<BlogsEntry> findByC_LtD_S(long companyId, Date displayDate,
15387                    int status) {
15388                    return findByC_LtD_S(companyId, displayDate, status, QueryUtil.ALL_POS,
15389                            QueryUtil.ALL_POS, null);
15390            }
15391    
15392            /**
15393             * Returns a range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
15394             *
15395             * <p>
15396             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
15397             * </p>
15398             *
15399             * @param companyId the company ID
15400             * @param displayDate the display date
15401             * @param status the status
15402             * @param start the lower bound of the range of blogs entries
15403             * @param end the upper bound of the range of blogs entries (not inclusive)
15404             * @return the range of matching blogs entries
15405             */
15406            @Override
15407            public List<BlogsEntry> findByC_LtD_S(long companyId, Date displayDate,
15408                    int status, int start, int end) {
15409                    return findByC_LtD_S(companyId, displayDate, status, start, end, null);
15410            }
15411    
15412            /**
15413             * Returns an ordered range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
15414             *
15415             * <p>
15416             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
15417             * </p>
15418             *
15419             * @param companyId the company ID
15420             * @param displayDate the display date
15421             * @param status the status
15422             * @param start the lower bound of the range of blogs entries
15423             * @param end the upper bound of the range of blogs entries (not inclusive)
15424             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
15425             * @return the ordered range of matching blogs entries
15426             */
15427            @Override
15428            public List<BlogsEntry> findByC_LtD_S(long companyId, Date displayDate,
15429                    int status, int start, int end,
15430                    OrderByComparator<BlogsEntry> orderByComparator) {
15431                    return findByC_LtD_S(companyId, displayDate, status, start, end,
15432                            orderByComparator, true);
15433            }
15434    
15435            /**
15436             * Returns an ordered range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
15437             *
15438             * <p>
15439             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
15440             * </p>
15441             *
15442             * @param companyId the company ID
15443             * @param displayDate the display date
15444             * @param status the status
15445             * @param start the lower bound of the range of blogs entries
15446             * @param end the upper bound of the range of blogs entries (not inclusive)
15447             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
15448             * @param retrieveFromCache whether to retrieve from the finder cache
15449             * @return the ordered range of matching blogs entries
15450             */
15451            @Override
15452            public List<BlogsEntry> findByC_LtD_S(long companyId, Date displayDate,
15453                    int status, int start, int end,
15454                    OrderByComparator<BlogsEntry> orderByComparator,
15455                    boolean retrieveFromCache) {
15456                    boolean pagination = true;
15457                    FinderPath finderPath = null;
15458                    Object[] finderArgs = null;
15459    
15460                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD_S;
15461                    finderArgs = new Object[] {
15462                                    companyId, displayDate, status,
15463                                    
15464                                    start, end, orderByComparator
15465                            };
15466    
15467                    List<BlogsEntry> list = null;
15468    
15469                    if (retrieveFromCache) {
15470                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
15471                                            finderArgs, this);
15472    
15473                            if ((list != null) && !list.isEmpty()) {
15474                                    for (BlogsEntry blogsEntry : list) {
15475                                            if ((companyId != blogsEntry.getCompanyId()) ||
15476                                                            (displayDate.getTime() <= blogsEntry.getDisplayDate()
15477                                                                                                                                            .getTime()) ||
15478                                                            (status != blogsEntry.getStatus())) {
15479                                                    list = null;
15480    
15481                                                    break;
15482                                            }
15483                                    }
15484                            }
15485                    }
15486    
15487                    if (list == null) {
15488                            StringBundler query = null;
15489    
15490                            if (orderByComparator != null) {
15491                                    query = new StringBundler(5 +
15492                                                    (orderByComparator.getOrderByFields().length * 2));
15493                            }
15494                            else {
15495                                    query = new StringBundler(5);
15496                            }
15497    
15498                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
15499    
15500                            query.append(_FINDER_COLUMN_C_LTD_S_COMPANYID_2);
15501    
15502                            boolean bindDisplayDate = false;
15503    
15504                            if (displayDate == null) {
15505                                    query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_1);
15506                            }
15507                            else {
15508                                    bindDisplayDate = true;
15509    
15510                                    query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_2);
15511                            }
15512    
15513                            query.append(_FINDER_COLUMN_C_LTD_S_STATUS_2);
15514    
15515                            if (orderByComparator != null) {
15516                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
15517                                            orderByComparator);
15518                            }
15519                            else
15520                             if (pagination) {
15521                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
15522                            }
15523    
15524                            String sql = query.toString();
15525    
15526                            Session session = null;
15527    
15528                            try {
15529                                    session = openSession();
15530    
15531                                    Query q = session.createQuery(sql);
15532    
15533                                    QueryPos qPos = QueryPos.getInstance(q);
15534    
15535                                    qPos.add(companyId);
15536    
15537                                    if (bindDisplayDate) {
15538                                            qPos.add(new Timestamp(displayDate.getTime()));
15539                                    }
15540    
15541                                    qPos.add(status);
15542    
15543                                    if (!pagination) {
15544                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
15545                                                            start, end, false);
15546    
15547                                            Collections.sort(list);
15548    
15549                                            list = Collections.unmodifiableList(list);
15550                                    }
15551                                    else {
15552                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
15553                                                            start, end);
15554                                    }
15555    
15556                                    cacheResult(list);
15557    
15558                                    finderCache.putResult(finderPath, finderArgs, list);
15559                            }
15560                            catch (Exception e) {
15561                                    finderCache.removeResult(finderPath, finderArgs);
15562    
15563                                    throw processException(e);
15564                            }
15565                            finally {
15566                                    closeSession(session);
15567                            }
15568                    }
15569    
15570                    return list;
15571            }
15572    
15573            /**
15574             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
15575             *
15576             * @param companyId the company ID
15577             * @param displayDate the display date
15578             * @param status the status
15579             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15580             * @return the first matching blogs entry
15581             * @throws NoSuchEntryException if a matching blogs entry could not be found
15582             */
15583            @Override
15584            public BlogsEntry findByC_LtD_S_First(long companyId, Date displayDate,
15585                    int status, OrderByComparator<BlogsEntry> orderByComparator)
15586                    throws NoSuchEntryException {
15587                    BlogsEntry blogsEntry = fetchByC_LtD_S_First(companyId, displayDate,
15588                                    status, orderByComparator);
15589    
15590                    if (blogsEntry != null) {
15591                            return blogsEntry;
15592                    }
15593    
15594                    StringBundler msg = new StringBundler(8);
15595    
15596                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15597    
15598                    msg.append("companyId=");
15599                    msg.append(companyId);
15600    
15601                    msg.append(", displayDate=");
15602                    msg.append(displayDate);
15603    
15604                    msg.append(", status=");
15605                    msg.append(status);
15606    
15607                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15608    
15609                    throw new NoSuchEntryException(msg.toString());
15610            }
15611    
15612            /**
15613             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
15614             *
15615             * @param companyId the company ID
15616             * @param displayDate the display date
15617             * @param status the status
15618             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15619             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
15620             */
15621            @Override
15622            public BlogsEntry fetchByC_LtD_S_First(long companyId, Date displayDate,
15623                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
15624                    List<BlogsEntry> list = findByC_LtD_S(companyId, displayDate, status,
15625                                    0, 1, orderByComparator);
15626    
15627                    if (!list.isEmpty()) {
15628                            return list.get(0);
15629                    }
15630    
15631                    return null;
15632            }
15633    
15634            /**
15635             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
15636             *
15637             * @param companyId the company ID
15638             * @param displayDate the display date
15639             * @param status the status
15640             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15641             * @return the last matching blogs entry
15642             * @throws NoSuchEntryException if a matching blogs entry could not be found
15643             */
15644            @Override
15645            public BlogsEntry findByC_LtD_S_Last(long companyId, Date displayDate,
15646                    int status, OrderByComparator<BlogsEntry> orderByComparator)
15647                    throws NoSuchEntryException {
15648                    BlogsEntry blogsEntry = fetchByC_LtD_S_Last(companyId, displayDate,
15649                                    status, orderByComparator);
15650    
15651                    if (blogsEntry != null) {
15652                            return blogsEntry;
15653                    }
15654    
15655                    StringBundler msg = new StringBundler(8);
15656    
15657                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15658    
15659                    msg.append("companyId=");
15660                    msg.append(companyId);
15661    
15662                    msg.append(", displayDate=");
15663                    msg.append(displayDate);
15664    
15665                    msg.append(", status=");
15666                    msg.append(status);
15667    
15668                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15669    
15670                    throw new NoSuchEntryException(msg.toString());
15671            }
15672    
15673            /**
15674             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
15675             *
15676             * @param companyId the company ID
15677             * @param displayDate the display date
15678             * @param status the status
15679             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15680             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
15681             */
15682            @Override
15683            public BlogsEntry fetchByC_LtD_S_Last(long companyId, Date displayDate,
15684                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
15685                    int count = countByC_LtD_S(companyId, displayDate, status);
15686    
15687                    if (count == 0) {
15688                            return null;
15689                    }
15690    
15691                    List<BlogsEntry> list = findByC_LtD_S(companyId, displayDate, status,
15692                                    count - 1, count, orderByComparator);
15693    
15694                    if (!list.isEmpty()) {
15695                            return list.get(0);
15696                    }
15697    
15698                    return null;
15699            }
15700    
15701            /**
15702             * 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;.
15703             *
15704             * @param entryId the primary key of the current blogs entry
15705             * @param companyId the company ID
15706             * @param displayDate the display date
15707             * @param status the status
15708             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15709             * @return the previous, current, and next blogs entry
15710             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
15711             */
15712            @Override
15713            public BlogsEntry[] findByC_LtD_S_PrevAndNext(long entryId, long companyId,
15714                    Date displayDate, int status,
15715                    OrderByComparator<BlogsEntry> orderByComparator)
15716                    throws NoSuchEntryException {
15717                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
15718    
15719                    Session session = null;
15720    
15721                    try {
15722                            session = openSession();
15723    
15724                            BlogsEntry[] array = new BlogsEntryImpl[3];
15725    
15726                            array[0] = getByC_LtD_S_PrevAndNext(session, blogsEntry, companyId,
15727                                            displayDate, status, orderByComparator, true);
15728    
15729                            array[1] = blogsEntry;
15730    
15731                            array[2] = getByC_LtD_S_PrevAndNext(session, blogsEntry, companyId,
15732                                            displayDate, status, orderByComparator, false);
15733    
15734                            return array;
15735                    }
15736                    catch (Exception e) {
15737                            throw processException(e);
15738                    }
15739                    finally {
15740                            closeSession(session);
15741                    }
15742            }
15743    
15744            protected BlogsEntry getByC_LtD_S_PrevAndNext(Session session,
15745                    BlogsEntry blogsEntry, long companyId, Date displayDate, int status,
15746                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
15747                    StringBundler query = null;
15748    
15749                    if (orderByComparator != null) {
15750                            query = new StringBundler(6 +
15751                                            (orderByComparator.getOrderByConditionFields().length * 3) +
15752                                            (orderByComparator.getOrderByFields().length * 3));
15753                    }
15754                    else {
15755                            query = new StringBundler(5);
15756                    }
15757    
15758                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
15759    
15760                    query.append(_FINDER_COLUMN_C_LTD_S_COMPANYID_2);
15761    
15762                    boolean bindDisplayDate = false;
15763    
15764                    if (displayDate == null) {
15765                            query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_1);
15766                    }
15767                    else {
15768                            bindDisplayDate = true;
15769    
15770                            query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_2);
15771                    }
15772    
15773                    query.append(_FINDER_COLUMN_C_LTD_S_STATUS_2);
15774    
15775                    if (orderByComparator != null) {
15776                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
15777    
15778                            if (orderByConditionFields.length > 0) {
15779                                    query.append(WHERE_AND);
15780                            }
15781    
15782                            for (int i = 0; i < orderByConditionFields.length; i++) {
15783                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15784                                    query.append(orderByConditionFields[i]);
15785    
15786                                    if ((i + 1) < orderByConditionFields.length) {
15787                                            if (orderByComparator.isAscending() ^ previous) {
15788                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
15789                                            }
15790                                            else {
15791                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
15792                                            }
15793                                    }
15794                                    else {
15795                                            if (orderByComparator.isAscending() ^ previous) {
15796                                                    query.append(WHERE_GREATER_THAN);
15797                                            }
15798                                            else {
15799                                                    query.append(WHERE_LESSER_THAN);
15800                                            }
15801                                    }
15802                            }
15803    
15804                            query.append(ORDER_BY_CLAUSE);
15805    
15806                            String[] orderByFields = orderByComparator.getOrderByFields();
15807    
15808                            for (int i = 0; i < orderByFields.length; i++) {
15809                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15810                                    query.append(orderByFields[i]);
15811    
15812                                    if ((i + 1) < orderByFields.length) {
15813                                            if (orderByComparator.isAscending() ^ previous) {
15814                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
15815                                            }
15816                                            else {
15817                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
15818                                            }
15819                                    }
15820                                    else {
15821                                            if (orderByComparator.isAscending() ^ previous) {
15822                                                    query.append(ORDER_BY_ASC);
15823                                            }
15824                                            else {
15825                                                    query.append(ORDER_BY_DESC);
15826                                            }
15827                                    }
15828                            }
15829                    }
15830                    else {
15831                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
15832                    }
15833    
15834                    String sql = query.toString();
15835    
15836                    Query q = session.createQuery(sql);
15837    
15838                    q.setFirstResult(0);
15839                    q.setMaxResults(2);
15840    
15841                    QueryPos qPos = QueryPos.getInstance(q);
15842    
15843                    qPos.add(companyId);
15844    
15845                    if (bindDisplayDate) {
15846                            qPos.add(new Timestamp(displayDate.getTime()));
15847                    }
15848    
15849                    qPos.add(status);
15850    
15851                    if (orderByComparator != null) {
15852                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
15853    
15854                            for (Object value : values) {
15855                                    qPos.add(value);
15856                            }
15857                    }
15858    
15859                    List<BlogsEntry> list = q.list();
15860    
15861                    if (list.size() == 2) {
15862                            return list.get(1);
15863                    }
15864                    else {
15865                            return null;
15866                    }
15867            }
15868    
15869            /**
15870             * Removes all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63; from the database.
15871             *
15872             * @param companyId the company ID
15873             * @param displayDate the display date
15874             * @param status the status
15875             */
15876            @Override
15877            public void removeByC_LtD_S(long companyId, Date displayDate, int status) {
15878                    for (BlogsEntry blogsEntry : findByC_LtD_S(companyId, displayDate,
15879                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
15880                            remove(blogsEntry);
15881                    }
15882            }
15883    
15884            /**
15885             * Returns the number of blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
15886             *
15887             * @param companyId the company ID
15888             * @param displayDate the display date
15889             * @param status the status
15890             * @return the number of matching blogs entries
15891             */
15892            @Override
15893            public int countByC_LtD_S(long companyId, Date displayDate, int status) {
15894                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD_S;
15895    
15896                    Object[] finderArgs = new Object[] { companyId, displayDate, status };
15897    
15898                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
15899    
15900                    if (count == null) {
15901                            StringBundler query = new StringBundler(4);
15902    
15903                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
15904    
15905                            query.append(_FINDER_COLUMN_C_LTD_S_COMPANYID_2);
15906    
15907                            boolean bindDisplayDate = false;
15908    
15909                            if (displayDate == null) {
15910                                    query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_1);
15911                            }
15912                            else {
15913                                    bindDisplayDate = true;
15914    
15915                                    query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_2);
15916                            }
15917    
15918                            query.append(_FINDER_COLUMN_C_LTD_S_STATUS_2);
15919    
15920                            String sql = query.toString();
15921    
15922                            Session session = null;
15923    
15924                            try {
15925                                    session = openSession();
15926    
15927                                    Query q = session.createQuery(sql);
15928    
15929                                    QueryPos qPos = QueryPos.getInstance(q);
15930    
15931                                    qPos.add(companyId);
15932    
15933                                    if (bindDisplayDate) {
15934                                            qPos.add(new Timestamp(displayDate.getTime()));
15935                                    }
15936    
15937                                    qPos.add(status);
15938    
15939                                    count = (Long)q.uniqueResult();
15940    
15941                                    finderCache.putResult(finderPath, finderArgs, count);
15942                            }
15943                            catch (Exception e) {
15944                                    finderCache.removeResult(finderPath, finderArgs);
15945    
15946                                    throw processException(e);
15947                            }
15948                            finally {
15949                                    closeSession(session);
15950                            }
15951                    }
15952    
15953                    return count.intValue();
15954            }
15955    
15956            private static final String _FINDER_COLUMN_C_LTD_S_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
15957            private static final String _FINDER_COLUMN_C_LTD_S_DISPLAYDATE_1 = "blogsEntry.displayDate IS NULL AND ";
15958            private static final String _FINDER_COLUMN_C_LTD_S_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
15959            private static final String _FINDER_COLUMN_C_LTD_S_STATUS_2 = "blogsEntry.status = ?";
15960            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD_NOTS =
15961                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
15962                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
15963                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_LtD_NotS",
15964                            new String[] {
15965                                    Long.class.getName(), Date.class.getName(),
15966                                    Integer.class.getName(),
15967                                    
15968                            Integer.class.getName(), Integer.class.getName(),
15969                                    OrderByComparator.class.getName()
15970                            });
15971            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD_NOTS =
15972                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
15973                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
15974                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_LtD_NotS",
15975                            new String[] {
15976                                    Long.class.getName(), Date.class.getName(),
15977                                    Integer.class.getName()
15978                            });
15979    
15980            /**
15981             * Returns all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
15982             *
15983             * @param companyId the company ID
15984             * @param displayDate the display date
15985             * @param status the status
15986             * @return the matching blogs entries
15987             */
15988            @Override
15989            public List<BlogsEntry> findByC_LtD_NotS(long companyId, Date displayDate,
15990                    int status) {
15991                    return findByC_LtD_NotS(companyId, displayDate, status,
15992                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
15993            }
15994    
15995            /**
15996             * Returns a range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
15997             *
15998             * <p>
15999             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
16000             * </p>
16001             *
16002             * @param companyId the company ID
16003             * @param displayDate the display date
16004             * @param status the status
16005             * @param start the lower bound of the range of blogs entries
16006             * @param end the upper bound of the range of blogs entries (not inclusive)
16007             * @return the range of matching blogs entries
16008             */
16009            @Override
16010            public List<BlogsEntry> findByC_LtD_NotS(long companyId, Date displayDate,
16011                    int status, int start, int end) {
16012                    return findByC_LtD_NotS(companyId, displayDate, status, start, end, null);
16013            }
16014    
16015            /**
16016             * Returns an ordered range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
16017             *
16018             * <p>
16019             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
16020             * </p>
16021             *
16022             * @param companyId the company ID
16023             * @param displayDate the display date
16024             * @param status the status
16025             * @param start the lower bound of the range of blogs entries
16026             * @param end the upper bound of the range of blogs entries (not inclusive)
16027             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
16028             * @return the ordered range of matching blogs entries
16029             */
16030            @Override
16031            public List<BlogsEntry> findByC_LtD_NotS(long companyId, Date displayDate,
16032                    int status, int start, int end,
16033                    OrderByComparator<BlogsEntry> orderByComparator) {
16034                    return findByC_LtD_NotS(companyId, displayDate, status, start, end,
16035                            orderByComparator, true);
16036            }
16037    
16038            /**
16039             * Returns an ordered range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
16040             *
16041             * <p>
16042             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
16043             * </p>
16044             *
16045             * @param companyId the company ID
16046             * @param displayDate the display date
16047             * @param status the status
16048             * @param start the lower bound of the range of blogs entries
16049             * @param end the upper bound of the range of blogs entries (not inclusive)
16050             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
16051             * @param retrieveFromCache whether to retrieve from the finder cache
16052             * @return the ordered range of matching blogs entries
16053             */
16054            @Override
16055            public List<BlogsEntry> findByC_LtD_NotS(long companyId, Date displayDate,
16056                    int status, int start, int end,
16057                    OrderByComparator<BlogsEntry> orderByComparator,
16058                    boolean retrieveFromCache) {
16059                    boolean pagination = true;
16060                    FinderPath finderPath = null;
16061                    Object[] finderArgs = null;
16062    
16063                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD_NOTS;
16064                    finderArgs = new Object[] {
16065                                    companyId, displayDate, status,
16066                                    
16067                                    start, end, orderByComparator
16068                            };
16069    
16070                    List<BlogsEntry> list = null;
16071    
16072                    if (retrieveFromCache) {
16073                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
16074                                            finderArgs, this);
16075    
16076                            if ((list != null) && !list.isEmpty()) {
16077                                    for (BlogsEntry blogsEntry : list) {
16078                                            if ((companyId != blogsEntry.getCompanyId()) ||
16079                                                            (displayDate.getTime() <= blogsEntry.getDisplayDate()
16080                                                                                                                                            .getTime()) ||
16081                                                            (status == blogsEntry.getStatus())) {
16082                                                    list = null;
16083    
16084                                                    break;
16085                                            }
16086                                    }
16087                            }
16088                    }
16089    
16090                    if (list == null) {
16091                            StringBundler query = null;
16092    
16093                            if (orderByComparator != null) {
16094                                    query = new StringBundler(5 +
16095                                                    (orderByComparator.getOrderByFields().length * 2));
16096                            }
16097                            else {
16098                                    query = new StringBundler(5);
16099                            }
16100    
16101                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
16102    
16103                            query.append(_FINDER_COLUMN_C_LTD_NOTS_COMPANYID_2);
16104    
16105                            boolean bindDisplayDate = false;
16106    
16107                            if (displayDate == null) {
16108                                    query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_1);
16109                            }
16110                            else {
16111                                    bindDisplayDate = true;
16112    
16113                                    query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_2);
16114                            }
16115    
16116                            query.append(_FINDER_COLUMN_C_LTD_NOTS_STATUS_2);
16117    
16118                            if (orderByComparator != null) {
16119                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
16120                                            orderByComparator);
16121                            }
16122                            else
16123                             if (pagination) {
16124                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
16125                            }
16126    
16127                            String sql = query.toString();
16128    
16129                            Session session = null;
16130    
16131                            try {
16132                                    session = openSession();
16133    
16134                                    Query q = session.createQuery(sql);
16135    
16136                                    QueryPos qPos = QueryPos.getInstance(q);
16137    
16138                                    qPos.add(companyId);
16139    
16140                                    if (bindDisplayDate) {
16141                                            qPos.add(new Timestamp(displayDate.getTime()));
16142                                    }
16143    
16144                                    qPos.add(status);
16145    
16146                                    if (!pagination) {
16147                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
16148                                                            start, end, false);
16149    
16150                                            Collections.sort(list);
16151    
16152                                            list = Collections.unmodifiableList(list);
16153                                    }
16154                                    else {
16155                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
16156                                                            start, end);
16157                                    }
16158    
16159                                    cacheResult(list);
16160    
16161                                    finderCache.putResult(finderPath, finderArgs, list);
16162                            }
16163                            catch (Exception e) {
16164                                    finderCache.removeResult(finderPath, finderArgs);
16165    
16166                                    throw processException(e);
16167                            }
16168                            finally {
16169                                    closeSession(session);
16170                            }
16171                    }
16172    
16173                    return list;
16174            }
16175    
16176            /**
16177             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
16178             *
16179             * @param companyId the company ID
16180             * @param displayDate the display date
16181             * @param status the status
16182             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16183             * @return the first matching blogs entry
16184             * @throws NoSuchEntryException if a matching blogs entry could not be found
16185             */
16186            @Override
16187            public BlogsEntry findByC_LtD_NotS_First(long companyId, Date displayDate,
16188                    int status, OrderByComparator<BlogsEntry> orderByComparator)
16189                    throws NoSuchEntryException {
16190                    BlogsEntry blogsEntry = fetchByC_LtD_NotS_First(companyId, displayDate,
16191                                    status, orderByComparator);
16192    
16193                    if (blogsEntry != null) {
16194                            return blogsEntry;
16195                    }
16196    
16197                    StringBundler msg = new StringBundler(8);
16198    
16199                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
16200    
16201                    msg.append("companyId=");
16202                    msg.append(companyId);
16203    
16204                    msg.append(", displayDate=");
16205                    msg.append(displayDate);
16206    
16207                    msg.append(", status=");
16208                    msg.append(status);
16209    
16210                    msg.append(StringPool.CLOSE_CURLY_BRACE);
16211    
16212                    throw new NoSuchEntryException(msg.toString());
16213            }
16214    
16215            /**
16216             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
16217             *
16218             * @param companyId the company ID
16219             * @param displayDate the display date
16220             * @param status the status
16221             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16222             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
16223             */
16224            @Override
16225            public BlogsEntry fetchByC_LtD_NotS_First(long companyId, Date displayDate,
16226                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
16227                    List<BlogsEntry> list = findByC_LtD_NotS(companyId, displayDate,
16228                                    status, 0, 1, orderByComparator);
16229    
16230                    if (!list.isEmpty()) {
16231                            return list.get(0);
16232                    }
16233    
16234                    return null;
16235            }
16236    
16237            /**
16238             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
16239             *
16240             * @param companyId the company ID
16241             * @param displayDate the display date
16242             * @param status the status
16243             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16244             * @return the last matching blogs entry
16245             * @throws NoSuchEntryException if a matching blogs entry could not be found
16246             */
16247            @Override
16248            public BlogsEntry findByC_LtD_NotS_Last(long companyId, Date displayDate,
16249                    int status, OrderByComparator<BlogsEntry> orderByComparator)
16250                    throws NoSuchEntryException {
16251                    BlogsEntry blogsEntry = fetchByC_LtD_NotS_Last(companyId, displayDate,
16252                                    status, orderByComparator);
16253    
16254                    if (blogsEntry != null) {
16255                            return blogsEntry;
16256                    }
16257    
16258                    StringBundler msg = new StringBundler(8);
16259    
16260                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
16261    
16262                    msg.append("companyId=");
16263                    msg.append(companyId);
16264    
16265                    msg.append(", displayDate=");
16266                    msg.append(displayDate);
16267    
16268                    msg.append(", status=");
16269                    msg.append(status);
16270    
16271                    msg.append(StringPool.CLOSE_CURLY_BRACE);
16272    
16273                    throw new NoSuchEntryException(msg.toString());
16274            }
16275    
16276            /**
16277             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
16278             *
16279             * @param companyId the company ID
16280             * @param displayDate the display date
16281             * @param status the status
16282             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16283             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
16284             */
16285            @Override
16286            public BlogsEntry fetchByC_LtD_NotS_Last(long companyId, Date displayDate,
16287                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
16288                    int count = countByC_LtD_NotS(companyId, displayDate, status);
16289    
16290                    if (count == 0) {
16291                            return null;
16292                    }
16293    
16294                    List<BlogsEntry> list = findByC_LtD_NotS(companyId, displayDate,
16295                                    status, count - 1, count, orderByComparator);
16296    
16297                    if (!list.isEmpty()) {
16298                            return list.get(0);
16299                    }
16300    
16301                    return null;
16302            }
16303    
16304            /**
16305             * 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;.
16306             *
16307             * @param entryId the primary key of the current blogs entry
16308             * @param companyId the company ID
16309             * @param displayDate the display date
16310             * @param status the status
16311             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16312             * @return the previous, current, and next blogs entry
16313             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
16314             */
16315            @Override
16316            public BlogsEntry[] findByC_LtD_NotS_PrevAndNext(long entryId,
16317                    long companyId, Date displayDate, int status,
16318                    OrderByComparator<BlogsEntry> orderByComparator)
16319                    throws NoSuchEntryException {
16320                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
16321    
16322                    Session session = null;
16323    
16324                    try {
16325                            session = openSession();
16326    
16327                            BlogsEntry[] array = new BlogsEntryImpl[3];
16328    
16329                            array[0] = getByC_LtD_NotS_PrevAndNext(session, blogsEntry,
16330                                            companyId, displayDate, status, orderByComparator, true);
16331    
16332                            array[1] = blogsEntry;
16333    
16334                            array[2] = getByC_LtD_NotS_PrevAndNext(session, blogsEntry,
16335                                            companyId, displayDate, status, orderByComparator, false);
16336    
16337                            return array;
16338                    }
16339                    catch (Exception e) {
16340                            throw processException(e);
16341                    }
16342                    finally {
16343                            closeSession(session);
16344                    }
16345            }
16346    
16347            protected BlogsEntry getByC_LtD_NotS_PrevAndNext(Session session,
16348                    BlogsEntry blogsEntry, long companyId, Date displayDate, int status,
16349                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
16350                    StringBundler query = null;
16351    
16352                    if (orderByComparator != null) {
16353                            query = new StringBundler(6 +
16354                                            (orderByComparator.getOrderByConditionFields().length * 3) +
16355                                            (orderByComparator.getOrderByFields().length * 3));
16356                    }
16357                    else {
16358                            query = new StringBundler(5);
16359                    }
16360    
16361                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
16362    
16363                    query.append(_FINDER_COLUMN_C_LTD_NOTS_COMPANYID_2);
16364    
16365                    boolean bindDisplayDate = false;
16366    
16367                    if (displayDate == null) {
16368                            query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_1);
16369                    }
16370                    else {
16371                            bindDisplayDate = true;
16372    
16373                            query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_2);
16374                    }
16375    
16376                    query.append(_FINDER_COLUMN_C_LTD_NOTS_STATUS_2);
16377    
16378                    if (orderByComparator != null) {
16379                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
16380    
16381                            if (orderByConditionFields.length > 0) {
16382                                    query.append(WHERE_AND);
16383                            }
16384    
16385                            for (int i = 0; i < orderByConditionFields.length; i++) {
16386                                    query.append(_ORDER_BY_ENTITY_ALIAS);
16387                                    query.append(orderByConditionFields[i]);
16388    
16389                                    if ((i + 1) < orderByConditionFields.length) {
16390                                            if (orderByComparator.isAscending() ^ previous) {
16391                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
16392                                            }
16393                                            else {
16394                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
16395                                            }
16396                                    }
16397                                    else {
16398                                            if (orderByComparator.isAscending() ^ previous) {
16399                                                    query.append(WHERE_GREATER_THAN);
16400                                            }
16401                                            else {
16402                                                    query.append(WHERE_LESSER_THAN);
16403                                            }
16404                                    }
16405                            }
16406    
16407                            query.append(ORDER_BY_CLAUSE);
16408    
16409                            String[] orderByFields = orderByComparator.getOrderByFields();
16410    
16411                            for (int i = 0; i < orderByFields.length; i++) {
16412                                    query.append(_ORDER_BY_ENTITY_ALIAS);
16413                                    query.append(orderByFields[i]);
16414    
16415                                    if ((i + 1) < orderByFields.length) {
16416                                            if (orderByComparator.isAscending() ^ previous) {
16417                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
16418                                            }
16419                                            else {
16420                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
16421                                            }
16422                                    }
16423                                    else {
16424                                            if (orderByComparator.isAscending() ^ previous) {
16425                                                    query.append(ORDER_BY_ASC);
16426                                            }
16427                                            else {
16428                                                    query.append(ORDER_BY_DESC);
16429                                            }
16430                                    }
16431                            }
16432                    }
16433                    else {
16434                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
16435                    }
16436    
16437                    String sql = query.toString();
16438    
16439                    Query q = session.createQuery(sql);
16440    
16441                    q.setFirstResult(0);
16442                    q.setMaxResults(2);
16443    
16444                    QueryPos qPos = QueryPos.getInstance(q);
16445    
16446                    qPos.add(companyId);
16447    
16448                    if (bindDisplayDate) {
16449                            qPos.add(new Timestamp(displayDate.getTime()));
16450                    }
16451    
16452                    qPos.add(status);
16453    
16454                    if (orderByComparator != null) {
16455                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
16456    
16457                            for (Object value : values) {
16458                                    qPos.add(value);
16459                            }
16460                    }
16461    
16462                    List<BlogsEntry> list = q.list();
16463    
16464                    if (list.size() == 2) {
16465                            return list.get(1);
16466                    }
16467                    else {
16468                            return null;
16469                    }
16470            }
16471    
16472            /**
16473             * Removes all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63; from the database.
16474             *
16475             * @param companyId the company ID
16476             * @param displayDate the display date
16477             * @param status the status
16478             */
16479            @Override
16480            public void removeByC_LtD_NotS(long companyId, Date displayDate, int status) {
16481                    for (BlogsEntry blogsEntry : findByC_LtD_NotS(companyId, displayDate,
16482                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
16483                            remove(blogsEntry);
16484                    }
16485            }
16486    
16487            /**
16488             * Returns the number of blogs entries where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
16489             *
16490             * @param companyId the company ID
16491             * @param displayDate the display date
16492             * @param status the status
16493             * @return the number of matching blogs entries
16494             */
16495            @Override
16496            public int countByC_LtD_NotS(long companyId, Date displayDate, int status) {
16497                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD_NOTS;
16498    
16499                    Object[] finderArgs = new Object[] { companyId, displayDate, status };
16500    
16501                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
16502    
16503                    if (count == null) {
16504                            StringBundler query = new StringBundler(4);
16505    
16506                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
16507    
16508                            query.append(_FINDER_COLUMN_C_LTD_NOTS_COMPANYID_2);
16509    
16510                            boolean bindDisplayDate = false;
16511    
16512                            if (displayDate == null) {
16513                                    query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_1);
16514                            }
16515                            else {
16516                                    bindDisplayDate = true;
16517    
16518                                    query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_2);
16519                            }
16520    
16521                            query.append(_FINDER_COLUMN_C_LTD_NOTS_STATUS_2);
16522    
16523                            String sql = query.toString();
16524    
16525                            Session session = null;
16526    
16527                            try {
16528                                    session = openSession();
16529    
16530                                    Query q = session.createQuery(sql);
16531    
16532                                    QueryPos qPos = QueryPos.getInstance(q);
16533    
16534                                    qPos.add(companyId);
16535    
16536                                    if (bindDisplayDate) {
16537                                            qPos.add(new Timestamp(displayDate.getTime()));
16538                                    }
16539    
16540                                    qPos.add(status);
16541    
16542                                    count = (Long)q.uniqueResult();
16543    
16544                                    finderCache.putResult(finderPath, finderArgs, count);
16545                            }
16546                            catch (Exception e) {
16547                                    finderCache.removeResult(finderPath, finderArgs);
16548    
16549                                    throw processException(e);
16550                            }
16551                            finally {
16552                                    closeSession(session);
16553                            }
16554                    }
16555    
16556                    return count.intValue();
16557            }
16558    
16559            private static final String _FINDER_COLUMN_C_LTD_NOTS_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
16560            private static final String _FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_1 = "blogsEntry.displayDate IS NULL AND ";
16561            private static final String _FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
16562            private static final String _FINDER_COLUMN_C_LTD_NOTS_STATUS_2 = "blogsEntry.status != ?";
16563            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD_S =
16564                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
16565                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
16566                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_LtD_S",
16567                            new String[] {
16568                                    Long.class.getName(), Long.class.getName(), Date.class.getName(),
16569                                    Integer.class.getName(),
16570                                    
16571                            Integer.class.getName(), Integer.class.getName(),
16572                                    OrderByComparator.class.getName()
16573                            });
16574            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD_S =
16575                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
16576                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
16577                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_U_LtD_S",
16578                            new String[] {
16579                                    Long.class.getName(), Long.class.getName(), Date.class.getName(),
16580                                    Integer.class.getName()
16581                            });
16582    
16583            /**
16584             * Returns all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16585             *
16586             * @param groupId the group ID
16587             * @param userId the user ID
16588             * @param displayDate the display date
16589             * @param status the status
16590             * @return the matching blogs entries
16591             */
16592            @Override
16593            public List<BlogsEntry> findByG_U_LtD_S(long groupId, long userId,
16594                    Date displayDate, int status) {
16595                    return findByG_U_LtD_S(groupId, userId, displayDate, status,
16596                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
16597            }
16598    
16599            /**
16600             * Returns a range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16601             *
16602             * <p>
16603             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
16604             * </p>
16605             *
16606             * @param groupId the group ID
16607             * @param userId the user ID
16608             * @param displayDate the display date
16609             * @param status the status
16610             * @param start the lower bound of the range of blogs entries
16611             * @param end the upper bound of the range of blogs entries (not inclusive)
16612             * @return the range of matching blogs entries
16613             */
16614            @Override
16615            public List<BlogsEntry> findByG_U_LtD_S(long groupId, long userId,
16616                    Date displayDate, int status, int start, int end) {
16617                    return findByG_U_LtD_S(groupId, userId, displayDate, status, start,
16618                            end, null);
16619            }
16620    
16621            /**
16622             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16623             *
16624             * <p>
16625             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
16626             * </p>
16627             *
16628             * @param groupId the group ID
16629             * @param userId the user ID
16630             * @param displayDate the display date
16631             * @param status the status
16632             * @param start the lower bound of the range of blogs entries
16633             * @param end the upper bound of the range of blogs entries (not inclusive)
16634             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
16635             * @return the ordered range of matching blogs entries
16636             */
16637            @Override
16638            public List<BlogsEntry> findByG_U_LtD_S(long groupId, long userId,
16639                    Date displayDate, int status, int start, int end,
16640                    OrderByComparator<BlogsEntry> orderByComparator) {
16641                    return findByG_U_LtD_S(groupId, userId, displayDate, status, start,
16642                            end, orderByComparator, true);
16643            }
16644    
16645            /**
16646             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16647             *
16648             * <p>
16649             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
16650             * </p>
16651             *
16652             * @param groupId the group ID
16653             * @param userId the user ID
16654             * @param displayDate the display date
16655             * @param status the status
16656             * @param start the lower bound of the range of blogs entries
16657             * @param end the upper bound of the range of blogs entries (not inclusive)
16658             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
16659             * @param retrieveFromCache whether to retrieve from the finder cache
16660             * @return the ordered range of matching blogs entries
16661             */
16662            @Override
16663            public List<BlogsEntry> findByG_U_LtD_S(long groupId, long userId,
16664                    Date displayDate, int status, int start, int end,
16665                    OrderByComparator<BlogsEntry> orderByComparator,
16666                    boolean retrieveFromCache) {
16667                    boolean pagination = true;
16668                    FinderPath finderPath = null;
16669                    Object[] finderArgs = null;
16670    
16671                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD_S;
16672                    finderArgs = new Object[] {
16673                                    groupId, userId, displayDate, status,
16674                                    
16675                                    start, end, orderByComparator
16676                            };
16677    
16678                    List<BlogsEntry> list = null;
16679    
16680                    if (retrieveFromCache) {
16681                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
16682                                            finderArgs, this);
16683    
16684                            if ((list != null) && !list.isEmpty()) {
16685                                    for (BlogsEntry blogsEntry : list) {
16686                                            if ((groupId != blogsEntry.getGroupId()) ||
16687                                                            (userId != blogsEntry.getUserId()) ||
16688                                                            (displayDate.getTime() <= blogsEntry.getDisplayDate()
16689                                                                                                                                            .getTime()) ||
16690                                                            (status != blogsEntry.getStatus())) {
16691                                                    list = null;
16692    
16693                                                    break;
16694                                            }
16695                                    }
16696                            }
16697                    }
16698    
16699                    if (list == null) {
16700                            StringBundler query = null;
16701    
16702                            if (orderByComparator != null) {
16703                                    query = new StringBundler(6 +
16704                                                    (orderByComparator.getOrderByFields().length * 2));
16705                            }
16706                            else {
16707                                    query = new StringBundler(6);
16708                            }
16709    
16710                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
16711    
16712                            query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
16713    
16714                            query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
16715    
16716                            boolean bindDisplayDate = false;
16717    
16718                            if (displayDate == null) {
16719                                    query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
16720                            }
16721                            else {
16722                                    bindDisplayDate = true;
16723    
16724                                    query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
16725                            }
16726    
16727                            query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
16728    
16729                            if (orderByComparator != null) {
16730                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
16731                                            orderByComparator);
16732                            }
16733                            else
16734                             if (pagination) {
16735                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
16736                            }
16737    
16738                            String sql = query.toString();
16739    
16740                            Session session = null;
16741    
16742                            try {
16743                                    session = openSession();
16744    
16745                                    Query q = session.createQuery(sql);
16746    
16747                                    QueryPos qPos = QueryPos.getInstance(q);
16748    
16749                                    qPos.add(groupId);
16750    
16751                                    qPos.add(userId);
16752    
16753                                    if (bindDisplayDate) {
16754                                            qPos.add(new Timestamp(displayDate.getTime()));
16755                                    }
16756    
16757                                    qPos.add(status);
16758    
16759                                    if (!pagination) {
16760                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
16761                                                            start, end, false);
16762    
16763                                            Collections.sort(list);
16764    
16765                                            list = Collections.unmodifiableList(list);
16766                                    }
16767                                    else {
16768                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
16769                                                            start, end);
16770                                    }
16771    
16772                                    cacheResult(list);
16773    
16774                                    finderCache.putResult(finderPath, finderArgs, list);
16775                            }
16776                            catch (Exception e) {
16777                                    finderCache.removeResult(finderPath, finderArgs);
16778    
16779                                    throw processException(e);
16780                            }
16781                            finally {
16782                                    closeSession(session);
16783                            }
16784                    }
16785    
16786                    return list;
16787            }
16788    
16789            /**
16790             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16791             *
16792             * @param groupId the group ID
16793             * @param userId the user ID
16794             * @param displayDate the display date
16795             * @param status the status
16796             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16797             * @return the first matching blogs entry
16798             * @throws NoSuchEntryException if a matching blogs entry could not be found
16799             */
16800            @Override
16801            public BlogsEntry findByG_U_LtD_S_First(long groupId, long userId,
16802                    Date displayDate, int status,
16803                    OrderByComparator<BlogsEntry> orderByComparator)
16804                    throws NoSuchEntryException {
16805                    BlogsEntry blogsEntry = fetchByG_U_LtD_S_First(groupId, userId,
16806                                    displayDate, status, orderByComparator);
16807    
16808                    if (blogsEntry != null) {
16809                            return blogsEntry;
16810                    }
16811    
16812                    StringBundler msg = new StringBundler(10);
16813    
16814                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
16815    
16816                    msg.append("groupId=");
16817                    msg.append(groupId);
16818    
16819                    msg.append(", userId=");
16820                    msg.append(userId);
16821    
16822                    msg.append(", displayDate=");
16823                    msg.append(displayDate);
16824    
16825                    msg.append(", status=");
16826                    msg.append(status);
16827    
16828                    msg.append(StringPool.CLOSE_CURLY_BRACE);
16829    
16830                    throw new NoSuchEntryException(msg.toString());
16831            }
16832    
16833            /**
16834             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16835             *
16836             * @param groupId the group ID
16837             * @param userId the user ID
16838             * @param displayDate the display date
16839             * @param status the status
16840             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16841             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
16842             */
16843            @Override
16844            public BlogsEntry fetchByG_U_LtD_S_First(long groupId, long userId,
16845                    Date displayDate, int status,
16846                    OrderByComparator<BlogsEntry> orderByComparator) {
16847                    List<BlogsEntry> list = findByG_U_LtD_S(groupId, userId, displayDate,
16848                                    status, 0, 1, orderByComparator);
16849    
16850                    if (!list.isEmpty()) {
16851                            return list.get(0);
16852                    }
16853    
16854                    return null;
16855            }
16856    
16857            /**
16858             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16859             *
16860             * @param groupId the group ID
16861             * @param userId the user ID
16862             * @param displayDate the display date
16863             * @param status the status
16864             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16865             * @return the last matching blogs entry
16866             * @throws NoSuchEntryException if a matching blogs entry could not be found
16867             */
16868            @Override
16869            public BlogsEntry findByG_U_LtD_S_Last(long groupId, long userId,
16870                    Date displayDate, int status,
16871                    OrderByComparator<BlogsEntry> orderByComparator)
16872                    throws NoSuchEntryException {
16873                    BlogsEntry blogsEntry = fetchByG_U_LtD_S_Last(groupId, userId,
16874                                    displayDate, status, orderByComparator);
16875    
16876                    if (blogsEntry != null) {
16877                            return blogsEntry;
16878                    }
16879    
16880                    StringBundler msg = new StringBundler(10);
16881    
16882                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
16883    
16884                    msg.append("groupId=");
16885                    msg.append(groupId);
16886    
16887                    msg.append(", userId=");
16888                    msg.append(userId);
16889    
16890                    msg.append(", displayDate=");
16891                    msg.append(displayDate);
16892    
16893                    msg.append(", status=");
16894                    msg.append(status);
16895    
16896                    msg.append(StringPool.CLOSE_CURLY_BRACE);
16897    
16898                    throw new NoSuchEntryException(msg.toString());
16899            }
16900    
16901            /**
16902             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16903             *
16904             * @param groupId the group ID
16905             * @param userId the user ID
16906             * @param displayDate the display date
16907             * @param status the status
16908             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16909             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
16910             */
16911            @Override
16912            public BlogsEntry fetchByG_U_LtD_S_Last(long groupId, long userId,
16913                    Date displayDate, int status,
16914                    OrderByComparator<BlogsEntry> orderByComparator) {
16915                    int count = countByG_U_LtD_S(groupId, userId, displayDate, status);
16916    
16917                    if (count == 0) {
16918                            return null;
16919                    }
16920    
16921                    List<BlogsEntry> list = findByG_U_LtD_S(groupId, userId, displayDate,
16922                                    status, count - 1, count, orderByComparator);
16923    
16924                    if (!list.isEmpty()) {
16925                            return list.get(0);
16926                    }
16927    
16928                    return null;
16929            }
16930    
16931            /**
16932             * 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;.
16933             *
16934             * @param entryId the primary key of the current blogs entry
16935             * @param groupId the group ID
16936             * @param userId the user ID
16937             * @param displayDate the display date
16938             * @param status the status
16939             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16940             * @return the previous, current, and next blogs entry
16941             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
16942             */
16943            @Override
16944            public BlogsEntry[] findByG_U_LtD_S_PrevAndNext(long entryId, long groupId,
16945                    long userId, Date displayDate, int status,
16946                    OrderByComparator<BlogsEntry> orderByComparator)
16947                    throws NoSuchEntryException {
16948                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
16949    
16950                    Session session = null;
16951    
16952                    try {
16953                            session = openSession();
16954    
16955                            BlogsEntry[] array = new BlogsEntryImpl[3];
16956    
16957                            array[0] = getByG_U_LtD_S_PrevAndNext(session, blogsEntry, groupId,
16958                                            userId, displayDate, status, orderByComparator, true);
16959    
16960                            array[1] = blogsEntry;
16961    
16962                            array[2] = getByG_U_LtD_S_PrevAndNext(session, blogsEntry, groupId,
16963                                            userId, displayDate, status, orderByComparator, false);
16964    
16965                            return array;
16966                    }
16967                    catch (Exception e) {
16968                            throw processException(e);
16969                    }
16970                    finally {
16971                            closeSession(session);
16972                    }
16973            }
16974    
16975            protected BlogsEntry getByG_U_LtD_S_PrevAndNext(Session session,
16976                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
16977                    int status, OrderByComparator<BlogsEntry> orderByComparator,
16978                    boolean previous) {
16979                    StringBundler query = null;
16980    
16981                    if (orderByComparator != null) {
16982                            query = new StringBundler(7 +
16983                                            (orderByComparator.getOrderByConditionFields().length * 3) +
16984                                            (orderByComparator.getOrderByFields().length * 3));
16985                    }
16986                    else {
16987                            query = new StringBundler(6);
16988                    }
16989    
16990                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
16991    
16992                    query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
16993    
16994                    query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
16995    
16996                    boolean bindDisplayDate = false;
16997    
16998                    if (displayDate == null) {
16999                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
17000                    }
17001                    else {
17002                            bindDisplayDate = true;
17003    
17004                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
17005                    }
17006    
17007                    query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
17008    
17009                    if (orderByComparator != null) {
17010                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
17011    
17012                            if (orderByConditionFields.length > 0) {
17013                                    query.append(WHERE_AND);
17014                            }
17015    
17016                            for (int i = 0; i < orderByConditionFields.length; i++) {
17017                                    query.append(_ORDER_BY_ENTITY_ALIAS);
17018                                    query.append(orderByConditionFields[i]);
17019    
17020                                    if ((i + 1) < orderByConditionFields.length) {
17021                                            if (orderByComparator.isAscending() ^ previous) {
17022                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
17023                                            }
17024                                            else {
17025                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
17026                                            }
17027                                    }
17028                                    else {
17029                                            if (orderByComparator.isAscending() ^ previous) {
17030                                                    query.append(WHERE_GREATER_THAN);
17031                                            }
17032                                            else {
17033                                                    query.append(WHERE_LESSER_THAN);
17034                                            }
17035                                    }
17036                            }
17037    
17038                            query.append(ORDER_BY_CLAUSE);
17039    
17040                            String[] orderByFields = orderByComparator.getOrderByFields();
17041    
17042                            for (int i = 0; i < orderByFields.length; i++) {
17043                                    query.append(_ORDER_BY_ENTITY_ALIAS);
17044                                    query.append(orderByFields[i]);
17045    
17046                                    if ((i + 1) < orderByFields.length) {
17047                                            if (orderByComparator.isAscending() ^ previous) {
17048                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
17049                                            }
17050                                            else {
17051                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
17052                                            }
17053                                    }
17054                                    else {
17055                                            if (orderByComparator.isAscending() ^ previous) {
17056                                                    query.append(ORDER_BY_ASC);
17057                                            }
17058                                            else {
17059                                                    query.append(ORDER_BY_DESC);
17060                                            }
17061                                    }
17062                            }
17063                    }
17064                    else {
17065                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
17066                    }
17067    
17068                    String sql = query.toString();
17069    
17070                    Query q = session.createQuery(sql);
17071    
17072                    q.setFirstResult(0);
17073                    q.setMaxResults(2);
17074    
17075                    QueryPos qPos = QueryPos.getInstance(q);
17076    
17077                    qPos.add(groupId);
17078    
17079                    qPos.add(userId);
17080    
17081                    if (bindDisplayDate) {
17082                            qPos.add(new Timestamp(displayDate.getTime()));
17083                    }
17084    
17085                    qPos.add(status);
17086    
17087                    if (orderByComparator != null) {
17088                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
17089    
17090                            for (Object value : values) {
17091                                    qPos.add(value);
17092                            }
17093                    }
17094    
17095                    List<BlogsEntry> list = q.list();
17096    
17097                    if (list.size() == 2) {
17098                            return list.get(1);
17099                    }
17100                    else {
17101                            return null;
17102                    }
17103            }
17104    
17105            /**
17106             * 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;.
17107             *
17108             * @param groupId the group ID
17109             * @param userId the user ID
17110             * @param displayDate the display date
17111             * @param status the status
17112             * @return the matching blogs entries that the user has permission to view
17113             */
17114            @Override
17115            public List<BlogsEntry> filterFindByG_U_LtD_S(long groupId, long userId,
17116                    Date displayDate, int status) {
17117                    return filterFindByG_U_LtD_S(groupId, userId, displayDate, status,
17118                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
17119            }
17120    
17121            /**
17122             * 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;.
17123             *
17124             * <p>
17125             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
17126             * </p>
17127             *
17128             * @param groupId the group ID
17129             * @param userId the user ID
17130             * @param displayDate the display date
17131             * @param status the status
17132             * @param start the lower bound of the range of blogs entries
17133             * @param end the upper bound of the range of blogs entries (not inclusive)
17134             * @return the range of matching blogs entries that the user has permission to view
17135             */
17136            @Override
17137            public List<BlogsEntry> filterFindByG_U_LtD_S(long groupId, long userId,
17138                    Date displayDate, int status, int start, int end) {
17139                    return filterFindByG_U_LtD_S(groupId, userId, displayDate, status,
17140                            start, end, null);
17141            }
17142    
17143            /**
17144             * 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;.
17145             *
17146             * <p>
17147             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
17148             * </p>
17149             *
17150             * @param groupId the group ID
17151             * @param userId the user ID
17152             * @param displayDate the display date
17153             * @param status the status
17154             * @param start the lower bound of the range of blogs entries
17155             * @param end the upper bound of the range of blogs entries (not inclusive)
17156             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
17157             * @return the ordered range of matching blogs entries that the user has permission to view
17158             */
17159            @Override
17160            public List<BlogsEntry> filterFindByG_U_LtD_S(long groupId, long userId,
17161                    Date displayDate, int status, int start, int end,
17162                    OrderByComparator<BlogsEntry> orderByComparator) {
17163                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17164                            return findByG_U_LtD_S(groupId, userId, displayDate, status, start,
17165                                    end, orderByComparator);
17166                    }
17167    
17168                    StringBundler query = null;
17169    
17170                    if (orderByComparator != null) {
17171                            query = new StringBundler(6 +
17172                                            (orderByComparator.getOrderByFields().length * 2));
17173                    }
17174                    else {
17175                            query = new StringBundler(7);
17176                    }
17177    
17178                    if (getDB().isSupportsInlineDistinct()) {
17179                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
17180                    }
17181                    else {
17182                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
17183                    }
17184    
17185                    query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
17186    
17187                    query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
17188    
17189                    boolean bindDisplayDate = false;
17190    
17191                    if (displayDate == null) {
17192                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
17193                    }
17194                    else {
17195                            bindDisplayDate = true;
17196    
17197                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
17198                    }
17199    
17200                    query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
17201    
17202                    if (!getDB().isSupportsInlineDistinct()) {
17203                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
17204                    }
17205    
17206                    if (orderByComparator != null) {
17207                            if (getDB().isSupportsInlineDistinct()) {
17208                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
17209                                            orderByComparator, true);
17210                            }
17211                            else {
17212                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
17213                                            orderByComparator, true);
17214                            }
17215                    }
17216                    else {
17217                            if (getDB().isSupportsInlineDistinct()) {
17218                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
17219                            }
17220                            else {
17221                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
17222                            }
17223                    }
17224    
17225                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17226                                    BlogsEntry.class.getName(),
17227                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17228    
17229                    Session session = null;
17230    
17231                    try {
17232                            session = openSession();
17233    
17234                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
17235    
17236                            if (getDB().isSupportsInlineDistinct()) {
17237                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
17238                            }
17239                            else {
17240                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
17241                            }
17242    
17243                            QueryPos qPos = QueryPos.getInstance(q);
17244    
17245                            qPos.add(groupId);
17246    
17247                            qPos.add(userId);
17248    
17249                            if (bindDisplayDate) {
17250                                    qPos.add(new Timestamp(displayDate.getTime()));
17251                            }
17252    
17253                            qPos.add(status);
17254    
17255                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
17256                    }
17257                    catch (Exception e) {
17258                            throw processException(e);
17259                    }
17260                    finally {
17261                            closeSession(session);
17262                    }
17263            }
17264    
17265            /**
17266             * 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;.
17267             *
17268             * @param entryId the primary key of the current blogs entry
17269             * @param groupId the group ID
17270             * @param userId the user ID
17271             * @param displayDate the display date
17272             * @param status the status
17273             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17274             * @return the previous, current, and next blogs entry
17275             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
17276             */
17277            @Override
17278            public BlogsEntry[] filterFindByG_U_LtD_S_PrevAndNext(long entryId,
17279                    long groupId, long userId, Date displayDate, int status,
17280                    OrderByComparator<BlogsEntry> orderByComparator)
17281                    throws NoSuchEntryException {
17282                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17283                            return findByG_U_LtD_S_PrevAndNext(entryId, groupId, userId,
17284                                    displayDate, status, orderByComparator);
17285                    }
17286    
17287                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
17288    
17289                    Session session = null;
17290    
17291                    try {
17292                            session = openSession();
17293    
17294                            BlogsEntry[] array = new BlogsEntryImpl[3];
17295    
17296                            array[0] = filterGetByG_U_LtD_S_PrevAndNext(session, blogsEntry,
17297                                            groupId, userId, displayDate, status, orderByComparator,
17298                                            true);
17299    
17300                            array[1] = blogsEntry;
17301    
17302                            array[2] = filterGetByG_U_LtD_S_PrevAndNext(session, blogsEntry,
17303                                            groupId, userId, displayDate, status, orderByComparator,
17304                                            false);
17305    
17306                            return array;
17307                    }
17308                    catch (Exception e) {
17309                            throw processException(e);
17310                    }
17311                    finally {
17312                            closeSession(session);
17313                    }
17314            }
17315    
17316            protected BlogsEntry filterGetByG_U_LtD_S_PrevAndNext(Session session,
17317                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
17318                    int status, OrderByComparator<BlogsEntry> orderByComparator,
17319                    boolean previous) {
17320                    StringBundler query = null;
17321    
17322                    if (orderByComparator != null) {
17323                            query = new StringBundler(8 +
17324                                            (orderByComparator.getOrderByConditionFields().length * 3) +
17325                                            (orderByComparator.getOrderByFields().length * 3));
17326                    }
17327                    else {
17328                            query = new StringBundler(7);
17329                    }
17330    
17331                    if (getDB().isSupportsInlineDistinct()) {
17332                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
17333                    }
17334                    else {
17335                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
17336                    }
17337    
17338                    query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
17339    
17340                    query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
17341    
17342                    boolean bindDisplayDate = false;
17343    
17344                    if (displayDate == null) {
17345                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
17346                    }
17347                    else {
17348                            bindDisplayDate = true;
17349    
17350                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
17351                    }
17352    
17353                    query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
17354    
17355                    if (!getDB().isSupportsInlineDistinct()) {
17356                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
17357                    }
17358    
17359                    if (orderByComparator != null) {
17360                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
17361    
17362                            if (orderByConditionFields.length > 0) {
17363                                    query.append(WHERE_AND);
17364                            }
17365    
17366                            for (int i = 0; i < orderByConditionFields.length; i++) {
17367                                    if (getDB().isSupportsInlineDistinct()) {
17368                                            query.append(_ORDER_BY_ENTITY_ALIAS);
17369                                    }
17370                                    else {
17371                                            query.append(_ORDER_BY_ENTITY_TABLE);
17372                                    }
17373    
17374                                    query.append(orderByConditionFields[i]);
17375    
17376                                    if ((i + 1) < orderByConditionFields.length) {
17377                                            if (orderByComparator.isAscending() ^ previous) {
17378                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
17379                                            }
17380                                            else {
17381                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
17382                                            }
17383                                    }
17384                                    else {
17385                                            if (orderByComparator.isAscending() ^ previous) {
17386                                                    query.append(WHERE_GREATER_THAN);
17387                                            }
17388                                            else {
17389                                                    query.append(WHERE_LESSER_THAN);
17390                                            }
17391                                    }
17392                            }
17393    
17394                            query.append(ORDER_BY_CLAUSE);
17395    
17396                            String[] orderByFields = orderByComparator.getOrderByFields();
17397    
17398                            for (int i = 0; i < orderByFields.length; i++) {
17399                                    if (getDB().isSupportsInlineDistinct()) {
17400                                            query.append(_ORDER_BY_ENTITY_ALIAS);
17401                                    }
17402                                    else {
17403                                            query.append(_ORDER_BY_ENTITY_TABLE);
17404                                    }
17405    
17406                                    query.append(orderByFields[i]);
17407    
17408                                    if ((i + 1) < orderByFields.length) {
17409                                            if (orderByComparator.isAscending() ^ previous) {
17410                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
17411                                            }
17412                                            else {
17413                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
17414                                            }
17415                                    }
17416                                    else {
17417                                            if (orderByComparator.isAscending() ^ previous) {
17418                                                    query.append(ORDER_BY_ASC);
17419                                            }
17420                                            else {
17421                                                    query.append(ORDER_BY_DESC);
17422                                            }
17423                                    }
17424                            }
17425                    }
17426                    else {
17427                            if (getDB().isSupportsInlineDistinct()) {
17428                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
17429                            }
17430                            else {
17431                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
17432                            }
17433                    }
17434    
17435                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17436                                    BlogsEntry.class.getName(),
17437                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17438    
17439                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
17440    
17441                    q.setFirstResult(0);
17442                    q.setMaxResults(2);
17443    
17444                    if (getDB().isSupportsInlineDistinct()) {
17445                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
17446                    }
17447                    else {
17448                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
17449                    }
17450    
17451                    QueryPos qPos = QueryPos.getInstance(q);
17452    
17453                    qPos.add(groupId);
17454    
17455                    qPos.add(userId);
17456    
17457                    if (bindDisplayDate) {
17458                            qPos.add(new Timestamp(displayDate.getTime()));
17459                    }
17460    
17461                    qPos.add(status);
17462    
17463                    if (orderByComparator != null) {
17464                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
17465    
17466                            for (Object value : values) {
17467                                    qPos.add(value);
17468                            }
17469                    }
17470    
17471                    List<BlogsEntry> list = q.list();
17472    
17473                    if (list.size() == 2) {
17474                            return list.get(1);
17475                    }
17476                    else {
17477                            return null;
17478                    }
17479            }
17480    
17481            /**
17482             * Removes all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63; from the database.
17483             *
17484             * @param groupId the group ID
17485             * @param userId the user ID
17486             * @param displayDate the display date
17487             * @param status the status
17488             */
17489            @Override
17490            public void removeByG_U_LtD_S(long groupId, long userId, Date displayDate,
17491                    int status) {
17492                    for (BlogsEntry blogsEntry : findByG_U_LtD_S(groupId, userId,
17493                                    displayDate, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
17494                            remove(blogsEntry);
17495                    }
17496            }
17497    
17498            /**
17499             * Returns the number of blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
17500             *
17501             * @param groupId the group ID
17502             * @param userId the user ID
17503             * @param displayDate the display date
17504             * @param status the status
17505             * @return the number of matching blogs entries
17506             */
17507            @Override
17508            public int countByG_U_LtD_S(long groupId, long userId, Date displayDate,
17509                    int status) {
17510                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD_S;
17511    
17512                    Object[] finderArgs = new Object[] { groupId, userId, displayDate, status };
17513    
17514                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
17515    
17516                    if (count == null) {
17517                            StringBundler query = new StringBundler(5);
17518    
17519                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
17520    
17521                            query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
17522    
17523                            query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
17524    
17525                            boolean bindDisplayDate = false;
17526    
17527                            if (displayDate == null) {
17528                                    query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
17529                            }
17530                            else {
17531                                    bindDisplayDate = true;
17532    
17533                                    query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
17534                            }
17535    
17536                            query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
17537    
17538                            String sql = query.toString();
17539    
17540                            Session session = null;
17541    
17542                            try {
17543                                    session = openSession();
17544    
17545                                    Query q = session.createQuery(sql);
17546    
17547                                    QueryPos qPos = QueryPos.getInstance(q);
17548    
17549                                    qPos.add(groupId);
17550    
17551                                    qPos.add(userId);
17552    
17553                                    if (bindDisplayDate) {
17554                                            qPos.add(new Timestamp(displayDate.getTime()));
17555                                    }
17556    
17557                                    qPos.add(status);
17558    
17559                                    count = (Long)q.uniqueResult();
17560    
17561                                    finderCache.putResult(finderPath, finderArgs, count);
17562                            }
17563                            catch (Exception e) {
17564                                    finderCache.removeResult(finderPath, finderArgs);
17565    
17566                                    throw processException(e);
17567                            }
17568                            finally {
17569                                    closeSession(session);
17570                            }
17571                    }
17572    
17573                    return count.intValue();
17574            }
17575    
17576            /**
17577             * 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;.
17578             *
17579             * @param groupId the group ID
17580             * @param userId the user ID
17581             * @param displayDate the display date
17582             * @param status the status
17583             * @return the number of matching blogs entries that the user has permission to view
17584             */
17585            @Override
17586            public int filterCountByG_U_LtD_S(long groupId, long userId,
17587                    Date displayDate, int status) {
17588                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17589                            return countByG_U_LtD_S(groupId, userId, displayDate, status);
17590                    }
17591    
17592                    StringBundler query = new StringBundler(5);
17593    
17594                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
17595    
17596                    query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
17597    
17598                    query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
17599    
17600                    boolean bindDisplayDate = false;
17601    
17602                    if (displayDate == null) {
17603                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
17604                    }
17605                    else {
17606                            bindDisplayDate = true;
17607    
17608                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
17609                    }
17610    
17611                    query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
17612    
17613                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17614                                    BlogsEntry.class.getName(),
17615                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17616    
17617                    Session session = null;
17618    
17619                    try {
17620                            session = openSession();
17621    
17622                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
17623    
17624                            q.addScalar(COUNT_COLUMN_NAME,
17625                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
17626    
17627                            QueryPos qPos = QueryPos.getInstance(q);
17628    
17629                            qPos.add(groupId);
17630    
17631                            qPos.add(userId);
17632    
17633                            if (bindDisplayDate) {
17634                                    qPos.add(new Timestamp(displayDate.getTime()));
17635                            }
17636    
17637                            qPos.add(status);
17638    
17639                            Long count = (Long)q.uniqueResult();
17640    
17641                            return count.intValue();
17642                    }
17643                    catch (Exception e) {
17644                            throw processException(e);
17645                    }
17646                    finally {
17647                            closeSession(session);
17648                    }
17649            }
17650    
17651            private static final String _FINDER_COLUMN_G_U_LTD_S_GROUPID_2 = "blogsEntry.groupId = ? AND ";
17652            private static final String _FINDER_COLUMN_G_U_LTD_S_USERID_2 = "blogsEntry.userId = ? AND ";
17653            private static final String _FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1 = "blogsEntry.displayDate IS NULL AND ";
17654            private static final String _FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
17655            private static final String _FINDER_COLUMN_G_U_LTD_S_STATUS_2 = "blogsEntry.status = ?";
17656            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD_NOTS =
17657                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
17658                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
17659                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_LtD_NotS",
17660                            new String[] {
17661                                    Long.class.getName(), Long.class.getName(), Date.class.getName(),
17662                                    Integer.class.getName(),
17663                                    
17664                            Integer.class.getName(), Integer.class.getName(),
17665                                    OrderByComparator.class.getName()
17666                            });
17667            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD_NOTS =
17668                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
17669                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
17670                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_U_LtD_NotS",
17671                            new String[] {
17672                                    Long.class.getName(), Long.class.getName(), Date.class.getName(),
17673                                    Integer.class.getName()
17674                            });
17675    
17676            /**
17677             * Returns all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
17678             *
17679             * @param groupId the group ID
17680             * @param userId the user ID
17681             * @param displayDate the display date
17682             * @param status the status
17683             * @return the matching blogs entries
17684             */
17685            @Override
17686            public List<BlogsEntry> findByG_U_LtD_NotS(long groupId, long userId,
17687                    Date displayDate, int status) {
17688                    return findByG_U_LtD_NotS(groupId, userId, displayDate, status,
17689                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
17690            }
17691    
17692            /**
17693             * Returns a range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
17694             *
17695             * <p>
17696             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
17697             * </p>
17698             *
17699             * @param groupId the group ID
17700             * @param userId the user ID
17701             * @param displayDate the display date
17702             * @param status the status
17703             * @param start the lower bound of the range of blogs entries
17704             * @param end the upper bound of the range of blogs entries (not inclusive)
17705             * @return the range of matching blogs entries
17706             */
17707            @Override
17708            public List<BlogsEntry> findByG_U_LtD_NotS(long groupId, long userId,
17709                    Date displayDate, int status, int start, int end) {
17710                    return findByG_U_LtD_NotS(groupId, userId, displayDate, status, start,
17711                            end, null);
17712            }
17713    
17714            /**
17715             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
17716             *
17717             * <p>
17718             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
17719             * </p>
17720             *
17721             * @param groupId the group ID
17722             * @param userId the user ID
17723             * @param displayDate the display date
17724             * @param status the status
17725             * @param start the lower bound of the range of blogs entries
17726             * @param end the upper bound of the range of blogs entries (not inclusive)
17727             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
17728             * @return the ordered range of matching blogs entries
17729             */
17730            @Override
17731            public List<BlogsEntry> findByG_U_LtD_NotS(long groupId, long userId,
17732                    Date displayDate, int status, int start, int end,
17733                    OrderByComparator<BlogsEntry> orderByComparator) {
17734                    return findByG_U_LtD_NotS(groupId, userId, displayDate, status, start,
17735                            end, orderByComparator, true);
17736            }
17737    
17738            /**
17739             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
17740             *
17741             * <p>
17742             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
17743             * </p>
17744             *
17745             * @param groupId the group ID
17746             * @param userId the user ID
17747             * @param displayDate the display date
17748             * @param status the status
17749             * @param start the lower bound of the range of blogs entries
17750             * @param end the upper bound of the range of blogs entries (not inclusive)
17751             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
17752             * @param retrieveFromCache whether to retrieve from the finder cache
17753             * @return the ordered range of matching blogs entries
17754             */
17755            @Override
17756            public List<BlogsEntry> findByG_U_LtD_NotS(long groupId, long userId,
17757                    Date displayDate, int status, int start, int end,
17758                    OrderByComparator<BlogsEntry> orderByComparator,
17759                    boolean retrieveFromCache) {
17760                    boolean pagination = true;
17761                    FinderPath finderPath = null;
17762                    Object[] finderArgs = null;
17763    
17764                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD_NOTS;
17765                    finderArgs = new Object[] {
17766                                    groupId, userId, displayDate, status,
17767                                    
17768                                    start, end, orderByComparator
17769                            };
17770    
17771                    List<BlogsEntry> list = null;
17772    
17773                    if (retrieveFromCache) {
17774                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
17775                                            finderArgs, this);
17776    
17777                            if ((list != null) && !list.isEmpty()) {
17778                                    for (BlogsEntry blogsEntry : list) {
17779                                            if ((groupId != blogsEntry.getGroupId()) ||
17780                                                            (userId != blogsEntry.getUserId()) ||
17781                                                            (displayDate.getTime() <= blogsEntry.getDisplayDate()
17782                                                                                                                                            .getTime()) ||
17783                                                            (status == blogsEntry.getStatus())) {
17784                                                    list = null;
17785    
17786                                                    break;
17787                                            }
17788                                    }
17789                            }
17790                    }
17791    
17792                    if (list == null) {
17793                            StringBundler query = null;
17794    
17795                            if (orderByComparator != null) {
17796                                    query = new StringBundler(6 +
17797                                                    (orderByComparator.getOrderByFields().length * 2));
17798                            }
17799                            else {
17800                                    query = new StringBundler(6);
17801                            }
17802    
17803                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
17804    
17805                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
17806    
17807                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
17808    
17809                            boolean bindDisplayDate = false;
17810    
17811                            if (displayDate == null) {
17812                                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
17813                            }
17814                            else {
17815                                    bindDisplayDate = true;
17816    
17817                                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
17818                            }
17819    
17820                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
17821    
17822                            if (orderByComparator != null) {
17823                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
17824                                            orderByComparator);
17825                            }
17826                            else
17827                             if (pagination) {
17828                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
17829                            }
17830    
17831                            String sql = query.toString();
17832    
17833                            Session session = null;
17834    
17835                            try {
17836                                    session = openSession();
17837    
17838                                    Query q = session.createQuery(sql);
17839    
17840                                    QueryPos qPos = QueryPos.getInstance(q);
17841    
17842                                    qPos.add(groupId);
17843    
17844                                    qPos.add(userId);
17845    
17846                                    if (bindDisplayDate) {
17847                                            qPos.add(new Timestamp(displayDate.getTime()));
17848                                    }
17849    
17850                                    qPos.add(status);
17851    
17852                                    if (!pagination) {
17853                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
17854                                                            start, end, false);
17855    
17856                                            Collections.sort(list);
17857    
17858                                            list = Collections.unmodifiableList(list);
17859                                    }
17860                                    else {
17861                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
17862                                                            start, end);
17863                                    }
17864    
17865                                    cacheResult(list);
17866    
17867                                    finderCache.putResult(finderPath, finderArgs, list);
17868                            }
17869                            catch (Exception e) {
17870                                    finderCache.removeResult(finderPath, finderArgs);
17871    
17872                                    throw processException(e);
17873                            }
17874                            finally {
17875                                    closeSession(session);
17876                            }
17877                    }
17878    
17879                    return list;
17880            }
17881    
17882            /**
17883             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
17884             *
17885             * @param groupId the group ID
17886             * @param userId the user ID
17887             * @param displayDate the display date
17888             * @param status the status
17889             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17890             * @return the first matching blogs entry
17891             * @throws NoSuchEntryException if a matching blogs entry could not be found
17892             */
17893            @Override
17894            public BlogsEntry findByG_U_LtD_NotS_First(long groupId, long userId,
17895                    Date displayDate, int status,
17896                    OrderByComparator<BlogsEntry> orderByComparator)
17897                    throws NoSuchEntryException {
17898                    BlogsEntry blogsEntry = fetchByG_U_LtD_NotS_First(groupId, userId,
17899                                    displayDate, status, orderByComparator);
17900    
17901                    if (blogsEntry != null) {
17902                            return blogsEntry;
17903                    }
17904    
17905                    StringBundler msg = new StringBundler(10);
17906    
17907                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
17908    
17909                    msg.append("groupId=");
17910                    msg.append(groupId);
17911    
17912                    msg.append(", userId=");
17913                    msg.append(userId);
17914    
17915                    msg.append(", displayDate=");
17916                    msg.append(displayDate);
17917    
17918                    msg.append(", status=");
17919                    msg.append(status);
17920    
17921                    msg.append(StringPool.CLOSE_CURLY_BRACE);
17922    
17923                    throw new NoSuchEntryException(msg.toString());
17924            }
17925    
17926            /**
17927             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
17928             *
17929             * @param groupId the group ID
17930             * @param userId the user ID
17931             * @param displayDate the display date
17932             * @param status the status
17933             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17934             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
17935             */
17936            @Override
17937            public BlogsEntry fetchByG_U_LtD_NotS_First(long groupId, long userId,
17938                    Date displayDate, int status,
17939                    OrderByComparator<BlogsEntry> orderByComparator) {
17940                    List<BlogsEntry> list = findByG_U_LtD_NotS(groupId, userId,
17941                                    displayDate, status, 0, 1, orderByComparator);
17942    
17943                    if (!list.isEmpty()) {
17944                            return list.get(0);
17945                    }
17946    
17947                    return null;
17948            }
17949    
17950            /**
17951             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
17952             *
17953             * @param groupId the group ID
17954             * @param userId the user ID
17955             * @param displayDate the display date
17956             * @param status the status
17957             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17958             * @return the last matching blogs entry
17959             * @throws NoSuchEntryException if a matching blogs entry could not be found
17960             */
17961            @Override
17962            public BlogsEntry findByG_U_LtD_NotS_Last(long groupId, long userId,
17963                    Date displayDate, int status,
17964                    OrderByComparator<BlogsEntry> orderByComparator)
17965                    throws NoSuchEntryException {
17966                    BlogsEntry blogsEntry = fetchByG_U_LtD_NotS_Last(groupId, userId,
17967                                    displayDate, status, orderByComparator);
17968    
17969                    if (blogsEntry != null) {
17970                            return blogsEntry;
17971                    }
17972    
17973                    StringBundler msg = new StringBundler(10);
17974    
17975                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
17976    
17977                    msg.append("groupId=");
17978                    msg.append(groupId);
17979    
17980                    msg.append(", userId=");
17981                    msg.append(userId);
17982    
17983                    msg.append(", displayDate=");
17984                    msg.append(displayDate);
17985    
17986                    msg.append(", status=");
17987                    msg.append(status);
17988    
17989                    msg.append(StringPool.CLOSE_CURLY_BRACE);
17990    
17991                    throw new NoSuchEntryException(msg.toString());
17992            }
17993    
17994            /**
17995             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
17996             *
17997             * @param groupId the group ID
17998             * @param userId the user ID
17999             * @param displayDate the display date
18000             * @param status the status
18001             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18002             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
18003             */
18004            @Override
18005            public BlogsEntry fetchByG_U_LtD_NotS_Last(long groupId, long userId,
18006                    Date displayDate, int status,
18007                    OrderByComparator<BlogsEntry> orderByComparator) {
18008                    int count = countByG_U_LtD_NotS(groupId, userId, displayDate, status);
18009    
18010                    if (count == 0) {
18011                            return null;
18012                    }
18013    
18014                    List<BlogsEntry> list = findByG_U_LtD_NotS(groupId, userId,
18015                                    displayDate, status, count - 1, count, orderByComparator);
18016    
18017                    if (!list.isEmpty()) {
18018                            return list.get(0);
18019                    }
18020    
18021                    return null;
18022            }
18023    
18024            /**
18025             * 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;.
18026             *
18027             * @param entryId the primary key of the current blogs entry
18028             * @param groupId the group ID
18029             * @param userId the user ID
18030             * @param displayDate the display date
18031             * @param status the status
18032             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18033             * @return the previous, current, and next blogs entry
18034             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
18035             */
18036            @Override
18037            public BlogsEntry[] findByG_U_LtD_NotS_PrevAndNext(long entryId,
18038                    long groupId, long userId, Date displayDate, int status,
18039                    OrderByComparator<BlogsEntry> orderByComparator)
18040                    throws NoSuchEntryException {
18041                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
18042    
18043                    Session session = null;
18044    
18045                    try {
18046                            session = openSession();
18047    
18048                            BlogsEntry[] array = new BlogsEntryImpl[3];
18049    
18050                            array[0] = getByG_U_LtD_NotS_PrevAndNext(session, blogsEntry,
18051                                            groupId, userId, displayDate, status, orderByComparator,
18052                                            true);
18053    
18054                            array[1] = blogsEntry;
18055    
18056                            array[2] = getByG_U_LtD_NotS_PrevAndNext(session, blogsEntry,
18057                                            groupId, userId, displayDate, status, orderByComparator,
18058                                            false);
18059    
18060                            return array;
18061                    }
18062                    catch (Exception e) {
18063                            throw processException(e);
18064                    }
18065                    finally {
18066                            closeSession(session);
18067                    }
18068            }
18069    
18070            protected BlogsEntry getByG_U_LtD_NotS_PrevAndNext(Session session,
18071                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
18072                    int status, OrderByComparator<BlogsEntry> orderByComparator,
18073                    boolean previous) {
18074                    StringBundler query = null;
18075    
18076                    if (orderByComparator != null) {
18077                            query = new StringBundler(7 +
18078                                            (orderByComparator.getOrderByConditionFields().length * 3) +
18079                                            (orderByComparator.getOrderByFields().length * 3));
18080                    }
18081                    else {
18082                            query = new StringBundler(6);
18083                    }
18084    
18085                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
18086    
18087                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
18088    
18089                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
18090    
18091                    boolean bindDisplayDate = false;
18092    
18093                    if (displayDate == null) {
18094                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
18095                    }
18096                    else {
18097                            bindDisplayDate = true;
18098    
18099                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
18100                    }
18101    
18102                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
18103    
18104                    if (orderByComparator != null) {
18105                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
18106    
18107                            if (orderByConditionFields.length > 0) {
18108                                    query.append(WHERE_AND);
18109                            }
18110    
18111                            for (int i = 0; i < orderByConditionFields.length; i++) {
18112                                    query.append(_ORDER_BY_ENTITY_ALIAS);
18113                                    query.append(orderByConditionFields[i]);
18114    
18115                                    if ((i + 1) < orderByConditionFields.length) {
18116                                            if (orderByComparator.isAscending() ^ previous) {
18117                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
18118                                            }
18119                                            else {
18120                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
18121                                            }
18122                                    }
18123                                    else {
18124                                            if (orderByComparator.isAscending() ^ previous) {
18125                                                    query.append(WHERE_GREATER_THAN);
18126                                            }
18127                                            else {
18128                                                    query.append(WHERE_LESSER_THAN);
18129                                            }
18130                                    }
18131                            }
18132    
18133                            query.append(ORDER_BY_CLAUSE);
18134    
18135                            String[] orderByFields = orderByComparator.getOrderByFields();
18136    
18137                            for (int i = 0; i < orderByFields.length; i++) {
18138                                    query.append(_ORDER_BY_ENTITY_ALIAS);
18139                                    query.append(orderByFields[i]);
18140    
18141                                    if ((i + 1) < orderByFields.length) {
18142                                            if (orderByComparator.isAscending() ^ previous) {
18143                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
18144                                            }
18145                                            else {
18146                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
18147                                            }
18148                                    }
18149                                    else {
18150                                            if (orderByComparator.isAscending() ^ previous) {
18151                                                    query.append(ORDER_BY_ASC);
18152                                            }
18153                                            else {
18154                                                    query.append(ORDER_BY_DESC);
18155                                            }
18156                                    }
18157                            }
18158                    }
18159                    else {
18160                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
18161                    }
18162    
18163                    String sql = query.toString();
18164    
18165                    Query q = session.createQuery(sql);
18166    
18167                    q.setFirstResult(0);
18168                    q.setMaxResults(2);
18169    
18170                    QueryPos qPos = QueryPos.getInstance(q);
18171    
18172                    qPos.add(groupId);
18173    
18174                    qPos.add(userId);
18175    
18176                    if (bindDisplayDate) {
18177                            qPos.add(new Timestamp(displayDate.getTime()));
18178                    }
18179    
18180                    qPos.add(status);
18181    
18182                    if (orderByComparator != null) {
18183                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
18184    
18185                            for (Object value : values) {
18186                                    qPos.add(value);
18187                            }
18188                    }
18189    
18190                    List<BlogsEntry> list = q.list();
18191    
18192                    if (list.size() == 2) {
18193                            return list.get(1);
18194                    }
18195                    else {
18196                            return null;
18197                    }
18198            }
18199    
18200            /**
18201             * 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;.
18202             *
18203             * @param groupId the group ID
18204             * @param userId the user ID
18205             * @param displayDate the display date
18206             * @param status the status
18207             * @return the matching blogs entries that the user has permission to view
18208             */
18209            @Override
18210            public List<BlogsEntry> filterFindByG_U_LtD_NotS(long groupId, long userId,
18211                    Date displayDate, int status) {
18212                    return filterFindByG_U_LtD_NotS(groupId, userId, displayDate, status,
18213                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
18214            }
18215    
18216            /**
18217             * 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;.
18218             *
18219             * <p>
18220             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
18221             * </p>
18222             *
18223             * @param groupId the group ID
18224             * @param userId the user ID
18225             * @param displayDate the display date
18226             * @param status the status
18227             * @param start the lower bound of the range of blogs entries
18228             * @param end the upper bound of the range of blogs entries (not inclusive)
18229             * @return the range of matching blogs entries that the user has permission to view
18230             */
18231            @Override
18232            public List<BlogsEntry> filterFindByG_U_LtD_NotS(long groupId, long userId,
18233                    Date displayDate, int status, int start, int end) {
18234                    return filterFindByG_U_LtD_NotS(groupId, userId, displayDate, status,
18235                            start, end, null);
18236            }
18237    
18238            /**
18239             * 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;.
18240             *
18241             * <p>
18242             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
18243             * </p>
18244             *
18245             * @param groupId the group ID
18246             * @param userId the user ID
18247             * @param displayDate the display date
18248             * @param status the status
18249             * @param start the lower bound of the range of blogs entries
18250             * @param end the upper bound of the range of blogs entries (not inclusive)
18251             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
18252             * @return the ordered range of matching blogs entries that the user has permission to view
18253             */
18254            @Override
18255            public List<BlogsEntry> filterFindByG_U_LtD_NotS(long groupId, long userId,
18256                    Date displayDate, int status, int start, int end,
18257                    OrderByComparator<BlogsEntry> orderByComparator) {
18258                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
18259                            return findByG_U_LtD_NotS(groupId, userId, displayDate, status,
18260                                    start, end, orderByComparator);
18261                    }
18262    
18263                    StringBundler query = null;
18264    
18265                    if (orderByComparator != null) {
18266                            query = new StringBundler(6 +
18267                                            (orderByComparator.getOrderByFields().length * 2));
18268                    }
18269                    else {
18270                            query = new StringBundler(7);
18271                    }
18272    
18273                    if (getDB().isSupportsInlineDistinct()) {
18274                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
18275                    }
18276                    else {
18277                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
18278                    }
18279    
18280                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
18281    
18282                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
18283    
18284                    boolean bindDisplayDate = false;
18285    
18286                    if (displayDate == null) {
18287                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
18288                    }
18289                    else {
18290                            bindDisplayDate = true;
18291    
18292                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
18293                    }
18294    
18295                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
18296    
18297                    if (!getDB().isSupportsInlineDistinct()) {
18298                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
18299                    }
18300    
18301                    if (orderByComparator != null) {
18302                            if (getDB().isSupportsInlineDistinct()) {
18303                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
18304                                            orderByComparator, true);
18305                            }
18306                            else {
18307                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
18308                                            orderByComparator, true);
18309                            }
18310                    }
18311                    else {
18312                            if (getDB().isSupportsInlineDistinct()) {
18313                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
18314                            }
18315                            else {
18316                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
18317                            }
18318                    }
18319    
18320                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
18321                                    BlogsEntry.class.getName(),
18322                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
18323    
18324                    Session session = null;
18325    
18326                    try {
18327                            session = openSession();
18328    
18329                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
18330    
18331                            if (getDB().isSupportsInlineDistinct()) {
18332                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
18333                            }
18334                            else {
18335                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
18336                            }
18337    
18338                            QueryPos qPos = QueryPos.getInstance(q);
18339    
18340                            qPos.add(groupId);
18341    
18342                            qPos.add(userId);
18343    
18344                            if (bindDisplayDate) {
18345                                    qPos.add(new Timestamp(displayDate.getTime()));
18346                            }
18347    
18348                            qPos.add(status);
18349    
18350                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
18351                    }
18352                    catch (Exception e) {
18353                            throw processException(e);
18354                    }
18355                    finally {
18356                            closeSession(session);
18357                    }
18358            }
18359    
18360            /**
18361             * 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;.
18362             *
18363             * @param entryId the primary key of the current blogs entry
18364             * @param groupId the group ID
18365             * @param userId the user ID
18366             * @param displayDate the display date
18367             * @param status the status
18368             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18369             * @return the previous, current, and next blogs entry
18370             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
18371             */
18372            @Override
18373            public BlogsEntry[] filterFindByG_U_LtD_NotS_PrevAndNext(long entryId,
18374                    long groupId, long userId, Date displayDate, int status,
18375                    OrderByComparator<BlogsEntry> orderByComparator)
18376                    throws NoSuchEntryException {
18377                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
18378                            return findByG_U_LtD_NotS_PrevAndNext(entryId, groupId, userId,
18379                                    displayDate, status, orderByComparator);
18380                    }
18381    
18382                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
18383    
18384                    Session session = null;
18385    
18386                    try {
18387                            session = openSession();
18388    
18389                            BlogsEntry[] array = new BlogsEntryImpl[3];
18390    
18391                            array[0] = filterGetByG_U_LtD_NotS_PrevAndNext(session, blogsEntry,
18392                                            groupId, userId, displayDate, status, orderByComparator,
18393                                            true);
18394    
18395                            array[1] = blogsEntry;
18396    
18397                            array[2] = filterGetByG_U_LtD_NotS_PrevAndNext(session, blogsEntry,
18398                                            groupId, userId, displayDate, status, orderByComparator,
18399                                            false);
18400    
18401                            return array;
18402                    }
18403                    catch (Exception e) {
18404                            throw processException(e);
18405                    }
18406                    finally {
18407                            closeSession(session);
18408                    }
18409            }
18410    
18411            protected BlogsEntry filterGetByG_U_LtD_NotS_PrevAndNext(Session session,
18412                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
18413                    int status, OrderByComparator<BlogsEntry> orderByComparator,
18414                    boolean previous) {
18415                    StringBundler query = null;
18416    
18417                    if (orderByComparator != null) {
18418                            query = new StringBundler(8 +
18419                                            (orderByComparator.getOrderByConditionFields().length * 3) +
18420                                            (orderByComparator.getOrderByFields().length * 3));
18421                    }
18422                    else {
18423                            query = new StringBundler(7);
18424                    }
18425    
18426                    if (getDB().isSupportsInlineDistinct()) {
18427                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
18428                    }
18429                    else {
18430                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
18431                    }
18432    
18433                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
18434    
18435                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
18436    
18437                    boolean bindDisplayDate = false;
18438    
18439                    if (displayDate == null) {
18440                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
18441                    }
18442                    else {
18443                            bindDisplayDate = true;
18444    
18445                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
18446                    }
18447    
18448                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
18449    
18450                    if (!getDB().isSupportsInlineDistinct()) {
18451                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
18452                    }
18453    
18454                    if (orderByComparator != null) {
18455                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
18456    
18457                            if (orderByConditionFields.length > 0) {
18458                                    query.append(WHERE_AND);
18459                            }
18460    
18461                            for (int i = 0; i < orderByConditionFields.length; i++) {
18462                                    if (getDB().isSupportsInlineDistinct()) {
18463                                            query.append(_ORDER_BY_ENTITY_ALIAS);
18464                                    }
18465                                    else {
18466                                            query.append(_ORDER_BY_ENTITY_TABLE);
18467                                    }
18468    
18469                                    query.append(orderByConditionFields[i]);
18470    
18471                                    if ((i + 1) < orderByConditionFields.length) {
18472                                            if (orderByComparator.isAscending() ^ previous) {
18473                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
18474                                            }
18475                                            else {
18476                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
18477                                            }
18478                                    }
18479                                    else {
18480                                            if (orderByComparator.isAscending() ^ previous) {
18481                                                    query.append(WHERE_GREATER_THAN);
18482                                            }
18483                                            else {
18484                                                    query.append(WHERE_LESSER_THAN);
18485                                            }
18486                                    }
18487                            }
18488    
18489                            query.append(ORDER_BY_CLAUSE);
18490    
18491                            String[] orderByFields = orderByComparator.getOrderByFields();
18492    
18493                            for (int i = 0; i < orderByFields.length; i++) {
18494                                    if (getDB().isSupportsInlineDistinct()) {
18495                                            query.append(_ORDER_BY_ENTITY_ALIAS);
18496                                    }
18497                                    else {
18498                                            query.append(_ORDER_BY_ENTITY_TABLE);
18499                                    }
18500    
18501                                    query.append(orderByFields[i]);
18502    
18503                                    if ((i + 1) < orderByFields.length) {
18504                                            if (orderByComparator.isAscending() ^ previous) {
18505                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
18506                                            }
18507                                            else {
18508                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
18509                                            }
18510                                    }
18511                                    else {
18512                                            if (orderByComparator.isAscending() ^ previous) {
18513                                                    query.append(ORDER_BY_ASC);
18514                                            }
18515                                            else {
18516                                                    query.append(ORDER_BY_DESC);
18517                                            }
18518                                    }
18519                            }
18520                    }
18521                    else {
18522                            if (getDB().isSupportsInlineDistinct()) {
18523                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
18524                            }
18525                            else {
18526                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
18527                            }
18528                    }
18529    
18530                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
18531                                    BlogsEntry.class.getName(),
18532                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
18533    
18534                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
18535    
18536                    q.setFirstResult(0);
18537                    q.setMaxResults(2);
18538    
18539                    if (getDB().isSupportsInlineDistinct()) {
18540                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
18541                    }
18542                    else {
18543                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
18544                    }
18545    
18546                    QueryPos qPos = QueryPos.getInstance(q);
18547    
18548                    qPos.add(groupId);
18549    
18550                    qPos.add(userId);
18551    
18552                    if (bindDisplayDate) {
18553                            qPos.add(new Timestamp(displayDate.getTime()));
18554                    }
18555    
18556                    qPos.add(status);
18557    
18558                    if (orderByComparator != null) {
18559                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
18560    
18561                            for (Object value : values) {
18562                                    qPos.add(value);
18563                            }
18564                    }
18565    
18566                    List<BlogsEntry> list = q.list();
18567    
18568                    if (list.size() == 2) {
18569                            return list.get(1);
18570                    }
18571                    else {
18572                            return null;
18573                    }
18574            }
18575    
18576            /**
18577             * Removes all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63; from the database.
18578             *
18579             * @param groupId the group ID
18580             * @param userId the user ID
18581             * @param displayDate the display date
18582             * @param status the status
18583             */
18584            @Override
18585            public void removeByG_U_LtD_NotS(long groupId, long userId,
18586                    Date displayDate, int status) {
18587                    for (BlogsEntry blogsEntry : findByG_U_LtD_NotS(groupId, userId,
18588                                    displayDate, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
18589                            remove(blogsEntry);
18590                    }
18591            }
18592    
18593            /**
18594             * Returns the number of blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
18595             *
18596             * @param groupId the group ID
18597             * @param userId the user ID
18598             * @param displayDate the display date
18599             * @param status the status
18600             * @return the number of matching blogs entries
18601             */
18602            @Override
18603            public int countByG_U_LtD_NotS(long groupId, long userId, Date displayDate,
18604                    int status) {
18605                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD_NOTS;
18606    
18607                    Object[] finderArgs = new Object[] { groupId, userId, displayDate, status };
18608    
18609                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
18610    
18611                    if (count == null) {
18612                            StringBundler query = new StringBundler(5);
18613    
18614                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
18615    
18616                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
18617    
18618                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
18619    
18620                            boolean bindDisplayDate = false;
18621    
18622                            if (displayDate == null) {
18623                                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
18624                            }
18625                            else {
18626                                    bindDisplayDate = true;
18627    
18628                                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
18629                            }
18630    
18631                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
18632    
18633                            String sql = query.toString();
18634    
18635                            Session session = null;
18636    
18637                            try {
18638                                    session = openSession();
18639    
18640                                    Query q = session.createQuery(sql);
18641    
18642                                    QueryPos qPos = QueryPos.getInstance(q);
18643    
18644                                    qPos.add(groupId);
18645    
18646                                    qPos.add(userId);
18647    
18648                                    if (bindDisplayDate) {
18649                                            qPos.add(new Timestamp(displayDate.getTime()));
18650                                    }
18651    
18652                                    qPos.add(status);
18653    
18654                                    count = (Long)q.uniqueResult();
18655    
18656                                    finderCache.putResult(finderPath, finderArgs, count);
18657                            }
18658                            catch (Exception e) {
18659                                    finderCache.removeResult(finderPath, finderArgs);
18660    
18661                                    throw processException(e);
18662                            }
18663                            finally {
18664                                    closeSession(session);
18665                            }
18666                    }
18667    
18668                    return count.intValue();
18669            }
18670    
18671            /**
18672             * 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;.
18673             *
18674             * @param groupId the group ID
18675             * @param userId the user ID
18676             * @param displayDate the display date
18677             * @param status the status
18678             * @return the number of matching blogs entries that the user has permission to view
18679             */
18680            @Override
18681            public int filterCountByG_U_LtD_NotS(long groupId, long userId,
18682                    Date displayDate, int status) {
18683                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
18684                            return countByG_U_LtD_NotS(groupId, userId, displayDate, status);
18685                    }
18686    
18687                    StringBundler query = new StringBundler(5);
18688    
18689                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
18690    
18691                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
18692    
18693                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
18694    
18695                    boolean bindDisplayDate = false;
18696    
18697                    if (displayDate == null) {
18698                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
18699                    }
18700                    else {
18701                            bindDisplayDate = true;
18702    
18703                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
18704                    }
18705    
18706                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
18707    
18708                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
18709                                    BlogsEntry.class.getName(),
18710                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
18711    
18712                    Session session = null;
18713    
18714                    try {
18715                            session = openSession();
18716    
18717                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
18718    
18719                            q.addScalar(COUNT_COLUMN_NAME,
18720                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
18721    
18722                            QueryPos qPos = QueryPos.getInstance(q);
18723    
18724                            qPos.add(groupId);
18725    
18726                            qPos.add(userId);
18727    
18728                            if (bindDisplayDate) {
18729                                    qPos.add(new Timestamp(displayDate.getTime()));
18730                            }
18731    
18732                            qPos.add(status);
18733    
18734                            Long count = (Long)q.uniqueResult();
18735    
18736                            return count.intValue();
18737                    }
18738                    catch (Exception e) {
18739                            throw processException(e);
18740                    }
18741                    finally {
18742                            closeSession(session);
18743                    }
18744            }
18745    
18746            private static final String _FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2 = "blogsEntry.groupId = ? AND ";
18747            private static final String _FINDER_COLUMN_G_U_LTD_NOTS_USERID_2 = "blogsEntry.userId = ? AND ";
18748            private static final String _FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1 = "blogsEntry.displayDate IS NULL AND ";
18749            private static final String _FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
18750            private static final String _FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2 = "blogsEntry.status != ?";
18751    
18752            public BlogsEntryPersistenceImpl() {
18753                    setModelClass(BlogsEntry.class);
18754            }
18755    
18756            /**
18757             * Caches the blogs entry in the entity cache if it is enabled.
18758             *
18759             * @param blogsEntry the blogs entry
18760             */
18761            @Override
18762            public void cacheResult(BlogsEntry blogsEntry) {
18763                    entityCache.putResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18764                            BlogsEntryImpl.class, blogsEntry.getPrimaryKey(), blogsEntry);
18765    
18766                    finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G,
18767                            new Object[] { blogsEntry.getUuid(), blogsEntry.getGroupId() },
18768                            blogsEntry);
18769    
18770                    finderCache.putResult(FINDER_PATH_FETCH_BY_G_UT,
18771                            new Object[] { blogsEntry.getGroupId(), blogsEntry.getUrlTitle() },
18772                            blogsEntry);
18773    
18774                    blogsEntry.resetOriginalValues();
18775            }
18776    
18777            /**
18778             * Caches the blogs entries in the entity cache if it is enabled.
18779             *
18780             * @param blogsEntries the blogs entries
18781             */
18782            @Override
18783            public void cacheResult(List<BlogsEntry> blogsEntries) {
18784                    for (BlogsEntry blogsEntry : blogsEntries) {
18785                            if (entityCache.getResult(
18786                                                    BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18787                                                    BlogsEntryImpl.class, blogsEntry.getPrimaryKey()) == null) {
18788                                    cacheResult(blogsEntry);
18789                            }
18790                            else {
18791                                    blogsEntry.resetOriginalValues();
18792                            }
18793                    }
18794            }
18795    
18796            /**
18797             * Clears the cache for all blogs entries.
18798             *
18799             * <p>
18800             * The {@link EntityCache} and {@link FinderCache} are both cleared by this method.
18801             * </p>
18802             */
18803            @Override
18804            public void clearCache() {
18805                    entityCache.clearCache(BlogsEntryImpl.class);
18806    
18807                    finderCache.clearCache(FINDER_CLASS_NAME_ENTITY);
18808                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
18809                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
18810            }
18811    
18812            /**
18813             * Clears the cache for the blogs entry.
18814             *
18815             * <p>
18816             * The {@link EntityCache} and {@link FinderCache} are both cleared by this method.
18817             * </p>
18818             */
18819            @Override
18820            public void clearCache(BlogsEntry blogsEntry) {
18821                    entityCache.removeResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18822                            BlogsEntryImpl.class, blogsEntry.getPrimaryKey());
18823    
18824                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
18825                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
18826    
18827                    clearUniqueFindersCache((BlogsEntryModelImpl)blogsEntry);
18828            }
18829    
18830            @Override
18831            public void clearCache(List<BlogsEntry> blogsEntries) {
18832                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
18833                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
18834    
18835                    for (BlogsEntry blogsEntry : blogsEntries) {
18836                            entityCache.removeResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18837                                    BlogsEntryImpl.class, blogsEntry.getPrimaryKey());
18838    
18839                            clearUniqueFindersCache((BlogsEntryModelImpl)blogsEntry);
18840                    }
18841            }
18842    
18843            protected void cacheUniqueFindersCache(
18844                    BlogsEntryModelImpl blogsEntryModelImpl, boolean isNew) {
18845                    if (isNew) {
18846                            Object[] args = new Object[] {
18847                                            blogsEntryModelImpl.getUuid(),
18848                                            blogsEntryModelImpl.getGroupId()
18849                                    };
18850    
18851                            finderCache.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
18852                                    Long.valueOf(1));
18853                            finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
18854                                    blogsEntryModelImpl);
18855    
18856                            args = new Object[] {
18857                                            blogsEntryModelImpl.getGroupId(),
18858                                            blogsEntryModelImpl.getUrlTitle()
18859                                    };
18860    
18861                            finderCache.putResult(FINDER_PATH_COUNT_BY_G_UT, args,
18862                                    Long.valueOf(1));
18863                            finderCache.putResult(FINDER_PATH_FETCH_BY_G_UT, args,
18864                                    blogsEntryModelImpl);
18865                    }
18866                    else {
18867                            if ((blogsEntryModelImpl.getColumnBitmask() &
18868                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
18869                                    Object[] args = new Object[] {
18870                                                    blogsEntryModelImpl.getUuid(),
18871                                                    blogsEntryModelImpl.getGroupId()
18872                                            };
18873    
18874                                    finderCache.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
18875                                            Long.valueOf(1));
18876                                    finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
18877                                            blogsEntryModelImpl);
18878                            }
18879    
18880                            if ((blogsEntryModelImpl.getColumnBitmask() &
18881                                            FINDER_PATH_FETCH_BY_G_UT.getColumnBitmask()) != 0) {
18882                                    Object[] args = new Object[] {
18883                                                    blogsEntryModelImpl.getGroupId(),
18884                                                    blogsEntryModelImpl.getUrlTitle()
18885                                            };
18886    
18887                                    finderCache.putResult(FINDER_PATH_COUNT_BY_G_UT, args,
18888                                            Long.valueOf(1));
18889                                    finderCache.putResult(FINDER_PATH_FETCH_BY_G_UT, args,
18890                                            blogsEntryModelImpl);
18891                            }
18892                    }
18893            }
18894    
18895            protected void clearUniqueFindersCache(
18896                    BlogsEntryModelImpl blogsEntryModelImpl) {
18897                    Object[] args = new Object[] {
18898                                    blogsEntryModelImpl.getUuid(), blogsEntryModelImpl.getGroupId()
18899                            };
18900    
18901                    finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
18902                    finderCache.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
18903    
18904                    if ((blogsEntryModelImpl.getColumnBitmask() &
18905                                    FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
18906                            args = new Object[] {
18907                                            blogsEntryModelImpl.getOriginalUuid(),
18908                                            blogsEntryModelImpl.getOriginalGroupId()
18909                                    };
18910    
18911                            finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
18912                            finderCache.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
18913                    }
18914    
18915                    args = new Object[] {
18916                                    blogsEntryModelImpl.getGroupId(),
18917                                    blogsEntryModelImpl.getUrlTitle()
18918                            };
18919    
18920                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_UT, args);
18921                    finderCache.removeResult(FINDER_PATH_FETCH_BY_G_UT, args);
18922    
18923                    if ((blogsEntryModelImpl.getColumnBitmask() &
18924                                    FINDER_PATH_FETCH_BY_G_UT.getColumnBitmask()) != 0) {
18925                            args = new Object[] {
18926                                            blogsEntryModelImpl.getOriginalGroupId(),
18927                                            blogsEntryModelImpl.getOriginalUrlTitle()
18928                                    };
18929    
18930                            finderCache.removeResult(FINDER_PATH_COUNT_BY_G_UT, args);
18931                            finderCache.removeResult(FINDER_PATH_FETCH_BY_G_UT, args);
18932                    }
18933            }
18934    
18935            /**
18936             * Creates a new blogs entry with the primary key. Does not add the blogs entry to the database.
18937             *
18938             * @param entryId the primary key for the new blogs entry
18939             * @return the new blogs entry
18940             */
18941            @Override
18942            public BlogsEntry create(long entryId) {
18943                    BlogsEntry blogsEntry = new BlogsEntryImpl();
18944    
18945                    blogsEntry.setNew(true);
18946                    blogsEntry.setPrimaryKey(entryId);
18947    
18948                    String uuid = PortalUUIDUtil.generate();
18949    
18950                    blogsEntry.setUuid(uuid);
18951    
18952                    blogsEntry.setCompanyId(companyProvider.getCompanyId());
18953    
18954                    return blogsEntry;
18955            }
18956    
18957            /**
18958             * Removes the blogs entry with the primary key from the database. Also notifies the appropriate model listeners.
18959             *
18960             * @param entryId the primary key of the blogs entry
18961             * @return the blogs entry that was removed
18962             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
18963             */
18964            @Override
18965            public BlogsEntry remove(long entryId) throws NoSuchEntryException {
18966                    return remove((Serializable)entryId);
18967            }
18968    
18969            /**
18970             * Removes the blogs entry with the primary key from the database. Also notifies the appropriate model listeners.
18971             *
18972             * @param primaryKey the primary key of the blogs entry
18973             * @return the blogs entry that was removed
18974             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
18975             */
18976            @Override
18977            public BlogsEntry remove(Serializable primaryKey)
18978                    throws NoSuchEntryException {
18979                    Session session = null;
18980    
18981                    try {
18982                            session = openSession();
18983    
18984                            BlogsEntry blogsEntry = (BlogsEntry)session.get(BlogsEntryImpl.class,
18985                                            primaryKey);
18986    
18987                            if (blogsEntry == null) {
18988                                    if (_log.isDebugEnabled()) {
18989                                            _log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
18990                                    }
18991    
18992                                    throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
18993                                            primaryKey);
18994                            }
18995    
18996                            return remove(blogsEntry);
18997                    }
18998                    catch (NoSuchEntryException nsee) {
18999                            throw nsee;
19000                    }
19001                    catch (Exception e) {
19002                            throw processException(e);
19003                    }
19004                    finally {
19005                            closeSession(session);
19006                    }
19007            }
19008    
19009            @Override
19010            protected BlogsEntry removeImpl(BlogsEntry blogsEntry) {
19011                    blogsEntry = toUnwrappedModel(blogsEntry);
19012    
19013                    Session session = null;
19014    
19015                    try {
19016                            session = openSession();
19017    
19018                            if (!session.contains(blogsEntry)) {
19019                                    blogsEntry = (BlogsEntry)session.get(BlogsEntryImpl.class,
19020                                                    blogsEntry.getPrimaryKeyObj());
19021                            }
19022    
19023                            if (blogsEntry != null) {
19024                                    session.delete(blogsEntry);
19025                            }
19026                    }
19027                    catch (Exception e) {
19028                            throw processException(e);
19029                    }
19030                    finally {
19031                            closeSession(session);
19032                    }
19033    
19034                    if (blogsEntry != null) {
19035                            clearCache(blogsEntry);
19036                    }
19037    
19038                    return blogsEntry;
19039            }
19040    
19041            @Override
19042            public BlogsEntry updateImpl(BlogsEntry blogsEntry) {
19043                    blogsEntry = toUnwrappedModel(blogsEntry);
19044    
19045                    boolean isNew = blogsEntry.isNew();
19046    
19047                    BlogsEntryModelImpl blogsEntryModelImpl = (BlogsEntryModelImpl)blogsEntry;
19048    
19049                    if (Validator.isNull(blogsEntry.getUuid())) {
19050                            String uuid = PortalUUIDUtil.generate();
19051    
19052                            blogsEntry.setUuid(uuid);
19053                    }
19054    
19055                    ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();
19056    
19057                    Date now = new Date();
19058    
19059                    if (isNew && (blogsEntry.getCreateDate() == null)) {
19060                            if (serviceContext == null) {
19061                                    blogsEntry.setCreateDate(now);
19062                            }
19063                            else {
19064                                    blogsEntry.setCreateDate(serviceContext.getCreateDate(now));
19065                            }
19066                    }
19067    
19068                    if (!blogsEntryModelImpl.hasSetModifiedDate()) {
19069                            if (serviceContext == null) {
19070                                    blogsEntry.setModifiedDate(now);
19071                            }
19072                            else {
19073                                    blogsEntry.setModifiedDate(serviceContext.getModifiedDate(now));
19074                            }
19075                    }
19076    
19077                    long userId = GetterUtil.getLong(PrincipalThreadLocal.getName());
19078    
19079                    if (userId > 0) {
19080                            long companyId = blogsEntry.getCompanyId();
19081    
19082                            long groupId = blogsEntry.getGroupId();
19083    
19084                            long entryId = 0;
19085    
19086                            if (!isNew) {
19087                                    entryId = blogsEntry.getPrimaryKey();
19088                            }
19089    
19090                            try {
19091                                    blogsEntry.setTitle(SanitizerUtil.sanitize(companyId, groupId,
19092                                                    userId, BlogsEntry.class.getName(), entryId,
19093                                                    ContentTypes.TEXT_PLAIN, Sanitizer.MODE_ALL,
19094                                                    blogsEntry.getTitle(), null));
19095    
19096                                    blogsEntry.setContent(SanitizerUtil.sanitize(companyId,
19097                                                    groupId, userId, BlogsEntry.class.getName(), entryId,
19098                                                    ContentTypes.TEXT_HTML, Sanitizer.MODE_ALL,
19099                                                    blogsEntry.getContent(), null));
19100                            }
19101                            catch (SanitizerException se) {
19102                                    throw new SystemException(se);
19103                            }
19104                    }
19105    
19106                    Session session = null;
19107    
19108                    try {
19109                            session = openSession();
19110    
19111                            if (blogsEntry.isNew()) {
19112                                    session.save(blogsEntry);
19113    
19114                                    blogsEntry.setNew(false);
19115                            }
19116                            else {
19117                                    blogsEntry = (BlogsEntry)session.merge(blogsEntry);
19118                            }
19119                    }
19120                    catch (Exception e) {
19121                            throw processException(e);
19122                    }
19123                    finally {
19124                            closeSession(session);
19125                    }
19126    
19127                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
19128    
19129                    if (isNew || !BlogsEntryModelImpl.COLUMN_BITMASK_ENABLED) {
19130                            finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
19131                    }
19132    
19133                    else {
19134                            if ((blogsEntryModelImpl.getColumnBitmask() &
19135                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
19136                                    Object[] args = new Object[] {
19137                                                    blogsEntryModelImpl.getOriginalUuid()
19138                                            };
19139    
19140                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
19141                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
19142                                            args);
19143    
19144                                    args = new Object[] { blogsEntryModelImpl.getUuid() };
19145    
19146                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
19147                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
19148                                            args);
19149                            }
19150    
19151                            if ((blogsEntryModelImpl.getColumnBitmask() &
19152                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
19153                                    Object[] args = new Object[] {
19154                                                    blogsEntryModelImpl.getOriginalUuid(),
19155                                                    blogsEntryModelImpl.getOriginalCompanyId()
19156                                            };
19157    
19158                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
19159                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
19160                                            args);
19161    
19162                                    args = new Object[] {
19163                                                    blogsEntryModelImpl.getUuid(),
19164                                                    blogsEntryModelImpl.getCompanyId()
19165                                            };
19166    
19167                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
19168                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
19169                                            args);
19170                            }
19171    
19172                            if ((blogsEntryModelImpl.getColumnBitmask() &
19173                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
19174                                    Object[] args = new Object[] {
19175                                                    blogsEntryModelImpl.getOriginalGroupId()
19176                                            };
19177    
19178                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
19179                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
19180                                            args);
19181    
19182                                    args = new Object[] { blogsEntryModelImpl.getGroupId() };
19183    
19184                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
19185                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
19186                                            args);
19187                            }
19188    
19189                            if ((blogsEntryModelImpl.getColumnBitmask() &
19190                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
19191                                    Object[] args = new Object[] {
19192                                                    blogsEntryModelImpl.getOriginalCompanyId()
19193                                            };
19194    
19195                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_COMPANYID, args);
19196                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
19197                                            args);
19198    
19199                                    args = new Object[] { blogsEntryModelImpl.getCompanyId() };
19200    
19201                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_COMPANYID, args);
19202                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
19203                                            args);
19204                            }
19205    
19206                            if ((blogsEntryModelImpl.getColumnBitmask() &
19207                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S.getColumnBitmask()) != 0) {
19208                                    Object[] args = new Object[] {
19209                                                    blogsEntryModelImpl.getOriginalGroupId(),
19210                                                    blogsEntryModelImpl.getOriginalStatus()
19211                                            };
19212    
19213                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
19214                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
19215                                            args);
19216    
19217                                    args = new Object[] {
19218                                                    blogsEntryModelImpl.getGroupId(),
19219                                                    blogsEntryModelImpl.getStatus()
19220                                            };
19221    
19222                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
19223                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
19224                                            args);
19225                            }
19226    
19227                            if ((blogsEntryModelImpl.getColumnBitmask() &
19228                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U.getColumnBitmask()) != 0) {
19229                                    Object[] args = new Object[] {
19230                                                    blogsEntryModelImpl.getOriginalCompanyId(),
19231                                                    blogsEntryModelImpl.getOriginalUserId()
19232                                            };
19233    
19234                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_C_U, args);
19235                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U,
19236                                            args);
19237    
19238                                    args = new Object[] {
19239                                                    blogsEntryModelImpl.getCompanyId(),
19240                                                    blogsEntryModelImpl.getUserId()
19241                                            };
19242    
19243                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_C_U, args);
19244                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U,
19245                                            args);
19246                            }
19247    
19248                            if ((blogsEntryModelImpl.getColumnBitmask() &
19249                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S.getColumnBitmask()) != 0) {
19250                                    Object[] args = new Object[] {
19251                                                    blogsEntryModelImpl.getOriginalCompanyId(),
19252                                                    blogsEntryModelImpl.getOriginalStatus()
19253                                            };
19254    
19255                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_C_S, args);
19256                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S,
19257                                            args);
19258    
19259                                    args = new Object[] {
19260                                                    blogsEntryModelImpl.getCompanyId(),
19261                                                    blogsEntryModelImpl.getStatus()
19262                                            };
19263    
19264                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_C_S, args);
19265                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S,
19266                                            args);
19267                            }
19268    
19269                            if ((blogsEntryModelImpl.getColumnBitmask() &
19270                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S.getColumnBitmask()) != 0) {
19271                                    Object[] args = new Object[] {
19272                                                    blogsEntryModelImpl.getOriginalGroupId(),
19273                                                    blogsEntryModelImpl.getOriginalUserId(),
19274                                                    blogsEntryModelImpl.getOriginalStatus()
19275                                            };
19276    
19277                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_U_S, args);
19278                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S,
19279                                            args);
19280    
19281                                    args = new Object[] {
19282                                                    blogsEntryModelImpl.getGroupId(),
19283                                                    blogsEntryModelImpl.getUserId(),
19284                                                    blogsEntryModelImpl.getStatus()
19285                                            };
19286    
19287                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_U_S, args);
19288                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S,
19289                                            args);
19290                            }
19291    
19292                            if ((blogsEntryModelImpl.getColumnBitmask() &
19293                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U_S.getColumnBitmask()) != 0) {
19294                                    Object[] args = new Object[] {
19295                                                    blogsEntryModelImpl.getOriginalCompanyId(),
19296                                                    blogsEntryModelImpl.getOriginalUserId(),
19297                                                    blogsEntryModelImpl.getOriginalStatus()
19298                                            };
19299    
19300                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_C_U_S, args);
19301                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U_S,
19302                                            args);
19303    
19304                                    args = new Object[] {
19305                                                    blogsEntryModelImpl.getCompanyId(),
19306                                                    blogsEntryModelImpl.getUserId(),
19307                                                    blogsEntryModelImpl.getStatus()
19308                                            };
19309    
19310                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_C_U_S, args);
19311                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U_S,
19312                                            args);
19313                            }
19314                    }
19315    
19316                    entityCache.putResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
19317                            BlogsEntryImpl.class, blogsEntry.getPrimaryKey(), blogsEntry, false);
19318    
19319                    clearUniqueFindersCache(blogsEntryModelImpl);
19320                    cacheUniqueFindersCache(blogsEntryModelImpl, isNew);
19321    
19322                    blogsEntry.resetOriginalValues();
19323    
19324                    return blogsEntry;
19325            }
19326    
19327            protected BlogsEntry toUnwrappedModel(BlogsEntry blogsEntry) {
19328                    if (blogsEntry instanceof BlogsEntryImpl) {
19329                            return blogsEntry;
19330                    }
19331    
19332                    BlogsEntryImpl blogsEntryImpl = new BlogsEntryImpl();
19333    
19334                    blogsEntryImpl.setNew(blogsEntry.isNew());
19335                    blogsEntryImpl.setPrimaryKey(blogsEntry.getPrimaryKey());
19336    
19337                    blogsEntryImpl.setUuid(blogsEntry.getUuid());
19338                    blogsEntryImpl.setEntryId(blogsEntry.getEntryId());
19339                    blogsEntryImpl.setGroupId(blogsEntry.getGroupId());
19340                    blogsEntryImpl.setCompanyId(blogsEntry.getCompanyId());
19341                    blogsEntryImpl.setUserId(blogsEntry.getUserId());
19342                    blogsEntryImpl.setUserName(blogsEntry.getUserName());
19343                    blogsEntryImpl.setCreateDate(blogsEntry.getCreateDate());
19344                    blogsEntryImpl.setModifiedDate(blogsEntry.getModifiedDate());
19345                    blogsEntryImpl.setTitle(blogsEntry.getTitle());
19346                    blogsEntryImpl.setSubtitle(blogsEntry.getSubtitle());
19347                    blogsEntryImpl.setUrlTitle(blogsEntry.getUrlTitle());
19348                    blogsEntryImpl.setDescription(blogsEntry.getDescription());
19349                    blogsEntryImpl.setContent(blogsEntry.getContent());
19350                    blogsEntryImpl.setDisplayDate(blogsEntry.getDisplayDate());
19351                    blogsEntryImpl.setAllowPingbacks(blogsEntry.isAllowPingbacks());
19352                    blogsEntryImpl.setAllowTrackbacks(blogsEntry.isAllowTrackbacks());
19353                    blogsEntryImpl.setTrackbacks(blogsEntry.getTrackbacks());
19354                    blogsEntryImpl.setCoverImageCaption(blogsEntry.getCoverImageCaption());
19355                    blogsEntryImpl.setCoverImageFileEntryId(blogsEntry.getCoverImageFileEntryId());
19356                    blogsEntryImpl.setCoverImageURL(blogsEntry.getCoverImageURL());
19357                    blogsEntryImpl.setSmallImage(blogsEntry.isSmallImage());
19358                    blogsEntryImpl.setSmallImageFileEntryId(blogsEntry.getSmallImageFileEntryId());
19359                    blogsEntryImpl.setSmallImageId(blogsEntry.getSmallImageId());
19360                    blogsEntryImpl.setSmallImageURL(blogsEntry.getSmallImageURL());
19361                    blogsEntryImpl.setLastPublishDate(blogsEntry.getLastPublishDate());
19362                    blogsEntryImpl.setStatus(blogsEntry.getStatus());
19363                    blogsEntryImpl.setStatusByUserId(blogsEntry.getStatusByUserId());
19364                    blogsEntryImpl.setStatusByUserName(blogsEntry.getStatusByUserName());
19365                    blogsEntryImpl.setStatusDate(blogsEntry.getStatusDate());
19366    
19367                    return blogsEntryImpl;
19368            }
19369    
19370            /**
19371             * Returns the blogs entry with the primary key or throws a {@link com.liferay.portal.kernel.exception.NoSuchModelException} if it could not be found.
19372             *
19373             * @param primaryKey the primary key of the blogs entry
19374             * @return the blogs entry
19375             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
19376             */
19377            @Override
19378            public BlogsEntry findByPrimaryKey(Serializable primaryKey)
19379                    throws NoSuchEntryException {
19380                    BlogsEntry blogsEntry = fetchByPrimaryKey(primaryKey);
19381    
19382                    if (blogsEntry == null) {
19383                            if (_log.isDebugEnabled()) {
19384                                    _log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
19385                            }
19386    
19387                            throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
19388                                    primaryKey);
19389                    }
19390    
19391                    return blogsEntry;
19392            }
19393    
19394            /**
19395             * Returns the blogs entry with the primary key or throws a {@link NoSuchEntryException} if it could not be found.
19396             *
19397             * @param entryId the primary key of the blogs entry
19398             * @return the blogs entry
19399             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
19400             */
19401            @Override
19402            public BlogsEntry findByPrimaryKey(long entryId)
19403                    throws NoSuchEntryException {
19404                    return findByPrimaryKey((Serializable)entryId);
19405            }
19406    
19407            /**
19408             * Returns the blogs entry with the primary key or returns <code>null</code> if it could not be found.
19409             *
19410             * @param primaryKey the primary key of the blogs entry
19411             * @return the blogs entry, or <code>null</code> if a blogs entry with the primary key could not be found
19412             */
19413            @Override
19414            public BlogsEntry fetchByPrimaryKey(Serializable primaryKey) {
19415                    BlogsEntry blogsEntry = (BlogsEntry)entityCache.getResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
19416                                    BlogsEntryImpl.class, primaryKey);
19417    
19418                    if (blogsEntry == _nullBlogsEntry) {
19419                            return null;
19420                    }
19421    
19422                    if (blogsEntry == null) {
19423                            Session session = null;
19424    
19425                            try {
19426                                    session = openSession();
19427    
19428                                    blogsEntry = (BlogsEntry)session.get(BlogsEntryImpl.class,
19429                                                    primaryKey);
19430    
19431                                    if (blogsEntry != null) {
19432                                            cacheResult(blogsEntry);
19433                                    }
19434                                    else {
19435                                            entityCache.putResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
19436                                                    BlogsEntryImpl.class, primaryKey, _nullBlogsEntry);
19437                                    }
19438                            }
19439                            catch (Exception e) {
19440                                    entityCache.removeResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
19441                                            BlogsEntryImpl.class, primaryKey);
19442    
19443                                    throw processException(e);
19444                            }
19445                            finally {
19446                                    closeSession(session);
19447                            }
19448                    }
19449    
19450                    return blogsEntry;
19451            }
19452    
19453            /**
19454             * Returns the blogs entry with the primary key or returns <code>null</code> if it could not be found.
19455             *
19456             * @param entryId the primary key of the blogs entry
19457             * @return the blogs entry, or <code>null</code> if a blogs entry with the primary key could not be found
19458             */
19459            @Override
19460            public BlogsEntry fetchByPrimaryKey(long entryId) {
19461                    return fetchByPrimaryKey((Serializable)entryId);
19462            }
19463    
19464            @Override
19465            public Map<Serializable, BlogsEntry> fetchByPrimaryKeys(
19466                    Set<Serializable> primaryKeys) {
19467                    if (primaryKeys.isEmpty()) {
19468                            return Collections.emptyMap();
19469                    }
19470    
19471                    Map<Serializable, BlogsEntry> map = new HashMap<Serializable, BlogsEntry>();
19472    
19473                    if (primaryKeys.size() == 1) {
19474                            Iterator<Serializable> iterator = primaryKeys.iterator();
19475    
19476                            Serializable primaryKey = iterator.next();
19477    
19478                            BlogsEntry blogsEntry = fetchByPrimaryKey(primaryKey);
19479    
19480                            if (blogsEntry != null) {
19481                                    map.put(primaryKey, blogsEntry);
19482                            }
19483    
19484                            return map;
19485                    }
19486    
19487                    Set<Serializable> uncachedPrimaryKeys = null;
19488    
19489                    for (Serializable primaryKey : primaryKeys) {
19490                            BlogsEntry blogsEntry = (BlogsEntry)entityCache.getResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
19491                                            BlogsEntryImpl.class, primaryKey);
19492    
19493                            if (blogsEntry == null) {
19494                                    if (uncachedPrimaryKeys == null) {
19495                                            uncachedPrimaryKeys = new HashSet<Serializable>();
19496                                    }
19497    
19498                                    uncachedPrimaryKeys.add(primaryKey);
19499                            }
19500                            else {
19501                                    map.put(primaryKey, blogsEntry);
19502                            }
19503                    }
19504    
19505                    if (uncachedPrimaryKeys == null) {
19506                            return map;
19507                    }
19508    
19509                    StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
19510                                    1);
19511    
19512                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE_PKS_IN);
19513    
19514                    for (Serializable primaryKey : uncachedPrimaryKeys) {
19515                            query.append(String.valueOf(primaryKey));
19516    
19517                            query.append(StringPool.COMMA);
19518                    }
19519    
19520                    query.setIndex(query.index() - 1);
19521    
19522                    query.append(StringPool.CLOSE_PARENTHESIS);
19523    
19524                    String sql = query.toString();
19525    
19526                    Session session = null;
19527    
19528                    try {
19529                            session = openSession();
19530    
19531                            Query q = session.createQuery(sql);
19532    
19533                            for (BlogsEntry blogsEntry : (List<BlogsEntry>)q.list()) {
19534                                    map.put(blogsEntry.getPrimaryKeyObj(), blogsEntry);
19535    
19536                                    cacheResult(blogsEntry);
19537    
19538                                    uncachedPrimaryKeys.remove(blogsEntry.getPrimaryKeyObj());
19539                            }
19540    
19541                            for (Serializable primaryKey : uncachedPrimaryKeys) {
19542                                    entityCache.putResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
19543                                            BlogsEntryImpl.class, primaryKey, _nullBlogsEntry);
19544                            }
19545                    }
19546                    catch (Exception e) {
19547                            throw processException(e);
19548                    }
19549                    finally {
19550                            closeSession(session);
19551                    }
19552    
19553                    return map;
19554            }
19555    
19556            /**
19557             * Returns all the blogs entries.
19558             *
19559             * @return the blogs entries
19560             */
19561            @Override
19562            public List<BlogsEntry> findAll() {
19563                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
19564            }
19565    
19566            /**
19567             * Returns a range of all the blogs entries.
19568             *
19569             * <p>
19570             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
19571             * </p>
19572             *
19573             * @param start the lower bound of the range of blogs entries
19574             * @param end the upper bound of the range of blogs entries (not inclusive)
19575             * @return the range of blogs entries
19576             */
19577            @Override
19578            public List<BlogsEntry> findAll(int start, int end) {
19579                    return findAll(start, end, null);
19580            }
19581    
19582            /**
19583             * Returns an ordered range of all the blogs entries.
19584             *
19585             * <p>
19586             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
19587             * </p>
19588             *
19589             * @param start the lower bound of the range of blogs entries
19590             * @param end the upper bound of the range of blogs entries (not inclusive)
19591             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
19592             * @return the ordered range of blogs entries
19593             */
19594            @Override
19595            public List<BlogsEntry> findAll(int start, int end,
19596                    OrderByComparator<BlogsEntry> orderByComparator) {
19597                    return findAll(start, end, orderByComparator, true);
19598            }
19599    
19600            /**
19601             * Returns an ordered range of all the blogs entries.
19602             *
19603             * <p>
19604             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
19605             * </p>
19606             *
19607             * @param start the lower bound of the range of blogs entries
19608             * @param end the upper bound of the range of blogs entries (not inclusive)
19609             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
19610             * @param retrieveFromCache whether to retrieve from the finder cache
19611             * @return the ordered range of blogs entries
19612             */
19613            @Override
19614            public List<BlogsEntry> findAll(int start, int end,
19615                    OrderByComparator<BlogsEntry> orderByComparator,
19616                    boolean retrieveFromCache) {
19617                    boolean pagination = true;
19618                    FinderPath finderPath = null;
19619                    Object[] finderArgs = null;
19620    
19621                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
19622                                    (orderByComparator == null)) {
19623                            pagination = false;
19624                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
19625                            finderArgs = FINDER_ARGS_EMPTY;
19626                    }
19627                    else {
19628                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
19629                            finderArgs = new Object[] { start, end, orderByComparator };
19630                    }
19631    
19632                    List<BlogsEntry> list = null;
19633    
19634                    if (retrieveFromCache) {
19635                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
19636                                            finderArgs, this);
19637                    }
19638    
19639                    if (list == null) {
19640                            StringBundler query = null;
19641                            String sql = null;
19642    
19643                            if (orderByComparator != null) {
19644                                    query = new StringBundler(2 +
19645                                                    (orderByComparator.getOrderByFields().length * 2));
19646    
19647                                    query.append(_SQL_SELECT_BLOGSENTRY);
19648    
19649                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
19650                                            orderByComparator);
19651    
19652                                    sql = query.toString();
19653                            }
19654                            else {
19655                                    sql = _SQL_SELECT_BLOGSENTRY;
19656    
19657                                    if (pagination) {
19658                                            sql = sql.concat(BlogsEntryModelImpl.ORDER_BY_JPQL);
19659                                    }
19660                            }
19661    
19662                            Session session = null;
19663    
19664                            try {
19665                                    session = openSession();
19666    
19667                                    Query q = session.createQuery(sql);
19668    
19669                                    if (!pagination) {
19670                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
19671                                                            start, end, false);
19672    
19673                                            Collections.sort(list);
19674    
19675                                            list = Collections.unmodifiableList(list);
19676                                    }
19677                                    else {
19678                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
19679                                                            start, end);
19680                                    }
19681    
19682                                    cacheResult(list);
19683    
19684                                    finderCache.putResult(finderPath, finderArgs, list);
19685                            }
19686                            catch (Exception e) {
19687                                    finderCache.removeResult(finderPath, finderArgs);
19688    
19689                                    throw processException(e);
19690                            }
19691                            finally {
19692                                    closeSession(session);
19693                            }
19694                    }
19695    
19696                    return list;
19697            }
19698    
19699            /**
19700             * Removes all the blogs entries from the database.
19701             *
19702             */
19703            @Override
19704            public void removeAll() {
19705                    for (BlogsEntry blogsEntry : findAll()) {
19706                            remove(blogsEntry);
19707                    }
19708            }
19709    
19710            /**
19711             * Returns the number of blogs entries.
19712             *
19713             * @return the number of blogs entries
19714             */
19715            @Override
19716            public int countAll() {
19717                    Long count = (Long)finderCache.getResult(FINDER_PATH_COUNT_ALL,
19718                                    FINDER_ARGS_EMPTY, this);
19719    
19720                    if (count == null) {
19721                            Session session = null;
19722    
19723                            try {
19724                                    session = openSession();
19725    
19726                                    Query q = session.createQuery(_SQL_COUNT_BLOGSENTRY);
19727    
19728                                    count = (Long)q.uniqueResult();
19729    
19730                                    finderCache.putResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY,
19731                                            count);
19732                            }
19733                            catch (Exception e) {
19734                                    finderCache.removeResult(FINDER_PATH_COUNT_ALL,
19735                                            FINDER_ARGS_EMPTY);
19736    
19737                                    throw processException(e);
19738                            }
19739                            finally {
19740                                    closeSession(session);
19741                            }
19742                    }
19743    
19744                    return count.intValue();
19745            }
19746    
19747            @Override
19748            public Set<String> getBadColumnNames() {
19749                    return _badColumnNames;
19750            }
19751    
19752            @Override
19753            protected Map<String, Integer> getTableColumnsMap() {
19754                    return BlogsEntryModelImpl.TABLE_COLUMNS_MAP;
19755            }
19756    
19757            /**
19758             * Initializes the blogs entry persistence.
19759             */
19760            public void afterPropertiesSet() {
19761            }
19762    
19763            public void destroy() {
19764                    entityCache.removeCache(BlogsEntryImpl.class.getName());
19765                    finderCache.removeCache(FINDER_CLASS_NAME_ENTITY);
19766                    finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
19767                    finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
19768            }
19769    
19770            @BeanReference(type = CompanyProviderWrapper.class)
19771            protected CompanyProvider companyProvider;
19772            protected EntityCache entityCache = EntityCacheUtil.getEntityCache();
19773            protected FinderCache finderCache = FinderCacheUtil.getFinderCache();
19774            private static final String _SQL_SELECT_BLOGSENTRY = "SELECT blogsEntry FROM BlogsEntry blogsEntry";
19775            private static final String _SQL_SELECT_BLOGSENTRY_WHERE_PKS_IN = "SELECT blogsEntry FROM BlogsEntry blogsEntry WHERE entryId IN (";
19776            private static final String _SQL_SELECT_BLOGSENTRY_WHERE = "SELECT blogsEntry FROM BlogsEntry blogsEntry WHERE ";
19777            private static final String _SQL_COUNT_BLOGSENTRY = "SELECT COUNT(blogsEntry) FROM BlogsEntry blogsEntry";
19778            private static final String _SQL_COUNT_BLOGSENTRY_WHERE = "SELECT COUNT(blogsEntry) FROM BlogsEntry blogsEntry WHERE ";
19779            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "blogsEntry.entryId";
19780            private static final String _FILTER_SQL_SELECT_BLOGSENTRY_WHERE = "SELECT DISTINCT {blogsEntry.*} FROM BlogsEntry blogsEntry WHERE ";
19781            private static final String _FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1 =
19782                    "SELECT {BlogsEntry.*} FROM (SELECT DISTINCT blogsEntry.entryId FROM BlogsEntry blogsEntry WHERE ";
19783            private static final String _FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2 =
19784                    ") TEMP_TABLE INNER JOIN BlogsEntry ON TEMP_TABLE.entryId = BlogsEntry.entryId";
19785            private static final String _FILTER_SQL_COUNT_BLOGSENTRY_WHERE = "SELECT COUNT(DISTINCT blogsEntry.entryId) AS COUNT_VALUE FROM BlogsEntry blogsEntry WHERE ";
19786            private static final String _FILTER_ENTITY_ALIAS = "blogsEntry";
19787            private static final String _FILTER_ENTITY_TABLE = "BlogsEntry";
19788            private static final String _ORDER_BY_ENTITY_ALIAS = "blogsEntry.";
19789            private static final String _ORDER_BY_ENTITY_TABLE = "BlogsEntry.";
19790            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No BlogsEntry exists with the primary key ";
19791            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No BlogsEntry exists with the key {";
19792            private static final Log _log = LogFactoryUtil.getLog(BlogsEntryPersistenceImpl.class);
19793            private static final Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
19794                                    "uuid"
19795                            });
19796            private static final BlogsEntry _nullBlogsEntry = new BlogsEntryImpl() {
19797                            @Override
19798                            public Object clone() {
19799                                    return this;
19800                            }
19801    
19802                            @Override
19803                            public CacheModel<BlogsEntry> toCacheModel() {
19804                                    return _nullBlogsEntryCacheModel;
19805                            }
19806                    };
19807    
19808            private static final CacheModel<BlogsEntry> _nullBlogsEntryCacheModel = new CacheModel<BlogsEntry>() {
19809                            @Override
19810                            public BlogsEntry toEntityModel() {
19811                                    return _nullBlogsEntry;
19812                            }
19813                    };
19814    }