001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.blogs.service.persistence.impl;
016    
017    import aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.kernel.bean.BeanReference;
020    import com.liferay.portal.kernel.dao.orm.EntityCache;
021    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
022    import com.liferay.portal.kernel.dao.orm.FinderCache;
023    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
024    import com.liferay.portal.kernel.dao.orm.FinderPath;
025    import com.liferay.portal.kernel.dao.orm.Query;
026    import com.liferay.portal.kernel.dao.orm.QueryPos;
027    import com.liferay.portal.kernel.dao.orm.QueryUtil;
028    import com.liferay.portal.kernel.dao.orm.SQLQuery;
029    import com.liferay.portal.kernel.dao.orm.Session;
030    import com.liferay.portal.kernel.exception.SystemException;
031    import com.liferay.portal.kernel.log.Log;
032    import com.liferay.portal.kernel.log.LogFactoryUtil;
033    import com.liferay.portal.kernel.sanitizer.Sanitizer;
034    import com.liferay.portal.kernel.sanitizer.SanitizerException;
035    import com.liferay.portal.kernel.sanitizer.SanitizerUtil;
036    import com.liferay.portal.kernel.security.auth.PrincipalThreadLocal;
037    import com.liferay.portal.kernel.security.permission.InlineSQLHelperUtil;
038    import com.liferay.portal.kernel.util.ArrayUtil;
039    import com.liferay.portal.kernel.util.ContentTypes;
040    import com.liferay.portal.kernel.util.GetterUtil;
041    import com.liferay.portal.kernel.util.OrderByComparator;
042    import com.liferay.portal.kernel.util.SetUtil;
043    import com.liferay.portal.kernel.util.StringBundler;
044    import com.liferay.portal.kernel.util.StringPool;
045    import com.liferay.portal.kernel.util.StringUtil;
046    import com.liferay.portal.kernel.util.Validator;
047    import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
048    import com.liferay.portal.model.CacheModel;
049    import com.liferay.portal.service.ServiceContext;
050    import com.liferay.portal.service.ServiceContextThreadLocal;
051    import com.liferay.portal.service.persistence.CompanyProvider;
052    import com.liferay.portal.service.persistence.CompanyProviderWrapper;
053    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
054    
055    import com.liferay.portlet.blogs.exception.NoSuchEntryException;
056    import com.liferay.portlet.blogs.model.BlogsEntry;
057    import com.liferay.portlet.blogs.model.impl.BlogsEntryImpl;
058    import com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl;
059    import com.liferay.portlet.blogs.service.persistence.BlogsEntryPersistence;
060    
061    import java.io.Serializable;
062    
063    import java.sql.Timestamp;
064    
065    import java.util.Arrays;
066    import java.util.Collections;
067    import java.util.Date;
068    import java.util.HashMap;
069    import java.util.HashSet;
070    import java.util.Iterator;
071    import java.util.List;
072    import java.util.Map;
073    import java.util.Set;
074    
075    /**
076     * The persistence implementation for the blogs entry service.
077     *
078     * <p>
079     * Caching information and settings can be found in <code>portal.properties</code>
080     * </p>
081     *
082     * @author Brian Wing Shun Chan
083     * @see BlogsEntryPersistence
084     * @see com.liferay.portlet.blogs.service.persistence.BlogsEntryUtil
085     * @generated
086     */
087    @ProviderType
088    public class BlogsEntryPersistenceImpl extends BasePersistenceImpl<BlogsEntry>
089            implements BlogsEntryPersistence {
090            /*
091             * NOTE FOR DEVELOPERS:
092             *
093             * 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.
094             */
095            public static final String FINDER_CLASS_NAME_ENTITY = BlogsEntryImpl.class.getName();
096            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
097                    ".List1";
098            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
099                    ".List2";
100            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
101                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
102                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
103            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
104                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
105                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
106            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
107                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
108                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
109            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
110                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
111                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
112                            new String[] {
113                                    String.class.getName(),
114                                    
115                            Integer.class.getName(), Integer.class.getName(),
116                                    OrderByComparator.class.getName()
117                            });
118            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
119                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
120                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
121                            new String[] { String.class.getName() },
122                            BlogsEntryModelImpl.UUID_COLUMN_BITMASK |
123                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
124                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
125            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
126                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
127                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
128                            new String[] { String.class.getName() });
129    
130            /**
131             * Returns all the blogs entries where uuid = &#63;.
132             *
133             * @param uuid the uuid
134             * @return the matching blogs entries
135             */
136            @Override
137            public List<BlogsEntry> findByUuid(String uuid) {
138                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
139            }
140    
141            /**
142             * Returns a range of all the blogs entries where uuid = &#63;.
143             *
144             * <p>
145             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
146             * </p>
147             *
148             * @param uuid the uuid
149             * @param start the lower bound of the range of blogs entries
150             * @param end the upper bound of the range of blogs entries (not inclusive)
151             * @return the range of matching blogs entries
152             */
153            @Override
154            public List<BlogsEntry> findByUuid(String uuid, int start, int end) {
155                    return findByUuid(uuid, start, end, null);
156            }
157    
158            /**
159             * Returns an ordered range of all the blogs entries where uuid = &#63;.
160             *
161             * <p>
162             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
163             * </p>
164             *
165             * @param uuid the uuid
166             * @param start the lower bound of the range of blogs entries
167             * @param end the upper bound of the range of blogs entries (not inclusive)
168             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
169             * @return the ordered range of matching blogs entries
170             */
171            @Override
172            public List<BlogsEntry> findByUuid(String uuid, int start, int end,
173                    OrderByComparator<BlogsEntry> orderByComparator) {
174                    return findByUuid(uuid, start, end, orderByComparator, true);
175            }
176    
177            /**
178             * Returns an ordered range of all the blogs entries where uuid = &#63;.
179             *
180             * <p>
181             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
182             * </p>
183             *
184             * @param uuid the uuid
185             * @param start the lower bound of the range of blogs entries
186             * @param end the upper bound of the range of blogs entries (not inclusive)
187             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
188             * @param retrieveFromCache whether to retrieve from the finder cache
189             * @return the ordered range of matching blogs entries
190             */
191            @Override
192            public List<BlogsEntry> findByUuid(String uuid, int start, int end,
193                    OrderByComparator<BlogsEntry> orderByComparator,
194                    boolean retrieveFromCache) {
195                    boolean pagination = true;
196                    FinderPath finderPath = null;
197                    Object[] finderArgs = null;
198    
199                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
200                                    (orderByComparator == null)) {
201                            pagination = false;
202                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
203                            finderArgs = new Object[] { uuid };
204                    }
205                    else {
206                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
207                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
208                    }
209    
210                    List<BlogsEntry> list = null;
211    
212                    if (retrieveFromCache) {
213                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
214                                            finderArgs, this);
215    
216                            if ((list != null) && !list.isEmpty()) {
217                                    for (BlogsEntry blogsEntry : list) {
218                                            if (!Validator.equals(uuid, blogsEntry.getUuid())) {
219                                                    list = null;
220    
221                                                    break;
222                                            }
223                                    }
224                            }
225                    }
226    
227                    if (list == null) {
228                            StringBundler query = null;
229    
230                            if (orderByComparator != null) {
231                                    query = new StringBundler(3 +
232                                                    (orderByComparator.getOrderByFields().length * 2));
233                            }
234                            else {
235                                    query = new StringBundler(3);
236                            }
237    
238                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
239    
240                            boolean bindUuid = false;
241    
242                            if (uuid == null) {
243                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
244                            }
245                            else if (uuid.equals(StringPool.BLANK)) {
246                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
247                            }
248                            else {
249                                    bindUuid = true;
250    
251                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
252                            }
253    
254                            if (orderByComparator != null) {
255                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
256                                            orderByComparator);
257                            }
258                            else
259                             if (pagination) {
260                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
261                            }
262    
263                            String sql = query.toString();
264    
265                            Session session = null;
266    
267                            try {
268                                    session = openSession();
269    
270                                    Query q = session.createQuery(sql);
271    
272                                    QueryPos qPos = QueryPos.getInstance(q);
273    
274                                    if (bindUuid) {
275                                            qPos.add(uuid);
276                                    }
277    
278                                    if (!pagination) {
279                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
280                                                            start, end, false);
281    
282                                            Collections.sort(list);
283    
284                                            list = Collections.unmodifiableList(list);
285                                    }
286                                    else {
287                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
288                                                            start, end);
289                                    }
290    
291                                    cacheResult(list);
292    
293                                    finderCache.putResult(finderPath, finderArgs, list);
294                            }
295                            catch (Exception e) {
296                                    finderCache.removeResult(finderPath, finderArgs);
297    
298                                    throw processException(e);
299                            }
300                            finally {
301                                    closeSession(session);
302                            }
303                    }
304    
305                    return list;
306            }
307    
308            /**
309             * Returns the first blogs entry in the ordered set where uuid = &#63;.
310             *
311             * @param uuid the uuid
312             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
313             * @return the first matching blogs entry
314             * @throws NoSuchEntryException if a matching blogs entry could not be found
315             */
316            @Override
317            public BlogsEntry findByUuid_First(String uuid,
318                    OrderByComparator<BlogsEntry> orderByComparator)
319                    throws NoSuchEntryException {
320                    BlogsEntry blogsEntry = fetchByUuid_First(uuid, orderByComparator);
321    
322                    if (blogsEntry != null) {
323                            return blogsEntry;
324                    }
325    
326                    StringBundler msg = new StringBundler(4);
327    
328                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
329    
330                    msg.append("uuid=");
331                    msg.append(uuid);
332    
333                    msg.append(StringPool.CLOSE_CURLY_BRACE);
334    
335                    throw new NoSuchEntryException(msg.toString());
336            }
337    
338            /**
339             * Returns the first blogs entry in the ordered set where uuid = &#63;.
340             *
341             * @param uuid the uuid
342             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
343             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
344             */
345            @Override
346            public BlogsEntry fetchByUuid_First(String uuid,
347                    OrderByComparator<BlogsEntry> orderByComparator) {
348                    List<BlogsEntry> list = findByUuid(uuid, 0, 1, orderByComparator);
349    
350                    if (!list.isEmpty()) {
351                            return list.get(0);
352                    }
353    
354                    return null;
355            }
356    
357            /**
358             * Returns the last blogs entry in the ordered set where uuid = &#63;.
359             *
360             * @param uuid the uuid
361             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
362             * @return the last matching blogs entry
363             * @throws NoSuchEntryException if a matching blogs entry could not be found
364             */
365            @Override
366            public BlogsEntry findByUuid_Last(String uuid,
367                    OrderByComparator<BlogsEntry> orderByComparator)
368                    throws NoSuchEntryException {
369                    BlogsEntry blogsEntry = fetchByUuid_Last(uuid, orderByComparator);
370    
371                    if (blogsEntry != null) {
372                            return blogsEntry;
373                    }
374    
375                    StringBundler msg = new StringBundler(4);
376    
377                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
378    
379                    msg.append("uuid=");
380                    msg.append(uuid);
381    
382                    msg.append(StringPool.CLOSE_CURLY_BRACE);
383    
384                    throw new NoSuchEntryException(msg.toString());
385            }
386    
387            /**
388             * Returns the last blogs entry in the ordered set where uuid = &#63;.
389             *
390             * @param uuid the uuid
391             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
392             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
393             */
394            @Override
395            public BlogsEntry fetchByUuid_Last(String uuid,
396                    OrderByComparator<BlogsEntry> orderByComparator) {
397                    int count = countByUuid(uuid);
398    
399                    if (count == 0) {
400                            return null;
401                    }
402    
403                    List<BlogsEntry> list = findByUuid(uuid, count - 1, count,
404                                    orderByComparator);
405    
406                    if (!list.isEmpty()) {
407                            return list.get(0);
408                    }
409    
410                    return null;
411            }
412    
413            /**
414             * Returns the blogs entries before and after the current blogs entry in the ordered set where uuid = &#63;.
415             *
416             * @param entryId the primary key of the current blogs entry
417             * @param uuid the uuid
418             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
419             * @return the previous, current, and next blogs entry
420             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
421             */
422            @Override
423            public BlogsEntry[] findByUuid_PrevAndNext(long entryId, String uuid,
424                    OrderByComparator<BlogsEntry> orderByComparator)
425                    throws NoSuchEntryException {
426                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
427    
428                    Session session = null;
429    
430                    try {
431                            session = openSession();
432    
433                            BlogsEntry[] array = new BlogsEntryImpl[3];
434    
435                            array[0] = getByUuid_PrevAndNext(session, blogsEntry, uuid,
436                                            orderByComparator, true);
437    
438                            array[1] = blogsEntry;
439    
440                            array[2] = getByUuid_PrevAndNext(session, blogsEntry, uuid,
441                                            orderByComparator, false);
442    
443                            return array;
444                    }
445                    catch (Exception e) {
446                            throw processException(e);
447                    }
448                    finally {
449                            closeSession(session);
450                    }
451            }
452    
453            protected BlogsEntry getByUuid_PrevAndNext(Session session,
454                    BlogsEntry blogsEntry, String uuid,
455                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
456                    StringBundler query = null;
457    
458                    if (orderByComparator != null) {
459                            query = new StringBundler(4 +
460                                            (orderByComparator.getOrderByConditionFields().length * 3) +
461                                            (orderByComparator.getOrderByFields().length * 3));
462                    }
463                    else {
464                            query = new StringBundler(3);
465                    }
466    
467                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
468    
469                    boolean bindUuid = false;
470    
471                    if (uuid == null) {
472                            query.append(_FINDER_COLUMN_UUID_UUID_1);
473                    }
474                    else if (uuid.equals(StringPool.BLANK)) {
475                            query.append(_FINDER_COLUMN_UUID_UUID_3);
476                    }
477                    else {
478                            bindUuid = true;
479    
480                            query.append(_FINDER_COLUMN_UUID_UUID_2);
481                    }
482    
483                    if (orderByComparator != null) {
484                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
485    
486                            if (orderByConditionFields.length > 0) {
487                                    query.append(WHERE_AND);
488                            }
489    
490                            for (int i = 0; i < orderByConditionFields.length; i++) {
491                                    query.append(_ORDER_BY_ENTITY_ALIAS);
492                                    query.append(orderByConditionFields[i]);
493    
494                                    if ((i + 1) < orderByConditionFields.length) {
495                                            if (orderByComparator.isAscending() ^ previous) {
496                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
497                                            }
498                                            else {
499                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
500                                            }
501                                    }
502                                    else {
503                                            if (orderByComparator.isAscending() ^ previous) {
504                                                    query.append(WHERE_GREATER_THAN);
505                                            }
506                                            else {
507                                                    query.append(WHERE_LESSER_THAN);
508                                            }
509                                    }
510                            }
511    
512                            query.append(ORDER_BY_CLAUSE);
513    
514                            String[] orderByFields = orderByComparator.getOrderByFields();
515    
516                            for (int i = 0; i < orderByFields.length; i++) {
517                                    query.append(_ORDER_BY_ENTITY_ALIAS);
518                                    query.append(orderByFields[i]);
519    
520                                    if ((i + 1) < orderByFields.length) {
521                                            if (orderByComparator.isAscending() ^ previous) {
522                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
523                                            }
524                                            else {
525                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
526                                            }
527                                    }
528                                    else {
529                                            if (orderByComparator.isAscending() ^ previous) {
530                                                    query.append(ORDER_BY_ASC);
531                                            }
532                                            else {
533                                                    query.append(ORDER_BY_DESC);
534                                            }
535                                    }
536                            }
537                    }
538                    else {
539                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
540                    }
541    
542                    String sql = query.toString();
543    
544                    Query q = session.createQuery(sql);
545    
546                    q.setFirstResult(0);
547                    q.setMaxResults(2);
548    
549                    QueryPos qPos = QueryPos.getInstance(q);
550    
551                    if (bindUuid) {
552                            qPos.add(uuid);
553                    }
554    
555                    if (orderByComparator != null) {
556                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
557    
558                            for (Object value : values) {
559                                    qPos.add(value);
560                            }
561                    }
562    
563                    List<BlogsEntry> list = q.list();
564    
565                    if (list.size() == 2) {
566                            return list.get(1);
567                    }
568                    else {
569                            return null;
570                    }
571            }
572    
573            /**
574             * Removes all the blogs entries where uuid = &#63; from the database.
575             *
576             * @param uuid the uuid
577             */
578            @Override
579            public void removeByUuid(String uuid) {
580                    for (BlogsEntry blogsEntry : findByUuid(uuid, QueryUtil.ALL_POS,
581                                    QueryUtil.ALL_POS, null)) {
582                            remove(blogsEntry);
583                    }
584            }
585    
586            /**
587             * Returns the number of blogs entries where uuid = &#63;.
588             *
589             * @param uuid the uuid
590             * @return the number of matching blogs entries
591             */
592            @Override
593            public int countByUuid(String uuid) {
594                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
595    
596                    Object[] finderArgs = new Object[] { uuid };
597    
598                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
599    
600                    if (count == null) {
601                            StringBundler query = new StringBundler(2);
602    
603                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
604    
605                            boolean bindUuid = false;
606    
607                            if (uuid == null) {
608                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
609                            }
610                            else if (uuid.equals(StringPool.BLANK)) {
611                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
612                            }
613                            else {
614                                    bindUuid = true;
615    
616                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
617                            }
618    
619                            String sql = query.toString();
620    
621                            Session session = null;
622    
623                            try {
624                                    session = openSession();
625    
626                                    Query q = session.createQuery(sql);
627    
628                                    QueryPos qPos = QueryPos.getInstance(q);
629    
630                                    if (bindUuid) {
631                                            qPos.add(uuid);
632                                    }
633    
634                                    count = (Long)q.uniqueResult();
635    
636                                    finderCache.putResult(finderPath, finderArgs, count);
637                            }
638                            catch (Exception e) {
639                                    finderCache.removeResult(finderPath, finderArgs);
640    
641                                    throw processException(e);
642                            }
643                            finally {
644                                    closeSession(session);
645                            }
646                    }
647    
648                    return count.intValue();
649            }
650    
651            private static final String _FINDER_COLUMN_UUID_UUID_1 = "blogsEntry.uuid IS NULL";
652            private static final String _FINDER_COLUMN_UUID_UUID_2 = "blogsEntry.uuid = ?";
653            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(blogsEntry.uuid IS NULL OR blogsEntry.uuid = '')";
654            public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
655                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
656                            FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
657                            new String[] { String.class.getName(), Long.class.getName() },
658                            BlogsEntryModelImpl.UUID_COLUMN_BITMASK |
659                            BlogsEntryModelImpl.GROUPID_COLUMN_BITMASK);
660            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
661                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
662                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
663                            new String[] { String.class.getName(), Long.class.getName() });
664    
665            /**
666             * Returns the blogs entry where uuid = &#63; and groupId = &#63; or throws a {@link NoSuchEntryException} if it could not be found.
667             *
668             * @param uuid the uuid
669             * @param groupId the group ID
670             * @return the matching blogs entry
671             * @throws NoSuchEntryException if a matching blogs entry could not be found
672             */
673            @Override
674            public BlogsEntry findByUUID_G(String uuid, long groupId)
675                    throws NoSuchEntryException {
676                    BlogsEntry blogsEntry = fetchByUUID_G(uuid, groupId);
677    
678                    if (blogsEntry == null) {
679                            StringBundler msg = new StringBundler(6);
680    
681                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
682    
683                            msg.append("uuid=");
684                            msg.append(uuid);
685    
686                            msg.append(", groupId=");
687                            msg.append(groupId);
688    
689                            msg.append(StringPool.CLOSE_CURLY_BRACE);
690    
691                            if (_log.isWarnEnabled()) {
692                                    _log.warn(msg.toString());
693                            }
694    
695                            throw new NoSuchEntryException(msg.toString());
696                    }
697    
698                    return blogsEntry;
699            }
700    
701            /**
702             * 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.
703             *
704             * @param uuid the uuid
705             * @param groupId the group ID
706             * @return the matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
707             */
708            @Override
709            public BlogsEntry fetchByUUID_G(String uuid, long groupId) {
710                    return fetchByUUID_G(uuid, groupId, true);
711            }
712    
713            /**
714             * 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.
715             *
716             * @param uuid the uuid
717             * @param groupId the group ID
718             * @param retrieveFromCache whether to retrieve from the finder cache
719             * @return the matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
720             */
721            @Override
722            public BlogsEntry fetchByUUID_G(String uuid, long groupId,
723                    boolean retrieveFromCache) {
724                    Object[] finderArgs = new Object[] { uuid, groupId };
725    
726                    Object result = null;
727    
728                    if (retrieveFromCache) {
729                            result = finderCache.getResult(FINDER_PATH_FETCH_BY_UUID_G,
730                                            finderArgs, this);
731                    }
732    
733                    if (result instanceof BlogsEntry) {
734                            BlogsEntry blogsEntry = (BlogsEntry)result;
735    
736                            if (!Validator.equals(uuid, blogsEntry.getUuid()) ||
737                                            (groupId != blogsEntry.getGroupId())) {
738                                    result = null;
739                            }
740                    }
741    
742                    if (result == null) {
743                            StringBundler query = new StringBundler(4);
744    
745                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
746    
747                            boolean bindUuid = false;
748    
749                            if (uuid == null) {
750                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
751                            }
752                            else if (uuid.equals(StringPool.BLANK)) {
753                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
754                            }
755                            else {
756                                    bindUuid = true;
757    
758                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
759                            }
760    
761                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
762    
763                            String sql = query.toString();
764    
765                            Session session = null;
766    
767                            try {
768                                    session = openSession();
769    
770                                    Query q = session.createQuery(sql);
771    
772                                    QueryPos qPos = QueryPos.getInstance(q);
773    
774                                    if (bindUuid) {
775                                            qPos.add(uuid);
776                                    }
777    
778                                    qPos.add(groupId);
779    
780                                    List<BlogsEntry> list = q.list();
781    
782                                    if (list.isEmpty()) {
783                                            finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G,
784                                                    finderArgs, list);
785                                    }
786                                    else {
787                                            BlogsEntry blogsEntry = list.get(0);
788    
789                                            result = blogsEntry;
790    
791                                            cacheResult(blogsEntry);
792    
793                                            if ((blogsEntry.getUuid() == null) ||
794                                                            !blogsEntry.getUuid().equals(uuid) ||
795                                                            (blogsEntry.getGroupId() != groupId)) {
796                                                    finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G,
797                                                            finderArgs, blogsEntry);
798                                            }
799                                    }
800                            }
801                            catch (Exception e) {
802                                    finderCache.removeResult(FINDER_PATH_FETCH_BY_UUID_G, finderArgs);
803    
804                                    throw processException(e);
805                            }
806                            finally {
807                                    closeSession(session);
808                            }
809                    }
810    
811                    if (result instanceof List<?>) {
812                            return null;
813                    }
814                    else {
815                            return (BlogsEntry)result;
816                    }
817            }
818    
819            /**
820             * Removes the blogs entry where uuid = &#63; and groupId = &#63; from the database.
821             *
822             * @param uuid the uuid
823             * @param groupId the group ID
824             * @return the blogs entry that was removed
825             */
826            @Override
827            public BlogsEntry removeByUUID_G(String uuid, long groupId)
828                    throws NoSuchEntryException {
829                    BlogsEntry blogsEntry = findByUUID_G(uuid, groupId);
830    
831                    return remove(blogsEntry);
832            }
833    
834            /**
835             * Returns the number of blogs entries where uuid = &#63; and groupId = &#63;.
836             *
837             * @param uuid the uuid
838             * @param groupId the group ID
839             * @return the number of matching blogs entries
840             */
841            @Override
842            public int countByUUID_G(String uuid, long groupId) {
843                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_G;
844    
845                    Object[] finderArgs = new Object[] { uuid, groupId };
846    
847                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
848    
849                    if (count == null) {
850                            StringBundler query = new StringBundler(3);
851    
852                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
853    
854                            boolean bindUuid = false;
855    
856                            if (uuid == null) {
857                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
858                            }
859                            else if (uuid.equals(StringPool.BLANK)) {
860                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
861                            }
862                            else {
863                                    bindUuid = true;
864    
865                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
866                            }
867    
868                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
869    
870                            String sql = query.toString();
871    
872                            Session session = null;
873    
874                            try {
875                                    session = openSession();
876    
877                                    Query q = session.createQuery(sql);
878    
879                                    QueryPos qPos = QueryPos.getInstance(q);
880    
881                                    if (bindUuid) {
882                                            qPos.add(uuid);
883                                    }
884    
885                                    qPos.add(groupId);
886    
887                                    count = (Long)q.uniqueResult();
888    
889                                    finderCache.putResult(finderPath, finderArgs, count);
890                            }
891                            catch (Exception e) {
892                                    finderCache.removeResult(finderPath, finderArgs);
893    
894                                    throw processException(e);
895                            }
896                            finally {
897                                    closeSession(session);
898                            }
899                    }
900    
901                    return count.intValue();
902            }
903    
904            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "blogsEntry.uuid IS NULL AND ";
905            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "blogsEntry.uuid = ? AND ";
906            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(blogsEntry.uuid IS NULL OR blogsEntry.uuid = '') AND ";
907            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "blogsEntry.groupId = ?";
908            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
909                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
910                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C",
911                            new String[] {
912                                    String.class.getName(), Long.class.getName(),
913                                    
914                            Integer.class.getName(), Integer.class.getName(),
915                                    OrderByComparator.class.getName()
916                            });
917            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
918                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
919                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
920                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
921                            new String[] { String.class.getName(), Long.class.getName() },
922                            BlogsEntryModelImpl.UUID_COLUMN_BITMASK |
923                            BlogsEntryModelImpl.COMPANYID_COLUMN_BITMASK |
924                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
925                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
926            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
927                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
928                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
929                            new String[] { String.class.getName(), Long.class.getName() });
930    
931            /**
932             * Returns all the blogs entries where uuid = &#63; and companyId = &#63;.
933             *
934             * @param uuid the uuid
935             * @param companyId the company ID
936             * @return the matching blogs entries
937             */
938            @Override
939            public List<BlogsEntry> findByUuid_C(String uuid, long companyId) {
940                    return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
941                            QueryUtil.ALL_POS, null);
942            }
943    
944            /**
945             * Returns a range of all the blogs entries where uuid = &#63; and companyId = &#63;.
946             *
947             * <p>
948             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
949             * </p>
950             *
951             * @param uuid the uuid
952             * @param companyId the company ID
953             * @param start the lower bound of the range of blogs entries
954             * @param end the upper bound of the range of blogs entries (not inclusive)
955             * @return the range of matching blogs entries
956             */
957            @Override
958            public List<BlogsEntry> findByUuid_C(String uuid, long companyId,
959                    int start, int end) {
960                    return findByUuid_C(uuid, companyId, start, end, null);
961            }
962    
963            /**
964             * Returns an ordered range of all the blogs entries where uuid = &#63; and companyId = &#63;.
965             *
966             * <p>
967             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
968             * </p>
969             *
970             * @param uuid the uuid
971             * @param companyId the company ID
972             * @param start the lower bound of the range of blogs entries
973             * @param end the upper bound of the range of blogs entries (not inclusive)
974             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
975             * @return the ordered range of matching blogs entries
976             */
977            @Override
978            public List<BlogsEntry> findByUuid_C(String uuid, long companyId,
979                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator) {
980                    return findByUuid_C(uuid, companyId, start, end, orderByComparator, true);
981            }
982    
983            /**
984             * Returns an ordered range of all the blogs entries where uuid = &#63; and companyId = &#63;.
985             *
986             * <p>
987             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
988             * </p>
989             *
990             * @param uuid the uuid
991             * @param companyId the company ID
992             * @param start the lower bound of the range of blogs entries
993             * @param end the upper bound of the range of blogs entries (not inclusive)
994             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
995             * @param retrieveFromCache whether to retrieve from the finder cache
996             * @return the ordered range of matching blogs entries
997             */
998            @Override
999            public List<BlogsEntry> findByUuid_C(String uuid, long companyId,
1000                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator,
1001                    boolean retrieveFromCache) {
1002                    boolean pagination = true;
1003                    FinderPath finderPath = null;
1004                    Object[] finderArgs = null;
1005    
1006                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1007                                    (orderByComparator == null)) {
1008                            pagination = false;
1009                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
1010                            finderArgs = new Object[] { uuid, companyId };
1011                    }
1012                    else {
1013                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
1014                            finderArgs = new Object[] {
1015                                            uuid, companyId,
1016                                            
1017                                            start, end, orderByComparator
1018                                    };
1019                    }
1020    
1021                    List<BlogsEntry> list = null;
1022    
1023                    if (retrieveFromCache) {
1024                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
1025                                            finderArgs, this);
1026    
1027                            if ((list != null) && !list.isEmpty()) {
1028                                    for (BlogsEntry blogsEntry : list) {
1029                                            if (!Validator.equals(uuid, blogsEntry.getUuid()) ||
1030                                                            (companyId != blogsEntry.getCompanyId())) {
1031                                                    list = null;
1032    
1033                                                    break;
1034                                            }
1035                                    }
1036                            }
1037                    }
1038    
1039                    if (list == null) {
1040                            StringBundler query = null;
1041    
1042                            if (orderByComparator != null) {
1043                                    query = new StringBundler(4 +
1044                                                    (orderByComparator.getOrderByFields().length * 2));
1045                            }
1046                            else {
1047                                    query = new StringBundler(4);
1048                            }
1049    
1050                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
1051    
1052                            boolean bindUuid = false;
1053    
1054                            if (uuid == null) {
1055                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1056                            }
1057                            else if (uuid.equals(StringPool.BLANK)) {
1058                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1059                            }
1060                            else {
1061                                    bindUuid = true;
1062    
1063                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1064                            }
1065    
1066                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1067    
1068                            if (orderByComparator != null) {
1069                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1070                                            orderByComparator);
1071                            }
1072                            else
1073                             if (pagination) {
1074                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
1075                            }
1076    
1077                            String sql = query.toString();
1078    
1079                            Session session = null;
1080    
1081                            try {
1082                                    session = openSession();
1083    
1084                                    Query q = session.createQuery(sql);
1085    
1086                                    QueryPos qPos = QueryPos.getInstance(q);
1087    
1088                                    if (bindUuid) {
1089                                            qPos.add(uuid);
1090                                    }
1091    
1092                                    qPos.add(companyId);
1093    
1094                                    if (!pagination) {
1095                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
1096                                                            start, end, false);
1097    
1098                                            Collections.sort(list);
1099    
1100                                            list = Collections.unmodifiableList(list);
1101                                    }
1102                                    else {
1103                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
1104                                                            start, end);
1105                                    }
1106    
1107                                    cacheResult(list);
1108    
1109                                    finderCache.putResult(finderPath, finderArgs, list);
1110                            }
1111                            catch (Exception e) {
1112                                    finderCache.removeResult(finderPath, finderArgs);
1113    
1114                                    throw processException(e);
1115                            }
1116                            finally {
1117                                    closeSession(session);
1118                            }
1119                    }
1120    
1121                    return list;
1122            }
1123    
1124            /**
1125             * Returns the first blogs entry in the ordered set where uuid = &#63; and companyId = &#63;.
1126             *
1127             * @param uuid the uuid
1128             * @param companyId the company ID
1129             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1130             * @return the first matching blogs entry
1131             * @throws NoSuchEntryException if a matching blogs entry could not be found
1132             */
1133            @Override
1134            public BlogsEntry findByUuid_C_First(String uuid, long companyId,
1135                    OrderByComparator<BlogsEntry> orderByComparator)
1136                    throws NoSuchEntryException {
1137                    BlogsEntry blogsEntry = fetchByUuid_C_First(uuid, companyId,
1138                                    orderByComparator);
1139    
1140                    if (blogsEntry != null) {
1141                            return blogsEntry;
1142                    }
1143    
1144                    StringBundler msg = new StringBundler(6);
1145    
1146                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1147    
1148                    msg.append("uuid=");
1149                    msg.append(uuid);
1150    
1151                    msg.append(", companyId=");
1152                    msg.append(companyId);
1153    
1154                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1155    
1156                    throw new NoSuchEntryException(msg.toString());
1157            }
1158    
1159            /**
1160             * Returns the first blogs entry in the ordered set where uuid = &#63; and companyId = &#63;.
1161             *
1162             * @param uuid the uuid
1163             * @param companyId the company ID
1164             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1165             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
1166             */
1167            @Override
1168            public BlogsEntry fetchByUuid_C_First(String uuid, long companyId,
1169                    OrderByComparator<BlogsEntry> orderByComparator) {
1170                    List<BlogsEntry> list = findByUuid_C(uuid, companyId, 0, 1,
1171                                    orderByComparator);
1172    
1173                    if (!list.isEmpty()) {
1174                            return list.get(0);
1175                    }
1176    
1177                    return null;
1178            }
1179    
1180            /**
1181             * Returns the last blogs entry in the ordered set where uuid = &#63; and companyId = &#63;.
1182             *
1183             * @param uuid the uuid
1184             * @param companyId the company ID
1185             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1186             * @return the last matching blogs entry
1187             * @throws NoSuchEntryException if a matching blogs entry could not be found
1188             */
1189            @Override
1190            public BlogsEntry findByUuid_C_Last(String uuid, long companyId,
1191                    OrderByComparator<BlogsEntry> orderByComparator)
1192                    throws NoSuchEntryException {
1193                    BlogsEntry blogsEntry = fetchByUuid_C_Last(uuid, companyId,
1194                                    orderByComparator);
1195    
1196                    if (blogsEntry != null) {
1197                            return blogsEntry;
1198                    }
1199    
1200                    StringBundler msg = new StringBundler(6);
1201    
1202                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1203    
1204                    msg.append("uuid=");
1205                    msg.append(uuid);
1206    
1207                    msg.append(", companyId=");
1208                    msg.append(companyId);
1209    
1210                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1211    
1212                    throw new NoSuchEntryException(msg.toString());
1213            }
1214    
1215            /**
1216             * Returns the last blogs entry in the ordered set where uuid = &#63; and companyId = &#63;.
1217             *
1218             * @param uuid the uuid
1219             * @param companyId the company ID
1220             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1221             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
1222             */
1223            @Override
1224            public BlogsEntry fetchByUuid_C_Last(String uuid, long companyId,
1225                    OrderByComparator<BlogsEntry> orderByComparator) {
1226                    int count = countByUuid_C(uuid, companyId);
1227    
1228                    if (count == 0) {
1229                            return null;
1230                    }
1231    
1232                    List<BlogsEntry> list = findByUuid_C(uuid, companyId, count - 1, count,
1233                                    orderByComparator);
1234    
1235                    if (!list.isEmpty()) {
1236                            return list.get(0);
1237                    }
1238    
1239                    return null;
1240            }
1241    
1242            /**
1243             * Returns the blogs entries before and after the current blogs entry in the ordered set where uuid = &#63; and companyId = &#63;.
1244             *
1245             * @param entryId the primary key of the current blogs entry
1246             * @param uuid the uuid
1247             * @param companyId the company ID
1248             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1249             * @return the previous, current, and next blogs entry
1250             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
1251             */
1252            @Override
1253            public BlogsEntry[] findByUuid_C_PrevAndNext(long entryId, String uuid,
1254                    long companyId, OrderByComparator<BlogsEntry> orderByComparator)
1255                    throws NoSuchEntryException {
1256                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
1257    
1258                    Session session = null;
1259    
1260                    try {
1261                            session = openSession();
1262    
1263                            BlogsEntry[] array = new BlogsEntryImpl[3];
1264    
1265                            array[0] = getByUuid_C_PrevAndNext(session, blogsEntry, uuid,
1266                                            companyId, orderByComparator, true);
1267    
1268                            array[1] = blogsEntry;
1269    
1270                            array[2] = getByUuid_C_PrevAndNext(session, blogsEntry, uuid,
1271                                            companyId, orderByComparator, false);
1272    
1273                            return array;
1274                    }
1275                    catch (Exception e) {
1276                            throw processException(e);
1277                    }
1278                    finally {
1279                            closeSession(session);
1280                    }
1281            }
1282    
1283            protected BlogsEntry getByUuid_C_PrevAndNext(Session session,
1284                    BlogsEntry blogsEntry, String uuid, long companyId,
1285                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
1286                    StringBundler query = null;
1287    
1288                    if (orderByComparator != null) {
1289                            query = new StringBundler(5 +
1290                                            (orderByComparator.getOrderByConditionFields().length * 3) +
1291                                            (orderByComparator.getOrderByFields().length * 3));
1292                    }
1293                    else {
1294                            query = new StringBundler(4);
1295                    }
1296    
1297                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
1298    
1299                    boolean bindUuid = false;
1300    
1301                    if (uuid == null) {
1302                            query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1303                    }
1304                    else if (uuid.equals(StringPool.BLANK)) {
1305                            query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1306                    }
1307                    else {
1308                            bindUuid = true;
1309    
1310                            query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1311                    }
1312    
1313                    query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1314    
1315                    if (orderByComparator != null) {
1316                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1317    
1318                            if (orderByConditionFields.length > 0) {
1319                                    query.append(WHERE_AND);
1320                            }
1321    
1322                            for (int i = 0; i < orderByConditionFields.length; i++) {
1323                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1324                                    query.append(orderByConditionFields[i]);
1325    
1326                                    if ((i + 1) < orderByConditionFields.length) {
1327                                            if (orderByComparator.isAscending() ^ previous) {
1328                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1329                                            }
1330                                            else {
1331                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1332                                            }
1333                                    }
1334                                    else {
1335                                            if (orderByComparator.isAscending() ^ previous) {
1336                                                    query.append(WHERE_GREATER_THAN);
1337                                            }
1338                                            else {
1339                                                    query.append(WHERE_LESSER_THAN);
1340                                            }
1341                                    }
1342                            }
1343    
1344                            query.append(ORDER_BY_CLAUSE);
1345    
1346                            String[] orderByFields = orderByComparator.getOrderByFields();
1347    
1348                            for (int i = 0; i < orderByFields.length; i++) {
1349                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1350                                    query.append(orderByFields[i]);
1351    
1352                                    if ((i + 1) < orderByFields.length) {
1353                                            if (orderByComparator.isAscending() ^ previous) {
1354                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1355                                            }
1356                                            else {
1357                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1358                                            }
1359                                    }
1360                                    else {
1361                                            if (orderByComparator.isAscending() ^ previous) {
1362                                                    query.append(ORDER_BY_ASC);
1363                                            }
1364                                            else {
1365                                                    query.append(ORDER_BY_DESC);
1366                                            }
1367                                    }
1368                            }
1369                    }
1370                    else {
1371                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
1372                    }
1373    
1374                    String sql = query.toString();
1375    
1376                    Query q = session.createQuery(sql);
1377    
1378                    q.setFirstResult(0);
1379                    q.setMaxResults(2);
1380    
1381                    QueryPos qPos = QueryPos.getInstance(q);
1382    
1383                    if (bindUuid) {
1384                            qPos.add(uuid);
1385                    }
1386    
1387                    qPos.add(companyId);
1388    
1389                    if (orderByComparator != null) {
1390                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
1391    
1392                            for (Object value : values) {
1393                                    qPos.add(value);
1394                            }
1395                    }
1396    
1397                    List<BlogsEntry> list = q.list();
1398    
1399                    if (list.size() == 2) {
1400                            return list.get(1);
1401                    }
1402                    else {
1403                            return null;
1404                    }
1405            }
1406    
1407            /**
1408             * Removes all the blogs entries where uuid = &#63; and companyId = &#63; from the database.
1409             *
1410             * @param uuid the uuid
1411             * @param companyId the company ID
1412             */
1413            @Override
1414            public void removeByUuid_C(String uuid, long companyId) {
1415                    for (BlogsEntry blogsEntry : findByUuid_C(uuid, companyId,
1416                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1417                            remove(blogsEntry);
1418                    }
1419            }
1420    
1421            /**
1422             * Returns the number of blogs entries where uuid = &#63; and companyId = &#63;.
1423             *
1424             * @param uuid the uuid
1425             * @param companyId the company ID
1426             * @return the number of matching blogs entries
1427             */
1428            @Override
1429            public int countByUuid_C(String uuid, long companyId) {
1430                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1431    
1432                    Object[] finderArgs = new Object[] { uuid, companyId };
1433    
1434                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
1435    
1436                    if (count == null) {
1437                            StringBundler query = new StringBundler(3);
1438    
1439                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
1440    
1441                            boolean bindUuid = false;
1442    
1443                            if (uuid == null) {
1444                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1445                            }
1446                            else if (uuid.equals(StringPool.BLANK)) {
1447                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1448                            }
1449                            else {
1450                                    bindUuid = true;
1451    
1452                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1453                            }
1454    
1455                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1456    
1457                            String sql = query.toString();
1458    
1459                            Session session = null;
1460    
1461                            try {
1462                                    session = openSession();
1463    
1464                                    Query q = session.createQuery(sql);
1465    
1466                                    QueryPos qPos = QueryPos.getInstance(q);
1467    
1468                                    if (bindUuid) {
1469                                            qPos.add(uuid);
1470                                    }
1471    
1472                                    qPos.add(companyId);
1473    
1474                                    count = (Long)q.uniqueResult();
1475    
1476                                    finderCache.putResult(finderPath, finderArgs, count);
1477                            }
1478                            catch (Exception e) {
1479                                    finderCache.removeResult(finderPath, finderArgs);
1480    
1481                                    throw processException(e);
1482                            }
1483                            finally {
1484                                    closeSession(session);
1485                            }
1486                    }
1487    
1488                    return count.intValue();
1489            }
1490    
1491            private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "blogsEntry.uuid IS NULL AND ";
1492            private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "blogsEntry.uuid = ? AND ";
1493            private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(blogsEntry.uuid IS NULL OR blogsEntry.uuid = '') AND ";
1494            private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "blogsEntry.companyId = ?";
1495            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
1496                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
1497                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId",
1498                            new String[] {
1499                                    Long.class.getName(),
1500                                    
1501                            Integer.class.getName(), Integer.class.getName(),
1502                                    OrderByComparator.class.getName()
1503                            });
1504            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
1505                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
1506                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
1507                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
1508                            new String[] { Long.class.getName() },
1509                            BlogsEntryModelImpl.GROUPID_COLUMN_BITMASK |
1510                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
1511                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
1512            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
1513                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
1514                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
1515                            new String[] { Long.class.getName() });
1516    
1517            /**
1518             * Returns all the blogs entries where groupId = &#63;.
1519             *
1520             * @param groupId the group ID
1521             * @return the matching blogs entries
1522             */
1523            @Override
1524            public List<BlogsEntry> findByGroupId(long groupId) {
1525                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1526            }
1527    
1528            /**
1529             * Returns a range of all the blogs entries where groupId = &#63;.
1530             *
1531             * <p>
1532             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1533             * </p>
1534             *
1535             * @param groupId the group ID
1536             * @param start the lower bound of the range of blogs entries
1537             * @param end the upper bound of the range of blogs entries (not inclusive)
1538             * @return the range of matching blogs entries
1539             */
1540            @Override
1541            public List<BlogsEntry> findByGroupId(long groupId, int start, int end) {
1542                    return findByGroupId(groupId, start, end, null);
1543            }
1544    
1545            /**
1546             * Returns an ordered range of all the blogs entries where groupId = &#63;.
1547             *
1548             * <p>
1549             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1550             * </p>
1551             *
1552             * @param groupId the group ID
1553             * @param start the lower bound of the range of blogs entries
1554             * @param end the upper bound of the range of blogs entries (not inclusive)
1555             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1556             * @return the ordered range of matching blogs entries
1557             */
1558            @Override
1559            public List<BlogsEntry> findByGroupId(long groupId, int start, int end,
1560                    OrderByComparator<BlogsEntry> orderByComparator) {
1561                    return findByGroupId(groupId, start, end, orderByComparator, true);
1562            }
1563    
1564            /**
1565             * Returns an ordered range of all the blogs entries where groupId = &#63;.
1566             *
1567             * <p>
1568             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1569             * </p>
1570             *
1571             * @param groupId the group ID
1572             * @param start the lower bound of the range of blogs entries
1573             * @param end the upper bound of the range of blogs entries (not inclusive)
1574             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1575             * @param retrieveFromCache whether to retrieve from the finder cache
1576             * @return the ordered range of matching blogs entries
1577             */
1578            @Override
1579            public List<BlogsEntry> findByGroupId(long groupId, int start, int end,
1580                    OrderByComparator<BlogsEntry> orderByComparator,
1581                    boolean retrieveFromCache) {
1582                    boolean pagination = true;
1583                    FinderPath finderPath = null;
1584                    Object[] finderArgs = null;
1585    
1586                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1587                                    (orderByComparator == null)) {
1588                            pagination = false;
1589                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1590                            finderArgs = new Object[] { groupId };
1591                    }
1592                    else {
1593                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1594                            finderArgs = new Object[] { groupId, start, end, orderByComparator };
1595                    }
1596    
1597                    List<BlogsEntry> list = null;
1598    
1599                    if (retrieveFromCache) {
1600                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
1601                                            finderArgs, this);
1602    
1603                            if ((list != null) && !list.isEmpty()) {
1604                                    for (BlogsEntry blogsEntry : list) {
1605                                            if ((groupId != blogsEntry.getGroupId())) {
1606                                                    list = null;
1607    
1608                                                    break;
1609                                            }
1610                                    }
1611                            }
1612                    }
1613    
1614                    if (list == null) {
1615                            StringBundler query = null;
1616    
1617                            if (orderByComparator != null) {
1618                                    query = new StringBundler(3 +
1619                                                    (orderByComparator.getOrderByFields().length * 2));
1620                            }
1621                            else {
1622                                    query = new StringBundler(3);
1623                            }
1624    
1625                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
1626    
1627                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1628    
1629                            if (orderByComparator != null) {
1630                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1631                                            orderByComparator);
1632                            }
1633                            else
1634                             if (pagination) {
1635                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
1636                            }
1637    
1638                            String sql = query.toString();
1639    
1640                            Session session = null;
1641    
1642                            try {
1643                                    session = openSession();
1644    
1645                                    Query q = session.createQuery(sql);
1646    
1647                                    QueryPos qPos = QueryPos.getInstance(q);
1648    
1649                                    qPos.add(groupId);
1650    
1651                                    if (!pagination) {
1652                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
1653                                                            start, end, false);
1654    
1655                                            Collections.sort(list);
1656    
1657                                            list = Collections.unmodifiableList(list);
1658                                    }
1659                                    else {
1660                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
1661                                                            start, end);
1662                                    }
1663    
1664                                    cacheResult(list);
1665    
1666                                    finderCache.putResult(finderPath, finderArgs, list);
1667                            }
1668                            catch (Exception e) {
1669                                    finderCache.removeResult(finderPath, finderArgs);
1670    
1671                                    throw processException(e);
1672                            }
1673                            finally {
1674                                    closeSession(session);
1675                            }
1676                    }
1677    
1678                    return list;
1679            }
1680    
1681            /**
1682             * Returns the first blogs entry in the ordered set where groupId = &#63;.
1683             *
1684             * @param groupId the group ID
1685             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1686             * @return the first matching blogs entry
1687             * @throws NoSuchEntryException if a matching blogs entry could not be found
1688             */
1689            @Override
1690            public BlogsEntry findByGroupId_First(long groupId,
1691                    OrderByComparator<BlogsEntry> orderByComparator)
1692                    throws NoSuchEntryException {
1693                    BlogsEntry blogsEntry = fetchByGroupId_First(groupId, orderByComparator);
1694    
1695                    if (blogsEntry != null) {
1696                            return blogsEntry;
1697                    }
1698    
1699                    StringBundler msg = new StringBundler(4);
1700    
1701                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1702    
1703                    msg.append("groupId=");
1704                    msg.append(groupId);
1705    
1706                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1707    
1708                    throw new NoSuchEntryException(msg.toString());
1709            }
1710    
1711            /**
1712             * Returns the first blogs entry in the ordered set where groupId = &#63;.
1713             *
1714             * @param groupId the group ID
1715             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1716             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
1717             */
1718            @Override
1719            public BlogsEntry fetchByGroupId_First(long groupId,
1720                    OrderByComparator<BlogsEntry> orderByComparator) {
1721                    List<BlogsEntry> list = findByGroupId(groupId, 0, 1, orderByComparator);
1722    
1723                    if (!list.isEmpty()) {
1724                            return list.get(0);
1725                    }
1726    
1727                    return null;
1728            }
1729    
1730            /**
1731             * Returns the last blogs entry in the ordered set where groupId = &#63;.
1732             *
1733             * @param groupId the group ID
1734             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1735             * @return the last matching blogs entry
1736             * @throws NoSuchEntryException if a matching blogs entry could not be found
1737             */
1738            @Override
1739            public BlogsEntry findByGroupId_Last(long groupId,
1740                    OrderByComparator<BlogsEntry> orderByComparator)
1741                    throws NoSuchEntryException {
1742                    BlogsEntry blogsEntry = fetchByGroupId_Last(groupId, orderByComparator);
1743    
1744                    if (blogsEntry != null) {
1745                            return blogsEntry;
1746                    }
1747    
1748                    StringBundler msg = new StringBundler(4);
1749    
1750                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1751    
1752                    msg.append("groupId=");
1753                    msg.append(groupId);
1754    
1755                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1756    
1757                    throw new NoSuchEntryException(msg.toString());
1758            }
1759    
1760            /**
1761             * Returns the last blogs entry in the ordered set where groupId = &#63;.
1762             *
1763             * @param groupId the group ID
1764             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1765             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
1766             */
1767            @Override
1768            public BlogsEntry fetchByGroupId_Last(long groupId,
1769                    OrderByComparator<BlogsEntry> orderByComparator) {
1770                    int count = countByGroupId(groupId);
1771    
1772                    if (count == 0) {
1773                            return null;
1774                    }
1775    
1776                    List<BlogsEntry> list = findByGroupId(groupId, count - 1, count,
1777                                    orderByComparator);
1778    
1779                    if (!list.isEmpty()) {
1780                            return list.get(0);
1781                    }
1782    
1783                    return null;
1784            }
1785    
1786            /**
1787             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63;.
1788             *
1789             * @param entryId the primary key of the current blogs entry
1790             * @param groupId the group ID
1791             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1792             * @return the previous, current, and next blogs entry
1793             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
1794             */
1795            @Override
1796            public BlogsEntry[] findByGroupId_PrevAndNext(long entryId, long groupId,
1797                    OrderByComparator<BlogsEntry> orderByComparator)
1798                    throws NoSuchEntryException {
1799                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
1800    
1801                    Session session = null;
1802    
1803                    try {
1804                            session = openSession();
1805    
1806                            BlogsEntry[] array = new BlogsEntryImpl[3];
1807    
1808                            array[0] = getByGroupId_PrevAndNext(session, blogsEntry, groupId,
1809                                            orderByComparator, true);
1810    
1811                            array[1] = blogsEntry;
1812    
1813                            array[2] = getByGroupId_PrevAndNext(session, blogsEntry, groupId,
1814                                            orderByComparator, false);
1815    
1816                            return array;
1817                    }
1818                    catch (Exception e) {
1819                            throw processException(e);
1820                    }
1821                    finally {
1822                            closeSession(session);
1823                    }
1824            }
1825    
1826            protected BlogsEntry getByGroupId_PrevAndNext(Session session,
1827                    BlogsEntry blogsEntry, long groupId,
1828                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
1829                    StringBundler query = null;
1830    
1831                    if (orderByComparator != null) {
1832                            query = new StringBundler(4 +
1833                                            (orderByComparator.getOrderByConditionFields().length * 3) +
1834                                            (orderByComparator.getOrderByFields().length * 3));
1835                    }
1836                    else {
1837                            query = new StringBundler(3);
1838                    }
1839    
1840                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
1841    
1842                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1843    
1844                    if (orderByComparator != null) {
1845                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1846    
1847                            if (orderByConditionFields.length > 0) {
1848                                    query.append(WHERE_AND);
1849                            }
1850    
1851                            for (int i = 0; i < orderByConditionFields.length; i++) {
1852                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1853                                    query.append(orderByConditionFields[i]);
1854    
1855                                    if ((i + 1) < orderByConditionFields.length) {
1856                                            if (orderByComparator.isAscending() ^ previous) {
1857                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1858                                            }
1859                                            else {
1860                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1861                                            }
1862                                    }
1863                                    else {
1864                                            if (orderByComparator.isAscending() ^ previous) {
1865                                                    query.append(WHERE_GREATER_THAN);
1866                                            }
1867                                            else {
1868                                                    query.append(WHERE_LESSER_THAN);
1869                                            }
1870                                    }
1871                            }
1872    
1873                            query.append(ORDER_BY_CLAUSE);
1874    
1875                            String[] orderByFields = orderByComparator.getOrderByFields();
1876    
1877                            for (int i = 0; i < orderByFields.length; i++) {
1878                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1879                                    query.append(orderByFields[i]);
1880    
1881                                    if ((i + 1) < orderByFields.length) {
1882                                            if (orderByComparator.isAscending() ^ previous) {
1883                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1884                                            }
1885                                            else {
1886                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1887                                            }
1888                                    }
1889                                    else {
1890                                            if (orderByComparator.isAscending() ^ previous) {
1891                                                    query.append(ORDER_BY_ASC);
1892                                            }
1893                                            else {
1894                                                    query.append(ORDER_BY_DESC);
1895                                            }
1896                                    }
1897                            }
1898                    }
1899                    else {
1900                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
1901                    }
1902    
1903                    String sql = query.toString();
1904    
1905                    Query q = session.createQuery(sql);
1906    
1907                    q.setFirstResult(0);
1908                    q.setMaxResults(2);
1909    
1910                    QueryPos qPos = QueryPos.getInstance(q);
1911    
1912                    qPos.add(groupId);
1913    
1914                    if (orderByComparator != null) {
1915                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
1916    
1917                            for (Object value : values) {
1918                                    qPos.add(value);
1919                            }
1920                    }
1921    
1922                    List<BlogsEntry> list = q.list();
1923    
1924                    if (list.size() == 2) {
1925                            return list.get(1);
1926                    }
1927                    else {
1928                            return null;
1929                    }
1930            }
1931    
1932            /**
1933             * Returns all the blogs entries that the user has permission to view where groupId = &#63;.
1934             *
1935             * @param groupId the group ID
1936             * @return the matching blogs entries that the user has permission to view
1937             */
1938            @Override
1939            public List<BlogsEntry> filterFindByGroupId(long groupId) {
1940                    return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1941                            QueryUtil.ALL_POS, null);
1942            }
1943    
1944            /**
1945             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63;.
1946             *
1947             * <p>
1948             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1949             * </p>
1950             *
1951             * @param groupId the group ID
1952             * @param start the lower bound of the range of blogs entries
1953             * @param end the upper bound of the range of blogs entries (not inclusive)
1954             * @return the range of matching blogs entries that the user has permission to view
1955             */
1956            @Override
1957            public List<BlogsEntry> filterFindByGroupId(long groupId, int start, int end) {
1958                    return filterFindByGroupId(groupId, start, end, null);
1959            }
1960    
1961            /**
1962             * Returns an ordered range of all the blogs entries that the user has permissions to view where groupId = &#63;.
1963             *
1964             * <p>
1965             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1966             * </p>
1967             *
1968             * @param groupId the group ID
1969             * @param start the lower bound of the range of blogs entries
1970             * @param end the upper bound of the range of blogs entries (not inclusive)
1971             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1972             * @return the ordered range of matching blogs entries that the user has permission to view
1973             */
1974            @Override
1975            public List<BlogsEntry> filterFindByGroupId(long groupId, int start,
1976                    int end, OrderByComparator<BlogsEntry> orderByComparator) {
1977                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1978                            return findByGroupId(groupId, start, end, orderByComparator);
1979                    }
1980    
1981                    StringBundler query = null;
1982    
1983                    if (orderByComparator != null) {
1984                            query = new StringBundler(3 +
1985                                            (orderByComparator.getOrderByFields().length * 2));
1986                    }
1987                    else {
1988                            query = new StringBundler(4);
1989                    }
1990    
1991                    if (getDB().isSupportsInlineDistinct()) {
1992                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
1993                    }
1994                    else {
1995                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
1996                    }
1997    
1998                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1999    
2000                    if (!getDB().isSupportsInlineDistinct()) {
2001                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
2002                    }
2003    
2004                    if (orderByComparator != null) {
2005                            if (getDB().isSupportsInlineDistinct()) {
2006                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2007                                            orderByComparator, true);
2008                            }
2009                            else {
2010                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2011                                            orderByComparator, true);
2012                            }
2013                    }
2014                    else {
2015                            if (getDB().isSupportsInlineDistinct()) {
2016                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
2017                            }
2018                            else {
2019                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
2020                            }
2021                    }
2022    
2023                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2024                                    BlogsEntry.class.getName(),
2025                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2026    
2027                    Session session = null;
2028    
2029                    try {
2030                            session = openSession();
2031    
2032                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
2033    
2034                            if (getDB().isSupportsInlineDistinct()) {
2035                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
2036                            }
2037                            else {
2038                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
2039                            }
2040    
2041                            QueryPos qPos = QueryPos.getInstance(q);
2042    
2043                            qPos.add(groupId);
2044    
2045                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
2046                    }
2047                    catch (Exception e) {
2048                            throw processException(e);
2049                    }
2050                    finally {
2051                            closeSession(session);
2052                    }
2053            }
2054    
2055            /**
2056             * 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;.
2057             *
2058             * @param entryId the primary key of the current blogs entry
2059             * @param groupId the group ID
2060             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2061             * @return the previous, current, and next blogs entry
2062             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
2063             */
2064            @Override
2065            public BlogsEntry[] filterFindByGroupId_PrevAndNext(long entryId,
2066                    long groupId, OrderByComparator<BlogsEntry> orderByComparator)
2067                    throws NoSuchEntryException {
2068                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2069                            return findByGroupId_PrevAndNext(entryId, groupId, orderByComparator);
2070                    }
2071    
2072                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
2073    
2074                    Session session = null;
2075    
2076                    try {
2077                            session = openSession();
2078    
2079                            BlogsEntry[] array = new BlogsEntryImpl[3];
2080    
2081                            array[0] = filterGetByGroupId_PrevAndNext(session, blogsEntry,
2082                                            groupId, orderByComparator, true);
2083    
2084                            array[1] = blogsEntry;
2085    
2086                            array[2] = filterGetByGroupId_PrevAndNext(session, blogsEntry,
2087                                            groupId, orderByComparator, false);
2088    
2089                            return array;
2090                    }
2091                    catch (Exception e) {
2092                            throw processException(e);
2093                    }
2094                    finally {
2095                            closeSession(session);
2096                    }
2097            }
2098    
2099            protected BlogsEntry filterGetByGroupId_PrevAndNext(Session session,
2100                    BlogsEntry blogsEntry, long groupId,
2101                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
2102                    StringBundler query = null;
2103    
2104                    if (orderByComparator != null) {
2105                            query = new StringBundler(5 +
2106                                            (orderByComparator.getOrderByConditionFields().length * 3) +
2107                                            (orderByComparator.getOrderByFields().length * 3));
2108                    }
2109                    else {
2110                            query = new StringBundler(4);
2111                    }
2112    
2113                    if (getDB().isSupportsInlineDistinct()) {
2114                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
2115                    }
2116                    else {
2117                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
2118                    }
2119    
2120                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2121    
2122                    if (!getDB().isSupportsInlineDistinct()) {
2123                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
2124                    }
2125    
2126                    if (orderByComparator != null) {
2127                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2128    
2129                            if (orderByConditionFields.length > 0) {
2130                                    query.append(WHERE_AND);
2131                            }
2132    
2133                            for (int i = 0; i < orderByConditionFields.length; i++) {
2134                                    if (getDB().isSupportsInlineDistinct()) {
2135                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2136                                    }
2137                                    else {
2138                                            query.append(_ORDER_BY_ENTITY_TABLE);
2139                                    }
2140    
2141                                    query.append(orderByConditionFields[i]);
2142    
2143                                    if ((i + 1) < orderByConditionFields.length) {
2144                                            if (orderByComparator.isAscending() ^ previous) {
2145                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2146                                            }
2147                                            else {
2148                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2149                                            }
2150                                    }
2151                                    else {
2152                                            if (orderByComparator.isAscending() ^ previous) {
2153                                                    query.append(WHERE_GREATER_THAN);
2154                                            }
2155                                            else {
2156                                                    query.append(WHERE_LESSER_THAN);
2157                                            }
2158                                    }
2159                            }
2160    
2161                            query.append(ORDER_BY_CLAUSE);
2162    
2163                            String[] orderByFields = orderByComparator.getOrderByFields();
2164    
2165                            for (int i = 0; i < orderByFields.length; i++) {
2166                                    if (getDB().isSupportsInlineDistinct()) {
2167                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2168                                    }
2169                                    else {
2170                                            query.append(_ORDER_BY_ENTITY_TABLE);
2171                                    }
2172    
2173                                    query.append(orderByFields[i]);
2174    
2175                                    if ((i + 1) < orderByFields.length) {
2176                                            if (orderByComparator.isAscending() ^ previous) {
2177                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2178                                            }
2179                                            else {
2180                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2181                                            }
2182                                    }
2183                                    else {
2184                                            if (orderByComparator.isAscending() ^ previous) {
2185                                                    query.append(ORDER_BY_ASC);
2186                                            }
2187                                            else {
2188                                                    query.append(ORDER_BY_DESC);
2189                                            }
2190                                    }
2191                            }
2192                    }
2193                    else {
2194                            if (getDB().isSupportsInlineDistinct()) {
2195                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
2196                            }
2197                            else {
2198                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
2199                            }
2200                    }
2201    
2202                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2203                                    BlogsEntry.class.getName(),
2204                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2205    
2206                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
2207    
2208                    q.setFirstResult(0);
2209                    q.setMaxResults(2);
2210    
2211                    if (getDB().isSupportsInlineDistinct()) {
2212                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
2213                    }
2214                    else {
2215                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
2216                    }
2217    
2218                    QueryPos qPos = QueryPos.getInstance(q);
2219    
2220                    qPos.add(groupId);
2221    
2222                    if (orderByComparator != null) {
2223                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
2224    
2225                            for (Object value : values) {
2226                                    qPos.add(value);
2227                            }
2228                    }
2229    
2230                    List<BlogsEntry> list = q.list();
2231    
2232                    if (list.size() == 2) {
2233                            return list.get(1);
2234                    }
2235                    else {
2236                            return null;
2237                    }
2238            }
2239    
2240            /**
2241             * Removes all the blogs entries where groupId = &#63; from the database.
2242             *
2243             * @param groupId the group ID
2244             */
2245            @Override
2246            public void removeByGroupId(long groupId) {
2247                    for (BlogsEntry blogsEntry : findByGroupId(groupId, QueryUtil.ALL_POS,
2248                                    QueryUtil.ALL_POS, null)) {
2249                            remove(blogsEntry);
2250                    }
2251            }
2252    
2253            /**
2254             * Returns the number of blogs entries where groupId = &#63;.
2255             *
2256             * @param groupId the group ID
2257             * @return the number of matching blogs entries
2258             */
2259            @Override
2260            public int countByGroupId(long groupId) {
2261                    FinderPath finderPath = FINDER_PATH_COUNT_BY_GROUPID;
2262    
2263                    Object[] finderArgs = new Object[] { groupId };
2264    
2265                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
2266    
2267                    if (count == null) {
2268                            StringBundler query = new StringBundler(2);
2269    
2270                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
2271    
2272                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2273    
2274                            String sql = query.toString();
2275    
2276                            Session session = null;
2277    
2278                            try {
2279                                    session = openSession();
2280    
2281                                    Query q = session.createQuery(sql);
2282    
2283                                    QueryPos qPos = QueryPos.getInstance(q);
2284    
2285                                    qPos.add(groupId);
2286    
2287                                    count = (Long)q.uniqueResult();
2288    
2289                                    finderCache.putResult(finderPath, finderArgs, count);
2290                            }
2291                            catch (Exception e) {
2292                                    finderCache.removeResult(finderPath, finderArgs);
2293    
2294                                    throw processException(e);
2295                            }
2296                            finally {
2297                                    closeSession(session);
2298                            }
2299                    }
2300    
2301                    return count.intValue();
2302            }
2303    
2304            /**
2305             * Returns the number of blogs entries that the user has permission to view where groupId = &#63;.
2306             *
2307             * @param groupId the group ID
2308             * @return the number of matching blogs entries that the user has permission to view
2309             */
2310            @Override
2311            public int filterCountByGroupId(long groupId) {
2312                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2313                            return countByGroupId(groupId);
2314                    }
2315    
2316                    StringBundler query = new StringBundler(2);
2317    
2318                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
2319    
2320                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2321    
2322                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2323                                    BlogsEntry.class.getName(),
2324                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2325    
2326                    Session session = null;
2327    
2328                    try {
2329                            session = openSession();
2330    
2331                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
2332    
2333                            q.addScalar(COUNT_COLUMN_NAME,
2334                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
2335    
2336                            QueryPos qPos = QueryPos.getInstance(q);
2337    
2338                            qPos.add(groupId);
2339    
2340                            Long count = (Long)q.uniqueResult();
2341    
2342                            return count.intValue();
2343                    }
2344                    catch (Exception e) {
2345                            throw processException(e);
2346                    }
2347                    finally {
2348                            closeSession(session);
2349                    }
2350            }
2351    
2352            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "blogsEntry.groupId = ?";
2353            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
2354                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
2355                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
2356                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId",
2357                            new String[] {
2358                                    Long.class.getName(),
2359                                    
2360                            Integer.class.getName(), Integer.class.getName(),
2361                                    OrderByComparator.class.getName()
2362                            });
2363            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
2364                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
2365                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
2366                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
2367                            new String[] { Long.class.getName() },
2368                            BlogsEntryModelImpl.COMPANYID_COLUMN_BITMASK |
2369                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
2370                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
2371            public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
2372                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
2373                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
2374                            new String[] { Long.class.getName() });
2375    
2376            /**
2377             * Returns all the blogs entries where companyId = &#63;.
2378             *
2379             * @param companyId the company ID
2380             * @return the matching blogs entries
2381             */
2382            @Override
2383            public List<BlogsEntry> findByCompanyId(long companyId) {
2384                    return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2385                            null);
2386            }
2387    
2388            /**
2389             * Returns a range of all the blogs entries where companyId = &#63;.
2390             *
2391             * <p>
2392             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2393             * </p>
2394             *
2395             * @param companyId the company ID
2396             * @param start the lower bound of the range of blogs entries
2397             * @param end the upper bound of the range of blogs entries (not inclusive)
2398             * @return the range of matching blogs entries
2399             */
2400            @Override
2401            public List<BlogsEntry> findByCompanyId(long companyId, int start, int end) {
2402                    return findByCompanyId(companyId, start, end, null);
2403            }
2404    
2405            /**
2406             * Returns an ordered range of all the blogs entries where companyId = &#63;.
2407             *
2408             * <p>
2409             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2410             * </p>
2411             *
2412             * @param companyId the company ID
2413             * @param start the lower bound of the range of blogs entries
2414             * @param end the upper bound of the range of blogs entries (not inclusive)
2415             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2416             * @return the ordered range of matching blogs entries
2417             */
2418            @Override
2419            public List<BlogsEntry> findByCompanyId(long companyId, int start, int end,
2420                    OrderByComparator<BlogsEntry> orderByComparator) {
2421                    return findByCompanyId(companyId, start, end, orderByComparator, true);
2422            }
2423    
2424            /**
2425             * Returns an ordered range of all the blogs entries where companyId = &#63;.
2426             *
2427             * <p>
2428             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2429             * </p>
2430             *
2431             * @param companyId the company ID
2432             * @param start the lower bound of the range of blogs entries
2433             * @param end the upper bound of the range of blogs entries (not inclusive)
2434             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2435             * @param retrieveFromCache whether to retrieve from the finder cache
2436             * @return the ordered range of matching blogs entries
2437             */
2438            @Override
2439            public List<BlogsEntry> findByCompanyId(long companyId, int start, int end,
2440                    OrderByComparator<BlogsEntry> orderByComparator,
2441                    boolean retrieveFromCache) {
2442                    boolean pagination = true;
2443                    FinderPath finderPath = null;
2444                    Object[] finderArgs = null;
2445    
2446                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2447                                    (orderByComparator == null)) {
2448                            pagination = false;
2449                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
2450                            finderArgs = new Object[] { companyId };
2451                    }
2452                    else {
2453                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
2454                            finderArgs = new Object[] { companyId, start, end, orderByComparator };
2455                    }
2456    
2457                    List<BlogsEntry> list = null;
2458    
2459                    if (retrieveFromCache) {
2460                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
2461                                            finderArgs, this);
2462    
2463                            if ((list != null) && !list.isEmpty()) {
2464                                    for (BlogsEntry blogsEntry : list) {
2465                                            if ((companyId != blogsEntry.getCompanyId())) {
2466                                                    list = null;
2467    
2468                                                    break;
2469                                            }
2470                                    }
2471                            }
2472                    }
2473    
2474                    if (list == null) {
2475                            StringBundler query = null;
2476    
2477                            if (orderByComparator != null) {
2478                                    query = new StringBundler(3 +
2479                                                    (orderByComparator.getOrderByFields().length * 2));
2480                            }
2481                            else {
2482                                    query = new StringBundler(3);
2483                            }
2484    
2485                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
2486    
2487                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2488    
2489                            if (orderByComparator != null) {
2490                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2491                                            orderByComparator);
2492                            }
2493                            else
2494                             if (pagination) {
2495                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
2496                            }
2497    
2498                            String sql = query.toString();
2499    
2500                            Session session = null;
2501    
2502                            try {
2503                                    session = openSession();
2504    
2505                                    Query q = session.createQuery(sql);
2506    
2507                                    QueryPos qPos = QueryPos.getInstance(q);
2508    
2509                                    qPos.add(companyId);
2510    
2511                                    if (!pagination) {
2512                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
2513                                                            start, end, false);
2514    
2515                                            Collections.sort(list);
2516    
2517                                            list = Collections.unmodifiableList(list);
2518                                    }
2519                                    else {
2520                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
2521                                                            start, end);
2522                                    }
2523    
2524                                    cacheResult(list);
2525    
2526                                    finderCache.putResult(finderPath, finderArgs, list);
2527                            }
2528                            catch (Exception e) {
2529                                    finderCache.removeResult(finderPath, finderArgs);
2530    
2531                                    throw processException(e);
2532                            }
2533                            finally {
2534                                    closeSession(session);
2535                            }
2536                    }
2537    
2538                    return list;
2539            }
2540    
2541            /**
2542             * Returns the first blogs entry in the ordered set where companyId = &#63;.
2543             *
2544             * @param companyId the company ID
2545             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2546             * @return the first matching blogs entry
2547             * @throws NoSuchEntryException if a matching blogs entry could not be found
2548             */
2549            @Override
2550            public BlogsEntry findByCompanyId_First(long companyId,
2551                    OrderByComparator<BlogsEntry> orderByComparator)
2552                    throws NoSuchEntryException {
2553                    BlogsEntry blogsEntry = fetchByCompanyId_First(companyId,
2554                                    orderByComparator);
2555    
2556                    if (blogsEntry != null) {
2557                            return blogsEntry;
2558                    }
2559    
2560                    StringBundler msg = new StringBundler(4);
2561    
2562                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2563    
2564                    msg.append("companyId=");
2565                    msg.append(companyId);
2566    
2567                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2568    
2569                    throw new NoSuchEntryException(msg.toString());
2570            }
2571    
2572            /**
2573             * Returns the first blogs entry in the ordered set where companyId = &#63;.
2574             *
2575             * @param companyId the company ID
2576             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2577             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
2578             */
2579            @Override
2580            public BlogsEntry fetchByCompanyId_First(long companyId,
2581                    OrderByComparator<BlogsEntry> orderByComparator) {
2582                    List<BlogsEntry> list = findByCompanyId(companyId, 0, 1,
2583                                    orderByComparator);
2584    
2585                    if (!list.isEmpty()) {
2586                            return list.get(0);
2587                    }
2588    
2589                    return null;
2590            }
2591    
2592            /**
2593             * Returns the last blogs entry in the ordered set where companyId = &#63;.
2594             *
2595             * @param companyId the company ID
2596             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2597             * @return the last matching blogs entry
2598             * @throws NoSuchEntryException if a matching blogs entry could not be found
2599             */
2600            @Override
2601            public BlogsEntry findByCompanyId_Last(long companyId,
2602                    OrderByComparator<BlogsEntry> orderByComparator)
2603                    throws NoSuchEntryException {
2604                    BlogsEntry blogsEntry = fetchByCompanyId_Last(companyId,
2605                                    orderByComparator);
2606    
2607                    if (blogsEntry != null) {
2608                            return blogsEntry;
2609                    }
2610    
2611                    StringBundler msg = new StringBundler(4);
2612    
2613                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2614    
2615                    msg.append("companyId=");
2616                    msg.append(companyId);
2617    
2618                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2619    
2620                    throw new NoSuchEntryException(msg.toString());
2621            }
2622    
2623            /**
2624             * Returns the last blogs entry in the ordered set where companyId = &#63;.
2625             *
2626             * @param companyId the company ID
2627             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2628             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
2629             */
2630            @Override
2631            public BlogsEntry fetchByCompanyId_Last(long companyId,
2632                    OrderByComparator<BlogsEntry> orderByComparator) {
2633                    int count = countByCompanyId(companyId);
2634    
2635                    if (count == 0) {
2636                            return null;
2637                    }
2638    
2639                    List<BlogsEntry> list = findByCompanyId(companyId, count - 1, count,
2640                                    orderByComparator);
2641    
2642                    if (!list.isEmpty()) {
2643                            return list.get(0);
2644                    }
2645    
2646                    return null;
2647            }
2648    
2649            /**
2650             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63;.
2651             *
2652             * @param entryId the primary key of the current blogs entry
2653             * @param companyId the company ID
2654             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2655             * @return the previous, current, and next blogs entry
2656             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
2657             */
2658            @Override
2659            public BlogsEntry[] findByCompanyId_PrevAndNext(long entryId,
2660                    long companyId, OrderByComparator<BlogsEntry> orderByComparator)
2661                    throws NoSuchEntryException {
2662                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
2663    
2664                    Session session = null;
2665    
2666                    try {
2667                            session = openSession();
2668    
2669                            BlogsEntry[] array = new BlogsEntryImpl[3];
2670    
2671                            array[0] = getByCompanyId_PrevAndNext(session, blogsEntry,
2672                                            companyId, orderByComparator, true);
2673    
2674                            array[1] = blogsEntry;
2675    
2676                            array[2] = getByCompanyId_PrevAndNext(session, blogsEntry,
2677                                            companyId, orderByComparator, false);
2678    
2679                            return array;
2680                    }
2681                    catch (Exception e) {
2682                            throw processException(e);
2683                    }
2684                    finally {
2685                            closeSession(session);
2686                    }
2687            }
2688    
2689            protected BlogsEntry getByCompanyId_PrevAndNext(Session session,
2690                    BlogsEntry blogsEntry, long companyId,
2691                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
2692                    StringBundler query = null;
2693    
2694                    if (orderByComparator != null) {
2695                            query = new StringBundler(4 +
2696                                            (orderByComparator.getOrderByConditionFields().length * 3) +
2697                                            (orderByComparator.getOrderByFields().length * 3));
2698                    }
2699                    else {
2700                            query = new StringBundler(3);
2701                    }
2702    
2703                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
2704    
2705                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2706    
2707                    if (orderByComparator != null) {
2708                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2709    
2710                            if (orderByConditionFields.length > 0) {
2711                                    query.append(WHERE_AND);
2712                            }
2713    
2714                            for (int i = 0; i < orderByConditionFields.length; i++) {
2715                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2716                                    query.append(orderByConditionFields[i]);
2717    
2718                                    if ((i + 1) < orderByConditionFields.length) {
2719                                            if (orderByComparator.isAscending() ^ previous) {
2720                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2721                                            }
2722                                            else {
2723                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2724                                            }
2725                                    }
2726                                    else {
2727                                            if (orderByComparator.isAscending() ^ previous) {
2728                                                    query.append(WHERE_GREATER_THAN);
2729                                            }
2730                                            else {
2731                                                    query.append(WHERE_LESSER_THAN);
2732                                            }
2733                                    }
2734                            }
2735    
2736                            query.append(ORDER_BY_CLAUSE);
2737    
2738                            String[] orderByFields = orderByComparator.getOrderByFields();
2739    
2740                            for (int i = 0; i < orderByFields.length; i++) {
2741                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2742                                    query.append(orderByFields[i]);
2743    
2744                                    if ((i + 1) < orderByFields.length) {
2745                                            if (orderByComparator.isAscending() ^ previous) {
2746                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2747                                            }
2748                                            else {
2749                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2750                                            }
2751                                    }
2752                                    else {
2753                                            if (orderByComparator.isAscending() ^ previous) {
2754                                                    query.append(ORDER_BY_ASC);
2755                                            }
2756                                            else {
2757                                                    query.append(ORDER_BY_DESC);
2758                                            }
2759                                    }
2760                            }
2761                    }
2762                    else {
2763                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
2764                    }
2765    
2766                    String sql = query.toString();
2767    
2768                    Query q = session.createQuery(sql);
2769    
2770                    q.setFirstResult(0);
2771                    q.setMaxResults(2);
2772    
2773                    QueryPos qPos = QueryPos.getInstance(q);
2774    
2775                    qPos.add(companyId);
2776    
2777                    if (orderByComparator != null) {
2778                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
2779    
2780                            for (Object value : values) {
2781                                    qPos.add(value);
2782                            }
2783                    }
2784    
2785                    List<BlogsEntry> list = q.list();
2786    
2787                    if (list.size() == 2) {
2788                            return list.get(1);
2789                    }
2790                    else {
2791                            return null;
2792                    }
2793            }
2794    
2795            /**
2796             * Removes all the blogs entries where companyId = &#63; from the database.
2797             *
2798             * @param companyId the company ID
2799             */
2800            @Override
2801            public void removeByCompanyId(long companyId) {
2802                    for (BlogsEntry blogsEntry : findByCompanyId(companyId,
2803                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2804                            remove(blogsEntry);
2805                    }
2806            }
2807    
2808            /**
2809             * Returns the number of blogs entries where companyId = &#63;.
2810             *
2811             * @param companyId the company ID
2812             * @return the number of matching blogs entries
2813             */
2814            @Override
2815            public int countByCompanyId(long companyId) {
2816                    FinderPath finderPath = FINDER_PATH_COUNT_BY_COMPANYID;
2817    
2818                    Object[] finderArgs = new Object[] { companyId };
2819    
2820                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
2821    
2822                    if (count == null) {
2823                            StringBundler query = new StringBundler(2);
2824    
2825                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
2826    
2827                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2828    
2829                            String sql = query.toString();
2830    
2831                            Session session = null;
2832    
2833                            try {
2834                                    session = openSession();
2835    
2836                                    Query q = session.createQuery(sql);
2837    
2838                                    QueryPos qPos = QueryPos.getInstance(q);
2839    
2840                                    qPos.add(companyId);
2841    
2842                                    count = (Long)q.uniqueResult();
2843    
2844                                    finderCache.putResult(finderPath, finderArgs, count);
2845                            }
2846                            catch (Exception e) {
2847                                    finderCache.removeResult(finderPath, finderArgs);
2848    
2849                                    throw processException(e);
2850                            }
2851                            finally {
2852                                    closeSession(session);
2853                            }
2854                    }
2855    
2856                    return count.intValue();
2857            }
2858    
2859            private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "blogsEntry.companyId = ?";
2860            public static final FinderPath FINDER_PATH_FETCH_BY_G_UT = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
2861                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
2862                            FINDER_CLASS_NAME_ENTITY, "fetchByG_UT",
2863                            new String[] { Long.class.getName(), String.class.getName() },
2864                            BlogsEntryModelImpl.GROUPID_COLUMN_BITMASK |
2865                            BlogsEntryModelImpl.URLTITLE_COLUMN_BITMASK);
2866            public static final FinderPath FINDER_PATH_COUNT_BY_G_UT = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
2867                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
2868                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_UT",
2869                            new String[] { Long.class.getName(), String.class.getName() });
2870    
2871            /**
2872             * Returns the blogs entry where groupId = &#63; and urlTitle = &#63; or throws a {@link NoSuchEntryException} if it could not be found.
2873             *
2874             * @param groupId the group ID
2875             * @param urlTitle the url title
2876             * @return the matching blogs entry
2877             * @throws NoSuchEntryException if a matching blogs entry could not be found
2878             */
2879            @Override
2880            public BlogsEntry findByG_UT(long groupId, String urlTitle)
2881                    throws NoSuchEntryException {
2882                    BlogsEntry blogsEntry = fetchByG_UT(groupId, urlTitle);
2883    
2884                    if (blogsEntry == null) {
2885                            StringBundler msg = new StringBundler(6);
2886    
2887                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2888    
2889                            msg.append("groupId=");
2890                            msg.append(groupId);
2891    
2892                            msg.append(", urlTitle=");
2893                            msg.append(urlTitle);
2894    
2895                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2896    
2897                            if (_log.isWarnEnabled()) {
2898                                    _log.warn(msg.toString());
2899                            }
2900    
2901                            throw new NoSuchEntryException(msg.toString());
2902                    }
2903    
2904                    return blogsEntry;
2905            }
2906    
2907            /**
2908             * 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.
2909             *
2910             * @param groupId the group ID
2911             * @param urlTitle the url title
2912             * @return the matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
2913             */
2914            @Override
2915            public BlogsEntry fetchByG_UT(long groupId, String urlTitle) {
2916                    return fetchByG_UT(groupId, urlTitle, true);
2917            }
2918    
2919            /**
2920             * 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.
2921             *
2922             * @param groupId the group ID
2923             * @param urlTitle the url title
2924             * @param retrieveFromCache whether to retrieve from the finder cache
2925             * @return the matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
2926             */
2927            @Override
2928            public BlogsEntry fetchByG_UT(long groupId, String urlTitle,
2929                    boolean retrieveFromCache) {
2930                    Object[] finderArgs = new Object[] { groupId, urlTitle };
2931    
2932                    Object result = null;
2933    
2934                    if (retrieveFromCache) {
2935                            result = finderCache.getResult(FINDER_PATH_FETCH_BY_G_UT,
2936                                            finderArgs, this);
2937                    }
2938    
2939                    if (result instanceof BlogsEntry) {
2940                            BlogsEntry blogsEntry = (BlogsEntry)result;
2941    
2942                            if ((groupId != blogsEntry.getGroupId()) ||
2943                                            !Validator.equals(urlTitle, blogsEntry.getUrlTitle())) {
2944                                    result = null;
2945                            }
2946                    }
2947    
2948                    if (result == null) {
2949                            StringBundler query = new StringBundler(4);
2950    
2951                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
2952    
2953                            query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
2954    
2955                            boolean bindUrlTitle = false;
2956    
2957                            if (urlTitle == null) {
2958                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
2959                            }
2960                            else if (urlTitle.equals(StringPool.BLANK)) {
2961                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
2962                            }
2963                            else {
2964                                    bindUrlTitle = true;
2965    
2966                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
2967                            }
2968    
2969                            String sql = query.toString();
2970    
2971                            Session session = null;
2972    
2973                            try {
2974                                    session = openSession();
2975    
2976                                    Query q = session.createQuery(sql);
2977    
2978                                    QueryPos qPos = QueryPos.getInstance(q);
2979    
2980                                    qPos.add(groupId);
2981    
2982                                    if (bindUrlTitle) {
2983                                            qPos.add(urlTitle);
2984                                    }
2985    
2986                                    List<BlogsEntry> list = q.list();
2987    
2988                                    if (list.isEmpty()) {
2989                                            finderCache.putResult(FINDER_PATH_FETCH_BY_G_UT,
2990                                                    finderArgs, list);
2991                                    }
2992                                    else {
2993                                            BlogsEntry blogsEntry = list.get(0);
2994    
2995                                            result = blogsEntry;
2996    
2997                                            cacheResult(blogsEntry);
2998    
2999                                            if ((blogsEntry.getGroupId() != groupId) ||
3000                                                            (blogsEntry.getUrlTitle() == null) ||
3001                                                            !blogsEntry.getUrlTitle().equals(urlTitle)) {
3002                                                    finderCache.putResult(FINDER_PATH_FETCH_BY_G_UT,
3003                                                            finderArgs, blogsEntry);
3004                                            }
3005                                    }
3006                            }
3007                            catch (Exception e) {
3008                                    finderCache.removeResult(FINDER_PATH_FETCH_BY_G_UT, finderArgs);
3009    
3010                                    throw processException(e);
3011                            }
3012                            finally {
3013                                    closeSession(session);
3014                            }
3015                    }
3016    
3017                    if (result instanceof List<?>) {
3018                            return null;
3019                    }
3020                    else {
3021                            return (BlogsEntry)result;
3022                    }
3023            }
3024    
3025            /**
3026             * Removes the blogs entry where groupId = &#63; and urlTitle = &#63; from the database.
3027             *
3028             * @param groupId the group ID
3029             * @param urlTitle the url title
3030             * @return the blogs entry that was removed
3031             */
3032            @Override
3033            public BlogsEntry removeByG_UT(long groupId, String urlTitle)
3034                    throws NoSuchEntryException {
3035                    BlogsEntry blogsEntry = findByG_UT(groupId, urlTitle);
3036    
3037                    return remove(blogsEntry);
3038            }
3039    
3040            /**
3041             * Returns the number of blogs entries where groupId = &#63; and urlTitle = &#63;.
3042             *
3043             * @param groupId the group ID
3044             * @param urlTitle the url title
3045             * @return the number of matching blogs entries
3046             */
3047            @Override
3048            public int countByG_UT(long groupId, String urlTitle) {
3049                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_UT;
3050    
3051                    Object[] finderArgs = new Object[] { groupId, urlTitle };
3052    
3053                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
3054    
3055                    if (count == null) {
3056                            StringBundler query = new StringBundler(3);
3057    
3058                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
3059    
3060                            query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
3061    
3062                            boolean bindUrlTitle = false;
3063    
3064                            if (urlTitle == null) {
3065                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
3066                            }
3067                            else if (urlTitle.equals(StringPool.BLANK)) {
3068                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
3069                            }
3070                            else {
3071                                    bindUrlTitle = true;
3072    
3073                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
3074                            }
3075    
3076                            String sql = query.toString();
3077    
3078                            Session session = null;
3079    
3080                            try {
3081                                    session = openSession();
3082    
3083                                    Query q = session.createQuery(sql);
3084    
3085                                    QueryPos qPos = QueryPos.getInstance(q);
3086    
3087                                    qPos.add(groupId);
3088    
3089                                    if (bindUrlTitle) {
3090                                            qPos.add(urlTitle);
3091                                    }
3092    
3093                                    count = (Long)q.uniqueResult();
3094    
3095                                    finderCache.putResult(finderPath, finderArgs, count);
3096                            }
3097                            catch (Exception e) {
3098                                    finderCache.removeResult(finderPath, finderArgs);
3099    
3100                                    throw processException(e);
3101                            }
3102                            finally {
3103                                    closeSession(session);
3104                            }
3105                    }
3106    
3107                    return count.intValue();
3108            }
3109    
3110            private static final String _FINDER_COLUMN_G_UT_GROUPID_2 = "blogsEntry.groupId = ? AND ";
3111            private static final String _FINDER_COLUMN_G_UT_URLTITLE_1 = "blogsEntry.urlTitle IS NULL";
3112            private static final String _FINDER_COLUMN_G_UT_URLTITLE_2 = "blogsEntry.urlTitle = ?";
3113            private static final String _FINDER_COLUMN_G_UT_URLTITLE_3 = "(blogsEntry.urlTitle IS NULL OR blogsEntry.urlTitle = '')";
3114            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
3115                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
3116                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_LtD",
3117                            new String[] {
3118                                    Long.class.getName(), Date.class.getName(),
3119                                    
3120                            Integer.class.getName(), Integer.class.getName(),
3121                                    OrderByComparator.class.getName()
3122                            });
3123            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
3124                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
3125                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_LtD",
3126                            new String[] { Long.class.getName(), Date.class.getName() });
3127    
3128            /**
3129             * Returns all the blogs entries where groupId = &#63; and displayDate &lt; &#63;.
3130             *
3131             * @param groupId the group ID
3132             * @param displayDate the display date
3133             * @return the matching blogs entries
3134             */
3135            @Override
3136            public List<BlogsEntry> findByG_LtD(long groupId, Date displayDate) {
3137                    return findByG_LtD(groupId, displayDate, QueryUtil.ALL_POS,
3138                            QueryUtil.ALL_POS, null);
3139            }
3140    
3141            /**
3142             * Returns a range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63;.
3143             *
3144             * <p>
3145             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3146             * </p>
3147             *
3148             * @param groupId the group ID
3149             * @param displayDate the display date
3150             * @param start the lower bound of the range of blogs entries
3151             * @param end the upper bound of the range of blogs entries (not inclusive)
3152             * @return the range of matching blogs entries
3153             */
3154            @Override
3155            public List<BlogsEntry> findByG_LtD(long groupId, Date displayDate,
3156                    int start, int end) {
3157                    return findByG_LtD(groupId, displayDate, start, end, null);
3158            }
3159    
3160            /**
3161             * Returns an ordered range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63;.
3162             *
3163             * <p>
3164             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3165             * </p>
3166             *
3167             * @param groupId the group ID
3168             * @param displayDate the display date
3169             * @param start the lower bound of the range of blogs entries
3170             * @param end the upper bound of the range of blogs entries (not inclusive)
3171             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3172             * @return the ordered range of matching blogs entries
3173             */
3174            @Override
3175            public List<BlogsEntry> findByG_LtD(long groupId, Date displayDate,
3176                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator) {
3177                    return findByG_LtD(groupId, displayDate, start, end, orderByComparator,
3178                            true);
3179            }
3180    
3181            /**
3182             * Returns an ordered range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63;.
3183             *
3184             * <p>
3185             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3186             * </p>
3187             *
3188             * @param groupId the group ID
3189             * @param displayDate the display date
3190             * @param start the lower bound of the range of blogs entries
3191             * @param end the upper bound of the range of blogs entries (not inclusive)
3192             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3193             * @param retrieveFromCache whether to retrieve from the finder cache
3194             * @return the ordered range of matching blogs entries
3195             */
3196            @Override
3197            public List<BlogsEntry> findByG_LtD(long groupId, Date displayDate,
3198                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator,
3199                    boolean retrieveFromCache) {
3200                    boolean pagination = true;
3201                    FinderPath finderPath = null;
3202                    Object[] finderArgs = null;
3203    
3204                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD;
3205                    finderArgs = new Object[] {
3206                                    groupId, displayDate,
3207                                    
3208                                    start, end, orderByComparator
3209                            };
3210    
3211                    List<BlogsEntry> list = null;
3212    
3213                    if (retrieveFromCache) {
3214                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
3215                                            finderArgs, this);
3216    
3217                            if ((list != null) && !list.isEmpty()) {
3218                                    for (BlogsEntry blogsEntry : list) {
3219                                            if ((groupId != blogsEntry.getGroupId()) ||
3220                                                            (displayDate.getTime() <= blogsEntry.getDisplayDate()
3221                                                                                                                                            .getTime())) {
3222                                                    list = null;
3223    
3224                                                    break;
3225                                            }
3226                                    }
3227                            }
3228                    }
3229    
3230                    if (list == null) {
3231                            StringBundler query = null;
3232    
3233                            if (orderByComparator != null) {
3234                                    query = new StringBundler(4 +
3235                                                    (orderByComparator.getOrderByFields().length * 2));
3236                            }
3237                            else {
3238                                    query = new StringBundler(4);
3239                            }
3240    
3241                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
3242    
3243                            query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
3244    
3245                            boolean bindDisplayDate = false;
3246    
3247                            if (displayDate == null) {
3248                                    query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
3249                            }
3250                            else {
3251                                    bindDisplayDate = true;
3252    
3253                                    query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
3254                            }
3255    
3256                            if (orderByComparator != null) {
3257                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3258                                            orderByComparator);
3259                            }
3260                            else
3261                             if (pagination) {
3262                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
3263                            }
3264    
3265                            String sql = query.toString();
3266    
3267                            Session session = null;
3268    
3269                            try {
3270                                    session = openSession();
3271    
3272                                    Query q = session.createQuery(sql);
3273    
3274                                    QueryPos qPos = QueryPos.getInstance(q);
3275    
3276                                    qPos.add(groupId);
3277    
3278                                    if (bindDisplayDate) {
3279                                            qPos.add(new Timestamp(displayDate.getTime()));
3280                                    }
3281    
3282                                    if (!pagination) {
3283                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
3284                                                            start, end, false);
3285    
3286                                            Collections.sort(list);
3287    
3288                                            list = Collections.unmodifiableList(list);
3289                                    }
3290                                    else {
3291                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
3292                                                            start, end);
3293                                    }
3294    
3295                                    cacheResult(list);
3296    
3297                                    finderCache.putResult(finderPath, finderArgs, list);
3298                            }
3299                            catch (Exception e) {
3300                                    finderCache.removeResult(finderPath, finderArgs);
3301    
3302                                    throw processException(e);
3303                            }
3304                            finally {
3305                                    closeSession(session);
3306                            }
3307                    }
3308    
3309                    return list;
3310            }
3311    
3312            /**
3313             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63;.
3314             *
3315             * @param groupId the group ID
3316             * @param displayDate the display date
3317             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3318             * @return the first matching blogs entry
3319             * @throws NoSuchEntryException if a matching blogs entry could not be found
3320             */
3321            @Override
3322            public BlogsEntry findByG_LtD_First(long groupId, Date displayDate,
3323                    OrderByComparator<BlogsEntry> orderByComparator)
3324                    throws NoSuchEntryException {
3325                    BlogsEntry blogsEntry = fetchByG_LtD_First(groupId, displayDate,
3326                                    orderByComparator);
3327    
3328                    if (blogsEntry != null) {
3329                            return blogsEntry;
3330                    }
3331    
3332                    StringBundler msg = new StringBundler(6);
3333    
3334                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3335    
3336                    msg.append("groupId=");
3337                    msg.append(groupId);
3338    
3339                    msg.append(", displayDate=");
3340                    msg.append(displayDate);
3341    
3342                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3343    
3344                    throw new NoSuchEntryException(msg.toString());
3345            }
3346    
3347            /**
3348             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63;.
3349             *
3350             * @param groupId the group ID
3351             * @param displayDate the display date
3352             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3353             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
3354             */
3355            @Override
3356            public BlogsEntry fetchByG_LtD_First(long groupId, Date displayDate,
3357                    OrderByComparator<BlogsEntry> orderByComparator) {
3358                    List<BlogsEntry> list = findByG_LtD(groupId, displayDate, 0, 1,
3359                                    orderByComparator);
3360    
3361                    if (!list.isEmpty()) {
3362                            return list.get(0);
3363                    }
3364    
3365                    return null;
3366            }
3367    
3368            /**
3369             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63;.
3370             *
3371             * @param groupId the group ID
3372             * @param displayDate the display date
3373             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3374             * @return the last matching blogs entry
3375             * @throws NoSuchEntryException if a matching blogs entry could not be found
3376             */
3377            @Override
3378            public BlogsEntry findByG_LtD_Last(long groupId, Date displayDate,
3379                    OrderByComparator<BlogsEntry> orderByComparator)
3380                    throws NoSuchEntryException {
3381                    BlogsEntry blogsEntry = fetchByG_LtD_Last(groupId, displayDate,
3382                                    orderByComparator);
3383    
3384                    if (blogsEntry != null) {
3385                            return blogsEntry;
3386                    }
3387    
3388                    StringBundler msg = new StringBundler(6);
3389    
3390                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3391    
3392                    msg.append("groupId=");
3393                    msg.append(groupId);
3394    
3395                    msg.append(", displayDate=");
3396                    msg.append(displayDate);
3397    
3398                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3399    
3400                    throw new NoSuchEntryException(msg.toString());
3401            }
3402    
3403            /**
3404             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63;.
3405             *
3406             * @param groupId the group ID
3407             * @param displayDate the display date
3408             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3409             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
3410             */
3411            @Override
3412            public BlogsEntry fetchByG_LtD_Last(long groupId, Date displayDate,
3413                    OrderByComparator<BlogsEntry> orderByComparator) {
3414                    int count = countByG_LtD(groupId, displayDate);
3415    
3416                    if (count == 0) {
3417                            return null;
3418                    }
3419    
3420                    List<BlogsEntry> list = findByG_LtD(groupId, displayDate, count - 1,
3421                                    count, orderByComparator);
3422    
3423                    if (!list.isEmpty()) {
3424                            return list.get(0);
3425                    }
3426    
3427                    return null;
3428            }
3429    
3430            /**
3431             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63;.
3432             *
3433             * @param entryId the primary key of the current blogs entry
3434             * @param groupId the group ID
3435             * @param displayDate the display date
3436             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3437             * @return the previous, current, and next blogs entry
3438             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
3439             */
3440            @Override
3441            public BlogsEntry[] findByG_LtD_PrevAndNext(long entryId, long groupId,
3442                    Date displayDate, OrderByComparator<BlogsEntry> orderByComparator)
3443                    throws NoSuchEntryException {
3444                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
3445    
3446                    Session session = null;
3447    
3448                    try {
3449                            session = openSession();
3450    
3451                            BlogsEntry[] array = new BlogsEntryImpl[3];
3452    
3453                            array[0] = getByG_LtD_PrevAndNext(session, blogsEntry, groupId,
3454                                            displayDate, orderByComparator, true);
3455    
3456                            array[1] = blogsEntry;
3457    
3458                            array[2] = getByG_LtD_PrevAndNext(session, blogsEntry, groupId,
3459                                            displayDate, orderByComparator, false);
3460    
3461                            return array;
3462                    }
3463                    catch (Exception e) {
3464                            throw processException(e);
3465                    }
3466                    finally {
3467                            closeSession(session);
3468                    }
3469            }
3470    
3471            protected BlogsEntry getByG_LtD_PrevAndNext(Session session,
3472                    BlogsEntry blogsEntry, long groupId, Date displayDate,
3473                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
3474                    StringBundler query = null;
3475    
3476                    if (orderByComparator != null) {
3477                            query = new StringBundler(5 +
3478                                            (orderByComparator.getOrderByConditionFields().length * 3) +
3479                                            (orderByComparator.getOrderByFields().length * 3));
3480                    }
3481                    else {
3482                            query = new StringBundler(4);
3483                    }
3484    
3485                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
3486    
3487                    query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
3488    
3489                    boolean bindDisplayDate = false;
3490    
3491                    if (displayDate == null) {
3492                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
3493                    }
3494                    else {
3495                            bindDisplayDate = true;
3496    
3497                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
3498                    }
3499    
3500                    if (orderByComparator != null) {
3501                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3502    
3503                            if (orderByConditionFields.length > 0) {
3504                                    query.append(WHERE_AND);
3505                            }
3506    
3507                            for (int i = 0; i < orderByConditionFields.length; i++) {
3508                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3509                                    query.append(orderByConditionFields[i]);
3510    
3511                                    if ((i + 1) < orderByConditionFields.length) {
3512                                            if (orderByComparator.isAscending() ^ previous) {
3513                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3514                                            }
3515                                            else {
3516                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3517                                            }
3518                                    }
3519                                    else {
3520                                            if (orderByComparator.isAscending() ^ previous) {
3521                                                    query.append(WHERE_GREATER_THAN);
3522                                            }
3523                                            else {
3524                                                    query.append(WHERE_LESSER_THAN);
3525                                            }
3526                                    }
3527                            }
3528    
3529                            query.append(ORDER_BY_CLAUSE);
3530    
3531                            String[] orderByFields = orderByComparator.getOrderByFields();
3532    
3533                            for (int i = 0; i < orderByFields.length; i++) {
3534                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3535                                    query.append(orderByFields[i]);
3536    
3537                                    if ((i + 1) < orderByFields.length) {
3538                                            if (orderByComparator.isAscending() ^ previous) {
3539                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3540                                            }
3541                                            else {
3542                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3543                                            }
3544                                    }
3545                                    else {
3546                                            if (orderByComparator.isAscending() ^ previous) {
3547                                                    query.append(ORDER_BY_ASC);
3548                                            }
3549                                            else {
3550                                                    query.append(ORDER_BY_DESC);
3551                                            }
3552                                    }
3553                            }
3554                    }
3555                    else {
3556                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
3557                    }
3558    
3559                    String sql = query.toString();
3560    
3561                    Query q = session.createQuery(sql);
3562    
3563                    q.setFirstResult(0);
3564                    q.setMaxResults(2);
3565    
3566                    QueryPos qPos = QueryPos.getInstance(q);
3567    
3568                    qPos.add(groupId);
3569    
3570                    if (bindDisplayDate) {
3571                            qPos.add(new Timestamp(displayDate.getTime()));
3572                    }
3573    
3574                    if (orderByComparator != null) {
3575                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
3576    
3577                            for (Object value : values) {
3578                                    qPos.add(value);
3579                            }
3580                    }
3581    
3582                    List<BlogsEntry> list = q.list();
3583    
3584                    if (list.size() == 2) {
3585                            return list.get(1);
3586                    }
3587                    else {
3588                            return null;
3589                    }
3590            }
3591    
3592            /**
3593             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63;.
3594             *
3595             * @param groupId the group ID
3596             * @param displayDate the display date
3597             * @return the matching blogs entries that the user has permission to view
3598             */
3599            @Override
3600            public List<BlogsEntry> filterFindByG_LtD(long groupId, Date displayDate) {
3601                    return filterFindByG_LtD(groupId, displayDate, QueryUtil.ALL_POS,
3602                            QueryUtil.ALL_POS, null);
3603            }
3604    
3605            /**
3606             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63;.
3607             *
3608             * <p>
3609             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3610             * </p>
3611             *
3612             * @param groupId the group ID
3613             * @param displayDate the display date
3614             * @param start the lower bound of the range of blogs entries
3615             * @param end the upper bound of the range of blogs entries (not inclusive)
3616             * @return the range of matching blogs entries that the user has permission to view
3617             */
3618            @Override
3619            public List<BlogsEntry> filterFindByG_LtD(long groupId, Date displayDate,
3620                    int start, int end) {
3621                    return filterFindByG_LtD(groupId, displayDate, start, end, null);
3622            }
3623    
3624            /**
3625             * Returns an ordered range of all the blogs entries that the user has permissions to view where groupId = &#63; and displayDate &lt; &#63;.
3626             *
3627             * <p>
3628             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3629             * </p>
3630             *
3631             * @param groupId the group ID
3632             * @param displayDate the display date
3633             * @param start the lower bound of the range of blogs entries
3634             * @param end the upper bound of the range of blogs entries (not inclusive)
3635             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3636             * @return the ordered range of matching blogs entries that the user has permission to view
3637             */
3638            @Override
3639            public List<BlogsEntry> filterFindByG_LtD(long groupId, Date displayDate,
3640                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator) {
3641                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3642                            return findByG_LtD(groupId, displayDate, start, end,
3643                                    orderByComparator);
3644                    }
3645    
3646                    StringBundler query = null;
3647    
3648                    if (orderByComparator != null) {
3649                            query = new StringBundler(4 +
3650                                            (orderByComparator.getOrderByFields().length * 2));
3651                    }
3652                    else {
3653                            query = new StringBundler(5);
3654                    }
3655    
3656                    if (getDB().isSupportsInlineDistinct()) {
3657                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
3658                    }
3659                    else {
3660                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
3661                    }
3662    
3663                    query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
3664    
3665                    boolean bindDisplayDate = false;
3666    
3667                    if (displayDate == null) {
3668                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
3669                    }
3670                    else {
3671                            bindDisplayDate = true;
3672    
3673                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
3674                    }
3675    
3676                    if (!getDB().isSupportsInlineDistinct()) {
3677                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
3678                    }
3679    
3680                    if (orderByComparator != null) {
3681                            if (getDB().isSupportsInlineDistinct()) {
3682                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3683                                            orderByComparator, true);
3684                            }
3685                            else {
3686                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
3687                                            orderByComparator, true);
3688                            }
3689                    }
3690                    else {
3691                            if (getDB().isSupportsInlineDistinct()) {
3692                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
3693                            }
3694                            else {
3695                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
3696                            }
3697                    }
3698    
3699                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3700                                    BlogsEntry.class.getName(),
3701                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3702    
3703                    Session session = null;
3704    
3705                    try {
3706                            session = openSession();
3707    
3708                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
3709    
3710                            if (getDB().isSupportsInlineDistinct()) {
3711                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
3712                            }
3713                            else {
3714                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
3715                            }
3716    
3717                            QueryPos qPos = QueryPos.getInstance(q);
3718    
3719                            qPos.add(groupId);
3720    
3721                            if (bindDisplayDate) {
3722                                    qPos.add(new Timestamp(displayDate.getTime()));
3723                            }
3724    
3725                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
3726                    }
3727                    catch (Exception e) {
3728                            throw processException(e);
3729                    }
3730                    finally {
3731                            closeSession(session);
3732                    }
3733            }
3734    
3735            /**
3736             * 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;.
3737             *
3738             * @param entryId the primary key of the current blogs entry
3739             * @param groupId the group ID
3740             * @param displayDate the display date
3741             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3742             * @return the previous, current, and next blogs entry
3743             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
3744             */
3745            @Override
3746            public BlogsEntry[] filterFindByG_LtD_PrevAndNext(long entryId,
3747                    long groupId, Date displayDate,
3748                    OrderByComparator<BlogsEntry> orderByComparator)
3749                    throws NoSuchEntryException {
3750                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3751                            return findByG_LtD_PrevAndNext(entryId, groupId, displayDate,
3752                                    orderByComparator);
3753                    }
3754    
3755                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
3756    
3757                    Session session = null;
3758    
3759                    try {
3760                            session = openSession();
3761    
3762                            BlogsEntry[] array = new BlogsEntryImpl[3];
3763    
3764                            array[0] = filterGetByG_LtD_PrevAndNext(session, blogsEntry,
3765                                            groupId, displayDate, orderByComparator, true);
3766    
3767                            array[1] = blogsEntry;
3768    
3769                            array[2] = filterGetByG_LtD_PrevAndNext(session, blogsEntry,
3770                                            groupId, displayDate, orderByComparator, false);
3771    
3772                            return array;
3773                    }
3774                    catch (Exception e) {
3775                            throw processException(e);
3776                    }
3777                    finally {
3778                            closeSession(session);
3779                    }
3780            }
3781    
3782            protected BlogsEntry filterGetByG_LtD_PrevAndNext(Session session,
3783                    BlogsEntry blogsEntry, long groupId, Date displayDate,
3784                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
3785                    StringBundler query = null;
3786    
3787                    if (orderByComparator != null) {
3788                            query = new StringBundler(6 +
3789                                            (orderByComparator.getOrderByConditionFields().length * 3) +
3790                                            (orderByComparator.getOrderByFields().length * 3));
3791                    }
3792                    else {
3793                            query = new StringBundler(5);
3794                    }
3795    
3796                    if (getDB().isSupportsInlineDistinct()) {
3797                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
3798                    }
3799                    else {
3800                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
3801                    }
3802    
3803                    query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
3804    
3805                    boolean bindDisplayDate = false;
3806    
3807                    if (displayDate == null) {
3808                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
3809                    }
3810                    else {
3811                            bindDisplayDate = true;
3812    
3813                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
3814                    }
3815    
3816                    if (!getDB().isSupportsInlineDistinct()) {
3817                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
3818                    }
3819    
3820                    if (orderByComparator != null) {
3821                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3822    
3823                            if (orderByConditionFields.length > 0) {
3824                                    query.append(WHERE_AND);
3825                            }
3826    
3827                            for (int i = 0; i < orderByConditionFields.length; i++) {
3828                                    if (getDB().isSupportsInlineDistinct()) {
3829                                            query.append(_ORDER_BY_ENTITY_ALIAS);
3830                                    }
3831                                    else {
3832                                            query.append(_ORDER_BY_ENTITY_TABLE);
3833                                    }
3834    
3835                                    query.append(orderByConditionFields[i]);
3836    
3837                                    if ((i + 1) < orderByConditionFields.length) {
3838                                            if (orderByComparator.isAscending() ^ previous) {
3839                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3840                                            }
3841                                            else {
3842                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3843                                            }
3844                                    }
3845                                    else {
3846                                            if (orderByComparator.isAscending() ^ previous) {
3847                                                    query.append(WHERE_GREATER_THAN);
3848                                            }
3849                                            else {
3850                                                    query.append(WHERE_LESSER_THAN);
3851                                            }
3852                                    }
3853                            }
3854    
3855                            query.append(ORDER_BY_CLAUSE);
3856    
3857                            String[] orderByFields = orderByComparator.getOrderByFields();
3858    
3859                            for (int i = 0; i < orderByFields.length; i++) {
3860                                    if (getDB().isSupportsInlineDistinct()) {
3861                                            query.append(_ORDER_BY_ENTITY_ALIAS);
3862                                    }
3863                                    else {
3864                                            query.append(_ORDER_BY_ENTITY_TABLE);
3865                                    }
3866    
3867                                    query.append(orderByFields[i]);
3868    
3869                                    if ((i + 1) < orderByFields.length) {
3870                                            if (orderByComparator.isAscending() ^ previous) {
3871                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3872                                            }
3873                                            else {
3874                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3875                                            }
3876                                    }
3877                                    else {
3878                                            if (orderByComparator.isAscending() ^ previous) {
3879                                                    query.append(ORDER_BY_ASC);
3880                                            }
3881                                            else {
3882                                                    query.append(ORDER_BY_DESC);
3883                                            }
3884                                    }
3885                            }
3886                    }
3887                    else {
3888                            if (getDB().isSupportsInlineDistinct()) {
3889                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
3890                            }
3891                            else {
3892                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
3893                            }
3894                    }
3895    
3896                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3897                                    BlogsEntry.class.getName(),
3898                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3899    
3900                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
3901    
3902                    q.setFirstResult(0);
3903                    q.setMaxResults(2);
3904    
3905                    if (getDB().isSupportsInlineDistinct()) {
3906                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
3907                    }
3908                    else {
3909                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
3910                    }
3911    
3912                    QueryPos qPos = QueryPos.getInstance(q);
3913    
3914                    qPos.add(groupId);
3915    
3916                    if (bindDisplayDate) {
3917                            qPos.add(new Timestamp(displayDate.getTime()));
3918                    }
3919    
3920                    if (orderByComparator != null) {
3921                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
3922    
3923                            for (Object value : values) {
3924                                    qPos.add(value);
3925                            }
3926                    }
3927    
3928                    List<BlogsEntry> list = q.list();
3929    
3930                    if (list.size() == 2) {
3931                            return list.get(1);
3932                    }
3933                    else {
3934                            return null;
3935                    }
3936            }
3937    
3938            /**
3939             * Removes all the blogs entries where groupId = &#63; and displayDate &lt; &#63; from the database.
3940             *
3941             * @param groupId the group ID
3942             * @param displayDate the display date
3943             */
3944            @Override
3945            public void removeByG_LtD(long groupId, Date displayDate) {
3946                    for (BlogsEntry blogsEntry : findByG_LtD(groupId, displayDate,
3947                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3948                            remove(blogsEntry);
3949                    }
3950            }
3951    
3952            /**
3953             * Returns the number of blogs entries where groupId = &#63; and displayDate &lt; &#63;.
3954             *
3955             * @param groupId the group ID
3956             * @param displayDate the display date
3957             * @return the number of matching blogs entries
3958             */
3959            @Override
3960            public int countByG_LtD(long groupId, Date displayDate) {
3961                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD;
3962    
3963                    Object[] finderArgs = new Object[] { groupId, displayDate };
3964    
3965                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
3966    
3967                    if (count == null) {
3968                            StringBundler query = new StringBundler(3);
3969    
3970                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
3971    
3972                            query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
3973    
3974                            boolean bindDisplayDate = false;
3975    
3976                            if (displayDate == null) {
3977                                    query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
3978                            }
3979                            else {
3980                                    bindDisplayDate = true;
3981    
3982                                    query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
3983                            }
3984    
3985                            String sql = query.toString();
3986    
3987                            Session session = null;
3988    
3989                            try {
3990                                    session = openSession();
3991    
3992                                    Query q = session.createQuery(sql);
3993    
3994                                    QueryPos qPos = QueryPos.getInstance(q);
3995    
3996                                    qPos.add(groupId);
3997    
3998                                    if (bindDisplayDate) {
3999                                            qPos.add(new Timestamp(displayDate.getTime()));
4000                                    }
4001    
4002                                    count = (Long)q.uniqueResult();
4003    
4004                                    finderCache.putResult(finderPath, finderArgs, count);
4005                            }
4006                            catch (Exception e) {
4007                                    finderCache.removeResult(finderPath, finderArgs);
4008    
4009                                    throw processException(e);
4010                            }
4011                            finally {
4012                                    closeSession(session);
4013                            }
4014                    }
4015    
4016                    return count.intValue();
4017            }
4018    
4019            /**
4020             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63;.
4021             *
4022             * @param groupId the group ID
4023             * @param displayDate the display date
4024             * @return the number of matching blogs entries that the user has permission to view
4025             */
4026            @Override
4027            public int filterCountByG_LtD(long groupId, Date displayDate) {
4028                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4029                            return countByG_LtD(groupId, displayDate);
4030                    }
4031    
4032                    StringBundler query = new StringBundler(3);
4033    
4034                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
4035    
4036                    query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
4037    
4038                    boolean bindDisplayDate = false;
4039    
4040                    if (displayDate == null) {
4041                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
4042                    }
4043                    else {
4044                            bindDisplayDate = true;
4045    
4046                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
4047                    }
4048    
4049                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4050                                    BlogsEntry.class.getName(),
4051                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4052    
4053                    Session session = null;
4054    
4055                    try {
4056                            session = openSession();
4057    
4058                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
4059    
4060                            q.addScalar(COUNT_COLUMN_NAME,
4061                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
4062    
4063                            QueryPos qPos = QueryPos.getInstance(q);
4064    
4065                            qPos.add(groupId);
4066    
4067                            if (bindDisplayDate) {
4068                                    qPos.add(new Timestamp(displayDate.getTime()));
4069                            }
4070    
4071                            Long count = (Long)q.uniqueResult();
4072    
4073                            return count.intValue();
4074                    }
4075                    catch (Exception e) {
4076                            throw processException(e);
4077                    }
4078                    finally {
4079                            closeSession(session);
4080                    }
4081            }
4082    
4083            private static final String _FINDER_COLUMN_G_LTD_GROUPID_2 = "blogsEntry.groupId = ? AND ";
4084            private static final String _FINDER_COLUMN_G_LTD_DISPLAYDATE_1 = "blogsEntry.displayDate IS NULL";
4085            private static final String _FINDER_COLUMN_G_LTD_DISPLAYDATE_2 = "blogsEntry.displayDate < ?";
4086            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
4087                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
4088                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_S",
4089                            new String[] {
4090                                    Long.class.getName(), Integer.class.getName(),
4091                                    
4092                            Integer.class.getName(), Integer.class.getName(),
4093                                    OrderByComparator.class.getName()
4094                            });
4095            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
4096                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
4097                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_S",
4098                            new String[] { Long.class.getName(), Integer.class.getName() },
4099                            BlogsEntryModelImpl.GROUPID_COLUMN_BITMASK |
4100                            BlogsEntryModelImpl.STATUS_COLUMN_BITMASK |
4101                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
4102                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
4103            public static final FinderPath FINDER_PATH_COUNT_BY_G_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
4104                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
4105                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_S",
4106                            new String[] { Long.class.getName(), Integer.class.getName() });
4107    
4108            /**
4109             * Returns all the blogs entries where groupId = &#63; and status = &#63;.
4110             *
4111             * @param groupId the group ID
4112             * @param status the status
4113             * @return the matching blogs entries
4114             */
4115            @Override
4116            public List<BlogsEntry> findByG_S(long groupId, int status) {
4117                    return findByG_S(groupId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
4118                            null);
4119            }
4120    
4121            /**
4122             * Returns a range of all the blogs entries where groupId = &#63; and status = &#63;.
4123             *
4124             * <p>
4125             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4126             * </p>
4127             *
4128             * @param groupId the group ID
4129             * @param status the status
4130             * @param start the lower bound of the range of blogs entries
4131             * @param end the upper bound of the range of blogs entries (not inclusive)
4132             * @return the range of matching blogs entries
4133             */
4134            @Override
4135            public List<BlogsEntry> findByG_S(long groupId, int status, int start,
4136                    int end) {
4137                    return findByG_S(groupId, status, start, end, null);
4138            }
4139    
4140            /**
4141             * Returns an ordered range of all the blogs entries where groupId = &#63; and status = &#63;.
4142             *
4143             * <p>
4144             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4145             * </p>
4146             *
4147             * @param groupId the group ID
4148             * @param status the status
4149             * @param start the lower bound of the range of blogs entries
4150             * @param end the upper bound of the range of blogs entries (not inclusive)
4151             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4152             * @return the ordered range of matching blogs entries
4153             */
4154            @Override
4155            public List<BlogsEntry> findByG_S(long groupId, int status, int start,
4156                    int end, OrderByComparator<BlogsEntry> orderByComparator) {
4157                    return findByG_S(groupId, status, start, end, orderByComparator, true);
4158            }
4159    
4160            /**
4161             * Returns an ordered range of all the blogs entries where groupId = &#63; and status = &#63;.
4162             *
4163             * <p>
4164             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4165             * </p>
4166             *
4167             * @param groupId the group ID
4168             * @param status the status
4169             * @param start the lower bound of the range of blogs entries
4170             * @param end the upper bound of the range of blogs entries (not inclusive)
4171             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4172             * @param retrieveFromCache whether to retrieve from the finder cache
4173             * @return the ordered range of matching blogs entries
4174             */
4175            @Override
4176            public List<BlogsEntry> findByG_S(long groupId, int status, int start,
4177                    int end, OrderByComparator<BlogsEntry> orderByComparator,
4178                    boolean retrieveFromCache) {
4179                    boolean pagination = true;
4180                    FinderPath finderPath = null;
4181                    Object[] finderArgs = null;
4182    
4183                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4184                                    (orderByComparator == null)) {
4185                            pagination = false;
4186                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S;
4187                            finderArgs = new Object[] { groupId, status };
4188                    }
4189                    else {
4190                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S;
4191                            finderArgs = new Object[] {
4192                                            groupId, status,
4193                                            
4194                                            start, end, orderByComparator
4195                                    };
4196                    }
4197    
4198                    List<BlogsEntry> list = null;
4199    
4200                    if (retrieveFromCache) {
4201                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
4202                                            finderArgs, this);
4203    
4204                            if ((list != null) && !list.isEmpty()) {
4205                                    for (BlogsEntry blogsEntry : list) {
4206                                            if ((groupId != blogsEntry.getGroupId()) ||
4207                                                            (status != blogsEntry.getStatus())) {
4208                                                    list = null;
4209    
4210                                                    break;
4211                                            }
4212                                    }
4213                            }
4214                    }
4215    
4216                    if (list == null) {
4217                            StringBundler query = null;
4218    
4219                            if (orderByComparator != null) {
4220                                    query = new StringBundler(4 +
4221                                                    (orderByComparator.getOrderByFields().length * 2));
4222                            }
4223                            else {
4224                                    query = new StringBundler(4);
4225                            }
4226    
4227                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
4228    
4229                            query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4230    
4231                            query.append(_FINDER_COLUMN_G_S_STATUS_2);
4232    
4233                            if (orderByComparator != null) {
4234                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4235                                            orderByComparator);
4236                            }
4237                            else
4238                             if (pagination) {
4239                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
4240                            }
4241    
4242                            String sql = query.toString();
4243    
4244                            Session session = null;
4245    
4246                            try {
4247                                    session = openSession();
4248    
4249                                    Query q = session.createQuery(sql);
4250    
4251                                    QueryPos qPos = QueryPos.getInstance(q);
4252    
4253                                    qPos.add(groupId);
4254    
4255                                    qPos.add(status);
4256    
4257                                    if (!pagination) {
4258                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
4259                                                            start, end, false);
4260    
4261                                            Collections.sort(list);
4262    
4263                                            list = Collections.unmodifiableList(list);
4264                                    }
4265                                    else {
4266                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
4267                                                            start, end);
4268                                    }
4269    
4270                                    cacheResult(list);
4271    
4272                                    finderCache.putResult(finderPath, finderArgs, list);
4273                            }
4274                            catch (Exception e) {
4275                                    finderCache.removeResult(finderPath, finderArgs);
4276    
4277                                    throw processException(e);
4278                            }
4279                            finally {
4280                                    closeSession(session);
4281                            }
4282                    }
4283    
4284                    return list;
4285            }
4286    
4287            /**
4288             * Returns the first blogs entry in the ordered set where groupId = &#63; and status = &#63;.
4289             *
4290             * @param groupId the group ID
4291             * @param status the status
4292             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4293             * @return the first matching blogs entry
4294             * @throws NoSuchEntryException if a matching blogs entry could not be found
4295             */
4296            @Override
4297            public BlogsEntry findByG_S_First(long groupId, int status,
4298                    OrderByComparator<BlogsEntry> orderByComparator)
4299                    throws NoSuchEntryException {
4300                    BlogsEntry blogsEntry = fetchByG_S_First(groupId, status,
4301                                    orderByComparator);
4302    
4303                    if (blogsEntry != null) {
4304                            return blogsEntry;
4305                    }
4306    
4307                    StringBundler msg = new StringBundler(6);
4308    
4309                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4310    
4311                    msg.append("groupId=");
4312                    msg.append(groupId);
4313    
4314                    msg.append(", status=");
4315                    msg.append(status);
4316    
4317                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4318    
4319                    throw new NoSuchEntryException(msg.toString());
4320            }
4321    
4322            /**
4323             * Returns the first blogs entry in the ordered set where groupId = &#63; and status = &#63;.
4324             *
4325             * @param groupId the group ID
4326             * @param status the status
4327             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4328             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
4329             */
4330            @Override
4331            public BlogsEntry fetchByG_S_First(long groupId, int status,
4332                    OrderByComparator<BlogsEntry> orderByComparator) {
4333                    List<BlogsEntry> list = findByG_S(groupId, status, 0, 1,
4334                                    orderByComparator);
4335    
4336                    if (!list.isEmpty()) {
4337                            return list.get(0);
4338                    }
4339    
4340                    return null;
4341            }
4342    
4343            /**
4344             * Returns the last blogs entry in the ordered set where groupId = &#63; and status = &#63;.
4345             *
4346             * @param groupId the group ID
4347             * @param status the status
4348             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4349             * @return the last matching blogs entry
4350             * @throws NoSuchEntryException if a matching blogs entry could not be found
4351             */
4352            @Override
4353            public BlogsEntry findByG_S_Last(long groupId, int status,
4354                    OrderByComparator<BlogsEntry> orderByComparator)
4355                    throws NoSuchEntryException {
4356                    BlogsEntry blogsEntry = fetchByG_S_Last(groupId, status,
4357                                    orderByComparator);
4358    
4359                    if (blogsEntry != null) {
4360                            return blogsEntry;
4361                    }
4362    
4363                    StringBundler msg = new StringBundler(6);
4364    
4365                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4366    
4367                    msg.append("groupId=");
4368                    msg.append(groupId);
4369    
4370                    msg.append(", status=");
4371                    msg.append(status);
4372    
4373                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4374    
4375                    throw new NoSuchEntryException(msg.toString());
4376            }
4377    
4378            /**
4379             * Returns the last blogs entry in the ordered set where groupId = &#63; and status = &#63;.
4380             *
4381             * @param groupId the group ID
4382             * @param status the status
4383             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4384             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
4385             */
4386            @Override
4387            public BlogsEntry fetchByG_S_Last(long groupId, int status,
4388                    OrderByComparator<BlogsEntry> orderByComparator) {
4389                    int count = countByG_S(groupId, status);
4390    
4391                    if (count == 0) {
4392                            return null;
4393                    }
4394    
4395                    List<BlogsEntry> list = findByG_S(groupId, status, count - 1, count,
4396                                    orderByComparator);
4397    
4398                    if (!list.isEmpty()) {
4399                            return list.get(0);
4400                    }
4401    
4402                    return null;
4403            }
4404    
4405            /**
4406             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63; and status = &#63;.
4407             *
4408             * @param entryId the primary key of the current blogs entry
4409             * @param groupId the group ID
4410             * @param status the status
4411             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4412             * @return the previous, current, and next blogs entry
4413             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
4414             */
4415            @Override
4416            public BlogsEntry[] findByG_S_PrevAndNext(long entryId, long groupId,
4417                    int status, OrderByComparator<BlogsEntry> orderByComparator)
4418                    throws NoSuchEntryException {
4419                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
4420    
4421                    Session session = null;
4422    
4423                    try {
4424                            session = openSession();
4425    
4426                            BlogsEntry[] array = new BlogsEntryImpl[3];
4427    
4428                            array[0] = getByG_S_PrevAndNext(session, blogsEntry, groupId,
4429                                            status, orderByComparator, true);
4430    
4431                            array[1] = blogsEntry;
4432    
4433                            array[2] = getByG_S_PrevAndNext(session, blogsEntry, groupId,
4434                                            status, orderByComparator, false);
4435    
4436                            return array;
4437                    }
4438                    catch (Exception e) {
4439                            throw processException(e);
4440                    }
4441                    finally {
4442                            closeSession(session);
4443                    }
4444            }
4445    
4446            protected BlogsEntry getByG_S_PrevAndNext(Session session,
4447                    BlogsEntry blogsEntry, long groupId, int status,
4448                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
4449                    StringBundler query = null;
4450    
4451                    if (orderByComparator != null) {
4452                            query = new StringBundler(5 +
4453                                            (orderByComparator.getOrderByConditionFields().length * 3) +
4454                                            (orderByComparator.getOrderByFields().length * 3));
4455                    }
4456                    else {
4457                            query = new StringBundler(4);
4458                    }
4459    
4460                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
4461    
4462                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4463    
4464                    query.append(_FINDER_COLUMN_G_S_STATUS_2);
4465    
4466                    if (orderByComparator != null) {
4467                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4468    
4469                            if (orderByConditionFields.length > 0) {
4470                                    query.append(WHERE_AND);
4471                            }
4472    
4473                            for (int i = 0; i < orderByConditionFields.length; i++) {
4474                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4475                                    query.append(orderByConditionFields[i]);
4476    
4477                                    if ((i + 1) < orderByConditionFields.length) {
4478                                            if (orderByComparator.isAscending() ^ previous) {
4479                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4480                                            }
4481                                            else {
4482                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4483                                            }
4484                                    }
4485                                    else {
4486                                            if (orderByComparator.isAscending() ^ previous) {
4487                                                    query.append(WHERE_GREATER_THAN);
4488                                            }
4489                                            else {
4490                                                    query.append(WHERE_LESSER_THAN);
4491                                            }
4492                                    }
4493                            }
4494    
4495                            query.append(ORDER_BY_CLAUSE);
4496    
4497                            String[] orderByFields = orderByComparator.getOrderByFields();
4498    
4499                            for (int i = 0; i < orderByFields.length; i++) {
4500                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4501                                    query.append(orderByFields[i]);
4502    
4503                                    if ((i + 1) < orderByFields.length) {
4504                                            if (orderByComparator.isAscending() ^ previous) {
4505                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4506                                            }
4507                                            else {
4508                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4509                                            }
4510                                    }
4511                                    else {
4512                                            if (orderByComparator.isAscending() ^ previous) {
4513                                                    query.append(ORDER_BY_ASC);
4514                                            }
4515                                            else {
4516                                                    query.append(ORDER_BY_DESC);
4517                                            }
4518                                    }
4519                            }
4520                    }
4521                    else {
4522                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
4523                    }
4524    
4525                    String sql = query.toString();
4526    
4527                    Query q = session.createQuery(sql);
4528    
4529                    q.setFirstResult(0);
4530                    q.setMaxResults(2);
4531    
4532                    QueryPos qPos = QueryPos.getInstance(q);
4533    
4534                    qPos.add(groupId);
4535    
4536                    qPos.add(status);
4537    
4538                    if (orderByComparator != null) {
4539                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
4540    
4541                            for (Object value : values) {
4542                                    qPos.add(value);
4543                            }
4544                    }
4545    
4546                    List<BlogsEntry> list = q.list();
4547    
4548                    if (list.size() == 2) {
4549                            return list.get(1);
4550                    }
4551                    else {
4552                            return null;
4553                    }
4554            }
4555    
4556            /**
4557             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and status = &#63;.
4558             *
4559             * @param groupId the group ID
4560             * @param status the status
4561             * @return the matching blogs entries that the user has permission to view
4562             */
4563            @Override
4564            public List<BlogsEntry> filterFindByG_S(long groupId, int status) {
4565                    return filterFindByG_S(groupId, status, QueryUtil.ALL_POS,
4566                            QueryUtil.ALL_POS, null);
4567            }
4568    
4569            /**
4570             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63; and status = &#63;.
4571             *
4572             * <p>
4573             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4574             * </p>
4575             *
4576             * @param groupId the group ID
4577             * @param status the status
4578             * @param start the lower bound of the range of blogs entries
4579             * @param end the upper bound of the range of blogs entries (not inclusive)
4580             * @return the range of matching blogs entries that the user has permission to view
4581             */
4582            @Override
4583            public List<BlogsEntry> filterFindByG_S(long groupId, int status,
4584                    int start, int end) {
4585                    return filterFindByG_S(groupId, status, start, end, null);
4586            }
4587    
4588            /**
4589             * Returns an ordered range of all the blogs entries that the user has permissions to view where groupId = &#63; and status = &#63;.
4590             *
4591             * <p>
4592             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4593             * </p>
4594             *
4595             * @param groupId the group ID
4596             * @param status the status
4597             * @param start the lower bound of the range of blogs entries
4598             * @param end the upper bound of the range of blogs entries (not inclusive)
4599             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4600             * @return the ordered range of matching blogs entries that the user has permission to view
4601             */
4602            @Override
4603            public List<BlogsEntry> filterFindByG_S(long groupId, int status,
4604                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator) {
4605                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4606                            return findByG_S(groupId, status, start, end, orderByComparator);
4607                    }
4608    
4609                    StringBundler query = null;
4610    
4611                    if (orderByComparator != null) {
4612                            query = new StringBundler(4 +
4613                                            (orderByComparator.getOrderByFields().length * 2));
4614                    }
4615                    else {
4616                            query = new StringBundler(5);
4617                    }
4618    
4619                    if (getDB().isSupportsInlineDistinct()) {
4620                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
4621                    }
4622                    else {
4623                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
4624                    }
4625    
4626                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4627    
4628                    query.append(_FINDER_COLUMN_G_S_STATUS_2);
4629    
4630                    if (!getDB().isSupportsInlineDistinct()) {
4631                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
4632                    }
4633    
4634                    if (orderByComparator != null) {
4635                            if (getDB().isSupportsInlineDistinct()) {
4636                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4637                                            orderByComparator, true);
4638                            }
4639                            else {
4640                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
4641                                            orderByComparator, true);
4642                            }
4643                    }
4644                    else {
4645                            if (getDB().isSupportsInlineDistinct()) {
4646                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
4647                            }
4648                            else {
4649                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
4650                            }
4651                    }
4652    
4653                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4654                                    BlogsEntry.class.getName(),
4655                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4656    
4657                    Session session = null;
4658    
4659                    try {
4660                            session = openSession();
4661    
4662                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
4663    
4664                            if (getDB().isSupportsInlineDistinct()) {
4665                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
4666                            }
4667                            else {
4668                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
4669                            }
4670    
4671                            QueryPos qPos = QueryPos.getInstance(q);
4672    
4673                            qPos.add(groupId);
4674    
4675                            qPos.add(status);
4676    
4677                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
4678                    }
4679                    catch (Exception e) {
4680                            throw processException(e);
4681                    }
4682                    finally {
4683                            closeSession(session);
4684                    }
4685            }
4686    
4687            /**
4688             * 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;.
4689             *
4690             * @param entryId the primary key of the current blogs entry
4691             * @param groupId the group ID
4692             * @param status the status
4693             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4694             * @return the previous, current, and next blogs entry
4695             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
4696             */
4697            @Override
4698            public BlogsEntry[] filterFindByG_S_PrevAndNext(long entryId, long groupId,
4699                    int status, OrderByComparator<BlogsEntry> orderByComparator)
4700                    throws NoSuchEntryException {
4701                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4702                            return findByG_S_PrevAndNext(entryId, groupId, status,
4703                                    orderByComparator);
4704                    }
4705    
4706                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
4707    
4708                    Session session = null;
4709    
4710                    try {
4711                            session = openSession();
4712    
4713                            BlogsEntry[] array = new BlogsEntryImpl[3];
4714    
4715                            array[0] = filterGetByG_S_PrevAndNext(session, blogsEntry, groupId,
4716                                            status, orderByComparator, true);
4717    
4718                            array[1] = blogsEntry;
4719    
4720                            array[2] = filterGetByG_S_PrevAndNext(session, blogsEntry, groupId,
4721                                            status, orderByComparator, false);
4722    
4723                            return array;
4724                    }
4725                    catch (Exception e) {
4726                            throw processException(e);
4727                    }
4728                    finally {
4729                            closeSession(session);
4730                    }
4731            }
4732    
4733            protected BlogsEntry filterGetByG_S_PrevAndNext(Session session,
4734                    BlogsEntry blogsEntry, long groupId, int status,
4735                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
4736                    StringBundler query = null;
4737    
4738                    if (orderByComparator != null) {
4739                            query = new StringBundler(6 +
4740                                            (orderByComparator.getOrderByConditionFields().length * 3) +
4741                                            (orderByComparator.getOrderByFields().length * 3));
4742                    }
4743                    else {
4744                            query = new StringBundler(5);
4745                    }
4746    
4747                    if (getDB().isSupportsInlineDistinct()) {
4748                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
4749                    }
4750                    else {
4751                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
4752                    }
4753    
4754                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4755    
4756                    query.append(_FINDER_COLUMN_G_S_STATUS_2);
4757    
4758                    if (!getDB().isSupportsInlineDistinct()) {
4759                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
4760                    }
4761    
4762                    if (orderByComparator != null) {
4763                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4764    
4765                            if (orderByConditionFields.length > 0) {
4766                                    query.append(WHERE_AND);
4767                            }
4768    
4769                            for (int i = 0; i < orderByConditionFields.length; i++) {
4770                                    if (getDB().isSupportsInlineDistinct()) {
4771                                            query.append(_ORDER_BY_ENTITY_ALIAS);
4772                                    }
4773                                    else {
4774                                            query.append(_ORDER_BY_ENTITY_TABLE);
4775                                    }
4776    
4777                                    query.append(orderByConditionFields[i]);
4778    
4779                                    if ((i + 1) < orderByConditionFields.length) {
4780                                            if (orderByComparator.isAscending() ^ previous) {
4781                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4782                                            }
4783                                            else {
4784                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4785                                            }
4786                                    }
4787                                    else {
4788                                            if (orderByComparator.isAscending() ^ previous) {
4789                                                    query.append(WHERE_GREATER_THAN);
4790                                            }
4791                                            else {
4792                                                    query.append(WHERE_LESSER_THAN);
4793                                            }
4794                                    }
4795                            }
4796    
4797                            query.append(ORDER_BY_CLAUSE);
4798    
4799                            String[] orderByFields = orderByComparator.getOrderByFields();
4800    
4801                            for (int i = 0; i < orderByFields.length; i++) {
4802                                    if (getDB().isSupportsInlineDistinct()) {
4803                                            query.append(_ORDER_BY_ENTITY_ALIAS);
4804                                    }
4805                                    else {
4806                                            query.append(_ORDER_BY_ENTITY_TABLE);
4807                                    }
4808    
4809                                    query.append(orderByFields[i]);
4810    
4811                                    if ((i + 1) < orderByFields.length) {
4812                                            if (orderByComparator.isAscending() ^ previous) {
4813                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4814                                            }
4815                                            else {
4816                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4817                                            }
4818                                    }
4819                                    else {
4820                                            if (orderByComparator.isAscending() ^ previous) {
4821                                                    query.append(ORDER_BY_ASC);
4822                                            }
4823                                            else {
4824                                                    query.append(ORDER_BY_DESC);
4825                                            }
4826                                    }
4827                            }
4828                    }
4829                    else {
4830                            if (getDB().isSupportsInlineDistinct()) {
4831                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
4832                            }
4833                            else {
4834                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
4835                            }
4836                    }
4837    
4838                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4839                                    BlogsEntry.class.getName(),
4840                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4841    
4842                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
4843    
4844                    q.setFirstResult(0);
4845                    q.setMaxResults(2);
4846    
4847                    if (getDB().isSupportsInlineDistinct()) {
4848                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
4849                    }
4850                    else {
4851                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
4852                    }
4853    
4854                    QueryPos qPos = QueryPos.getInstance(q);
4855    
4856                    qPos.add(groupId);
4857    
4858                    qPos.add(status);
4859    
4860                    if (orderByComparator != null) {
4861                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
4862    
4863                            for (Object value : values) {
4864                                    qPos.add(value);
4865                            }
4866                    }
4867    
4868                    List<BlogsEntry> list = q.list();
4869    
4870                    if (list.size() == 2) {
4871                            return list.get(1);
4872                    }
4873                    else {
4874                            return null;
4875                    }
4876            }
4877    
4878            /**
4879             * Removes all the blogs entries where groupId = &#63; and status = &#63; from the database.
4880             *
4881             * @param groupId the group ID
4882             * @param status the status
4883             */
4884            @Override
4885            public void removeByG_S(long groupId, int status) {
4886                    for (BlogsEntry blogsEntry : findByG_S(groupId, status,
4887                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
4888                            remove(blogsEntry);
4889                    }
4890            }
4891    
4892            /**
4893             * Returns the number of blogs entries where groupId = &#63; and status = &#63;.
4894             *
4895             * @param groupId the group ID
4896             * @param status the status
4897             * @return the number of matching blogs entries
4898             */
4899            @Override
4900            public int countByG_S(long groupId, int status) {
4901                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_S;
4902    
4903                    Object[] finderArgs = new Object[] { groupId, status };
4904    
4905                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
4906    
4907                    if (count == null) {
4908                            StringBundler query = new StringBundler(3);
4909    
4910                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
4911    
4912                            query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4913    
4914                            query.append(_FINDER_COLUMN_G_S_STATUS_2);
4915    
4916                            String sql = query.toString();
4917    
4918                            Session session = null;
4919    
4920                            try {
4921                                    session = openSession();
4922    
4923                                    Query q = session.createQuery(sql);
4924    
4925                                    QueryPos qPos = QueryPos.getInstance(q);
4926    
4927                                    qPos.add(groupId);
4928    
4929                                    qPos.add(status);
4930    
4931                                    count = (Long)q.uniqueResult();
4932    
4933                                    finderCache.putResult(finderPath, finderArgs, count);
4934                            }
4935                            catch (Exception e) {
4936                                    finderCache.removeResult(finderPath, finderArgs);
4937    
4938                                    throw processException(e);
4939                            }
4940                            finally {
4941                                    closeSession(session);
4942                            }
4943                    }
4944    
4945                    return count.intValue();
4946            }
4947    
4948            /**
4949             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and status = &#63;.
4950             *
4951             * @param groupId the group ID
4952             * @param status the status
4953             * @return the number of matching blogs entries that the user has permission to view
4954             */
4955            @Override
4956            public int filterCountByG_S(long groupId, int status) {
4957                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4958                            return countByG_S(groupId, status);
4959                    }
4960    
4961                    StringBundler query = new StringBundler(3);
4962    
4963                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
4964    
4965                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4966    
4967                    query.append(_FINDER_COLUMN_G_S_STATUS_2);
4968    
4969                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4970                                    BlogsEntry.class.getName(),
4971                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4972    
4973                    Session session = null;
4974    
4975                    try {
4976                            session = openSession();
4977    
4978                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
4979    
4980                            q.addScalar(COUNT_COLUMN_NAME,
4981                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
4982    
4983                            QueryPos qPos = QueryPos.getInstance(q);
4984    
4985                            qPos.add(groupId);
4986    
4987                            qPos.add(status);
4988    
4989                            Long count = (Long)q.uniqueResult();
4990    
4991                            return count.intValue();
4992                    }
4993                    catch (Exception e) {
4994                            throw processException(e);
4995                    }
4996                    finally {
4997                            closeSession(session);
4998                    }
4999            }
5000    
5001            private static final String _FINDER_COLUMN_G_S_GROUPID_2 = "blogsEntry.groupId = ? AND ";
5002            private static final String _FINDER_COLUMN_G_S_STATUS_2 = "blogsEntry.status = ?";
5003            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_NOTS = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
5004                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
5005                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_NotS",
5006                            new String[] {
5007                                    Long.class.getName(), Integer.class.getName(),
5008                                    
5009                            Integer.class.getName(), Integer.class.getName(),
5010                                    OrderByComparator.class.getName()
5011                            });
5012            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_NOTS = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
5013                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
5014                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_NotS",
5015                            new String[] { Long.class.getName(), Integer.class.getName() });
5016    
5017            /**
5018             * Returns all the blogs entries where groupId = &#63; and status &ne; &#63;.
5019             *
5020             * @param groupId the group ID
5021             * @param status the status
5022             * @return the matching blogs entries
5023             */
5024            @Override
5025            public List<BlogsEntry> findByG_NotS(long groupId, int status) {
5026                    return findByG_NotS(groupId, status, QueryUtil.ALL_POS,
5027                            QueryUtil.ALL_POS, null);
5028            }
5029    
5030            /**
5031             * Returns a range of all the blogs entries where groupId = &#63; and status &ne; &#63;.
5032             *
5033             * <p>
5034             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5035             * </p>
5036             *
5037             * @param groupId the group ID
5038             * @param status the status
5039             * @param start the lower bound of the range of blogs entries
5040             * @param end the upper bound of the range of blogs entries (not inclusive)
5041             * @return the range of matching blogs entries
5042             */
5043            @Override
5044            public List<BlogsEntry> findByG_NotS(long groupId, int status, int start,
5045                    int end) {
5046                    return findByG_NotS(groupId, status, start, end, null);
5047            }
5048    
5049            /**
5050             * Returns an ordered range of all the blogs entries where groupId = &#63; and status &ne; &#63;.
5051             *
5052             * <p>
5053             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5054             * </p>
5055             *
5056             * @param groupId the group ID
5057             * @param status the status
5058             * @param start the lower bound of the range of blogs entries
5059             * @param end the upper bound of the range of blogs entries (not inclusive)
5060             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5061             * @return the ordered range of matching blogs entries
5062             */
5063            @Override
5064            public List<BlogsEntry> findByG_NotS(long groupId, int status, int start,
5065                    int end, OrderByComparator<BlogsEntry> orderByComparator) {
5066                    return findByG_NotS(groupId, status, start, end, orderByComparator, true);
5067            }
5068    
5069            /**
5070             * Returns an ordered range of all the blogs entries where groupId = &#63; and status &ne; &#63;.
5071             *
5072             * <p>
5073             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5074             * </p>
5075             *
5076             * @param groupId the group ID
5077             * @param status the status
5078             * @param start the lower bound of the range of blogs entries
5079             * @param end the upper bound of the range of blogs entries (not inclusive)
5080             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5081             * @param retrieveFromCache whether to retrieve from the finder cache
5082             * @return the ordered range of matching blogs entries
5083             */
5084            @Override
5085            public List<BlogsEntry> findByG_NotS(long groupId, int status, int start,
5086                    int end, OrderByComparator<BlogsEntry> orderByComparator,
5087                    boolean retrieveFromCache) {
5088                    boolean pagination = true;
5089                    FinderPath finderPath = null;
5090                    Object[] finderArgs = null;
5091    
5092                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_NOTS;
5093                    finderArgs = new Object[] { groupId, status, start, end, orderByComparator };
5094    
5095                    List<BlogsEntry> list = null;
5096    
5097                    if (retrieveFromCache) {
5098                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
5099                                            finderArgs, this);
5100    
5101                            if ((list != null) && !list.isEmpty()) {
5102                                    for (BlogsEntry blogsEntry : list) {
5103                                            if ((groupId != blogsEntry.getGroupId()) ||
5104                                                            (status == blogsEntry.getStatus())) {
5105                                                    list = null;
5106    
5107                                                    break;
5108                                            }
5109                                    }
5110                            }
5111                    }
5112    
5113                    if (list == null) {
5114                            StringBundler query = null;
5115    
5116                            if (orderByComparator != null) {
5117                                    query = new StringBundler(4 +
5118                                                    (orderByComparator.getOrderByFields().length * 2));
5119                            }
5120                            else {
5121                                    query = new StringBundler(4);
5122                            }
5123    
5124                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
5125    
5126                            query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
5127    
5128                            query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
5129    
5130                            if (orderByComparator != null) {
5131                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5132                                            orderByComparator);
5133                            }
5134                            else
5135                             if (pagination) {
5136                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
5137                            }
5138    
5139                            String sql = query.toString();
5140    
5141                            Session session = null;
5142    
5143                            try {
5144                                    session = openSession();
5145    
5146                                    Query q = session.createQuery(sql);
5147    
5148                                    QueryPos qPos = QueryPos.getInstance(q);
5149    
5150                                    qPos.add(groupId);
5151    
5152                                    qPos.add(status);
5153    
5154                                    if (!pagination) {
5155                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
5156                                                            start, end, false);
5157    
5158                                            Collections.sort(list);
5159    
5160                                            list = Collections.unmodifiableList(list);
5161                                    }
5162                                    else {
5163                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
5164                                                            start, end);
5165                                    }
5166    
5167                                    cacheResult(list);
5168    
5169                                    finderCache.putResult(finderPath, finderArgs, list);
5170                            }
5171                            catch (Exception e) {
5172                                    finderCache.removeResult(finderPath, finderArgs);
5173    
5174                                    throw processException(e);
5175                            }
5176                            finally {
5177                                    closeSession(session);
5178                            }
5179                    }
5180    
5181                    return list;
5182            }
5183    
5184            /**
5185             * Returns the first blogs entry in the ordered set where groupId = &#63; and status &ne; &#63;.
5186             *
5187             * @param groupId the group ID
5188             * @param status the status
5189             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5190             * @return the first matching blogs entry
5191             * @throws NoSuchEntryException if a matching blogs entry could not be found
5192             */
5193            @Override
5194            public BlogsEntry findByG_NotS_First(long groupId, int status,
5195                    OrderByComparator<BlogsEntry> orderByComparator)
5196                    throws NoSuchEntryException {
5197                    BlogsEntry blogsEntry = fetchByG_NotS_First(groupId, status,
5198                                    orderByComparator);
5199    
5200                    if (blogsEntry != null) {
5201                            return blogsEntry;
5202                    }
5203    
5204                    StringBundler msg = new StringBundler(6);
5205    
5206                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5207    
5208                    msg.append("groupId=");
5209                    msg.append(groupId);
5210    
5211                    msg.append(", status=");
5212                    msg.append(status);
5213    
5214                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5215    
5216                    throw new NoSuchEntryException(msg.toString());
5217            }
5218    
5219            /**
5220             * Returns the first blogs entry in the ordered set where groupId = &#63; and status &ne; &#63;.
5221             *
5222             * @param groupId the group ID
5223             * @param status the status
5224             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5225             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
5226             */
5227            @Override
5228            public BlogsEntry fetchByG_NotS_First(long groupId, int status,
5229                    OrderByComparator<BlogsEntry> orderByComparator) {
5230                    List<BlogsEntry> list = findByG_NotS(groupId, status, 0, 1,
5231                                    orderByComparator);
5232    
5233                    if (!list.isEmpty()) {
5234                            return list.get(0);
5235                    }
5236    
5237                    return null;
5238            }
5239    
5240            /**
5241             * Returns the last blogs entry in the ordered set where groupId = &#63; and status &ne; &#63;.
5242             *
5243             * @param groupId the group ID
5244             * @param status the status
5245             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5246             * @return the last matching blogs entry
5247             * @throws NoSuchEntryException if a matching blogs entry could not be found
5248             */
5249            @Override
5250            public BlogsEntry findByG_NotS_Last(long groupId, int status,
5251                    OrderByComparator<BlogsEntry> orderByComparator)
5252                    throws NoSuchEntryException {
5253                    BlogsEntry blogsEntry = fetchByG_NotS_Last(groupId, status,
5254                                    orderByComparator);
5255    
5256                    if (blogsEntry != null) {
5257                            return blogsEntry;
5258                    }
5259    
5260                    StringBundler msg = new StringBundler(6);
5261    
5262                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5263    
5264                    msg.append("groupId=");
5265                    msg.append(groupId);
5266    
5267                    msg.append(", status=");
5268                    msg.append(status);
5269    
5270                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5271    
5272                    throw new NoSuchEntryException(msg.toString());
5273            }
5274    
5275            /**
5276             * Returns the last blogs entry in the ordered set where groupId = &#63; and status &ne; &#63;.
5277             *
5278             * @param groupId the group ID
5279             * @param status the status
5280             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5281             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
5282             */
5283            @Override
5284            public BlogsEntry fetchByG_NotS_Last(long groupId, int status,
5285                    OrderByComparator<BlogsEntry> orderByComparator) {
5286                    int count = countByG_NotS(groupId, status);
5287    
5288                    if (count == 0) {
5289                            return null;
5290                    }
5291    
5292                    List<BlogsEntry> list = findByG_NotS(groupId, status, count - 1, count,
5293                                    orderByComparator);
5294    
5295                    if (!list.isEmpty()) {
5296                            return list.get(0);
5297                    }
5298    
5299                    return null;
5300            }
5301    
5302            /**
5303             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63; and status &ne; &#63;.
5304             *
5305             * @param entryId the primary key of the current blogs entry
5306             * @param groupId the group ID
5307             * @param status the status
5308             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5309             * @return the previous, current, and next blogs entry
5310             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
5311             */
5312            @Override
5313            public BlogsEntry[] findByG_NotS_PrevAndNext(long entryId, long groupId,
5314                    int status, OrderByComparator<BlogsEntry> orderByComparator)
5315                    throws NoSuchEntryException {
5316                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
5317    
5318                    Session session = null;
5319    
5320                    try {
5321                            session = openSession();
5322    
5323                            BlogsEntry[] array = new BlogsEntryImpl[3];
5324    
5325                            array[0] = getByG_NotS_PrevAndNext(session, blogsEntry, groupId,
5326                                            status, orderByComparator, true);
5327    
5328                            array[1] = blogsEntry;
5329    
5330                            array[2] = getByG_NotS_PrevAndNext(session, blogsEntry, groupId,
5331                                            status, orderByComparator, false);
5332    
5333                            return array;
5334                    }
5335                    catch (Exception e) {
5336                            throw processException(e);
5337                    }
5338                    finally {
5339                            closeSession(session);
5340                    }
5341            }
5342    
5343            protected BlogsEntry getByG_NotS_PrevAndNext(Session session,
5344                    BlogsEntry blogsEntry, long groupId, int status,
5345                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
5346                    StringBundler query = null;
5347    
5348                    if (orderByComparator != null) {
5349                            query = new StringBundler(5 +
5350                                            (orderByComparator.getOrderByConditionFields().length * 3) +
5351                                            (orderByComparator.getOrderByFields().length * 3));
5352                    }
5353                    else {
5354                            query = new StringBundler(4);
5355                    }
5356    
5357                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
5358    
5359                    query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
5360    
5361                    query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
5362    
5363                    if (orderByComparator != null) {
5364                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5365    
5366                            if (orderByConditionFields.length > 0) {
5367                                    query.append(WHERE_AND);
5368                            }
5369    
5370                            for (int i = 0; i < orderByConditionFields.length; i++) {
5371                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5372                                    query.append(orderByConditionFields[i]);
5373    
5374                                    if ((i + 1) < orderByConditionFields.length) {
5375                                            if (orderByComparator.isAscending() ^ previous) {
5376                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5377                                            }
5378                                            else {
5379                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5380                                            }
5381                                    }
5382                                    else {
5383                                            if (orderByComparator.isAscending() ^ previous) {
5384                                                    query.append(WHERE_GREATER_THAN);
5385                                            }
5386                                            else {
5387                                                    query.append(WHERE_LESSER_THAN);
5388                                            }
5389                                    }
5390                            }
5391    
5392                            query.append(ORDER_BY_CLAUSE);
5393    
5394                            String[] orderByFields = orderByComparator.getOrderByFields();
5395    
5396                            for (int i = 0; i < orderByFields.length; i++) {
5397                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5398                                    query.append(orderByFields[i]);
5399    
5400                                    if ((i + 1) < orderByFields.length) {
5401                                            if (orderByComparator.isAscending() ^ previous) {
5402                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5403                                            }
5404                                            else {
5405                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5406                                            }
5407                                    }
5408                                    else {
5409                                            if (orderByComparator.isAscending() ^ previous) {
5410                                                    query.append(ORDER_BY_ASC);
5411                                            }
5412                                            else {
5413                                                    query.append(ORDER_BY_DESC);
5414                                            }
5415                                    }
5416                            }
5417                    }
5418                    else {
5419                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
5420                    }
5421    
5422                    String sql = query.toString();
5423    
5424                    Query q = session.createQuery(sql);
5425    
5426                    q.setFirstResult(0);
5427                    q.setMaxResults(2);
5428    
5429                    QueryPos qPos = QueryPos.getInstance(q);
5430    
5431                    qPos.add(groupId);
5432    
5433                    qPos.add(status);
5434    
5435                    if (orderByComparator != null) {
5436                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
5437    
5438                            for (Object value : values) {
5439                                    qPos.add(value);
5440                            }
5441                    }
5442    
5443                    List<BlogsEntry> list = q.list();
5444    
5445                    if (list.size() == 2) {
5446                            return list.get(1);
5447                    }
5448                    else {
5449                            return null;
5450                    }
5451            }
5452    
5453            /**
5454             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and status &ne; &#63;.
5455             *
5456             * @param groupId the group ID
5457             * @param status the status
5458             * @return the matching blogs entries that the user has permission to view
5459             */
5460            @Override
5461            public List<BlogsEntry> filterFindByG_NotS(long groupId, int status) {
5462                    return filterFindByG_NotS(groupId, status, QueryUtil.ALL_POS,
5463                            QueryUtil.ALL_POS, null);
5464            }
5465    
5466            /**
5467             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63; and status &ne; &#63;.
5468             *
5469             * <p>
5470             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5471             * </p>
5472             *
5473             * @param groupId the group ID
5474             * @param status the status
5475             * @param start the lower bound of the range of blogs entries
5476             * @param end the upper bound of the range of blogs entries (not inclusive)
5477             * @return the range of matching blogs entries that the user has permission to view
5478             */
5479            @Override
5480            public List<BlogsEntry> filterFindByG_NotS(long groupId, int status,
5481                    int start, int end) {
5482                    return filterFindByG_NotS(groupId, status, start, end, null);
5483            }
5484    
5485            /**
5486             * Returns an ordered range of all the blogs entries that the user has permissions to view where groupId = &#63; and status &ne; &#63;.
5487             *
5488             * <p>
5489             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5490             * </p>
5491             *
5492             * @param groupId the group ID
5493             * @param status the status
5494             * @param start the lower bound of the range of blogs entries
5495             * @param end the upper bound of the range of blogs entries (not inclusive)
5496             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5497             * @return the ordered range of matching blogs entries that the user has permission to view
5498             */
5499            @Override
5500            public List<BlogsEntry> filterFindByG_NotS(long groupId, int status,
5501                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator) {
5502                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5503                            return findByG_NotS(groupId, status, start, end, orderByComparator);
5504                    }
5505    
5506                    StringBundler query = null;
5507    
5508                    if (orderByComparator != null) {
5509                            query = new StringBundler(4 +
5510                                            (orderByComparator.getOrderByFields().length * 2));
5511                    }
5512                    else {
5513                            query = new StringBundler(5);
5514                    }
5515    
5516                    if (getDB().isSupportsInlineDistinct()) {
5517                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
5518                    }
5519                    else {
5520                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
5521                    }
5522    
5523                    query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
5524    
5525                    query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
5526    
5527                    if (!getDB().isSupportsInlineDistinct()) {
5528                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
5529                    }
5530    
5531                    if (orderByComparator != null) {
5532                            if (getDB().isSupportsInlineDistinct()) {
5533                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5534                                            orderByComparator, true);
5535                            }
5536                            else {
5537                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
5538                                            orderByComparator, true);
5539                            }
5540                    }
5541                    else {
5542                            if (getDB().isSupportsInlineDistinct()) {
5543                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
5544                            }
5545                            else {
5546                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
5547                            }
5548                    }
5549    
5550                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5551                                    BlogsEntry.class.getName(),
5552                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5553    
5554                    Session session = null;
5555    
5556                    try {
5557                            session = openSession();
5558    
5559                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
5560    
5561                            if (getDB().isSupportsInlineDistinct()) {
5562                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
5563                            }
5564                            else {
5565                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
5566                            }
5567    
5568                            QueryPos qPos = QueryPos.getInstance(q);
5569    
5570                            qPos.add(groupId);
5571    
5572                            qPos.add(status);
5573    
5574                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
5575                    }
5576                    catch (Exception e) {
5577                            throw processException(e);
5578                    }
5579                    finally {
5580                            closeSession(session);
5581                    }
5582            }
5583    
5584            /**
5585             * 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;.
5586             *
5587             * @param entryId the primary key of the current blogs entry
5588             * @param groupId the group ID
5589             * @param status the status
5590             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5591             * @return the previous, current, and next blogs entry
5592             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
5593             */
5594            @Override
5595            public BlogsEntry[] filterFindByG_NotS_PrevAndNext(long entryId,
5596                    long groupId, int status,
5597                    OrderByComparator<BlogsEntry> orderByComparator)
5598                    throws NoSuchEntryException {
5599                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5600                            return findByG_NotS_PrevAndNext(entryId, groupId, status,
5601                                    orderByComparator);
5602                    }
5603    
5604                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
5605    
5606                    Session session = null;
5607    
5608                    try {
5609                            session = openSession();
5610    
5611                            BlogsEntry[] array = new BlogsEntryImpl[3];
5612    
5613                            array[0] = filterGetByG_NotS_PrevAndNext(session, blogsEntry,
5614                                            groupId, status, orderByComparator, true);
5615    
5616                            array[1] = blogsEntry;
5617    
5618                            array[2] = filterGetByG_NotS_PrevAndNext(session, blogsEntry,
5619                                            groupId, status, orderByComparator, false);
5620    
5621                            return array;
5622                    }
5623                    catch (Exception e) {
5624                            throw processException(e);
5625                    }
5626                    finally {
5627                            closeSession(session);
5628                    }
5629            }
5630    
5631            protected BlogsEntry filterGetByG_NotS_PrevAndNext(Session session,
5632                    BlogsEntry blogsEntry, long groupId, int status,
5633                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
5634                    StringBundler query = null;
5635    
5636                    if (orderByComparator != null) {
5637                            query = new StringBundler(6 +
5638                                            (orderByComparator.getOrderByConditionFields().length * 3) +
5639                                            (orderByComparator.getOrderByFields().length * 3));
5640                    }
5641                    else {
5642                            query = new StringBundler(5);
5643                    }
5644    
5645                    if (getDB().isSupportsInlineDistinct()) {
5646                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
5647                    }
5648                    else {
5649                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
5650                    }
5651    
5652                    query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
5653    
5654                    query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
5655    
5656                    if (!getDB().isSupportsInlineDistinct()) {
5657                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
5658                    }
5659    
5660                    if (orderByComparator != null) {
5661                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5662    
5663                            if (orderByConditionFields.length > 0) {
5664                                    query.append(WHERE_AND);
5665                            }
5666    
5667                            for (int i = 0; i < orderByConditionFields.length; i++) {
5668                                    if (getDB().isSupportsInlineDistinct()) {
5669                                            query.append(_ORDER_BY_ENTITY_ALIAS);
5670                                    }
5671                                    else {
5672                                            query.append(_ORDER_BY_ENTITY_TABLE);
5673                                    }
5674    
5675                                    query.append(orderByConditionFields[i]);
5676    
5677                                    if ((i + 1) < orderByConditionFields.length) {
5678                                            if (orderByComparator.isAscending() ^ previous) {
5679                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5680                                            }
5681                                            else {
5682                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5683                                            }
5684                                    }
5685                                    else {
5686                                            if (orderByComparator.isAscending() ^ previous) {
5687                                                    query.append(WHERE_GREATER_THAN);
5688                                            }
5689                                            else {
5690                                                    query.append(WHERE_LESSER_THAN);
5691                                            }
5692                                    }
5693                            }
5694    
5695                            query.append(ORDER_BY_CLAUSE);
5696    
5697                            String[] orderByFields = orderByComparator.getOrderByFields();
5698    
5699                            for (int i = 0; i < orderByFields.length; i++) {
5700                                    if (getDB().isSupportsInlineDistinct()) {
5701                                            query.append(_ORDER_BY_ENTITY_ALIAS);
5702                                    }
5703                                    else {
5704                                            query.append(_ORDER_BY_ENTITY_TABLE);
5705                                    }
5706    
5707                                    query.append(orderByFields[i]);
5708    
5709                                    if ((i + 1) < orderByFields.length) {
5710                                            if (orderByComparator.isAscending() ^ previous) {
5711                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5712                                            }
5713                                            else {
5714                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5715                                            }
5716                                    }
5717                                    else {
5718                                            if (orderByComparator.isAscending() ^ previous) {
5719                                                    query.append(ORDER_BY_ASC);
5720                                            }
5721                                            else {
5722                                                    query.append(ORDER_BY_DESC);
5723                                            }
5724                                    }
5725                            }
5726                    }
5727                    else {
5728                            if (getDB().isSupportsInlineDistinct()) {
5729                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
5730                            }
5731                            else {
5732                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
5733                            }
5734                    }
5735    
5736                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5737                                    BlogsEntry.class.getName(),
5738                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5739    
5740                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
5741    
5742                    q.setFirstResult(0);
5743                    q.setMaxResults(2);
5744    
5745                    if (getDB().isSupportsInlineDistinct()) {
5746                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
5747                    }
5748                    else {
5749                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
5750                    }
5751    
5752                    QueryPos qPos = QueryPos.getInstance(q);
5753    
5754                    qPos.add(groupId);
5755    
5756                    qPos.add(status);
5757    
5758                    if (orderByComparator != null) {
5759                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
5760    
5761                            for (Object value : values) {
5762                                    qPos.add(value);
5763                            }
5764                    }
5765    
5766                    List<BlogsEntry> list = q.list();
5767    
5768                    if (list.size() == 2) {
5769                            return list.get(1);
5770                    }
5771                    else {
5772                            return null;
5773                    }
5774            }
5775    
5776            /**
5777             * Removes all the blogs entries where groupId = &#63; and status &ne; &#63; from the database.
5778             *
5779             * @param groupId the group ID
5780             * @param status the status
5781             */
5782            @Override
5783            public void removeByG_NotS(long groupId, int status) {
5784                    for (BlogsEntry blogsEntry : findByG_NotS(groupId, status,
5785                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
5786                            remove(blogsEntry);
5787                    }
5788            }
5789    
5790            /**
5791             * Returns the number of blogs entries where groupId = &#63; and status &ne; &#63;.
5792             *
5793             * @param groupId the group ID
5794             * @param status the status
5795             * @return the number of matching blogs entries
5796             */
5797            @Override
5798            public int countByG_NotS(long groupId, int status) {
5799                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_NOTS;
5800    
5801                    Object[] finderArgs = new Object[] { groupId, status };
5802    
5803                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
5804    
5805                    if (count == null) {
5806                            StringBundler query = new StringBundler(3);
5807    
5808                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
5809    
5810                            query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
5811    
5812                            query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
5813    
5814                            String sql = query.toString();
5815    
5816                            Session session = null;
5817    
5818                            try {
5819                                    session = openSession();
5820    
5821                                    Query q = session.createQuery(sql);
5822    
5823                                    QueryPos qPos = QueryPos.getInstance(q);
5824    
5825                                    qPos.add(groupId);
5826    
5827                                    qPos.add(status);
5828    
5829                                    count = (Long)q.uniqueResult();
5830    
5831                                    finderCache.putResult(finderPath, finderArgs, count);
5832                            }
5833                            catch (Exception e) {
5834                                    finderCache.removeResult(finderPath, finderArgs);
5835    
5836                                    throw processException(e);
5837                            }
5838                            finally {
5839                                    closeSession(session);
5840                            }
5841                    }
5842    
5843                    return count.intValue();
5844            }
5845    
5846            /**
5847             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and status &ne; &#63;.
5848             *
5849             * @param groupId the group ID
5850             * @param status the status
5851             * @return the number of matching blogs entries that the user has permission to view
5852             */
5853            @Override
5854            public int filterCountByG_NotS(long groupId, int status) {
5855                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5856                            return countByG_NotS(groupId, status);
5857                    }
5858    
5859                    StringBundler query = new StringBundler(3);
5860    
5861                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
5862    
5863                    query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
5864    
5865                    query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
5866    
5867                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5868                                    BlogsEntry.class.getName(),
5869                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5870    
5871                    Session session = null;
5872    
5873                    try {
5874                            session = openSession();
5875    
5876                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
5877    
5878                            q.addScalar(COUNT_COLUMN_NAME,
5879                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
5880    
5881                            QueryPos qPos = QueryPos.getInstance(q);
5882    
5883                            qPos.add(groupId);
5884    
5885                            qPos.add(status);
5886    
5887                            Long count = (Long)q.uniqueResult();
5888    
5889                            return count.intValue();
5890                    }
5891                    catch (Exception e) {
5892                            throw processException(e);
5893                    }
5894                    finally {
5895                            closeSession(session);
5896                    }
5897            }
5898    
5899            private static final String _FINDER_COLUMN_G_NOTS_GROUPID_2 = "blogsEntry.groupId = ? AND ";
5900            private static final String _FINDER_COLUMN_G_NOTS_STATUS_2 = "blogsEntry.status != ?";
5901            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
5902                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
5903                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_U",
5904                            new String[] {
5905                                    Long.class.getName(), Long.class.getName(),
5906                                    
5907                            Integer.class.getName(), Integer.class.getName(),
5908                                    OrderByComparator.class.getName()
5909                            });
5910            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
5911                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
5912                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_U",
5913                            new String[] { Long.class.getName(), Long.class.getName() },
5914                            BlogsEntryModelImpl.COMPANYID_COLUMN_BITMASK |
5915                            BlogsEntryModelImpl.USERID_COLUMN_BITMASK |
5916                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
5917                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
5918            public static final FinderPath FINDER_PATH_COUNT_BY_C_U = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
5919                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
5920                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_U",
5921                            new String[] { Long.class.getName(), Long.class.getName() });
5922    
5923            /**
5924             * Returns all the blogs entries where companyId = &#63; and userId = &#63;.
5925             *
5926             * @param companyId the company ID
5927             * @param userId the user ID
5928             * @return the matching blogs entries
5929             */
5930            @Override
5931            public List<BlogsEntry> findByC_U(long companyId, long userId) {
5932                    return findByC_U(companyId, userId, QueryUtil.ALL_POS,
5933                            QueryUtil.ALL_POS, null);
5934            }
5935    
5936            /**
5937             * Returns a range of all the blogs entries where companyId = &#63; and userId = &#63;.
5938             *
5939             * <p>
5940             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5941             * </p>
5942             *
5943             * @param companyId the company ID
5944             * @param userId the user ID
5945             * @param start the lower bound of the range of blogs entries
5946             * @param end the upper bound of the range of blogs entries (not inclusive)
5947             * @return the range of matching blogs entries
5948             */
5949            @Override
5950            public List<BlogsEntry> findByC_U(long companyId, long userId, int start,
5951                    int end) {
5952                    return findByC_U(companyId, userId, start, end, null);
5953            }
5954    
5955            /**
5956             * Returns an ordered range of all the blogs entries where companyId = &#63; and userId = &#63;.
5957             *
5958             * <p>
5959             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5960             * </p>
5961             *
5962             * @param companyId the company ID
5963             * @param userId the user ID
5964             * @param start the lower bound of the range of blogs entries
5965             * @param end the upper bound of the range of blogs entries (not inclusive)
5966             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5967             * @return the ordered range of matching blogs entries
5968             */
5969            @Override
5970            public List<BlogsEntry> findByC_U(long companyId, long userId, int start,
5971                    int end, OrderByComparator<BlogsEntry> orderByComparator) {
5972                    return findByC_U(companyId, userId, start, end, orderByComparator, true);
5973            }
5974    
5975            /**
5976             * Returns an ordered range of all the blogs entries where companyId = &#63; and userId = &#63;.
5977             *
5978             * <p>
5979             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5980             * </p>
5981             *
5982             * @param companyId the company ID
5983             * @param userId the user ID
5984             * @param start the lower bound of the range of blogs entries
5985             * @param end the upper bound of the range of blogs entries (not inclusive)
5986             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5987             * @param retrieveFromCache whether to retrieve from the finder cache
5988             * @return the ordered range of matching blogs entries
5989             */
5990            @Override
5991            public List<BlogsEntry> findByC_U(long companyId, long userId, int start,
5992                    int end, OrderByComparator<BlogsEntry> orderByComparator,
5993                    boolean retrieveFromCache) {
5994                    boolean pagination = true;
5995                    FinderPath finderPath = null;
5996                    Object[] finderArgs = null;
5997    
5998                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5999                                    (orderByComparator == null)) {
6000                            pagination = false;
6001                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U;
6002                            finderArgs = new Object[] { companyId, userId };
6003                    }
6004                    else {
6005                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U;
6006                            finderArgs = new Object[] {
6007                                            companyId, userId,
6008                                            
6009                                            start, end, orderByComparator
6010                                    };
6011                    }
6012    
6013                    List<BlogsEntry> list = null;
6014    
6015                    if (retrieveFromCache) {
6016                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
6017                                            finderArgs, this);
6018    
6019                            if ((list != null) && !list.isEmpty()) {
6020                                    for (BlogsEntry blogsEntry : list) {
6021                                            if ((companyId != blogsEntry.getCompanyId()) ||
6022                                                            (userId != blogsEntry.getUserId())) {
6023                                                    list = null;
6024    
6025                                                    break;
6026                                            }
6027                                    }
6028                            }
6029                    }
6030    
6031                    if (list == null) {
6032                            StringBundler query = null;
6033    
6034                            if (orderByComparator != null) {
6035                                    query = new StringBundler(4 +
6036                                                    (orderByComparator.getOrderByFields().length * 2));
6037                            }
6038                            else {
6039                                    query = new StringBundler(4);
6040                            }
6041    
6042                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
6043    
6044                            query.append(_FINDER_COLUMN_C_U_COMPANYID_2);
6045    
6046                            query.append(_FINDER_COLUMN_C_U_USERID_2);
6047    
6048                            if (orderByComparator != null) {
6049                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6050                                            orderByComparator);
6051                            }
6052                            else
6053                             if (pagination) {
6054                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
6055                            }
6056    
6057                            String sql = query.toString();
6058    
6059                            Session session = null;
6060    
6061                            try {
6062                                    session = openSession();
6063    
6064                                    Query q = session.createQuery(sql);
6065    
6066                                    QueryPos qPos = QueryPos.getInstance(q);
6067    
6068                                    qPos.add(companyId);
6069    
6070                                    qPos.add(userId);
6071    
6072                                    if (!pagination) {
6073                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
6074                                                            start, end, false);
6075    
6076                                            Collections.sort(list);
6077    
6078                                            list = Collections.unmodifiableList(list);
6079                                    }
6080                                    else {
6081                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
6082                                                            start, end);
6083                                    }
6084    
6085                                    cacheResult(list);
6086    
6087                                    finderCache.putResult(finderPath, finderArgs, list);
6088                            }
6089                            catch (Exception e) {
6090                                    finderCache.removeResult(finderPath, finderArgs);
6091    
6092                                    throw processException(e);
6093                            }
6094                            finally {
6095                                    closeSession(session);
6096                            }
6097                    }
6098    
6099                    return list;
6100            }
6101    
6102            /**
6103             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63;.
6104             *
6105             * @param companyId the company ID
6106             * @param userId the user ID
6107             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6108             * @return the first matching blogs entry
6109             * @throws NoSuchEntryException if a matching blogs entry could not be found
6110             */
6111            @Override
6112            public BlogsEntry findByC_U_First(long companyId, long userId,
6113                    OrderByComparator<BlogsEntry> orderByComparator)
6114                    throws NoSuchEntryException {
6115                    BlogsEntry blogsEntry = fetchByC_U_First(companyId, userId,
6116                                    orderByComparator);
6117    
6118                    if (blogsEntry != null) {
6119                            return blogsEntry;
6120                    }
6121    
6122                    StringBundler msg = new StringBundler(6);
6123    
6124                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6125    
6126                    msg.append("companyId=");
6127                    msg.append(companyId);
6128    
6129                    msg.append(", userId=");
6130                    msg.append(userId);
6131    
6132                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6133    
6134                    throw new NoSuchEntryException(msg.toString());
6135            }
6136    
6137            /**
6138             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63;.
6139             *
6140             * @param companyId the company ID
6141             * @param userId the user ID
6142             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6143             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
6144             */
6145            @Override
6146            public BlogsEntry fetchByC_U_First(long companyId, long userId,
6147                    OrderByComparator<BlogsEntry> orderByComparator) {
6148                    List<BlogsEntry> list = findByC_U(companyId, userId, 0, 1,
6149                                    orderByComparator);
6150    
6151                    if (!list.isEmpty()) {
6152                            return list.get(0);
6153                    }
6154    
6155                    return null;
6156            }
6157    
6158            /**
6159             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63;.
6160             *
6161             * @param companyId the company ID
6162             * @param userId the user ID
6163             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6164             * @return the last matching blogs entry
6165             * @throws NoSuchEntryException if a matching blogs entry could not be found
6166             */
6167            @Override
6168            public BlogsEntry findByC_U_Last(long companyId, long userId,
6169                    OrderByComparator<BlogsEntry> orderByComparator)
6170                    throws NoSuchEntryException {
6171                    BlogsEntry blogsEntry = fetchByC_U_Last(companyId, userId,
6172                                    orderByComparator);
6173    
6174                    if (blogsEntry != null) {
6175                            return blogsEntry;
6176                    }
6177    
6178                    StringBundler msg = new StringBundler(6);
6179    
6180                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6181    
6182                    msg.append("companyId=");
6183                    msg.append(companyId);
6184    
6185                    msg.append(", userId=");
6186                    msg.append(userId);
6187    
6188                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6189    
6190                    throw new NoSuchEntryException(msg.toString());
6191            }
6192    
6193            /**
6194             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63;.
6195             *
6196             * @param companyId the company ID
6197             * @param userId the user ID
6198             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6199             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
6200             */
6201            @Override
6202            public BlogsEntry fetchByC_U_Last(long companyId, long userId,
6203                    OrderByComparator<BlogsEntry> orderByComparator) {
6204                    int count = countByC_U(companyId, userId);
6205    
6206                    if (count == 0) {
6207                            return null;
6208                    }
6209    
6210                    List<BlogsEntry> list = findByC_U(companyId, userId, count - 1, count,
6211                                    orderByComparator);
6212    
6213                    if (!list.isEmpty()) {
6214                            return list.get(0);
6215                    }
6216    
6217                    return null;
6218            }
6219    
6220            /**
6221             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63; and userId = &#63;.
6222             *
6223             * @param entryId the primary key of the current blogs entry
6224             * @param companyId the company ID
6225             * @param userId the user ID
6226             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6227             * @return the previous, current, and next blogs entry
6228             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
6229             */
6230            @Override
6231            public BlogsEntry[] findByC_U_PrevAndNext(long entryId, long companyId,
6232                    long userId, OrderByComparator<BlogsEntry> orderByComparator)
6233                    throws NoSuchEntryException {
6234                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
6235    
6236                    Session session = null;
6237    
6238                    try {
6239                            session = openSession();
6240    
6241                            BlogsEntry[] array = new BlogsEntryImpl[3];
6242    
6243                            array[0] = getByC_U_PrevAndNext(session, blogsEntry, companyId,
6244                                            userId, orderByComparator, true);
6245    
6246                            array[1] = blogsEntry;
6247    
6248                            array[2] = getByC_U_PrevAndNext(session, blogsEntry, companyId,
6249                                            userId, orderByComparator, false);
6250    
6251                            return array;
6252                    }
6253                    catch (Exception e) {
6254                            throw processException(e);
6255                    }
6256                    finally {
6257                            closeSession(session);
6258                    }
6259            }
6260    
6261            protected BlogsEntry getByC_U_PrevAndNext(Session session,
6262                    BlogsEntry blogsEntry, long companyId, long userId,
6263                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
6264                    StringBundler query = null;
6265    
6266                    if (orderByComparator != null) {
6267                            query = new StringBundler(5 +
6268                                            (orderByComparator.getOrderByConditionFields().length * 3) +
6269                                            (orderByComparator.getOrderByFields().length * 3));
6270                    }
6271                    else {
6272                            query = new StringBundler(4);
6273                    }
6274    
6275                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
6276    
6277                    query.append(_FINDER_COLUMN_C_U_COMPANYID_2);
6278    
6279                    query.append(_FINDER_COLUMN_C_U_USERID_2);
6280    
6281                    if (orderByComparator != null) {
6282                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6283    
6284                            if (orderByConditionFields.length > 0) {
6285                                    query.append(WHERE_AND);
6286                            }
6287    
6288                            for (int i = 0; i < orderByConditionFields.length; i++) {
6289                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6290                                    query.append(orderByConditionFields[i]);
6291    
6292                                    if ((i + 1) < orderByConditionFields.length) {
6293                                            if (orderByComparator.isAscending() ^ previous) {
6294                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6295                                            }
6296                                            else {
6297                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6298                                            }
6299                                    }
6300                                    else {
6301                                            if (orderByComparator.isAscending() ^ previous) {
6302                                                    query.append(WHERE_GREATER_THAN);
6303                                            }
6304                                            else {
6305                                                    query.append(WHERE_LESSER_THAN);
6306                                            }
6307                                    }
6308                            }
6309    
6310                            query.append(ORDER_BY_CLAUSE);
6311    
6312                            String[] orderByFields = orderByComparator.getOrderByFields();
6313    
6314                            for (int i = 0; i < orderByFields.length; i++) {
6315                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6316                                    query.append(orderByFields[i]);
6317    
6318                                    if ((i + 1) < orderByFields.length) {
6319                                            if (orderByComparator.isAscending() ^ previous) {
6320                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6321                                            }
6322                                            else {
6323                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6324                                            }
6325                                    }
6326                                    else {
6327                                            if (orderByComparator.isAscending() ^ previous) {
6328                                                    query.append(ORDER_BY_ASC);
6329                                            }
6330                                            else {
6331                                                    query.append(ORDER_BY_DESC);
6332                                            }
6333                                    }
6334                            }
6335                    }
6336                    else {
6337                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
6338                    }
6339    
6340                    String sql = query.toString();
6341    
6342                    Query q = session.createQuery(sql);
6343    
6344                    q.setFirstResult(0);
6345                    q.setMaxResults(2);
6346    
6347                    QueryPos qPos = QueryPos.getInstance(q);
6348    
6349                    qPos.add(companyId);
6350    
6351                    qPos.add(userId);
6352    
6353                    if (orderByComparator != null) {
6354                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
6355    
6356                            for (Object value : values) {
6357                                    qPos.add(value);
6358                            }
6359                    }
6360    
6361                    List<BlogsEntry> list = q.list();
6362    
6363                    if (list.size() == 2) {
6364                            return list.get(1);
6365                    }
6366                    else {
6367                            return null;
6368                    }
6369            }
6370    
6371            /**
6372             * Removes all the blogs entries where companyId = &#63; and userId = &#63; from the database.
6373             *
6374             * @param companyId the company ID
6375             * @param userId the user ID
6376             */
6377            @Override
6378            public void removeByC_U(long companyId, long userId) {
6379                    for (BlogsEntry blogsEntry : findByC_U(companyId, userId,
6380                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
6381                            remove(blogsEntry);
6382                    }
6383            }
6384    
6385            /**
6386             * Returns the number of blogs entries where companyId = &#63; and userId = &#63;.
6387             *
6388             * @param companyId the company ID
6389             * @param userId the user ID
6390             * @return the number of matching blogs entries
6391             */
6392            @Override
6393            public int countByC_U(long companyId, long userId) {
6394                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_U;
6395    
6396                    Object[] finderArgs = new Object[] { companyId, userId };
6397    
6398                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
6399    
6400                    if (count == null) {
6401                            StringBundler query = new StringBundler(3);
6402    
6403                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
6404    
6405                            query.append(_FINDER_COLUMN_C_U_COMPANYID_2);
6406    
6407                            query.append(_FINDER_COLUMN_C_U_USERID_2);
6408    
6409                            String sql = query.toString();
6410    
6411                            Session session = null;
6412    
6413                            try {
6414                                    session = openSession();
6415    
6416                                    Query q = session.createQuery(sql);
6417    
6418                                    QueryPos qPos = QueryPos.getInstance(q);
6419    
6420                                    qPos.add(companyId);
6421    
6422                                    qPos.add(userId);
6423    
6424                                    count = (Long)q.uniqueResult();
6425    
6426                                    finderCache.putResult(finderPath, finderArgs, count);
6427                            }
6428                            catch (Exception e) {
6429                                    finderCache.removeResult(finderPath, finderArgs);
6430    
6431                                    throw processException(e);
6432                            }
6433                            finally {
6434                                    closeSession(session);
6435                            }
6436                    }
6437    
6438                    return count.intValue();
6439            }
6440    
6441            private static final String _FINDER_COLUMN_C_U_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
6442            private static final String _FINDER_COLUMN_C_U_USERID_2 = "blogsEntry.userId = ?";
6443            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
6444                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
6445                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_LtD",
6446                            new String[] {
6447                                    Long.class.getName(), Date.class.getName(),
6448                                    
6449                            Integer.class.getName(), Integer.class.getName(),
6450                                    OrderByComparator.class.getName()
6451                            });
6452            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
6453                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
6454                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_LtD",
6455                            new String[] { Long.class.getName(), Date.class.getName() });
6456    
6457            /**
6458             * Returns all the blogs entries where companyId = &#63; and displayDate &lt; &#63;.
6459             *
6460             * @param companyId the company ID
6461             * @param displayDate the display date
6462             * @return the matching blogs entries
6463             */
6464            @Override
6465            public List<BlogsEntry> findByC_LtD(long companyId, Date displayDate) {
6466                    return findByC_LtD(companyId, displayDate, QueryUtil.ALL_POS,
6467                            QueryUtil.ALL_POS, null);
6468            }
6469    
6470            /**
6471             * Returns a range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63;.
6472             *
6473             * <p>
6474             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6475             * </p>
6476             *
6477             * @param companyId the company ID
6478             * @param displayDate the display date
6479             * @param start the lower bound of the range of blogs entries
6480             * @param end the upper bound of the range of blogs entries (not inclusive)
6481             * @return the range of matching blogs entries
6482             */
6483            @Override
6484            public List<BlogsEntry> findByC_LtD(long companyId, Date displayDate,
6485                    int start, int end) {
6486                    return findByC_LtD(companyId, displayDate, start, end, null);
6487            }
6488    
6489            /**
6490             * Returns an ordered range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63;.
6491             *
6492             * <p>
6493             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6494             * </p>
6495             *
6496             * @param companyId the company ID
6497             * @param displayDate the display date
6498             * @param start the lower bound of the range of blogs entries
6499             * @param end the upper bound of the range of blogs entries (not inclusive)
6500             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6501             * @return the ordered range of matching blogs entries
6502             */
6503            @Override
6504            public List<BlogsEntry> findByC_LtD(long companyId, Date displayDate,
6505                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator) {
6506                    return findByC_LtD(companyId, displayDate, start, end,
6507                            orderByComparator, true);
6508            }
6509    
6510            /**
6511             * Returns an ordered range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63;.
6512             *
6513             * <p>
6514             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6515             * </p>
6516             *
6517             * @param companyId the company ID
6518             * @param displayDate the display date
6519             * @param start the lower bound of the range of blogs entries
6520             * @param end the upper bound of the range of blogs entries (not inclusive)
6521             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6522             * @param retrieveFromCache whether to retrieve from the finder cache
6523             * @return the ordered range of matching blogs entries
6524             */
6525            @Override
6526            public List<BlogsEntry> findByC_LtD(long companyId, Date displayDate,
6527                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator,
6528                    boolean retrieveFromCache) {
6529                    boolean pagination = true;
6530                    FinderPath finderPath = null;
6531                    Object[] finderArgs = null;
6532    
6533                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD;
6534                    finderArgs = new Object[] {
6535                                    companyId, displayDate,
6536                                    
6537                                    start, end, orderByComparator
6538                            };
6539    
6540                    List<BlogsEntry> list = null;
6541    
6542                    if (retrieveFromCache) {
6543                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
6544                                            finderArgs, this);
6545    
6546                            if ((list != null) && !list.isEmpty()) {
6547                                    for (BlogsEntry blogsEntry : list) {
6548                                            if ((companyId != blogsEntry.getCompanyId()) ||
6549                                                            (displayDate.getTime() <= blogsEntry.getDisplayDate()
6550                                                                                                                                            .getTime())) {
6551                                                    list = null;
6552    
6553                                                    break;
6554                                            }
6555                                    }
6556                            }
6557                    }
6558    
6559                    if (list == null) {
6560                            StringBundler query = null;
6561    
6562                            if (orderByComparator != null) {
6563                                    query = new StringBundler(4 +
6564                                                    (orderByComparator.getOrderByFields().length * 2));
6565                            }
6566                            else {
6567                                    query = new StringBundler(4);
6568                            }
6569    
6570                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
6571    
6572                            query.append(_FINDER_COLUMN_C_LTD_COMPANYID_2);
6573    
6574                            boolean bindDisplayDate = false;
6575    
6576                            if (displayDate == null) {
6577                                    query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_1);
6578                            }
6579                            else {
6580                                    bindDisplayDate = true;
6581    
6582                                    query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_2);
6583                            }
6584    
6585                            if (orderByComparator != null) {
6586                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6587                                            orderByComparator);
6588                            }
6589                            else
6590                             if (pagination) {
6591                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
6592                            }
6593    
6594                            String sql = query.toString();
6595    
6596                            Session session = null;
6597    
6598                            try {
6599                                    session = openSession();
6600    
6601                                    Query q = session.createQuery(sql);
6602    
6603                                    QueryPos qPos = QueryPos.getInstance(q);
6604    
6605                                    qPos.add(companyId);
6606    
6607                                    if (bindDisplayDate) {
6608                                            qPos.add(new Timestamp(displayDate.getTime()));
6609                                    }
6610    
6611                                    if (!pagination) {
6612                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
6613                                                            start, end, false);
6614    
6615                                            Collections.sort(list);
6616    
6617                                            list = Collections.unmodifiableList(list);
6618                                    }
6619                                    else {
6620                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
6621                                                            start, end);
6622                                    }
6623    
6624                                    cacheResult(list);
6625    
6626                                    finderCache.putResult(finderPath, finderArgs, list);
6627                            }
6628                            catch (Exception e) {
6629                                    finderCache.removeResult(finderPath, finderArgs);
6630    
6631                                    throw processException(e);
6632                            }
6633                            finally {
6634                                    closeSession(session);
6635                            }
6636                    }
6637    
6638                    return list;
6639            }
6640    
6641            /**
6642             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63;.
6643             *
6644             * @param companyId the company ID
6645             * @param displayDate the display date
6646             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6647             * @return the first matching blogs entry
6648             * @throws NoSuchEntryException if a matching blogs entry could not be found
6649             */
6650            @Override
6651            public BlogsEntry findByC_LtD_First(long companyId, Date displayDate,
6652                    OrderByComparator<BlogsEntry> orderByComparator)
6653                    throws NoSuchEntryException {
6654                    BlogsEntry blogsEntry = fetchByC_LtD_First(companyId, displayDate,
6655                                    orderByComparator);
6656    
6657                    if (blogsEntry != null) {
6658                            return blogsEntry;
6659                    }
6660    
6661                    StringBundler msg = new StringBundler(6);
6662    
6663                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6664    
6665                    msg.append("companyId=");
6666                    msg.append(companyId);
6667    
6668                    msg.append(", displayDate=");
6669                    msg.append(displayDate);
6670    
6671                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6672    
6673                    throw new NoSuchEntryException(msg.toString());
6674            }
6675    
6676            /**
6677             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63;.
6678             *
6679             * @param companyId the company ID
6680             * @param displayDate the display date
6681             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6682             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
6683             */
6684            @Override
6685            public BlogsEntry fetchByC_LtD_First(long companyId, Date displayDate,
6686                    OrderByComparator<BlogsEntry> orderByComparator) {
6687                    List<BlogsEntry> list = findByC_LtD(companyId, displayDate, 0, 1,
6688                                    orderByComparator);
6689    
6690                    if (!list.isEmpty()) {
6691                            return list.get(0);
6692                    }
6693    
6694                    return null;
6695            }
6696    
6697            /**
6698             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63;.
6699             *
6700             * @param companyId the company ID
6701             * @param displayDate the display date
6702             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6703             * @return the last matching blogs entry
6704             * @throws NoSuchEntryException if a matching blogs entry could not be found
6705             */
6706            @Override
6707            public BlogsEntry findByC_LtD_Last(long companyId, Date displayDate,
6708                    OrderByComparator<BlogsEntry> orderByComparator)
6709                    throws NoSuchEntryException {
6710                    BlogsEntry blogsEntry = fetchByC_LtD_Last(companyId, displayDate,
6711                                    orderByComparator);
6712    
6713                    if (blogsEntry != null) {
6714                            return blogsEntry;
6715                    }
6716    
6717                    StringBundler msg = new StringBundler(6);
6718    
6719                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6720    
6721                    msg.append("companyId=");
6722                    msg.append(companyId);
6723    
6724                    msg.append(", displayDate=");
6725                    msg.append(displayDate);
6726    
6727                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6728    
6729                    throw new NoSuchEntryException(msg.toString());
6730            }
6731    
6732            /**
6733             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63;.
6734             *
6735             * @param companyId the company ID
6736             * @param displayDate the display date
6737             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6738             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
6739             */
6740            @Override
6741            public BlogsEntry fetchByC_LtD_Last(long companyId, Date displayDate,
6742                    OrderByComparator<BlogsEntry> orderByComparator) {
6743                    int count = countByC_LtD(companyId, displayDate);
6744    
6745                    if (count == 0) {
6746                            return null;
6747                    }
6748    
6749                    List<BlogsEntry> list = findByC_LtD(companyId, displayDate, count - 1,
6750                                    count, orderByComparator);
6751    
6752                    if (!list.isEmpty()) {
6753                            return list.get(0);
6754                    }
6755    
6756                    return null;
6757            }
6758    
6759            /**
6760             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63;.
6761             *
6762             * @param entryId the primary key of the current blogs entry
6763             * @param companyId the company ID
6764             * @param displayDate the display date
6765             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6766             * @return the previous, current, and next blogs entry
6767             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
6768             */
6769            @Override
6770            public BlogsEntry[] findByC_LtD_PrevAndNext(long entryId, long companyId,
6771                    Date displayDate, OrderByComparator<BlogsEntry> orderByComparator)
6772                    throws NoSuchEntryException {
6773                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
6774    
6775                    Session session = null;
6776    
6777                    try {
6778                            session = openSession();
6779    
6780                            BlogsEntry[] array = new BlogsEntryImpl[3];
6781    
6782                            array[0] = getByC_LtD_PrevAndNext(session, blogsEntry, companyId,
6783                                            displayDate, orderByComparator, true);
6784    
6785                            array[1] = blogsEntry;
6786    
6787                            array[2] = getByC_LtD_PrevAndNext(session, blogsEntry, companyId,
6788                                            displayDate, orderByComparator, false);
6789    
6790                            return array;
6791                    }
6792                    catch (Exception e) {
6793                            throw processException(e);
6794                    }
6795                    finally {
6796                            closeSession(session);
6797                    }
6798            }
6799    
6800            protected BlogsEntry getByC_LtD_PrevAndNext(Session session,
6801                    BlogsEntry blogsEntry, long companyId, Date displayDate,
6802                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
6803                    StringBundler query = null;
6804    
6805                    if (orderByComparator != null) {
6806                            query = new StringBundler(5 +
6807                                            (orderByComparator.getOrderByConditionFields().length * 3) +
6808                                            (orderByComparator.getOrderByFields().length * 3));
6809                    }
6810                    else {
6811                            query = new StringBundler(4);
6812                    }
6813    
6814                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
6815    
6816                    query.append(_FINDER_COLUMN_C_LTD_COMPANYID_2);
6817    
6818                    boolean bindDisplayDate = false;
6819    
6820                    if (displayDate == null) {
6821                            query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_1);
6822                    }
6823                    else {
6824                            bindDisplayDate = true;
6825    
6826                            query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_2);
6827                    }
6828    
6829                    if (orderByComparator != null) {
6830                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6831    
6832                            if (orderByConditionFields.length > 0) {
6833                                    query.append(WHERE_AND);
6834                            }
6835    
6836                            for (int i = 0; i < orderByConditionFields.length; i++) {
6837                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6838                                    query.append(orderByConditionFields[i]);
6839    
6840                                    if ((i + 1) < orderByConditionFields.length) {
6841                                            if (orderByComparator.isAscending() ^ previous) {
6842                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6843                                            }
6844                                            else {
6845                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6846                                            }
6847                                    }
6848                                    else {
6849                                            if (orderByComparator.isAscending() ^ previous) {
6850                                                    query.append(WHERE_GREATER_THAN);
6851                                            }
6852                                            else {
6853                                                    query.append(WHERE_LESSER_THAN);
6854                                            }
6855                                    }
6856                            }
6857    
6858                            query.append(ORDER_BY_CLAUSE);
6859    
6860                            String[] orderByFields = orderByComparator.getOrderByFields();
6861    
6862                            for (int i = 0; i < orderByFields.length; i++) {
6863                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6864                                    query.append(orderByFields[i]);
6865    
6866                                    if ((i + 1) < orderByFields.length) {
6867                                            if (orderByComparator.isAscending() ^ previous) {
6868                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6869                                            }
6870                                            else {
6871                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6872                                            }
6873                                    }
6874                                    else {
6875                                            if (orderByComparator.isAscending() ^ previous) {
6876                                                    query.append(ORDER_BY_ASC);
6877                                            }
6878                                            else {
6879                                                    query.append(ORDER_BY_DESC);
6880                                            }
6881                                    }
6882                            }
6883                    }
6884                    else {
6885                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
6886                    }
6887    
6888                    String sql = query.toString();
6889    
6890                    Query q = session.createQuery(sql);
6891    
6892                    q.setFirstResult(0);
6893                    q.setMaxResults(2);
6894    
6895                    QueryPos qPos = QueryPos.getInstance(q);
6896    
6897                    qPos.add(companyId);
6898    
6899                    if (bindDisplayDate) {
6900                            qPos.add(new Timestamp(displayDate.getTime()));
6901                    }
6902    
6903                    if (orderByComparator != null) {
6904                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
6905    
6906                            for (Object value : values) {
6907                                    qPos.add(value);
6908                            }
6909                    }
6910    
6911                    List<BlogsEntry> list = q.list();
6912    
6913                    if (list.size() == 2) {
6914                            return list.get(1);
6915                    }
6916                    else {
6917                            return null;
6918                    }
6919            }
6920    
6921            /**
6922             * Removes all the blogs entries where companyId = &#63; and displayDate &lt; &#63; from the database.
6923             *
6924             * @param companyId the company ID
6925             * @param displayDate the display date
6926             */
6927            @Override
6928            public void removeByC_LtD(long companyId, Date displayDate) {
6929                    for (BlogsEntry blogsEntry : findByC_LtD(companyId, displayDate,
6930                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
6931                            remove(blogsEntry);
6932                    }
6933            }
6934    
6935            /**
6936             * Returns the number of blogs entries where companyId = &#63; and displayDate &lt; &#63;.
6937             *
6938             * @param companyId the company ID
6939             * @param displayDate the display date
6940             * @return the number of matching blogs entries
6941             */
6942            @Override
6943            public int countByC_LtD(long companyId, Date displayDate) {
6944                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD;
6945    
6946                    Object[] finderArgs = new Object[] { companyId, displayDate };
6947    
6948                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
6949    
6950                    if (count == null) {
6951                            StringBundler query = new StringBundler(3);
6952    
6953                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
6954    
6955                            query.append(_FINDER_COLUMN_C_LTD_COMPANYID_2);
6956    
6957                            boolean bindDisplayDate = false;
6958    
6959                            if (displayDate == null) {
6960                                    query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_1);
6961                            }
6962                            else {
6963                                    bindDisplayDate = true;
6964    
6965                                    query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_2);
6966                            }
6967    
6968                            String sql = query.toString();
6969    
6970                            Session session = null;
6971    
6972                            try {
6973                                    session = openSession();
6974    
6975                                    Query q = session.createQuery(sql);
6976    
6977                                    QueryPos qPos = QueryPos.getInstance(q);
6978    
6979                                    qPos.add(companyId);
6980    
6981                                    if (bindDisplayDate) {
6982                                            qPos.add(new Timestamp(displayDate.getTime()));
6983                                    }
6984    
6985                                    count = (Long)q.uniqueResult();
6986    
6987                                    finderCache.putResult(finderPath, finderArgs, count);
6988                            }
6989                            catch (Exception e) {
6990                                    finderCache.removeResult(finderPath, finderArgs);
6991    
6992                                    throw processException(e);
6993                            }
6994                            finally {
6995                                    closeSession(session);
6996                            }
6997                    }
6998    
6999                    return count.intValue();
7000            }
7001    
7002            private static final String _FINDER_COLUMN_C_LTD_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
7003            private static final String _FINDER_COLUMN_C_LTD_DISPLAYDATE_1 = "blogsEntry.displayDate IS NULL";
7004            private static final String _FINDER_COLUMN_C_LTD_DISPLAYDATE_2 = "blogsEntry.displayDate < ?";
7005            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
7006                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
7007                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_S",
7008                            new String[] {
7009                                    Long.class.getName(), Integer.class.getName(),
7010                                    
7011                            Integer.class.getName(), Integer.class.getName(),
7012                                    OrderByComparator.class.getName()
7013                            });
7014            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
7015                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
7016                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_S",
7017                            new String[] { Long.class.getName(), Integer.class.getName() },
7018                            BlogsEntryModelImpl.COMPANYID_COLUMN_BITMASK |
7019                            BlogsEntryModelImpl.STATUS_COLUMN_BITMASK |
7020                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
7021                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
7022            public static final FinderPath FINDER_PATH_COUNT_BY_C_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
7023                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
7024                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_S",
7025                            new String[] { Long.class.getName(), Integer.class.getName() });
7026    
7027            /**
7028             * Returns all the blogs entries where companyId = &#63; and status = &#63;.
7029             *
7030             * @param companyId the company ID
7031             * @param status the status
7032             * @return the matching blogs entries
7033             */
7034            @Override
7035            public List<BlogsEntry> findByC_S(long companyId, int status) {
7036                    return findByC_S(companyId, status, QueryUtil.ALL_POS,
7037                            QueryUtil.ALL_POS, null);
7038            }
7039    
7040            /**
7041             * Returns a range of all the blogs entries where companyId = &#63; and status = &#63;.
7042             *
7043             * <p>
7044             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7045             * </p>
7046             *
7047             * @param companyId the company ID
7048             * @param status the status
7049             * @param start the lower bound of the range of blogs entries
7050             * @param end the upper bound of the range of blogs entries (not inclusive)
7051             * @return the range of matching blogs entries
7052             */
7053            @Override
7054            public List<BlogsEntry> findByC_S(long companyId, int status, int start,
7055                    int end) {
7056                    return findByC_S(companyId, status, start, end, null);
7057            }
7058    
7059            /**
7060             * Returns an ordered range of all the blogs entries where companyId = &#63; and status = &#63;.
7061             *
7062             * <p>
7063             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7064             * </p>
7065             *
7066             * @param companyId the company ID
7067             * @param status the status
7068             * @param start the lower bound of the range of blogs entries
7069             * @param end the upper bound of the range of blogs entries (not inclusive)
7070             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7071             * @return the ordered range of matching blogs entries
7072             */
7073            @Override
7074            public List<BlogsEntry> findByC_S(long companyId, int status, int start,
7075                    int end, OrderByComparator<BlogsEntry> orderByComparator) {
7076                    return findByC_S(companyId, status, start, end, orderByComparator, true);
7077            }
7078    
7079            /**
7080             * Returns an ordered range of all the blogs entries where companyId = &#63; and status = &#63;.
7081             *
7082             * <p>
7083             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7084             * </p>
7085             *
7086             * @param companyId the company ID
7087             * @param status the status
7088             * @param start the lower bound of the range of blogs entries
7089             * @param end the upper bound of the range of blogs entries (not inclusive)
7090             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7091             * @param retrieveFromCache whether to retrieve from the finder cache
7092             * @return the ordered range of matching blogs entries
7093             */
7094            @Override
7095            public List<BlogsEntry> findByC_S(long companyId, int status, int start,
7096                    int end, OrderByComparator<BlogsEntry> orderByComparator,
7097                    boolean retrieveFromCache) {
7098                    boolean pagination = true;
7099                    FinderPath finderPath = null;
7100                    Object[] finderArgs = null;
7101    
7102                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
7103                                    (orderByComparator == null)) {
7104                            pagination = false;
7105                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S;
7106                            finderArgs = new Object[] { companyId, status };
7107                    }
7108                    else {
7109                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_S;
7110                            finderArgs = new Object[] {
7111                                            companyId, status,
7112                                            
7113                                            start, end, orderByComparator
7114                                    };
7115                    }
7116    
7117                    List<BlogsEntry> list = null;
7118    
7119                    if (retrieveFromCache) {
7120                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
7121                                            finderArgs, this);
7122    
7123                            if ((list != null) && !list.isEmpty()) {
7124                                    for (BlogsEntry blogsEntry : list) {
7125                                            if ((companyId != blogsEntry.getCompanyId()) ||
7126                                                            (status != blogsEntry.getStatus())) {
7127                                                    list = null;
7128    
7129                                                    break;
7130                                            }
7131                                    }
7132                            }
7133                    }
7134    
7135                    if (list == null) {
7136                            StringBundler query = null;
7137    
7138                            if (orderByComparator != null) {
7139                                    query = new StringBundler(4 +
7140                                                    (orderByComparator.getOrderByFields().length * 2));
7141                            }
7142                            else {
7143                                    query = new StringBundler(4);
7144                            }
7145    
7146                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
7147    
7148                            query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
7149    
7150                            query.append(_FINDER_COLUMN_C_S_STATUS_2);
7151    
7152                            if (orderByComparator != null) {
7153                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7154                                            orderByComparator);
7155                            }
7156                            else
7157                             if (pagination) {
7158                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
7159                            }
7160    
7161                            String sql = query.toString();
7162    
7163                            Session session = null;
7164    
7165                            try {
7166                                    session = openSession();
7167    
7168                                    Query q = session.createQuery(sql);
7169    
7170                                    QueryPos qPos = QueryPos.getInstance(q);
7171    
7172                                    qPos.add(companyId);
7173    
7174                                    qPos.add(status);
7175    
7176                                    if (!pagination) {
7177                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
7178                                                            start, end, false);
7179    
7180                                            Collections.sort(list);
7181    
7182                                            list = Collections.unmodifiableList(list);
7183                                    }
7184                                    else {
7185                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
7186                                                            start, end);
7187                                    }
7188    
7189                                    cacheResult(list);
7190    
7191                                    finderCache.putResult(finderPath, finderArgs, list);
7192                            }
7193                            catch (Exception e) {
7194                                    finderCache.removeResult(finderPath, finderArgs);
7195    
7196                                    throw processException(e);
7197                            }
7198                            finally {
7199                                    closeSession(session);
7200                            }
7201                    }
7202    
7203                    return list;
7204            }
7205    
7206            /**
7207             * Returns the first blogs entry in the ordered set where companyId = &#63; and status = &#63;.
7208             *
7209             * @param companyId the company ID
7210             * @param status the status
7211             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7212             * @return the first matching blogs entry
7213             * @throws NoSuchEntryException if a matching blogs entry could not be found
7214             */
7215            @Override
7216            public BlogsEntry findByC_S_First(long companyId, int status,
7217                    OrderByComparator<BlogsEntry> orderByComparator)
7218                    throws NoSuchEntryException {
7219                    BlogsEntry blogsEntry = fetchByC_S_First(companyId, status,
7220                                    orderByComparator);
7221    
7222                    if (blogsEntry != null) {
7223                            return blogsEntry;
7224                    }
7225    
7226                    StringBundler msg = new StringBundler(6);
7227    
7228                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7229    
7230                    msg.append("companyId=");
7231                    msg.append(companyId);
7232    
7233                    msg.append(", status=");
7234                    msg.append(status);
7235    
7236                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7237    
7238                    throw new NoSuchEntryException(msg.toString());
7239            }
7240    
7241            /**
7242             * Returns the first blogs entry in the ordered set where companyId = &#63; and status = &#63;.
7243             *
7244             * @param companyId the company ID
7245             * @param status the status
7246             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7247             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
7248             */
7249            @Override
7250            public BlogsEntry fetchByC_S_First(long companyId, int status,
7251                    OrderByComparator<BlogsEntry> orderByComparator) {
7252                    List<BlogsEntry> list = findByC_S(companyId, status, 0, 1,
7253                                    orderByComparator);
7254    
7255                    if (!list.isEmpty()) {
7256                            return list.get(0);
7257                    }
7258    
7259                    return null;
7260            }
7261    
7262            /**
7263             * Returns the last blogs entry in the ordered set where companyId = &#63; and status = &#63;.
7264             *
7265             * @param companyId the company ID
7266             * @param status the status
7267             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7268             * @return the last matching blogs entry
7269             * @throws NoSuchEntryException if a matching blogs entry could not be found
7270             */
7271            @Override
7272            public BlogsEntry findByC_S_Last(long companyId, int status,
7273                    OrderByComparator<BlogsEntry> orderByComparator)
7274                    throws NoSuchEntryException {
7275                    BlogsEntry blogsEntry = fetchByC_S_Last(companyId, status,
7276                                    orderByComparator);
7277    
7278                    if (blogsEntry != null) {
7279                            return blogsEntry;
7280                    }
7281    
7282                    StringBundler msg = new StringBundler(6);
7283    
7284                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7285    
7286                    msg.append("companyId=");
7287                    msg.append(companyId);
7288    
7289                    msg.append(", status=");
7290                    msg.append(status);
7291    
7292                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7293    
7294                    throw new NoSuchEntryException(msg.toString());
7295            }
7296    
7297            /**
7298             * Returns the last blogs entry in the ordered set where companyId = &#63; and status = &#63;.
7299             *
7300             * @param companyId the company ID
7301             * @param status the status
7302             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7303             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
7304             */
7305            @Override
7306            public BlogsEntry fetchByC_S_Last(long companyId, int status,
7307                    OrderByComparator<BlogsEntry> orderByComparator) {
7308                    int count = countByC_S(companyId, status);
7309    
7310                    if (count == 0) {
7311                            return null;
7312                    }
7313    
7314                    List<BlogsEntry> list = findByC_S(companyId, status, count - 1, count,
7315                                    orderByComparator);
7316    
7317                    if (!list.isEmpty()) {
7318                            return list.get(0);
7319                    }
7320    
7321                    return null;
7322            }
7323    
7324            /**
7325             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63; and status = &#63;.
7326             *
7327             * @param entryId the primary key of the current blogs entry
7328             * @param companyId the company ID
7329             * @param status the status
7330             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7331             * @return the previous, current, and next blogs entry
7332             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
7333             */
7334            @Override
7335            public BlogsEntry[] findByC_S_PrevAndNext(long entryId, long companyId,
7336                    int status, OrderByComparator<BlogsEntry> orderByComparator)
7337                    throws NoSuchEntryException {
7338                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
7339    
7340                    Session session = null;
7341    
7342                    try {
7343                            session = openSession();
7344    
7345                            BlogsEntry[] array = new BlogsEntryImpl[3];
7346    
7347                            array[0] = getByC_S_PrevAndNext(session, blogsEntry, companyId,
7348                                            status, orderByComparator, true);
7349    
7350                            array[1] = blogsEntry;
7351    
7352                            array[2] = getByC_S_PrevAndNext(session, blogsEntry, companyId,
7353                                            status, orderByComparator, false);
7354    
7355                            return array;
7356                    }
7357                    catch (Exception e) {
7358                            throw processException(e);
7359                    }
7360                    finally {
7361                            closeSession(session);
7362                    }
7363            }
7364    
7365            protected BlogsEntry getByC_S_PrevAndNext(Session session,
7366                    BlogsEntry blogsEntry, long companyId, int status,
7367                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
7368                    StringBundler query = null;
7369    
7370                    if (orderByComparator != null) {
7371                            query = new StringBundler(5 +
7372                                            (orderByComparator.getOrderByConditionFields().length * 3) +
7373                                            (orderByComparator.getOrderByFields().length * 3));
7374                    }
7375                    else {
7376                            query = new StringBundler(4);
7377                    }
7378    
7379                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
7380    
7381                    query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
7382    
7383                    query.append(_FINDER_COLUMN_C_S_STATUS_2);
7384    
7385                    if (orderByComparator != null) {
7386                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7387    
7388                            if (orderByConditionFields.length > 0) {
7389                                    query.append(WHERE_AND);
7390                            }
7391    
7392                            for (int i = 0; i < orderByConditionFields.length; i++) {
7393                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7394                                    query.append(orderByConditionFields[i]);
7395    
7396                                    if ((i + 1) < orderByConditionFields.length) {
7397                                            if (orderByComparator.isAscending() ^ previous) {
7398                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7399                                            }
7400                                            else {
7401                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7402                                            }
7403                                    }
7404                                    else {
7405                                            if (orderByComparator.isAscending() ^ previous) {
7406                                                    query.append(WHERE_GREATER_THAN);
7407                                            }
7408                                            else {
7409                                                    query.append(WHERE_LESSER_THAN);
7410                                            }
7411                                    }
7412                            }
7413    
7414                            query.append(ORDER_BY_CLAUSE);
7415    
7416                            String[] orderByFields = orderByComparator.getOrderByFields();
7417    
7418                            for (int i = 0; i < orderByFields.length; i++) {
7419                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7420                                    query.append(orderByFields[i]);
7421    
7422                                    if ((i + 1) < orderByFields.length) {
7423                                            if (orderByComparator.isAscending() ^ previous) {
7424                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7425                                            }
7426                                            else {
7427                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7428                                            }
7429                                    }
7430                                    else {
7431                                            if (orderByComparator.isAscending() ^ previous) {
7432                                                    query.append(ORDER_BY_ASC);
7433                                            }
7434                                            else {
7435                                                    query.append(ORDER_BY_DESC);
7436                                            }
7437                                    }
7438                            }
7439                    }
7440                    else {
7441                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
7442                    }
7443    
7444                    String sql = query.toString();
7445    
7446                    Query q = session.createQuery(sql);
7447    
7448                    q.setFirstResult(0);
7449                    q.setMaxResults(2);
7450    
7451                    QueryPos qPos = QueryPos.getInstance(q);
7452    
7453                    qPos.add(companyId);
7454    
7455                    qPos.add(status);
7456    
7457                    if (orderByComparator != null) {
7458                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
7459    
7460                            for (Object value : values) {
7461                                    qPos.add(value);
7462                            }
7463                    }
7464    
7465                    List<BlogsEntry> list = q.list();
7466    
7467                    if (list.size() == 2) {
7468                            return list.get(1);
7469                    }
7470                    else {
7471                            return null;
7472                    }
7473            }
7474    
7475            /**
7476             * Removes all the blogs entries where companyId = &#63; and status = &#63; from the database.
7477             *
7478             * @param companyId the company ID
7479             * @param status the status
7480             */
7481            @Override
7482            public void removeByC_S(long companyId, int status) {
7483                    for (BlogsEntry blogsEntry : findByC_S(companyId, status,
7484                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
7485                            remove(blogsEntry);
7486                    }
7487            }
7488    
7489            /**
7490             * Returns the number of blogs entries where companyId = &#63; and status = &#63;.
7491             *
7492             * @param companyId the company ID
7493             * @param status the status
7494             * @return the number of matching blogs entries
7495             */
7496            @Override
7497            public int countByC_S(long companyId, int status) {
7498                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_S;
7499    
7500                    Object[] finderArgs = new Object[] { companyId, status };
7501    
7502                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
7503    
7504                    if (count == null) {
7505                            StringBundler query = new StringBundler(3);
7506    
7507                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
7508    
7509                            query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
7510    
7511                            query.append(_FINDER_COLUMN_C_S_STATUS_2);
7512    
7513                            String sql = query.toString();
7514    
7515                            Session session = null;
7516    
7517                            try {
7518                                    session = openSession();
7519    
7520                                    Query q = session.createQuery(sql);
7521    
7522                                    QueryPos qPos = QueryPos.getInstance(q);
7523    
7524                                    qPos.add(companyId);
7525    
7526                                    qPos.add(status);
7527    
7528                                    count = (Long)q.uniqueResult();
7529    
7530                                    finderCache.putResult(finderPath, finderArgs, count);
7531                            }
7532                            catch (Exception e) {
7533                                    finderCache.removeResult(finderPath, finderArgs);
7534    
7535                                    throw processException(e);
7536                            }
7537                            finally {
7538                                    closeSession(session);
7539                            }
7540                    }
7541    
7542                    return count.intValue();
7543            }
7544    
7545            private static final String _FINDER_COLUMN_C_S_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
7546            private static final String _FINDER_COLUMN_C_S_STATUS_2 = "blogsEntry.status = ?";
7547            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_NOTS = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
7548                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
7549                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_NotS",
7550                            new String[] {
7551                                    Long.class.getName(), Integer.class.getName(),
7552                                    
7553                            Integer.class.getName(), Integer.class.getName(),
7554                                    OrderByComparator.class.getName()
7555                            });
7556            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_NOTS = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
7557                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
7558                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_NotS",
7559                            new String[] { Long.class.getName(), Integer.class.getName() });
7560    
7561            /**
7562             * Returns all the blogs entries where companyId = &#63; and status &ne; &#63;.
7563             *
7564             * @param companyId the company ID
7565             * @param status the status
7566             * @return the matching blogs entries
7567             */
7568            @Override
7569            public List<BlogsEntry> findByC_NotS(long companyId, int status) {
7570                    return findByC_NotS(companyId, status, QueryUtil.ALL_POS,
7571                            QueryUtil.ALL_POS, null);
7572            }
7573    
7574            /**
7575             * Returns a range of all the blogs entries where companyId = &#63; and status &ne; &#63;.
7576             *
7577             * <p>
7578             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7579             * </p>
7580             *
7581             * @param companyId the company ID
7582             * @param status the status
7583             * @param start the lower bound of the range of blogs entries
7584             * @param end the upper bound of the range of blogs entries (not inclusive)
7585             * @return the range of matching blogs entries
7586             */
7587            @Override
7588            public List<BlogsEntry> findByC_NotS(long companyId, int status, int start,
7589                    int end) {
7590                    return findByC_NotS(companyId, status, start, end, null);
7591            }
7592    
7593            /**
7594             * Returns an ordered range of all the blogs entries where companyId = &#63; and status &ne; &#63;.
7595             *
7596             * <p>
7597             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7598             * </p>
7599             *
7600             * @param companyId the company ID
7601             * @param status the status
7602             * @param start the lower bound of the range of blogs entries
7603             * @param end the upper bound of the range of blogs entries (not inclusive)
7604             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7605             * @return the ordered range of matching blogs entries
7606             */
7607            @Override
7608            public List<BlogsEntry> findByC_NotS(long companyId, int status, int start,
7609                    int end, OrderByComparator<BlogsEntry> orderByComparator) {
7610                    return findByC_NotS(companyId, status, start, end, orderByComparator,
7611                            true);
7612            }
7613    
7614            /**
7615             * Returns an ordered range of all the blogs entries where companyId = &#63; and status &ne; &#63;.
7616             *
7617             * <p>
7618             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7619             * </p>
7620             *
7621             * @param companyId the company ID
7622             * @param status the status
7623             * @param start the lower bound of the range of blogs entries
7624             * @param end the upper bound of the range of blogs entries (not inclusive)
7625             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7626             * @param retrieveFromCache whether to retrieve from the finder cache
7627             * @return the ordered range of matching blogs entries
7628             */
7629            @Override
7630            public List<BlogsEntry> findByC_NotS(long companyId, int status, int start,
7631                    int end, OrderByComparator<BlogsEntry> orderByComparator,
7632                    boolean retrieveFromCache) {
7633                    boolean pagination = true;
7634                    FinderPath finderPath = null;
7635                    Object[] finderArgs = null;
7636    
7637                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_NOTS;
7638                    finderArgs = new Object[] {
7639                                    companyId, status,
7640                                    
7641                                    start, end, orderByComparator
7642                            };
7643    
7644                    List<BlogsEntry> list = null;
7645    
7646                    if (retrieveFromCache) {
7647                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
7648                                            finderArgs, this);
7649    
7650                            if ((list != null) && !list.isEmpty()) {
7651                                    for (BlogsEntry blogsEntry : list) {
7652                                            if ((companyId != blogsEntry.getCompanyId()) ||
7653                                                            (status == blogsEntry.getStatus())) {
7654                                                    list = null;
7655    
7656                                                    break;
7657                                            }
7658                                    }
7659                            }
7660                    }
7661    
7662                    if (list == null) {
7663                            StringBundler query = null;
7664    
7665                            if (orderByComparator != null) {
7666                                    query = new StringBundler(4 +
7667                                                    (orderByComparator.getOrderByFields().length * 2));
7668                            }
7669                            else {
7670                                    query = new StringBundler(4);
7671                            }
7672    
7673                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
7674    
7675                            query.append(_FINDER_COLUMN_C_NOTS_COMPANYID_2);
7676    
7677                            query.append(_FINDER_COLUMN_C_NOTS_STATUS_2);
7678    
7679                            if (orderByComparator != null) {
7680                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7681                                            orderByComparator);
7682                            }
7683                            else
7684                             if (pagination) {
7685                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
7686                            }
7687    
7688                            String sql = query.toString();
7689    
7690                            Session session = null;
7691    
7692                            try {
7693                                    session = openSession();
7694    
7695                                    Query q = session.createQuery(sql);
7696    
7697                                    QueryPos qPos = QueryPos.getInstance(q);
7698    
7699                                    qPos.add(companyId);
7700    
7701                                    qPos.add(status);
7702    
7703                                    if (!pagination) {
7704                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
7705                                                            start, end, false);
7706    
7707                                            Collections.sort(list);
7708    
7709                                            list = Collections.unmodifiableList(list);
7710                                    }
7711                                    else {
7712                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
7713                                                            start, end);
7714                                    }
7715    
7716                                    cacheResult(list);
7717    
7718                                    finderCache.putResult(finderPath, finderArgs, list);
7719                            }
7720                            catch (Exception e) {
7721                                    finderCache.removeResult(finderPath, finderArgs);
7722    
7723                                    throw processException(e);
7724                            }
7725                            finally {
7726                                    closeSession(session);
7727                            }
7728                    }
7729    
7730                    return list;
7731            }
7732    
7733            /**
7734             * Returns the first blogs entry in the ordered set where companyId = &#63; and status &ne; &#63;.
7735             *
7736             * @param companyId the company ID
7737             * @param status the status
7738             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7739             * @return the first matching blogs entry
7740             * @throws NoSuchEntryException if a matching blogs entry could not be found
7741             */
7742            @Override
7743            public BlogsEntry findByC_NotS_First(long companyId, int status,
7744                    OrderByComparator<BlogsEntry> orderByComparator)
7745                    throws NoSuchEntryException {
7746                    BlogsEntry blogsEntry = fetchByC_NotS_First(companyId, status,
7747                                    orderByComparator);
7748    
7749                    if (blogsEntry != null) {
7750                            return blogsEntry;
7751                    }
7752    
7753                    StringBundler msg = new StringBundler(6);
7754    
7755                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7756    
7757                    msg.append("companyId=");
7758                    msg.append(companyId);
7759    
7760                    msg.append(", status=");
7761                    msg.append(status);
7762    
7763                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7764    
7765                    throw new NoSuchEntryException(msg.toString());
7766            }
7767    
7768            /**
7769             * Returns the first blogs entry in the ordered set where companyId = &#63; and status &ne; &#63;.
7770             *
7771             * @param companyId the company ID
7772             * @param status the status
7773             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7774             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
7775             */
7776            @Override
7777            public BlogsEntry fetchByC_NotS_First(long companyId, int status,
7778                    OrderByComparator<BlogsEntry> orderByComparator) {
7779                    List<BlogsEntry> list = findByC_NotS(companyId, status, 0, 1,
7780                                    orderByComparator);
7781    
7782                    if (!list.isEmpty()) {
7783                            return list.get(0);
7784                    }
7785    
7786                    return null;
7787            }
7788    
7789            /**
7790             * Returns the last blogs entry in the ordered set where companyId = &#63; and status &ne; &#63;.
7791             *
7792             * @param companyId the company ID
7793             * @param status the status
7794             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7795             * @return the last matching blogs entry
7796             * @throws NoSuchEntryException if a matching blogs entry could not be found
7797             */
7798            @Override
7799            public BlogsEntry findByC_NotS_Last(long companyId, int status,
7800                    OrderByComparator<BlogsEntry> orderByComparator)
7801                    throws NoSuchEntryException {
7802                    BlogsEntry blogsEntry = fetchByC_NotS_Last(companyId, status,
7803                                    orderByComparator);
7804    
7805                    if (blogsEntry != null) {
7806                            return blogsEntry;
7807                    }
7808    
7809                    StringBundler msg = new StringBundler(6);
7810    
7811                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7812    
7813                    msg.append("companyId=");
7814                    msg.append(companyId);
7815    
7816                    msg.append(", status=");
7817                    msg.append(status);
7818    
7819                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7820    
7821                    throw new NoSuchEntryException(msg.toString());
7822            }
7823    
7824            /**
7825             * Returns the last blogs entry in the ordered set where companyId = &#63; and status &ne; &#63;.
7826             *
7827             * @param companyId the company ID
7828             * @param status the status
7829             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7830             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
7831             */
7832            @Override
7833            public BlogsEntry fetchByC_NotS_Last(long companyId, int status,
7834                    OrderByComparator<BlogsEntry> orderByComparator) {
7835                    int count = countByC_NotS(companyId, status);
7836    
7837                    if (count == 0) {
7838                            return null;
7839                    }
7840    
7841                    List<BlogsEntry> list = findByC_NotS(companyId, status, count - 1,
7842                                    count, orderByComparator);
7843    
7844                    if (!list.isEmpty()) {
7845                            return list.get(0);
7846                    }
7847    
7848                    return null;
7849            }
7850    
7851            /**
7852             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63; and status &ne; &#63;.
7853             *
7854             * @param entryId the primary key of the current blogs entry
7855             * @param companyId the company ID
7856             * @param status the status
7857             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7858             * @return the previous, current, and next blogs entry
7859             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
7860             */
7861            @Override
7862            public BlogsEntry[] findByC_NotS_PrevAndNext(long entryId, long companyId,
7863                    int status, OrderByComparator<BlogsEntry> orderByComparator)
7864                    throws NoSuchEntryException {
7865                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
7866    
7867                    Session session = null;
7868    
7869                    try {
7870                            session = openSession();
7871    
7872                            BlogsEntry[] array = new BlogsEntryImpl[3];
7873    
7874                            array[0] = getByC_NotS_PrevAndNext(session, blogsEntry, companyId,
7875                                            status, orderByComparator, true);
7876    
7877                            array[1] = blogsEntry;
7878    
7879                            array[2] = getByC_NotS_PrevAndNext(session, blogsEntry, companyId,
7880                                            status, orderByComparator, false);
7881    
7882                            return array;
7883                    }
7884                    catch (Exception e) {
7885                            throw processException(e);
7886                    }
7887                    finally {
7888                            closeSession(session);
7889                    }
7890            }
7891    
7892            protected BlogsEntry getByC_NotS_PrevAndNext(Session session,
7893                    BlogsEntry blogsEntry, long companyId, int status,
7894                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
7895                    StringBundler query = null;
7896    
7897                    if (orderByComparator != null) {
7898                            query = new StringBundler(5 +
7899                                            (orderByComparator.getOrderByConditionFields().length * 3) +
7900                                            (orderByComparator.getOrderByFields().length * 3));
7901                    }
7902                    else {
7903                            query = new StringBundler(4);
7904                    }
7905    
7906                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
7907    
7908                    query.append(_FINDER_COLUMN_C_NOTS_COMPANYID_2);
7909    
7910                    query.append(_FINDER_COLUMN_C_NOTS_STATUS_2);
7911    
7912                    if (orderByComparator != null) {
7913                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7914    
7915                            if (orderByConditionFields.length > 0) {
7916                                    query.append(WHERE_AND);
7917                            }
7918    
7919                            for (int i = 0; i < orderByConditionFields.length; i++) {
7920                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7921                                    query.append(orderByConditionFields[i]);
7922    
7923                                    if ((i + 1) < orderByConditionFields.length) {
7924                                            if (orderByComparator.isAscending() ^ previous) {
7925                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7926                                            }
7927                                            else {
7928                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7929                                            }
7930                                    }
7931                                    else {
7932                                            if (orderByComparator.isAscending() ^ previous) {
7933                                                    query.append(WHERE_GREATER_THAN);
7934                                            }
7935                                            else {
7936                                                    query.append(WHERE_LESSER_THAN);
7937                                            }
7938                                    }
7939                            }
7940    
7941                            query.append(ORDER_BY_CLAUSE);
7942    
7943                            String[] orderByFields = orderByComparator.getOrderByFields();
7944    
7945                            for (int i = 0; i < orderByFields.length; i++) {
7946                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7947                                    query.append(orderByFields[i]);
7948    
7949                                    if ((i + 1) < orderByFields.length) {
7950                                            if (orderByComparator.isAscending() ^ previous) {
7951                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7952                                            }
7953                                            else {
7954                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7955                                            }
7956                                    }
7957                                    else {
7958                                            if (orderByComparator.isAscending() ^ previous) {
7959                                                    query.append(ORDER_BY_ASC);
7960                                            }
7961                                            else {
7962                                                    query.append(ORDER_BY_DESC);
7963                                            }
7964                                    }
7965                            }
7966                    }
7967                    else {
7968                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
7969                    }
7970    
7971                    String sql = query.toString();
7972    
7973                    Query q = session.createQuery(sql);
7974    
7975                    q.setFirstResult(0);
7976                    q.setMaxResults(2);
7977    
7978                    QueryPos qPos = QueryPos.getInstance(q);
7979    
7980                    qPos.add(companyId);
7981    
7982                    qPos.add(status);
7983    
7984                    if (orderByComparator != null) {
7985                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
7986    
7987                            for (Object value : values) {
7988                                    qPos.add(value);
7989                            }
7990                    }
7991    
7992                    List<BlogsEntry> list = q.list();
7993    
7994                    if (list.size() == 2) {
7995                            return list.get(1);
7996                    }
7997                    else {
7998                            return null;
7999                    }
8000            }
8001    
8002            /**
8003             * Removes all the blogs entries where companyId = &#63; and status &ne; &#63; from the database.
8004             *
8005             * @param companyId the company ID
8006             * @param status the status
8007             */
8008            @Override
8009            public void removeByC_NotS(long companyId, int status) {
8010                    for (BlogsEntry blogsEntry : findByC_NotS(companyId, status,
8011                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
8012                            remove(blogsEntry);
8013                    }
8014            }
8015    
8016            /**
8017             * Returns the number of blogs entries where companyId = &#63; and status &ne; &#63;.
8018             *
8019             * @param companyId the company ID
8020             * @param status the status
8021             * @return the number of matching blogs entries
8022             */
8023            @Override
8024            public int countByC_NotS(long companyId, int status) {
8025                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_NOTS;
8026    
8027                    Object[] finderArgs = new Object[] { companyId, status };
8028    
8029                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
8030    
8031                    if (count == null) {
8032                            StringBundler query = new StringBundler(3);
8033    
8034                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
8035    
8036                            query.append(_FINDER_COLUMN_C_NOTS_COMPANYID_2);
8037    
8038                            query.append(_FINDER_COLUMN_C_NOTS_STATUS_2);
8039    
8040                            String sql = query.toString();
8041    
8042                            Session session = null;
8043    
8044                            try {
8045                                    session = openSession();
8046    
8047                                    Query q = session.createQuery(sql);
8048    
8049                                    QueryPos qPos = QueryPos.getInstance(q);
8050    
8051                                    qPos.add(companyId);
8052    
8053                                    qPos.add(status);
8054    
8055                                    count = (Long)q.uniqueResult();
8056    
8057                                    finderCache.putResult(finderPath, finderArgs, count);
8058                            }
8059                            catch (Exception e) {
8060                                    finderCache.removeResult(finderPath, finderArgs);
8061    
8062                                    throw processException(e);
8063                            }
8064                            finally {
8065                                    closeSession(session);
8066                            }
8067                    }
8068    
8069                    return count.intValue();
8070            }
8071    
8072            private static final String _FINDER_COLUMN_C_NOTS_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
8073            private static final String _FINDER_COLUMN_C_NOTS_STATUS_2 = "blogsEntry.status != ?";
8074            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
8075                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
8076                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByLtD_S",
8077                            new String[] {
8078                                    Date.class.getName(), Integer.class.getName(),
8079                                    
8080                            Integer.class.getName(), Integer.class.getName(),
8081                                    OrderByComparator.class.getName()
8082                            });
8083            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
8084                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
8085                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByLtD_S",
8086                            new String[] { Date.class.getName(), Integer.class.getName() });
8087    
8088            /**
8089             * Returns all the blogs entries where displayDate &lt; &#63; and status = &#63;.
8090             *
8091             * @param displayDate the display date
8092             * @param status the status
8093             * @return the matching blogs entries
8094             */
8095            @Override
8096            public List<BlogsEntry> findByLtD_S(Date displayDate, int status) {
8097                    return findByLtD_S(displayDate, status, QueryUtil.ALL_POS,
8098                            QueryUtil.ALL_POS, null);
8099            }
8100    
8101            /**
8102             * Returns a range of all the blogs entries where displayDate &lt; &#63; and status = &#63;.
8103             *
8104             * <p>
8105             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8106             * </p>
8107             *
8108             * @param displayDate the display date
8109             * @param status the status
8110             * @param start the lower bound of the range of blogs entries
8111             * @param end the upper bound of the range of blogs entries (not inclusive)
8112             * @return the range of matching blogs entries
8113             */
8114            @Override
8115            public List<BlogsEntry> findByLtD_S(Date displayDate, int status,
8116                    int start, int end) {
8117                    return findByLtD_S(displayDate, status, start, end, null);
8118            }
8119    
8120            /**
8121             * Returns an ordered range of all the blogs entries where displayDate &lt; &#63; and status = &#63;.
8122             *
8123             * <p>
8124             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8125             * </p>
8126             *
8127             * @param displayDate the display date
8128             * @param status the status
8129             * @param start the lower bound of the range of blogs entries
8130             * @param end the upper bound of the range of blogs entries (not inclusive)
8131             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8132             * @return the ordered range of matching blogs entries
8133             */
8134            @Override
8135            public List<BlogsEntry> findByLtD_S(Date displayDate, int status,
8136                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator) {
8137                    return findByLtD_S(displayDate, status, start, end, orderByComparator,
8138                            true);
8139            }
8140    
8141            /**
8142             * Returns an ordered range of all the blogs entries where displayDate &lt; &#63; and status = &#63;.
8143             *
8144             * <p>
8145             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8146             * </p>
8147             *
8148             * @param displayDate the display date
8149             * @param status the status
8150             * @param start the lower bound of the range of blogs entries
8151             * @param end the upper bound of the range of blogs entries (not inclusive)
8152             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8153             * @param retrieveFromCache whether to retrieve from the finder cache
8154             * @return the ordered range of matching blogs entries
8155             */
8156            @Override
8157            public List<BlogsEntry> findByLtD_S(Date displayDate, int status,
8158                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator,
8159                    boolean retrieveFromCache) {
8160                    boolean pagination = true;
8161                    FinderPath finderPath = null;
8162                    Object[] finderArgs = null;
8163    
8164                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_LTD_S;
8165                    finderArgs = new Object[] {
8166                                    displayDate, status,
8167                                    
8168                                    start, end, orderByComparator
8169                            };
8170    
8171                    List<BlogsEntry> list = null;
8172    
8173                    if (retrieveFromCache) {
8174                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
8175                                            finderArgs, this);
8176    
8177                            if ((list != null) && !list.isEmpty()) {
8178                                    for (BlogsEntry blogsEntry : list) {
8179                                            if ((displayDate.getTime() <= blogsEntry.getDisplayDate()
8180                                                                                                                                    .getTime()) ||
8181                                                            (status != blogsEntry.getStatus())) {
8182                                                    list = null;
8183    
8184                                                    break;
8185                                            }
8186                                    }
8187                            }
8188                    }
8189    
8190                    if (list == null) {
8191                            StringBundler query = null;
8192    
8193                            if (orderByComparator != null) {
8194                                    query = new StringBundler(4 +
8195                                                    (orderByComparator.getOrderByFields().length * 2));
8196                            }
8197                            else {
8198                                    query = new StringBundler(4);
8199                            }
8200    
8201                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
8202    
8203                            boolean bindDisplayDate = false;
8204    
8205                            if (displayDate == null) {
8206                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_1);
8207                            }
8208                            else {
8209                                    bindDisplayDate = true;
8210    
8211                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_2);
8212                            }
8213    
8214                            query.append(_FINDER_COLUMN_LTD_S_STATUS_2);
8215    
8216                            if (orderByComparator != null) {
8217                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8218                                            orderByComparator);
8219                            }
8220                            else
8221                             if (pagination) {
8222                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
8223                            }
8224    
8225                            String sql = query.toString();
8226    
8227                            Session session = null;
8228    
8229                            try {
8230                                    session = openSession();
8231    
8232                                    Query q = session.createQuery(sql);
8233    
8234                                    QueryPos qPos = QueryPos.getInstance(q);
8235    
8236                                    if (bindDisplayDate) {
8237                                            qPos.add(new Timestamp(displayDate.getTime()));
8238                                    }
8239    
8240                                    qPos.add(status);
8241    
8242                                    if (!pagination) {
8243                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
8244                                                            start, end, false);
8245    
8246                                            Collections.sort(list);
8247    
8248                                            list = Collections.unmodifiableList(list);
8249                                    }
8250                                    else {
8251                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
8252                                                            start, end);
8253                                    }
8254    
8255                                    cacheResult(list);
8256    
8257                                    finderCache.putResult(finderPath, finderArgs, list);
8258                            }
8259                            catch (Exception e) {
8260                                    finderCache.removeResult(finderPath, finderArgs);
8261    
8262                                    throw processException(e);
8263                            }
8264                            finally {
8265                                    closeSession(session);
8266                            }
8267                    }
8268    
8269                    return list;
8270            }
8271    
8272            /**
8273             * Returns the first blogs entry in the ordered set where displayDate &lt; &#63; and status = &#63;.
8274             *
8275             * @param displayDate the display date
8276             * @param status the status
8277             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8278             * @return the first matching blogs entry
8279             * @throws NoSuchEntryException if a matching blogs entry could not be found
8280             */
8281            @Override
8282            public BlogsEntry findByLtD_S_First(Date displayDate, int status,
8283                    OrderByComparator<BlogsEntry> orderByComparator)
8284                    throws NoSuchEntryException {
8285                    BlogsEntry blogsEntry = fetchByLtD_S_First(displayDate, status,
8286                                    orderByComparator);
8287    
8288                    if (blogsEntry != null) {
8289                            return blogsEntry;
8290                    }
8291    
8292                    StringBundler msg = new StringBundler(6);
8293    
8294                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8295    
8296                    msg.append("displayDate=");
8297                    msg.append(displayDate);
8298    
8299                    msg.append(", status=");
8300                    msg.append(status);
8301    
8302                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8303    
8304                    throw new NoSuchEntryException(msg.toString());
8305            }
8306    
8307            /**
8308             * Returns the first blogs entry in the ordered set where displayDate &lt; &#63; and status = &#63;.
8309             *
8310             * @param displayDate the display date
8311             * @param status the status
8312             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8313             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
8314             */
8315            @Override
8316            public BlogsEntry fetchByLtD_S_First(Date displayDate, int status,
8317                    OrderByComparator<BlogsEntry> orderByComparator) {
8318                    List<BlogsEntry> list = findByLtD_S(displayDate, status, 0, 1,
8319                                    orderByComparator);
8320    
8321                    if (!list.isEmpty()) {
8322                            return list.get(0);
8323                    }
8324    
8325                    return null;
8326            }
8327    
8328            /**
8329             * Returns the last blogs entry in the ordered set where displayDate &lt; &#63; and status = &#63;.
8330             *
8331             * @param displayDate the display date
8332             * @param status the status
8333             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8334             * @return the last matching blogs entry
8335             * @throws NoSuchEntryException if a matching blogs entry could not be found
8336             */
8337            @Override
8338            public BlogsEntry findByLtD_S_Last(Date displayDate, int status,
8339                    OrderByComparator<BlogsEntry> orderByComparator)
8340                    throws NoSuchEntryException {
8341                    BlogsEntry blogsEntry = fetchByLtD_S_Last(displayDate, status,
8342                                    orderByComparator);
8343    
8344                    if (blogsEntry != null) {
8345                            return blogsEntry;
8346                    }
8347    
8348                    StringBundler msg = new StringBundler(6);
8349    
8350                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8351    
8352                    msg.append("displayDate=");
8353                    msg.append(displayDate);
8354    
8355                    msg.append(", status=");
8356                    msg.append(status);
8357    
8358                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8359    
8360                    throw new NoSuchEntryException(msg.toString());
8361            }
8362    
8363            /**
8364             * Returns the last blogs entry in the ordered set where displayDate &lt; &#63; and status = &#63;.
8365             *
8366             * @param displayDate the display date
8367             * @param status the status
8368             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8369             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
8370             */
8371            @Override
8372            public BlogsEntry fetchByLtD_S_Last(Date displayDate, int status,
8373                    OrderByComparator<BlogsEntry> orderByComparator) {
8374                    int count = countByLtD_S(displayDate, status);
8375    
8376                    if (count == 0) {
8377                            return null;
8378                    }
8379    
8380                    List<BlogsEntry> list = findByLtD_S(displayDate, status, count - 1,
8381                                    count, orderByComparator);
8382    
8383                    if (!list.isEmpty()) {
8384                            return list.get(0);
8385                    }
8386    
8387                    return null;
8388            }
8389    
8390            /**
8391             * Returns the blogs entries before and after the current blogs entry in the ordered set where displayDate &lt; &#63; and status = &#63;.
8392             *
8393             * @param entryId the primary key of the current blogs entry
8394             * @param displayDate the display date
8395             * @param status the status
8396             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8397             * @return the previous, current, and next blogs entry
8398             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
8399             */
8400            @Override
8401            public BlogsEntry[] findByLtD_S_PrevAndNext(long entryId, Date displayDate,
8402                    int status, OrderByComparator<BlogsEntry> orderByComparator)
8403                    throws NoSuchEntryException {
8404                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
8405    
8406                    Session session = null;
8407    
8408                    try {
8409                            session = openSession();
8410    
8411                            BlogsEntry[] array = new BlogsEntryImpl[3];
8412    
8413                            array[0] = getByLtD_S_PrevAndNext(session, blogsEntry, displayDate,
8414                                            status, orderByComparator, true);
8415    
8416                            array[1] = blogsEntry;
8417    
8418                            array[2] = getByLtD_S_PrevAndNext(session, blogsEntry, displayDate,
8419                                            status, orderByComparator, false);
8420    
8421                            return array;
8422                    }
8423                    catch (Exception e) {
8424                            throw processException(e);
8425                    }
8426                    finally {
8427                            closeSession(session);
8428                    }
8429            }
8430    
8431            protected BlogsEntry getByLtD_S_PrevAndNext(Session session,
8432                    BlogsEntry blogsEntry, Date displayDate, int status,
8433                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
8434                    StringBundler query = null;
8435    
8436                    if (orderByComparator != null) {
8437                            query = new StringBundler(5 +
8438                                            (orderByComparator.getOrderByConditionFields().length * 3) +
8439                                            (orderByComparator.getOrderByFields().length * 3));
8440                    }
8441                    else {
8442                            query = new StringBundler(4);
8443                    }
8444    
8445                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
8446    
8447                    boolean bindDisplayDate = false;
8448    
8449                    if (displayDate == null) {
8450                            query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_1);
8451                    }
8452                    else {
8453                            bindDisplayDate = true;
8454    
8455                            query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_2);
8456                    }
8457    
8458                    query.append(_FINDER_COLUMN_LTD_S_STATUS_2);
8459    
8460                    if (orderByComparator != null) {
8461                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8462    
8463                            if (orderByConditionFields.length > 0) {
8464                                    query.append(WHERE_AND);
8465                            }
8466    
8467                            for (int i = 0; i < orderByConditionFields.length; i++) {
8468                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8469                                    query.append(orderByConditionFields[i]);
8470    
8471                                    if ((i + 1) < orderByConditionFields.length) {
8472                                            if (orderByComparator.isAscending() ^ previous) {
8473                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8474                                            }
8475                                            else {
8476                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8477                                            }
8478                                    }
8479                                    else {
8480                                            if (orderByComparator.isAscending() ^ previous) {
8481                                                    query.append(WHERE_GREATER_THAN);
8482                                            }
8483                                            else {
8484                                                    query.append(WHERE_LESSER_THAN);
8485                                            }
8486                                    }
8487                            }
8488    
8489                            query.append(ORDER_BY_CLAUSE);
8490    
8491                            String[] orderByFields = orderByComparator.getOrderByFields();
8492    
8493                            for (int i = 0; i < orderByFields.length; i++) {
8494                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8495                                    query.append(orderByFields[i]);
8496    
8497                                    if ((i + 1) < orderByFields.length) {
8498                                            if (orderByComparator.isAscending() ^ previous) {
8499                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8500                                            }
8501                                            else {
8502                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8503                                            }
8504                                    }
8505                                    else {
8506                                            if (orderByComparator.isAscending() ^ previous) {
8507                                                    query.append(ORDER_BY_ASC);
8508                                            }
8509                                            else {
8510                                                    query.append(ORDER_BY_DESC);
8511                                            }
8512                                    }
8513                            }
8514                    }
8515                    else {
8516                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
8517                    }
8518    
8519                    String sql = query.toString();
8520    
8521                    Query q = session.createQuery(sql);
8522    
8523                    q.setFirstResult(0);
8524                    q.setMaxResults(2);
8525    
8526                    QueryPos qPos = QueryPos.getInstance(q);
8527    
8528                    if (bindDisplayDate) {
8529                            qPos.add(new Timestamp(displayDate.getTime()));
8530                    }
8531    
8532                    qPos.add(status);
8533    
8534                    if (orderByComparator != null) {
8535                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
8536    
8537                            for (Object value : values) {
8538                                    qPos.add(value);
8539                            }
8540                    }
8541    
8542                    List<BlogsEntry> list = q.list();
8543    
8544                    if (list.size() == 2) {
8545                            return list.get(1);
8546                    }
8547                    else {
8548                            return null;
8549                    }
8550            }
8551    
8552            /**
8553             * Removes all the blogs entries where displayDate &lt; &#63; and status = &#63; from the database.
8554             *
8555             * @param displayDate the display date
8556             * @param status the status
8557             */
8558            @Override
8559            public void removeByLtD_S(Date displayDate, int status) {
8560                    for (BlogsEntry blogsEntry : findByLtD_S(displayDate, status,
8561                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
8562                            remove(blogsEntry);
8563                    }
8564            }
8565    
8566            /**
8567             * Returns the number of blogs entries where displayDate &lt; &#63; and status = &#63;.
8568             *
8569             * @param displayDate the display date
8570             * @param status the status
8571             * @return the number of matching blogs entries
8572             */
8573            @Override
8574            public int countByLtD_S(Date displayDate, int status) {
8575                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_LTD_S;
8576    
8577                    Object[] finderArgs = new Object[] { displayDate, status };
8578    
8579                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
8580    
8581                    if (count == null) {
8582                            StringBundler query = new StringBundler(3);
8583    
8584                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
8585    
8586                            boolean bindDisplayDate = false;
8587    
8588                            if (displayDate == null) {
8589                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_1);
8590                            }
8591                            else {
8592                                    bindDisplayDate = true;
8593    
8594                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_2);
8595                            }
8596    
8597                            query.append(_FINDER_COLUMN_LTD_S_STATUS_2);
8598    
8599                            String sql = query.toString();
8600    
8601                            Session session = null;
8602    
8603                            try {
8604                                    session = openSession();
8605    
8606                                    Query q = session.createQuery(sql);
8607    
8608                                    QueryPos qPos = QueryPos.getInstance(q);
8609    
8610                                    if (bindDisplayDate) {
8611                                            qPos.add(new Timestamp(displayDate.getTime()));
8612                                    }
8613    
8614                                    qPos.add(status);
8615    
8616                                    count = (Long)q.uniqueResult();
8617    
8618                                    finderCache.putResult(finderPath, finderArgs, count);
8619                            }
8620                            catch (Exception e) {
8621                                    finderCache.removeResult(finderPath, finderArgs);
8622    
8623                                    throw processException(e);
8624                            }
8625                            finally {
8626                                    closeSession(session);
8627                            }
8628                    }
8629    
8630                    return count.intValue();
8631            }
8632    
8633            private static final String _FINDER_COLUMN_LTD_S_DISPLAYDATE_1 = "blogsEntry.displayDate IS NULL AND ";
8634            private static final String _FINDER_COLUMN_LTD_S_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
8635            private static final String _FINDER_COLUMN_LTD_S_STATUS_2 = "blogsEntry.status = ?";
8636            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
8637                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
8638                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_LtD",
8639                            new String[] {
8640                                    Long.class.getName(), Long.class.getName(), Date.class.getName(),
8641                                    
8642                            Integer.class.getName(), Integer.class.getName(),
8643                                    OrderByComparator.class.getName()
8644                            });
8645            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
8646                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
8647                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_U_LtD",
8648                            new String[] {
8649                                    Long.class.getName(), Long.class.getName(), Date.class.getName()
8650                            });
8651    
8652            /**
8653             * Returns all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
8654             *
8655             * @param groupId the group ID
8656             * @param userId the user ID
8657             * @param displayDate the display date
8658             * @return the matching blogs entries
8659             */
8660            @Override
8661            public List<BlogsEntry> findByG_U_LtD(long groupId, long userId,
8662                    Date displayDate) {
8663                    return findByG_U_LtD(groupId, userId, displayDate, QueryUtil.ALL_POS,
8664                            QueryUtil.ALL_POS, null);
8665            }
8666    
8667            /**
8668             * Returns a range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
8669             *
8670             * <p>
8671             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8672             * </p>
8673             *
8674             * @param groupId the group ID
8675             * @param userId the user ID
8676             * @param displayDate the display date
8677             * @param start the lower bound of the range of blogs entries
8678             * @param end the upper bound of the range of blogs entries (not inclusive)
8679             * @return the range of matching blogs entries
8680             */
8681            @Override
8682            public List<BlogsEntry> findByG_U_LtD(long groupId, long userId,
8683                    Date displayDate, int start, int end) {
8684                    return findByG_U_LtD(groupId, userId, displayDate, start, end, null);
8685            }
8686    
8687            /**
8688             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
8689             *
8690             * <p>
8691             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8692             * </p>
8693             *
8694             * @param groupId the group ID
8695             * @param userId the user ID
8696             * @param displayDate the display date
8697             * @param start the lower bound of the range of blogs entries
8698             * @param end the upper bound of the range of blogs entries (not inclusive)
8699             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8700             * @return the ordered range of matching blogs entries
8701             */
8702            @Override
8703            public List<BlogsEntry> findByG_U_LtD(long groupId, long userId,
8704                    Date displayDate, int start, int end,
8705                    OrderByComparator<BlogsEntry> orderByComparator) {
8706                    return findByG_U_LtD(groupId, userId, displayDate, start, end,
8707                            orderByComparator, true);
8708            }
8709    
8710            /**
8711             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
8712             *
8713             * <p>
8714             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8715             * </p>
8716             *
8717             * @param groupId the group ID
8718             * @param userId the user ID
8719             * @param displayDate the display date
8720             * @param start the lower bound of the range of blogs entries
8721             * @param end the upper bound of the range of blogs entries (not inclusive)
8722             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8723             * @param retrieveFromCache whether to retrieve from the finder cache
8724             * @return the ordered range of matching blogs entries
8725             */
8726            @Override
8727            public List<BlogsEntry> findByG_U_LtD(long groupId, long userId,
8728                    Date displayDate, int start, int end,
8729                    OrderByComparator<BlogsEntry> orderByComparator,
8730                    boolean retrieveFromCache) {
8731                    boolean pagination = true;
8732                    FinderPath finderPath = null;
8733                    Object[] finderArgs = null;
8734    
8735                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD;
8736                    finderArgs = new Object[] {
8737                                    groupId, userId, displayDate,
8738                                    
8739                                    start, end, orderByComparator
8740                            };
8741    
8742                    List<BlogsEntry> list = null;
8743    
8744                    if (retrieveFromCache) {
8745                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
8746                                            finderArgs, this);
8747    
8748                            if ((list != null) && !list.isEmpty()) {
8749                                    for (BlogsEntry blogsEntry : list) {
8750                                            if ((groupId != blogsEntry.getGroupId()) ||
8751                                                            (userId != blogsEntry.getUserId()) ||
8752                                                            (displayDate.getTime() <= blogsEntry.getDisplayDate()
8753                                                                                                                                            .getTime())) {
8754                                                    list = null;
8755    
8756                                                    break;
8757                                            }
8758                                    }
8759                            }
8760                    }
8761    
8762                    if (list == null) {
8763                            StringBundler query = null;
8764    
8765                            if (orderByComparator != null) {
8766                                    query = new StringBundler(5 +
8767                                                    (orderByComparator.getOrderByFields().length * 2));
8768                            }
8769                            else {
8770                                    query = new StringBundler(5);
8771                            }
8772    
8773                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
8774    
8775                            query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
8776    
8777                            query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
8778    
8779                            boolean bindDisplayDate = false;
8780    
8781                            if (displayDate == null) {
8782                                    query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
8783                            }
8784                            else {
8785                                    bindDisplayDate = true;
8786    
8787                                    query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
8788                            }
8789    
8790                            if (orderByComparator != null) {
8791                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8792                                            orderByComparator);
8793                            }
8794                            else
8795                             if (pagination) {
8796                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
8797                            }
8798    
8799                            String sql = query.toString();
8800    
8801                            Session session = null;
8802    
8803                            try {
8804                                    session = openSession();
8805    
8806                                    Query q = session.createQuery(sql);
8807    
8808                                    QueryPos qPos = QueryPos.getInstance(q);
8809    
8810                                    qPos.add(groupId);
8811    
8812                                    qPos.add(userId);
8813    
8814                                    if (bindDisplayDate) {
8815                                            qPos.add(new Timestamp(displayDate.getTime()));
8816                                    }
8817    
8818                                    if (!pagination) {
8819                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
8820                                                            start, end, false);
8821    
8822                                            Collections.sort(list);
8823    
8824                                            list = Collections.unmodifiableList(list);
8825                                    }
8826                                    else {
8827                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
8828                                                            start, end);
8829                                    }
8830    
8831                                    cacheResult(list);
8832    
8833                                    finderCache.putResult(finderPath, finderArgs, list);
8834                            }
8835                            catch (Exception e) {
8836                                    finderCache.removeResult(finderPath, finderArgs);
8837    
8838                                    throw processException(e);
8839                            }
8840                            finally {
8841                                    closeSession(session);
8842                            }
8843                    }
8844    
8845                    return list;
8846            }
8847    
8848            /**
8849             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
8850             *
8851             * @param groupId the group ID
8852             * @param userId the user ID
8853             * @param displayDate the display date
8854             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8855             * @return the first matching blogs entry
8856             * @throws NoSuchEntryException if a matching blogs entry could not be found
8857             */
8858            @Override
8859            public BlogsEntry findByG_U_LtD_First(long groupId, long userId,
8860                    Date displayDate, OrderByComparator<BlogsEntry> orderByComparator)
8861                    throws NoSuchEntryException {
8862                    BlogsEntry blogsEntry = fetchByG_U_LtD_First(groupId, userId,
8863                                    displayDate, orderByComparator);
8864    
8865                    if (blogsEntry != null) {
8866                            return blogsEntry;
8867                    }
8868    
8869                    StringBundler msg = new StringBundler(8);
8870    
8871                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8872    
8873                    msg.append("groupId=");
8874                    msg.append(groupId);
8875    
8876                    msg.append(", userId=");
8877                    msg.append(userId);
8878    
8879                    msg.append(", displayDate=");
8880                    msg.append(displayDate);
8881    
8882                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8883    
8884                    throw new NoSuchEntryException(msg.toString());
8885            }
8886    
8887            /**
8888             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
8889             *
8890             * @param groupId the group ID
8891             * @param userId the user ID
8892             * @param displayDate the display date
8893             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8894             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
8895             */
8896            @Override
8897            public BlogsEntry fetchByG_U_LtD_First(long groupId, long userId,
8898                    Date displayDate, OrderByComparator<BlogsEntry> orderByComparator) {
8899                    List<BlogsEntry> list = findByG_U_LtD(groupId, userId, displayDate, 0,
8900                                    1, orderByComparator);
8901    
8902                    if (!list.isEmpty()) {
8903                            return list.get(0);
8904                    }
8905    
8906                    return null;
8907            }
8908    
8909            /**
8910             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
8911             *
8912             * @param groupId the group ID
8913             * @param userId the user ID
8914             * @param displayDate the display date
8915             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8916             * @return the last matching blogs entry
8917             * @throws NoSuchEntryException if a matching blogs entry could not be found
8918             */
8919            @Override
8920            public BlogsEntry findByG_U_LtD_Last(long groupId, long userId,
8921                    Date displayDate, OrderByComparator<BlogsEntry> orderByComparator)
8922                    throws NoSuchEntryException {
8923                    BlogsEntry blogsEntry = fetchByG_U_LtD_Last(groupId, userId,
8924                                    displayDate, orderByComparator);
8925    
8926                    if (blogsEntry != null) {
8927                            return blogsEntry;
8928                    }
8929    
8930                    StringBundler msg = new StringBundler(8);
8931    
8932                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8933    
8934                    msg.append("groupId=");
8935                    msg.append(groupId);
8936    
8937                    msg.append(", userId=");
8938                    msg.append(userId);
8939    
8940                    msg.append(", displayDate=");
8941                    msg.append(displayDate);
8942    
8943                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8944    
8945                    throw new NoSuchEntryException(msg.toString());
8946            }
8947    
8948            /**
8949             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
8950             *
8951             * @param groupId the group ID
8952             * @param userId the user ID
8953             * @param displayDate the display date
8954             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8955             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
8956             */
8957            @Override
8958            public BlogsEntry fetchByG_U_LtD_Last(long groupId, long userId,
8959                    Date displayDate, OrderByComparator<BlogsEntry> orderByComparator) {
8960                    int count = countByG_U_LtD(groupId, userId, displayDate);
8961    
8962                    if (count == 0) {
8963                            return null;
8964                    }
8965    
8966                    List<BlogsEntry> list = findByG_U_LtD(groupId, userId, displayDate,
8967                                    count - 1, count, orderByComparator);
8968    
8969                    if (!list.isEmpty()) {
8970                            return list.get(0);
8971                    }
8972    
8973                    return null;
8974            }
8975    
8976            /**
8977             * 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;.
8978             *
8979             * @param entryId the primary key of the current blogs entry
8980             * @param groupId the group ID
8981             * @param userId the user ID
8982             * @param displayDate the display date
8983             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8984             * @return the previous, current, and next blogs entry
8985             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
8986             */
8987            @Override
8988            public BlogsEntry[] findByG_U_LtD_PrevAndNext(long entryId, long groupId,
8989                    long userId, Date displayDate,
8990                    OrderByComparator<BlogsEntry> orderByComparator)
8991                    throws NoSuchEntryException {
8992                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
8993    
8994                    Session session = null;
8995    
8996                    try {
8997                            session = openSession();
8998    
8999                            BlogsEntry[] array = new BlogsEntryImpl[3];
9000    
9001                            array[0] = getByG_U_LtD_PrevAndNext(session, blogsEntry, groupId,
9002                                            userId, displayDate, orderByComparator, true);
9003    
9004                            array[1] = blogsEntry;
9005    
9006                            array[2] = getByG_U_LtD_PrevAndNext(session, blogsEntry, groupId,
9007                                            userId, displayDate, orderByComparator, false);
9008    
9009                            return array;
9010                    }
9011                    catch (Exception e) {
9012                            throw processException(e);
9013                    }
9014                    finally {
9015                            closeSession(session);
9016                    }
9017            }
9018    
9019            protected BlogsEntry getByG_U_LtD_PrevAndNext(Session session,
9020                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
9021                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
9022                    StringBundler query = null;
9023    
9024                    if (orderByComparator != null) {
9025                            query = new StringBundler(6 +
9026                                            (orderByComparator.getOrderByConditionFields().length * 3) +
9027                                            (orderByComparator.getOrderByFields().length * 3));
9028                    }
9029                    else {
9030                            query = new StringBundler(5);
9031                    }
9032    
9033                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
9034    
9035                    query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
9036    
9037                    query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
9038    
9039                    boolean bindDisplayDate = false;
9040    
9041                    if (displayDate == null) {
9042                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
9043                    }
9044                    else {
9045                            bindDisplayDate = true;
9046    
9047                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
9048                    }
9049    
9050                    if (orderByComparator != null) {
9051                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9052    
9053                            if (orderByConditionFields.length > 0) {
9054                                    query.append(WHERE_AND);
9055                            }
9056    
9057                            for (int i = 0; i < orderByConditionFields.length; i++) {
9058                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9059                                    query.append(orderByConditionFields[i]);
9060    
9061                                    if ((i + 1) < orderByConditionFields.length) {
9062                                            if (orderByComparator.isAscending() ^ previous) {
9063                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9064                                            }
9065                                            else {
9066                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
9067                                            }
9068                                    }
9069                                    else {
9070                                            if (orderByComparator.isAscending() ^ previous) {
9071                                                    query.append(WHERE_GREATER_THAN);
9072                                            }
9073                                            else {
9074                                                    query.append(WHERE_LESSER_THAN);
9075                                            }
9076                                    }
9077                            }
9078    
9079                            query.append(ORDER_BY_CLAUSE);
9080    
9081                            String[] orderByFields = orderByComparator.getOrderByFields();
9082    
9083                            for (int i = 0; i < orderByFields.length; i++) {
9084                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9085                                    query.append(orderByFields[i]);
9086    
9087                                    if ((i + 1) < orderByFields.length) {
9088                                            if (orderByComparator.isAscending() ^ previous) {
9089                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
9090                                            }
9091                                            else {
9092                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
9093                                            }
9094                                    }
9095                                    else {
9096                                            if (orderByComparator.isAscending() ^ previous) {
9097                                                    query.append(ORDER_BY_ASC);
9098                                            }
9099                                            else {
9100                                                    query.append(ORDER_BY_DESC);
9101                                            }
9102                                    }
9103                            }
9104                    }
9105                    else {
9106                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
9107                    }
9108    
9109                    String sql = query.toString();
9110    
9111                    Query q = session.createQuery(sql);
9112    
9113                    q.setFirstResult(0);
9114                    q.setMaxResults(2);
9115    
9116                    QueryPos qPos = QueryPos.getInstance(q);
9117    
9118                    qPos.add(groupId);
9119    
9120                    qPos.add(userId);
9121    
9122                    if (bindDisplayDate) {
9123                            qPos.add(new Timestamp(displayDate.getTime()));
9124                    }
9125    
9126                    if (orderByComparator != null) {
9127                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
9128    
9129                            for (Object value : values) {
9130                                    qPos.add(value);
9131                            }
9132                    }
9133    
9134                    List<BlogsEntry> list = q.list();
9135    
9136                    if (list.size() == 2) {
9137                            return list.get(1);
9138                    }
9139                    else {
9140                            return null;
9141                    }
9142            }
9143    
9144            /**
9145             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
9146             *
9147             * @param groupId the group ID
9148             * @param userId the user ID
9149             * @param displayDate the display date
9150             * @return the matching blogs entries that the user has permission to view
9151             */
9152            @Override
9153            public List<BlogsEntry> filterFindByG_U_LtD(long groupId, long userId,
9154                    Date displayDate) {
9155                    return filterFindByG_U_LtD(groupId, userId, displayDate,
9156                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
9157            }
9158    
9159            /**
9160             * 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;.
9161             *
9162             * <p>
9163             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9164             * </p>
9165             *
9166             * @param groupId the group ID
9167             * @param userId the user ID
9168             * @param displayDate the display date
9169             * @param start the lower bound of the range of blogs entries
9170             * @param end the upper bound of the range of blogs entries (not inclusive)
9171             * @return the range of matching blogs entries that the user has permission to view
9172             */
9173            @Override
9174            public List<BlogsEntry> filterFindByG_U_LtD(long groupId, long userId,
9175                    Date displayDate, int start, int end) {
9176                    return filterFindByG_U_LtD(groupId, userId, displayDate, start, end,
9177                            null);
9178            }
9179    
9180            /**
9181             * 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;.
9182             *
9183             * <p>
9184             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9185             * </p>
9186             *
9187             * @param groupId the group ID
9188             * @param userId the user ID
9189             * @param displayDate the display date
9190             * @param start the lower bound of the range of blogs entries
9191             * @param end the upper bound of the range of blogs entries (not inclusive)
9192             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9193             * @return the ordered range of matching blogs entries that the user has permission to view
9194             */
9195            @Override
9196            public List<BlogsEntry> filterFindByG_U_LtD(long groupId, long userId,
9197                    Date displayDate, int start, int end,
9198                    OrderByComparator<BlogsEntry> orderByComparator) {
9199                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9200                            return findByG_U_LtD(groupId, userId, displayDate, start, end,
9201                                    orderByComparator);
9202                    }
9203    
9204                    StringBundler query = null;
9205    
9206                    if (orderByComparator != null) {
9207                            query = new StringBundler(5 +
9208                                            (orderByComparator.getOrderByFields().length * 2));
9209                    }
9210                    else {
9211                            query = new StringBundler(6);
9212                    }
9213    
9214                    if (getDB().isSupportsInlineDistinct()) {
9215                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
9216                    }
9217                    else {
9218                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
9219                    }
9220    
9221                    query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
9222    
9223                    query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
9224    
9225                    boolean bindDisplayDate = false;
9226    
9227                    if (displayDate == null) {
9228                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
9229                    }
9230                    else {
9231                            bindDisplayDate = true;
9232    
9233                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
9234                    }
9235    
9236                    if (!getDB().isSupportsInlineDistinct()) {
9237                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
9238                    }
9239    
9240                    if (orderByComparator != null) {
9241                            if (getDB().isSupportsInlineDistinct()) {
9242                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9243                                            orderByComparator, true);
9244                            }
9245                            else {
9246                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
9247                                            orderByComparator, true);
9248                            }
9249                    }
9250                    else {
9251                            if (getDB().isSupportsInlineDistinct()) {
9252                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
9253                            }
9254                            else {
9255                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
9256                            }
9257                    }
9258    
9259                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9260                                    BlogsEntry.class.getName(),
9261                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9262    
9263                    Session session = null;
9264    
9265                    try {
9266                            session = openSession();
9267    
9268                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
9269    
9270                            if (getDB().isSupportsInlineDistinct()) {
9271                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
9272                            }
9273                            else {
9274                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
9275                            }
9276    
9277                            QueryPos qPos = QueryPos.getInstance(q);
9278    
9279                            qPos.add(groupId);
9280    
9281                            qPos.add(userId);
9282    
9283                            if (bindDisplayDate) {
9284                                    qPos.add(new Timestamp(displayDate.getTime()));
9285                            }
9286    
9287                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
9288                    }
9289                    catch (Exception e) {
9290                            throw processException(e);
9291                    }
9292                    finally {
9293                            closeSession(session);
9294                    }
9295            }
9296    
9297            /**
9298             * 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;.
9299             *
9300             * @param entryId the primary key of the current blogs entry
9301             * @param groupId the group ID
9302             * @param userId the user ID
9303             * @param displayDate the display date
9304             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9305             * @return the previous, current, and next blogs entry
9306             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
9307             */
9308            @Override
9309            public BlogsEntry[] filterFindByG_U_LtD_PrevAndNext(long entryId,
9310                    long groupId, long userId, Date displayDate,
9311                    OrderByComparator<BlogsEntry> orderByComparator)
9312                    throws NoSuchEntryException {
9313                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9314                            return findByG_U_LtD_PrevAndNext(entryId, groupId, userId,
9315                                    displayDate, orderByComparator);
9316                    }
9317    
9318                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
9319    
9320                    Session session = null;
9321    
9322                    try {
9323                            session = openSession();
9324    
9325                            BlogsEntry[] array = new BlogsEntryImpl[3];
9326    
9327                            array[0] = filterGetByG_U_LtD_PrevAndNext(session, blogsEntry,
9328                                            groupId, userId, displayDate, orderByComparator, true);
9329    
9330                            array[1] = blogsEntry;
9331    
9332                            array[2] = filterGetByG_U_LtD_PrevAndNext(session, blogsEntry,
9333                                            groupId, userId, displayDate, orderByComparator, false);
9334    
9335                            return array;
9336                    }
9337                    catch (Exception e) {
9338                            throw processException(e);
9339                    }
9340                    finally {
9341                            closeSession(session);
9342                    }
9343            }
9344    
9345            protected BlogsEntry filterGetByG_U_LtD_PrevAndNext(Session session,
9346                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
9347                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
9348                    StringBundler query = null;
9349    
9350                    if (orderByComparator != null) {
9351                            query = new StringBundler(7 +
9352                                            (orderByComparator.getOrderByConditionFields().length * 3) +
9353                                            (orderByComparator.getOrderByFields().length * 3));
9354                    }
9355                    else {
9356                            query = new StringBundler(6);
9357                    }
9358    
9359                    if (getDB().isSupportsInlineDistinct()) {
9360                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
9361                    }
9362                    else {
9363                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
9364                    }
9365    
9366                    query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
9367    
9368                    query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
9369    
9370                    boolean bindDisplayDate = false;
9371    
9372                    if (displayDate == null) {
9373                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
9374                    }
9375                    else {
9376                            bindDisplayDate = true;
9377    
9378                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
9379                    }
9380    
9381                    if (!getDB().isSupportsInlineDistinct()) {
9382                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
9383                    }
9384    
9385                    if (orderByComparator != null) {
9386                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9387    
9388                            if (orderByConditionFields.length > 0) {
9389                                    query.append(WHERE_AND);
9390                            }
9391    
9392                            for (int i = 0; i < orderByConditionFields.length; i++) {
9393                                    if (getDB().isSupportsInlineDistinct()) {
9394                                            query.append(_ORDER_BY_ENTITY_ALIAS);
9395                                    }
9396                                    else {
9397                                            query.append(_ORDER_BY_ENTITY_TABLE);
9398                                    }
9399    
9400                                    query.append(orderByConditionFields[i]);
9401    
9402                                    if ((i + 1) < orderByConditionFields.length) {
9403                                            if (orderByComparator.isAscending() ^ previous) {
9404                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9405                                            }
9406                                            else {
9407                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
9408                                            }
9409                                    }
9410                                    else {
9411                                            if (orderByComparator.isAscending() ^ previous) {
9412                                                    query.append(WHERE_GREATER_THAN);
9413                                            }
9414                                            else {
9415                                                    query.append(WHERE_LESSER_THAN);
9416                                            }
9417                                    }
9418                            }
9419    
9420                            query.append(ORDER_BY_CLAUSE);
9421    
9422                            String[] orderByFields = orderByComparator.getOrderByFields();
9423    
9424                            for (int i = 0; i < orderByFields.length; i++) {
9425                                    if (getDB().isSupportsInlineDistinct()) {
9426                                            query.append(_ORDER_BY_ENTITY_ALIAS);
9427                                    }
9428                                    else {
9429                                            query.append(_ORDER_BY_ENTITY_TABLE);
9430                                    }
9431    
9432                                    query.append(orderByFields[i]);
9433    
9434                                    if ((i + 1) < orderByFields.length) {
9435                                            if (orderByComparator.isAscending() ^ previous) {
9436                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
9437                                            }
9438                                            else {
9439                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
9440                                            }
9441                                    }
9442                                    else {
9443                                            if (orderByComparator.isAscending() ^ previous) {
9444                                                    query.append(ORDER_BY_ASC);
9445                                            }
9446                                            else {
9447                                                    query.append(ORDER_BY_DESC);
9448                                            }
9449                                    }
9450                            }
9451                    }
9452                    else {
9453                            if (getDB().isSupportsInlineDistinct()) {
9454                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
9455                            }
9456                            else {
9457                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
9458                            }
9459                    }
9460    
9461                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9462                                    BlogsEntry.class.getName(),
9463                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9464    
9465                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
9466    
9467                    q.setFirstResult(0);
9468                    q.setMaxResults(2);
9469    
9470                    if (getDB().isSupportsInlineDistinct()) {
9471                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
9472                    }
9473                    else {
9474                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
9475                    }
9476    
9477                    QueryPos qPos = QueryPos.getInstance(q);
9478    
9479                    qPos.add(groupId);
9480    
9481                    qPos.add(userId);
9482    
9483                    if (bindDisplayDate) {
9484                            qPos.add(new Timestamp(displayDate.getTime()));
9485                    }
9486    
9487                    if (orderByComparator != null) {
9488                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
9489    
9490                            for (Object value : values) {
9491                                    qPos.add(value);
9492                            }
9493                    }
9494    
9495                    List<BlogsEntry> list = q.list();
9496    
9497                    if (list.size() == 2) {
9498                            return list.get(1);
9499                    }
9500                    else {
9501                            return null;
9502                    }
9503            }
9504    
9505            /**
9506             * Removes all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; from the database.
9507             *
9508             * @param groupId the group ID
9509             * @param userId the user ID
9510             * @param displayDate the display date
9511             */
9512            @Override
9513            public void removeByG_U_LtD(long groupId, long userId, Date displayDate) {
9514                    for (BlogsEntry blogsEntry : findByG_U_LtD(groupId, userId,
9515                                    displayDate, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
9516                            remove(blogsEntry);
9517                    }
9518            }
9519    
9520            /**
9521             * Returns the number of blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
9522             *
9523             * @param groupId the group ID
9524             * @param userId the user ID
9525             * @param displayDate the display date
9526             * @return the number of matching blogs entries
9527             */
9528            @Override
9529            public int countByG_U_LtD(long groupId, long userId, Date displayDate) {
9530                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD;
9531    
9532                    Object[] finderArgs = new Object[] { groupId, userId, displayDate };
9533    
9534                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
9535    
9536                    if (count == null) {
9537                            StringBundler query = new StringBundler(4);
9538    
9539                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
9540    
9541                            query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
9542    
9543                            query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
9544    
9545                            boolean bindDisplayDate = false;
9546    
9547                            if (displayDate == null) {
9548                                    query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
9549                            }
9550                            else {
9551                                    bindDisplayDate = true;
9552    
9553                                    query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
9554                            }
9555    
9556                            String sql = query.toString();
9557    
9558                            Session session = null;
9559    
9560                            try {
9561                                    session = openSession();
9562    
9563                                    Query q = session.createQuery(sql);
9564    
9565                                    QueryPos qPos = QueryPos.getInstance(q);
9566    
9567                                    qPos.add(groupId);
9568    
9569                                    qPos.add(userId);
9570    
9571                                    if (bindDisplayDate) {
9572                                            qPos.add(new Timestamp(displayDate.getTime()));
9573                                    }
9574    
9575                                    count = (Long)q.uniqueResult();
9576    
9577                                    finderCache.putResult(finderPath, finderArgs, count);
9578                            }
9579                            catch (Exception e) {
9580                                    finderCache.removeResult(finderPath, finderArgs);
9581    
9582                                    throw processException(e);
9583                            }
9584                            finally {
9585                                    closeSession(session);
9586                            }
9587                    }
9588    
9589                    return count.intValue();
9590            }
9591    
9592            /**
9593             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
9594             *
9595             * @param groupId the group ID
9596             * @param userId the user ID
9597             * @param displayDate the display date
9598             * @return the number of matching blogs entries that the user has permission to view
9599             */
9600            @Override
9601            public int filterCountByG_U_LtD(long groupId, long userId, Date displayDate) {
9602                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9603                            return countByG_U_LtD(groupId, userId, displayDate);
9604                    }
9605    
9606                    StringBundler query = new StringBundler(4);
9607    
9608                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
9609    
9610                    query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
9611    
9612                    query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
9613    
9614                    boolean bindDisplayDate = false;
9615    
9616                    if (displayDate == null) {
9617                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
9618                    }
9619                    else {
9620                            bindDisplayDate = true;
9621    
9622                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
9623                    }
9624    
9625                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9626                                    BlogsEntry.class.getName(),
9627                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9628    
9629                    Session session = null;
9630    
9631                    try {
9632                            session = openSession();
9633    
9634                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
9635    
9636                            q.addScalar(COUNT_COLUMN_NAME,
9637                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
9638    
9639                            QueryPos qPos = QueryPos.getInstance(q);
9640    
9641                            qPos.add(groupId);
9642    
9643                            qPos.add(userId);
9644    
9645                            if (bindDisplayDate) {
9646                                    qPos.add(new Timestamp(displayDate.getTime()));
9647                            }
9648    
9649                            Long count = (Long)q.uniqueResult();
9650    
9651                            return count.intValue();
9652                    }
9653                    catch (Exception e) {
9654                            throw processException(e);
9655                    }
9656                    finally {
9657                            closeSession(session);
9658                    }
9659            }
9660    
9661            private static final String _FINDER_COLUMN_G_U_LTD_GROUPID_2 = "blogsEntry.groupId = ? AND ";
9662            private static final String _FINDER_COLUMN_G_U_LTD_USERID_2 = "blogsEntry.userId = ? AND ";
9663            private static final String _FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1 = "blogsEntry.displayDate IS NULL";
9664            private static final String _FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2 = "blogsEntry.displayDate < ?";
9665            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
9666                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
9667                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_S",
9668                            new String[] {
9669                                    Long.class.getName(), Long.class.getName(),
9670                                    Integer.class.getName(),
9671                                    
9672                            Integer.class.getName(), Integer.class.getName(),
9673                                    OrderByComparator.class.getName()
9674                            });
9675            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
9676                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
9677                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U_S",
9678                            new String[] {
9679                                    Long.class.getName(), Long.class.getName(),
9680                                    Integer.class.getName()
9681                            },
9682                            BlogsEntryModelImpl.GROUPID_COLUMN_BITMASK |
9683                            BlogsEntryModelImpl.USERID_COLUMN_BITMASK |
9684                            BlogsEntryModelImpl.STATUS_COLUMN_BITMASK |
9685                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
9686                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
9687            public static final FinderPath FINDER_PATH_COUNT_BY_G_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
9688                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
9689                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U_S",
9690                            new String[] {
9691                                    Long.class.getName(), Long.class.getName(),
9692                                    Integer.class.getName()
9693                            });
9694            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
9695                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
9696                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_U_S",
9697                            new String[] {
9698                                    Long.class.getName(), Long.class.getName(),
9699                                    Integer.class.getName()
9700                            });
9701    
9702            /**
9703             * Returns all the blogs entries where groupId = &#63; and userId = &#63; and status = &#63;.
9704             *
9705             * @param groupId the group ID
9706             * @param userId the user ID
9707             * @param status the status
9708             * @return the matching blogs entries
9709             */
9710            @Override
9711            public List<BlogsEntry> findByG_U_S(long groupId, long userId, int status) {
9712                    return findByG_U_S(groupId, userId, status, QueryUtil.ALL_POS,
9713                            QueryUtil.ALL_POS, null);
9714            }
9715    
9716            /**
9717             * Returns a range of all the blogs entries where groupId = &#63; and userId = &#63; and status = &#63;.
9718             *
9719             * <p>
9720             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9721             * </p>
9722             *
9723             * @param groupId the group ID
9724             * @param userId the user ID
9725             * @param status the status
9726             * @param start the lower bound of the range of blogs entries
9727             * @param end the upper bound of the range of blogs entries (not inclusive)
9728             * @return the range of matching blogs entries
9729             */
9730            @Override
9731            public List<BlogsEntry> findByG_U_S(long groupId, long userId, int status,
9732                    int start, int end) {
9733                    return findByG_U_S(groupId, userId, status, start, end, null);
9734            }
9735    
9736            /**
9737             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and status = &#63;.
9738             *
9739             * <p>
9740             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9741             * </p>
9742             *
9743             * @param groupId the group ID
9744             * @param userId the user ID
9745             * @param status the status
9746             * @param start the lower bound of the range of blogs entries
9747             * @param end the upper bound of the range of blogs entries (not inclusive)
9748             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9749             * @return the ordered range of matching blogs entries
9750             */
9751            @Override
9752            public List<BlogsEntry> findByG_U_S(long groupId, long userId, int status,
9753                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator) {
9754                    return findByG_U_S(groupId, userId, status, start, end,
9755                            orderByComparator, true);
9756            }
9757    
9758            /**
9759             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and status = &#63;.
9760             *
9761             * <p>
9762             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9763             * </p>
9764             *
9765             * @param groupId the group ID
9766             * @param userId the user ID
9767             * @param status the status
9768             * @param start the lower bound of the range of blogs entries
9769             * @param end the upper bound of the range of blogs entries (not inclusive)
9770             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9771             * @param retrieveFromCache whether to retrieve from the finder cache
9772             * @return the ordered range of matching blogs entries
9773             */
9774            @Override
9775            public List<BlogsEntry> findByG_U_S(long groupId, long userId, int status,
9776                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator,
9777                    boolean retrieveFromCache) {
9778                    boolean pagination = true;
9779                    FinderPath finderPath = null;
9780                    Object[] finderArgs = null;
9781    
9782                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
9783                                    (orderByComparator == null)) {
9784                            pagination = false;
9785                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S;
9786                            finderArgs = new Object[] { groupId, userId, status };
9787                    }
9788                    else {
9789                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_S;
9790                            finderArgs = new Object[] {
9791                                            groupId, userId, status,
9792                                            
9793                                            start, end, orderByComparator
9794                                    };
9795                    }
9796    
9797                    List<BlogsEntry> list = null;
9798    
9799                    if (retrieveFromCache) {
9800                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
9801                                            finderArgs, this);
9802    
9803                            if ((list != null) && !list.isEmpty()) {
9804                                    for (BlogsEntry blogsEntry : list) {
9805                                            if ((groupId != blogsEntry.getGroupId()) ||
9806                                                            (userId != blogsEntry.getUserId()) ||
9807                                                            (status != blogsEntry.getStatus())) {
9808                                                    list = null;
9809    
9810                                                    break;
9811                                            }
9812                                    }
9813                            }
9814                    }
9815    
9816                    if (list == null) {
9817                            StringBundler query = null;
9818    
9819                            if (orderByComparator != null) {
9820                                    query = new StringBundler(5 +
9821                                                    (orderByComparator.getOrderByFields().length * 2));
9822                            }
9823                            else {
9824                                    query = new StringBundler(5);
9825                            }
9826    
9827                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
9828    
9829                            query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
9830    
9831                            query.append(_FINDER_COLUMN_G_U_S_USERID_2);
9832    
9833                            query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
9834    
9835                            if (orderByComparator != null) {
9836                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9837                                            orderByComparator);
9838                            }
9839                            else
9840                             if (pagination) {
9841                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
9842                            }
9843    
9844                            String sql = query.toString();
9845    
9846                            Session session = null;
9847    
9848                            try {
9849                                    session = openSession();
9850    
9851                                    Query q = session.createQuery(sql);
9852    
9853                                    QueryPos qPos = QueryPos.getInstance(q);
9854    
9855                                    qPos.add(groupId);
9856    
9857                                    qPos.add(userId);
9858    
9859                                    qPos.add(status);
9860    
9861                                    if (!pagination) {
9862                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
9863                                                            start, end, false);
9864    
9865                                            Collections.sort(list);
9866    
9867                                            list = Collections.unmodifiableList(list);
9868                                    }
9869                                    else {
9870                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
9871                                                            start, end);
9872                                    }
9873    
9874                                    cacheResult(list);
9875    
9876                                    finderCache.putResult(finderPath, finderArgs, list);
9877                            }
9878                            catch (Exception e) {
9879                                    finderCache.removeResult(finderPath, finderArgs);
9880    
9881                                    throw processException(e);
9882                            }
9883                            finally {
9884                                    closeSession(session);
9885                            }
9886                    }
9887    
9888                    return list;
9889            }
9890    
9891            /**
9892             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
9893             *
9894             * @param groupId the group ID
9895             * @param userId the user ID
9896             * @param status the status
9897             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9898             * @return the first matching blogs entry
9899             * @throws NoSuchEntryException if a matching blogs entry could not be found
9900             */
9901            @Override
9902            public BlogsEntry findByG_U_S_First(long groupId, long userId, int status,
9903                    OrderByComparator<BlogsEntry> orderByComparator)
9904                    throws NoSuchEntryException {
9905                    BlogsEntry blogsEntry = fetchByG_U_S_First(groupId, userId, status,
9906                                    orderByComparator);
9907    
9908                    if (blogsEntry != null) {
9909                            return blogsEntry;
9910                    }
9911    
9912                    StringBundler msg = new StringBundler(8);
9913    
9914                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9915    
9916                    msg.append("groupId=");
9917                    msg.append(groupId);
9918    
9919                    msg.append(", userId=");
9920                    msg.append(userId);
9921    
9922                    msg.append(", status=");
9923                    msg.append(status);
9924    
9925                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9926    
9927                    throw new NoSuchEntryException(msg.toString());
9928            }
9929    
9930            /**
9931             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
9932             *
9933             * @param groupId the group ID
9934             * @param userId the user ID
9935             * @param status the status
9936             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9937             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
9938             */
9939            @Override
9940            public BlogsEntry fetchByG_U_S_First(long groupId, long userId, int status,
9941                    OrderByComparator<BlogsEntry> orderByComparator) {
9942                    List<BlogsEntry> list = findByG_U_S(groupId, userId, status, 0, 1,
9943                                    orderByComparator);
9944    
9945                    if (!list.isEmpty()) {
9946                            return list.get(0);
9947                    }
9948    
9949                    return null;
9950            }
9951    
9952            /**
9953             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
9954             *
9955             * @param groupId the group ID
9956             * @param userId the user ID
9957             * @param status the status
9958             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9959             * @return the last matching blogs entry
9960             * @throws NoSuchEntryException if a matching blogs entry could not be found
9961             */
9962            @Override
9963            public BlogsEntry findByG_U_S_Last(long groupId, long userId, int status,
9964                    OrderByComparator<BlogsEntry> orderByComparator)
9965                    throws NoSuchEntryException {
9966                    BlogsEntry blogsEntry = fetchByG_U_S_Last(groupId, userId, status,
9967                                    orderByComparator);
9968    
9969                    if (blogsEntry != null) {
9970                            return blogsEntry;
9971                    }
9972    
9973                    StringBundler msg = new StringBundler(8);
9974    
9975                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9976    
9977                    msg.append("groupId=");
9978                    msg.append(groupId);
9979    
9980                    msg.append(", userId=");
9981                    msg.append(userId);
9982    
9983                    msg.append(", status=");
9984                    msg.append(status);
9985    
9986                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9987    
9988                    throw new NoSuchEntryException(msg.toString());
9989            }
9990    
9991            /**
9992             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
9993             *
9994             * @param groupId the group ID
9995             * @param userId the user ID
9996             * @param status the status
9997             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9998             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
9999             */
10000            @Override
10001            public BlogsEntry fetchByG_U_S_Last(long groupId, long userId, int status,
10002                    OrderByComparator<BlogsEntry> orderByComparator) {
10003                    int count = countByG_U_S(groupId, userId, status);
10004    
10005                    if (count == 0) {
10006                            return null;
10007                    }
10008    
10009                    List<BlogsEntry> list = findByG_U_S(groupId, userId, status, count - 1,
10010                                    count, orderByComparator);
10011    
10012                    if (!list.isEmpty()) {
10013                            return list.get(0);
10014                    }
10015    
10016                    return null;
10017            }
10018    
10019            /**
10020             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
10021             *
10022             * @param entryId the primary key of the current blogs entry
10023             * @param groupId the group ID
10024             * @param userId the user ID
10025             * @param status the status
10026             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10027             * @return the previous, current, and next blogs entry
10028             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
10029             */
10030            @Override
10031            public BlogsEntry[] findByG_U_S_PrevAndNext(long entryId, long groupId,
10032                    long userId, int status, OrderByComparator<BlogsEntry> orderByComparator)
10033                    throws NoSuchEntryException {
10034                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
10035    
10036                    Session session = null;
10037    
10038                    try {
10039                            session = openSession();
10040    
10041                            BlogsEntry[] array = new BlogsEntryImpl[3];
10042    
10043                            array[0] = getByG_U_S_PrevAndNext(session, blogsEntry, groupId,
10044                                            userId, status, orderByComparator, true);
10045    
10046                            array[1] = blogsEntry;
10047    
10048                            array[2] = getByG_U_S_PrevAndNext(session, blogsEntry, groupId,
10049                                            userId, status, orderByComparator, false);
10050    
10051                            return array;
10052                    }
10053                    catch (Exception e) {
10054                            throw processException(e);
10055                    }
10056                    finally {
10057                            closeSession(session);
10058                    }
10059            }
10060    
10061            protected BlogsEntry getByG_U_S_PrevAndNext(Session session,
10062                    BlogsEntry blogsEntry, long groupId, long userId, int status,
10063                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
10064                    StringBundler query = null;
10065    
10066                    if (orderByComparator != null) {
10067                            query = new StringBundler(6 +
10068                                            (orderByComparator.getOrderByConditionFields().length * 3) +
10069                                            (orderByComparator.getOrderByFields().length * 3));
10070                    }
10071                    else {
10072                            query = new StringBundler(5);
10073                    }
10074    
10075                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
10076    
10077                    query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
10078    
10079                    query.append(_FINDER_COLUMN_G_U_S_USERID_2);
10080    
10081                    query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
10082    
10083                    if (orderByComparator != null) {
10084                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10085    
10086                            if (orderByConditionFields.length > 0) {
10087                                    query.append(WHERE_AND);
10088                            }
10089    
10090                            for (int i = 0; i < orderByConditionFields.length; i++) {
10091                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10092                                    query.append(orderByConditionFields[i]);
10093    
10094                                    if ((i + 1) < orderByConditionFields.length) {
10095                                            if (orderByComparator.isAscending() ^ previous) {
10096                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10097                                            }
10098                                            else {
10099                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10100                                            }
10101                                    }
10102                                    else {
10103                                            if (orderByComparator.isAscending() ^ previous) {
10104                                                    query.append(WHERE_GREATER_THAN);
10105                                            }
10106                                            else {
10107                                                    query.append(WHERE_LESSER_THAN);
10108                                            }
10109                                    }
10110                            }
10111    
10112                            query.append(ORDER_BY_CLAUSE);
10113    
10114                            String[] orderByFields = orderByComparator.getOrderByFields();
10115    
10116                            for (int i = 0; i < orderByFields.length; i++) {
10117                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10118                                    query.append(orderByFields[i]);
10119    
10120                                    if ((i + 1) < orderByFields.length) {
10121                                            if (orderByComparator.isAscending() ^ previous) {
10122                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10123                                            }
10124                                            else {
10125                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10126                                            }
10127                                    }
10128                                    else {
10129                                            if (orderByComparator.isAscending() ^ previous) {
10130                                                    query.append(ORDER_BY_ASC);
10131                                            }
10132                                            else {
10133                                                    query.append(ORDER_BY_DESC);
10134                                            }
10135                                    }
10136                            }
10137                    }
10138                    else {
10139                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
10140                    }
10141    
10142                    String sql = query.toString();
10143    
10144                    Query q = session.createQuery(sql);
10145    
10146                    q.setFirstResult(0);
10147                    q.setMaxResults(2);
10148    
10149                    QueryPos qPos = QueryPos.getInstance(q);
10150    
10151                    qPos.add(groupId);
10152    
10153                    qPos.add(userId);
10154    
10155                    qPos.add(status);
10156    
10157                    if (orderByComparator != null) {
10158                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
10159    
10160                            for (Object value : values) {
10161                                    qPos.add(value);
10162                            }
10163                    }
10164    
10165                    List<BlogsEntry> list = q.list();
10166    
10167                    if (list.size() == 2) {
10168                            return list.get(1);
10169                    }
10170                    else {
10171                            return null;
10172                    }
10173            }
10174    
10175            /**
10176             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status = &#63;.
10177             *
10178             * @param groupId the group ID
10179             * @param userId the user ID
10180             * @param status the status
10181             * @return the matching blogs entries that the user has permission to view
10182             */
10183            @Override
10184            public List<BlogsEntry> filterFindByG_U_S(long groupId, long userId,
10185                    int status) {
10186                    return filterFindByG_U_S(groupId, userId, status, QueryUtil.ALL_POS,
10187                            QueryUtil.ALL_POS, null);
10188            }
10189    
10190            /**
10191             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status = &#63;.
10192             *
10193             * <p>
10194             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10195             * </p>
10196             *
10197             * @param groupId the group ID
10198             * @param userId the user ID
10199             * @param status the status
10200             * @param start the lower bound of the range of blogs entries
10201             * @param end the upper bound of the range of blogs entries (not inclusive)
10202             * @return the range of matching blogs entries that the user has permission to view
10203             */
10204            @Override
10205            public List<BlogsEntry> filterFindByG_U_S(long groupId, long userId,
10206                    int status, int start, int end) {
10207                    return filterFindByG_U_S(groupId, userId, status, start, end, null);
10208            }
10209    
10210            /**
10211             * 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;.
10212             *
10213             * <p>
10214             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10215             * </p>
10216             *
10217             * @param groupId the group ID
10218             * @param userId the user ID
10219             * @param status the status
10220             * @param start the lower bound of the range of blogs entries
10221             * @param end the upper bound of the range of blogs entries (not inclusive)
10222             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10223             * @return the ordered range of matching blogs entries that the user has permission to view
10224             */
10225            @Override
10226            public List<BlogsEntry> filterFindByG_U_S(long groupId, long userId,
10227                    int status, int start, int end,
10228                    OrderByComparator<BlogsEntry> orderByComparator) {
10229                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10230                            return findByG_U_S(groupId, userId, status, start, end,
10231                                    orderByComparator);
10232                    }
10233    
10234                    StringBundler query = null;
10235    
10236                    if (orderByComparator != null) {
10237                            query = new StringBundler(5 +
10238                                            (orderByComparator.getOrderByFields().length * 2));
10239                    }
10240                    else {
10241                            query = new StringBundler(6);
10242                    }
10243    
10244                    if (getDB().isSupportsInlineDistinct()) {
10245                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
10246                    }
10247                    else {
10248                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
10249                    }
10250    
10251                    query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
10252    
10253                    query.append(_FINDER_COLUMN_G_U_S_USERID_2);
10254    
10255                    query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
10256    
10257                    if (!getDB().isSupportsInlineDistinct()) {
10258                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
10259                    }
10260    
10261                    if (orderByComparator != null) {
10262                            if (getDB().isSupportsInlineDistinct()) {
10263                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10264                                            orderByComparator, true);
10265                            }
10266                            else {
10267                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
10268                                            orderByComparator, true);
10269                            }
10270                    }
10271                    else {
10272                            if (getDB().isSupportsInlineDistinct()) {
10273                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
10274                            }
10275                            else {
10276                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
10277                            }
10278                    }
10279    
10280                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10281                                    BlogsEntry.class.getName(),
10282                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10283    
10284                    Session session = null;
10285    
10286                    try {
10287                            session = openSession();
10288    
10289                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
10290    
10291                            if (getDB().isSupportsInlineDistinct()) {
10292                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
10293                            }
10294                            else {
10295                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
10296                            }
10297    
10298                            QueryPos qPos = QueryPos.getInstance(q);
10299    
10300                            qPos.add(groupId);
10301    
10302                            qPos.add(userId);
10303    
10304                            qPos.add(status);
10305    
10306                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
10307                    }
10308                    catch (Exception e) {
10309                            throw processException(e);
10310                    }
10311                    finally {
10312                            closeSession(session);
10313                    }
10314            }
10315    
10316            /**
10317             * 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;.
10318             *
10319             * @param entryId the primary key of the current blogs entry
10320             * @param groupId the group ID
10321             * @param userId the user ID
10322             * @param status the status
10323             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10324             * @return the previous, current, and next blogs entry
10325             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
10326             */
10327            @Override
10328            public BlogsEntry[] filterFindByG_U_S_PrevAndNext(long entryId,
10329                    long groupId, long userId, int status,
10330                    OrderByComparator<BlogsEntry> orderByComparator)
10331                    throws NoSuchEntryException {
10332                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10333                            return findByG_U_S_PrevAndNext(entryId, groupId, userId, status,
10334                                    orderByComparator);
10335                    }
10336    
10337                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
10338    
10339                    Session session = null;
10340    
10341                    try {
10342                            session = openSession();
10343    
10344                            BlogsEntry[] array = new BlogsEntryImpl[3];
10345    
10346                            array[0] = filterGetByG_U_S_PrevAndNext(session, blogsEntry,
10347                                            groupId, userId, status, orderByComparator, true);
10348    
10349                            array[1] = blogsEntry;
10350    
10351                            array[2] = filterGetByG_U_S_PrevAndNext(session, blogsEntry,
10352                                            groupId, userId, status, orderByComparator, false);
10353    
10354                            return array;
10355                    }
10356                    catch (Exception e) {
10357                            throw processException(e);
10358                    }
10359                    finally {
10360                            closeSession(session);
10361                    }
10362            }
10363    
10364            protected BlogsEntry filterGetByG_U_S_PrevAndNext(Session session,
10365                    BlogsEntry blogsEntry, long groupId, long userId, int status,
10366                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
10367                    StringBundler query = null;
10368    
10369                    if (orderByComparator != null) {
10370                            query = new StringBundler(7 +
10371                                            (orderByComparator.getOrderByConditionFields().length * 3) +
10372                                            (orderByComparator.getOrderByFields().length * 3));
10373                    }
10374                    else {
10375                            query = new StringBundler(6);
10376                    }
10377    
10378                    if (getDB().isSupportsInlineDistinct()) {
10379                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
10380                    }
10381                    else {
10382                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
10383                    }
10384    
10385                    query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
10386    
10387                    query.append(_FINDER_COLUMN_G_U_S_USERID_2);
10388    
10389                    query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
10390    
10391                    if (!getDB().isSupportsInlineDistinct()) {
10392                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
10393                    }
10394    
10395                    if (orderByComparator != null) {
10396                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10397    
10398                            if (orderByConditionFields.length > 0) {
10399                                    query.append(WHERE_AND);
10400                            }
10401    
10402                            for (int i = 0; i < orderByConditionFields.length; i++) {
10403                                    if (getDB().isSupportsInlineDistinct()) {
10404                                            query.append(_ORDER_BY_ENTITY_ALIAS);
10405                                    }
10406                                    else {
10407                                            query.append(_ORDER_BY_ENTITY_TABLE);
10408                                    }
10409    
10410                                    query.append(orderByConditionFields[i]);
10411    
10412                                    if ((i + 1) < orderByConditionFields.length) {
10413                                            if (orderByComparator.isAscending() ^ previous) {
10414                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10415                                            }
10416                                            else {
10417                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10418                                            }
10419                                    }
10420                                    else {
10421                                            if (orderByComparator.isAscending() ^ previous) {
10422                                                    query.append(WHERE_GREATER_THAN);
10423                                            }
10424                                            else {
10425                                                    query.append(WHERE_LESSER_THAN);
10426                                            }
10427                                    }
10428                            }
10429    
10430                            query.append(ORDER_BY_CLAUSE);
10431    
10432                            String[] orderByFields = orderByComparator.getOrderByFields();
10433    
10434                            for (int i = 0; i < orderByFields.length; i++) {
10435                                    if (getDB().isSupportsInlineDistinct()) {
10436                                            query.append(_ORDER_BY_ENTITY_ALIAS);
10437                                    }
10438                                    else {
10439                                            query.append(_ORDER_BY_ENTITY_TABLE);
10440                                    }
10441    
10442                                    query.append(orderByFields[i]);
10443    
10444                                    if ((i + 1) < orderByFields.length) {
10445                                            if (orderByComparator.isAscending() ^ previous) {
10446                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10447                                            }
10448                                            else {
10449                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10450                                            }
10451                                    }
10452                                    else {
10453                                            if (orderByComparator.isAscending() ^ previous) {
10454                                                    query.append(ORDER_BY_ASC);
10455                                            }
10456                                            else {
10457                                                    query.append(ORDER_BY_DESC);
10458                                            }
10459                                    }
10460                            }
10461                    }
10462                    else {
10463                            if (getDB().isSupportsInlineDistinct()) {
10464                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
10465                            }
10466                            else {
10467                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
10468                            }
10469                    }
10470    
10471                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10472                                    BlogsEntry.class.getName(),
10473                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10474    
10475                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
10476    
10477                    q.setFirstResult(0);
10478                    q.setMaxResults(2);
10479    
10480                    if (getDB().isSupportsInlineDistinct()) {
10481                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
10482                    }
10483                    else {
10484                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
10485                    }
10486    
10487                    QueryPos qPos = QueryPos.getInstance(q);
10488    
10489                    qPos.add(groupId);
10490    
10491                    qPos.add(userId);
10492    
10493                    qPos.add(status);
10494    
10495                    if (orderByComparator != null) {
10496                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
10497    
10498                            for (Object value : values) {
10499                                    qPos.add(value);
10500                            }
10501                    }
10502    
10503                    List<BlogsEntry> list = q.list();
10504    
10505                    if (list.size() == 2) {
10506                            return list.get(1);
10507                    }
10508                    else {
10509                            return null;
10510                    }
10511            }
10512    
10513            /**
10514             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status = any &#63;.
10515             *
10516             * @param groupId the group ID
10517             * @param userId the user ID
10518             * @param statuses the statuses
10519             * @return the matching blogs entries that the user has permission to view
10520             */
10521            @Override
10522            public List<BlogsEntry> filterFindByG_U_S(long groupId, long userId,
10523                    int[] statuses) {
10524                    return filterFindByG_U_S(groupId, userId, statuses, QueryUtil.ALL_POS,
10525                            QueryUtil.ALL_POS, null);
10526            }
10527    
10528            /**
10529             * 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;.
10530             *
10531             * <p>
10532             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10533             * </p>
10534             *
10535             * @param groupId the group ID
10536             * @param userId the user ID
10537             * @param statuses the statuses
10538             * @param start the lower bound of the range of blogs entries
10539             * @param end the upper bound of the range of blogs entries (not inclusive)
10540             * @return the range of matching blogs entries that the user has permission to view
10541             */
10542            @Override
10543            public List<BlogsEntry> filterFindByG_U_S(long groupId, long userId,
10544                    int[] statuses, int start, int end) {
10545                    return filterFindByG_U_S(groupId, userId, statuses, start, end, null);
10546            }
10547    
10548            /**
10549             * 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;.
10550             *
10551             * <p>
10552             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10553             * </p>
10554             *
10555             * @param groupId the group ID
10556             * @param userId the user ID
10557             * @param statuses the statuses
10558             * @param start the lower bound of the range of blogs entries
10559             * @param end the upper bound of the range of blogs entries (not inclusive)
10560             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10561             * @return the ordered range of matching blogs entries that the user has permission to view
10562             */
10563            @Override
10564            public List<BlogsEntry> filterFindByG_U_S(long groupId, long userId,
10565                    int[] statuses, int start, int end,
10566                    OrderByComparator<BlogsEntry> orderByComparator) {
10567                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10568                            return findByG_U_S(groupId, userId, statuses, start, end,
10569                                    orderByComparator);
10570                    }
10571    
10572                    if (statuses == null) {
10573                            statuses = new int[0];
10574                    }
10575                    else if (statuses.length > 1) {
10576                            statuses = ArrayUtil.unique(statuses);
10577    
10578                            Arrays.sort(statuses);
10579                    }
10580    
10581                    StringBundler query = new StringBundler();
10582    
10583                    if (getDB().isSupportsInlineDistinct()) {
10584                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
10585                    }
10586                    else {
10587                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
10588                    }
10589    
10590                    query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
10591    
10592                    query.append(_FINDER_COLUMN_G_U_S_USERID_2);
10593    
10594                    if (statuses.length > 0) {
10595                            query.append(StringPool.OPEN_PARENTHESIS);
10596    
10597                            query.append(_FINDER_COLUMN_G_U_S_STATUS_7);
10598    
10599                            query.append(StringUtil.merge(statuses));
10600    
10601                            query.append(StringPool.CLOSE_PARENTHESIS);
10602    
10603                            query.append(StringPool.CLOSE_PARENTHESIS);
10604                    }
10605    
10606                    query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
10607                            query.index() - 1);
10608    
10609                    if (!getDB().isSupportsInlineDistinct()) {
10610                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
10611                    }
10612    
10613                    if (orderByComparator != null) {
10614                            if (getDB().isSupportsInlineDistinct()) {
10615                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10616                                            orderByComparator, true);
10617                            }
10618                            else {
10619                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
10620                                            orderByComparator, true);
10621                            }
10622                    }
10623                    else {
10624                            if (getDB().isSupportsInlineDistinct()) {
10625                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
10626                            }
10627                            else {
10628                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
10629                            }
10630                    }
10631    
10632                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10633                                    BlogsEntry.class.getName(),
10634                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10635    
10636                    Session session = null;
10637    
10638                    try {
10639                            session = openSession();
10640    
10641                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
10642    
10643                            if (getDB().isSupportsInlineDistinct()) {
10644                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
10645                            }
10646                            else {
10647                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
10648                            }
10649    
10650                            QueryPos qPos = QueryPos.getInstance(q);
10651    
10652                            qPos.add(groupId);
10653    
10654                            qPos.add(userId);
10655    
10656                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
10657                    }
10658                    catch (Exception e) {
10659                            throw processException(e);
10660                    }
10661                    finally {
10662                            closeSession(session);
10663                    }
10664            }
10665    
10666            /**
10667             * Returns all the blogs entries where groupId = &#63; and userId = &#63; and status = any &#63;.
10668             *
10669             * <p>
10670             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10671             * </p>
10672             *
10673             * @param groupId the group ID
10674             * @param userId the user ID
10675             * @param statuses the statuses
10676             * @return the matching blogs entries
10677             */
10678            @Override
10679            public List<BlogsEntry> findByG_U_S(long groupId, long userId,
10680                    int[] statuses) {
10681                    return findByG_U_S(groupId, userId, statuses, QueryUtil.ALL_POS,
10682                            QueryUtil.ALL_POS, null);
10683            }
10684    
10685            /**
10686             * Returns a range of all the blogs entries where groupId = &#63; and userId = &#63; and status = any &#63;.
10687             *
10688             * <p>
10689             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10690             * </p>
10691             *
10692             * @param groupId the group ID
10693             * @param userId the user ID
10694             * @param statuses the statuses
10695             * @param start the lower bound of the range of blogs entries
10696             * @param end the upper bound of the range of blogs entries (not inclusive)
10697             * @return the range of matching blogs entries
10698             */
10699            @Override
10700            public List<BlogsEntry> findByG_U_S(long groupId, long userId,
10701                    int[] statuses, int start, int end) {
10702                    return findByG_U_S(groupId, userId, statuses, start, end, null);
10703            }
10704    
10705            /**
10706             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and status = any &#63;.
10707             *
10708             * <p>
10709             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10710             * </p>
10711             *
10712             * @param groupId the group ID
10713             * @param userId the user ID
10714             * @param statuses the statuses
10715             * @param start the lower bound of the range of blogs entries
10716             * @param end the upper bound of the range of blogs entries (not inclusive)
10717             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10718             * @return the ordered range of matching blogs entries
10719             */
10720            @Override
10721            public List<BlogsEntry> findByG_U_S(long groupId, long userId,
10722                    int[] statuses, int start, int end,
10723                    OrderByComparator<BlogsEntry> orderByComparator) {
10724                    return findByG_U_S(groupId, userId, statuses, start, end,
10725                            orderByComparator, true);
10726            }
10727    
10728            /**
10729             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and status = &#63;, optionally using the finder cache.
10730             *
10731             * <p>
10732             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10733             * </p>
10734             *
10735             * @param groupId the group ID
10736             * @param userId the user ID
10737             * @param status the status
10738             * @param start the lower bound of the range of blogs entries
10739             * @param end the upper bound of the range of blogs entries (not inclusive)
10740             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10741             * @param retrieveFromCache whether to retrieve from the finder cache
10742             * @return the ordered range of matching blogs entries
10743             */
10744            @Override
10745            public List<BlogsEntry> findByG_U_S(long groupId, long userId,
10746                    int[] statuses, int start, int end,
10747                    OrderByComparator<BlogsEntry> orderByComparator,
10748                    boolean retrieveFromCache) {
10749                    if (statuses == null) {
10750                            statuses = new int[0];
10751                    }
10752                    else if (statuses.length > 1) {
10753                            statuses = ArrayUtil.unique(statuses);
10754    
10755                            Arrays.sort(statuses);
10756                    }
10757    
10758                    if (statuses.length == 1) {
10759                            return findByG_U_S(groupId, userId, statuses[0], start, end,
10760                                    orderByComparator);
10761                    }
10762    
10763                    boolean pagination = true;
10764                    Object[] finderArgs = null;
10765    
10766                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
10767                                    (orderByComparator == null)) {
10768                            pagination = false;
10769                            finderArgs = new Object[] {
10770                                            groupId, userId, StringUtil.merge(statuses)
10771                                    };
10772                    }
10773                    else {
10774                            finderArgs = new Object[] {
10775                                            groupId, userId, StringUtil.merge(statuses),
10776                                            
10777                                            start, end, orderByComparator
10778                                    };
10779                    }
10780    
10781                    List<BlogsEntry> list = null;
10782    
10783                    if (retrieveFromCache) {
10784                            list = (List<BlogsEntry>)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_S,
10785                                            finderArgs, this);
10786    
10787                            if ((list != null) && !list.isEmpty()) {
10788                                    for (BlogsEntry blogsEntry : list) {
10789                                            if ((groupId != blogsEntry.getGroupId()) ||
10790                                                            (userId != blogsEntry.getUserId()) ||
10791                                                            !ArrayUtil.contains(statuses, blogsEntry.getStatus())) {
10792                                                    list = null;
10793    
10794                                                    break;
10795                                            }
10796                                    }
10797                            }
10798                    }
10799    
10800                    if (list == null) {
10801                            StringBundler query = new StringBundler();
10802    
10803                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
10804    
10805                            query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
10806    
10807                            query.append(_FINDER_COLUMN_G_U_S_USERID_2);
10808    
10809                            if (statuses.length > 0) {
10810                                    query.append(StringPool.OPEN_PARENTHESIS);
10811    
10812                                    query.append(_FINDER_COLUMN_G_U_S_STATUS_7);
10813    
10814                                    query.append(StringUtil.merge(statuses));
10815    
10816                                    query.append(StringPool.CLOSE_PARENTHESIS);
10817    
10818                                    query.append(StringPool.CLOSE_PARENTHESIS);
10819                            }
10820    
10821                            query.setStringAt(removeConjunction(query.stringAt(query.index() -
10822                                                    1)), query.index() - 1);
10823    
10824                            if (orderByComparator != null) {
10825                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10826                                            orderByComparator);
10827                            }
10828                            else
10829                             if (pagination) {
10830                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
10831                            }
10832    
10833                            String sql = query.toString();
10834    
10835                            Session session = null;
10836    
10837                            try {
10838                                    session = openSession();
10839    
10840                                    Query q = session.createQuery(sql);
10841    
10842                                    QueryPos qPos = QueryPos.getInstance(q);
10843    
10844                                    qPos.add(groupId);
10845    
10846                                    qPos.add(userId);
10847    
10848                                    if (!pagination) {
10849                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
10850                                                            start, end, false);
10851    
10852                                            Collections.sort(list);
10853    
10854                                            list = Collections.unmodifiableList(list);
10855                                    }
10856                                    else {
10857                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
10858                                                            start, end);
10859                                    }
10860    
10861                                    cacheResult(list);
10862    
10863                                    finderCache.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_S,
10864                                            finderArgs, list);
10865                            }
10866                            catch (Exception e) {
10867                                    finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_S,
10868                                            finderArgs);
10869    
10870                                    throw processException(e);
10871                            }
10872                            finally {
10873                                    closeSession(session);
10874                            }
10875                    }
10876    
10877                    return list;
10878            }
10879    
10880            /**
10881             * Removes all the blogs entries where groupId = &#63; and userId = &#63; and status = &#63; from the database.
10882             *
10883             * @param groupId the group ID
10884             * @param userId the user ID
10885             * @param status the status
10886             */
10887            @Override
10888            public void removeByG_U_S(long groupId, long userId, int status) {
10889                    for (BlogsEntry blogsEntry : findByG_U_S(groupId, userId, status,
10890                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
10891                            remove(blogsEntry);
10892                    }
10893            }
10894    
10895            /**
10896             * Returns the number of blogs entries where groupId = &#63; and userId = &#63; and status = &#63;.
10897             *
10898             * @param groupId the group ID
10899             * @param userId the user ID
10900             * @param status the status
10901             * @return the number of matching blogs entries
10902             */
10903            @Override
10904            public int countByG_U_S(long groupId, long userId, int status) {
10905                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_U_S;
10906    
10907                    Object[] finderArgs = new Object[] { groupId, userId, status };
10908    
10909                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
10910    
10911                    if (count == null) {
10912                            StringBundler query = new StringBundler(4);
10913    
10914                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
10915    
10916                            query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
10917    
10918                            query.append(_FINDER_COLUMN_G_U_S_USERID_2);
10919    
10920                            query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
10921    
10922                            String sql = query.toString();
10923    
10924                            Session session = null;
10925    
10926                            try {
10927                                    session = openSession();
10928    
10929                                    Query q = session.createQuery(sql);
10930    
10931                                    QueryPos qPos = QueryPos.getInstance(q);
10932    
10933                                    qPos.add(groupId);
10934    
10935                                    qPos.add(userId);
10936    
10937                                    qPos.add(status);
10938    
10939                                    count = (Long)q.uniqueResult();
10940    
10941                                    finderCache.putResult(finderPath, finderArgs, count);
10942                            }
10943                            catch (Exception e) {
10944                                    finderCache.removeResult(finderPath, finderArgs);
10945    
10946                                    throw processException(e);
10947                            }
10948                            finally {
10949                                    closeSession(session);
10950                            }
10951                    }
10952    
10953                    return count.intValue();
10954            }
10955    
10956            /**
10957             * Returns the number of blogs entries where groupId = &#63; and userId = &#63; and status = any &#63;.
10958             *
10959             * @param groupId the group ID
10960             * @param userId the user ID
10961             * @param statuses the statuses
10962             * @return the number of matching blogs entries
10963             */
10964            @Override
10965            public int countByG_U_S(long groupId, long userId, int[] statuses) {
10966                    if (statuses == null) {
10967                            statuses = new int[0];
10968                    }
10969                    else if (statuses.length > 1) {
10970                            statuses = ArrayUtil.unique(statuses);
10971    
10972                            Arrays.sort(statuses);
10973                    }
10974    
10975                    Object[] finderArgs = new Object[] {
10976                                    groupId, userId, StringUtil.merge(statuses)
10977                            };
10978    
10979                    Long count = (Long)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_S,
10980                                    finderArgs, this);
10981    
10982                    if (count == null) {
10983                            StringBundler query = new StringBundler();
10984    
10985                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
10986    
10987                            query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
10988    
10989                            query.append(_FINDER_COLUMN_G_U_S_USERID_2);
10990    
10991                            if (statuses.length > 0) {
10992                                    query.append(StringPool.OPEN_PARENTHESIS);
10993    
10994                                    query.append(_FINDER_COLUMN_G_U_S_STATUS_7);
10995    
10996                                    query.append(StringUtil.merge(statuses));
10997    
10998                                    query.append(StringPool.CLOSE_PARENTHESIS);
10999    
11000                                    query.append(StringPool.CLOSE_PARENTHESIS);
11001                            }
11002    
11003                            query.setStringAt(removeConjunction(query.stringAt(query.index() -
11004                                                    1)), query.index() - 1);
11005    
11006                            String sql = query.toString();
11007    
11008                            Session session = null;
11009    
11010                            try {
11011                                    session = openSession();
11012    
11013                                    Query q = session.createQuery(sql);
11014    
11015                                    QueryPos qPos = QueryPos.getInstance(q);
11016    
11017                                    qPos.add(groupId);
11018    
11019                                    qPos.add(userId);
11020    
11021                                    count = (Long)q.uniqueResult();
11022    
11023                                    finderCache.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_S,
11024                                            finderArgs, count);
11025                            }
11026                            catch (Exception e) {
11027                                    finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_S,
11028                                            finderArgs);
11029    
11030                                    throw processException(e);
11031                            }
11032                            finally {
11033                                    closeSession(session);
11034                            }
11035                    }
11036    
11037                    return count.intValue();
11038            }
11039    
11040            /**
11041             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status = &#63;.
11042             *
11043             * @param groupId the group ID
11044             * @param userId the user ID
11045             * @param status the status
11046             * @return the number of matching blogs entries that the user has permission to view
11047             */
11048            @Override
11049            public int filterCountByG_U_S(long groupId, long userId, int status) {
11050                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11051                            return countByG_U_S(groupId, userId, status);
11052                    }
11053    
11054                    StringBundler query = new StringBundler(4);
11055    
11056                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
11057    
11058                    query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
11059    
11060                    query.append(_FINDER_COLUMN_G_U_S_USERID_2);
11061    
11062                    query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
11063    
11064                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11065                                    BlogsEntry.class.getName(),
11066                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11067    
11068                    Session session = null;
11069    
11070                    try {
11071                            session = openSession();
11072    
11073                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
11074    
11075                            q.addScalar(COUNT_COLUMN_NAME,
11076                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
11077    
11078                            QueryPos qPos = QueryPos.getInstance(q);
11079    
11080                            qPos.add(groupId);
11081    
11082                            qPos.add(userId);
11083    
11084                            qPos.add(status);
11085    
11086                            Long count = (Long)q.uniqueResult();
11087    
11088                            return count.intValue();
11089                    }
11090                    catch (Exception e) {
11091                            throw processException(e);
11092                    }
11093                    finally {
11094                            closeSession(session);
11095                    }
11096            }
11097    
11098            /**
11099             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status = any &#63;.
11100             *
11101             * @param groupId the group ID
11102             * @param userId the user ID
11103             * @param statuses the statuses
11104             * @return the number of matching blogs entries that the user has permission to view
11105             */
11106            @Override
11107            public int filterCountByG_U_S(long groupId, long userId, int[] statuses) {
11108                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11109                            return countByG_U_S(groupId, userId, statuses);
11110                    }
11111    
11112                    if (statuses == null) {
11113                            statuses = new int[0];
11114                    }
11115                    else if (statuses.length > 1) {
11116                            statuses = ArrayUtil.unique(statuses);
11117    
11118                            Arrays.sort(statuses);
11119                    }
11120    
11121                    StringBundler query = new StringBundler();
11122    
11123                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
11124    
11125                    query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
11126    
11127                    query.append(_FINDER_COLUMN_G_U_S_USERID_2);
11128    
11129                    if (statuses.length > 0) {
11130                            query.append(StringPool.OPEN_PARENTHESIS);
11131    
11132                            query.append(_FINDER_COLUMN_G_U_S_STATUS_7);
11133    
11134                            query.append(StringUtil.merge(statuses));
11135    
11136                            query.append(StringPool.CLOSE_PARENTHESIS);
11137    
11138                            query.append(StringPool.CLOSE_PARENTHESIS);
11139                    }
11140    
11141                    query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
11142                            query.index() - 1);
11143    
11144                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11145                                    BlogsEntry.class.getName(),
11146                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11147    
11148                    Session session = null;
11149    
11150                    try {
11151                            session = openSession();
11152    
11153                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
11154    
11155                            q.addScalar(COUNT_COLUMN_NAME,
11156                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
11157    
11158                            QueryPos qPos = QueryPos.getInstance(q);
11159    
11160                            qPos.add(groupId);
11161    
11162                            qPos.add(userId);
11163    
11164                            Long count = (Long)q.uniqueResult();
11165    
11166                            return count.intValue();
11167                    }
11168                    catch (Exception e) {
11169                            throw processException(e);
11170                    }
11171                    finally {
11172                            closeSession(session);
11173                    }
11174            }
11175    
11176            private static final String _FINDER_COLUMN_G_U_S_GROUPID_2 = "blogsEntry.groupId = ? AND ";
11177            private static final String _FINDER_COLUMN_G_U_S_USERID_2 = "blogsEntry.userId = ? AND ";
11178            private static final String _FINDER_COLUMN_G_U_S_STATUS_2 = "blogsEntry.status = ?";
11179            private static final String _FINDER_COLUMN_G_U_S_STATUS_7 = "blogsEntry.status IN (";
11180            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_NOTS = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
11181                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
11182                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_NotS",
11183                            new String[] {
11184                                    Long.class.getName(), Long.class.getName(),
11185                                    Integer.class.getName(),
11186                                    
11187                            Integer.class.getName(), Integer.class.getName(),
11188                                    OrderByComparator.class.getName()
11189                            });
11190            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_NOTS =
11191                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
11192                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
11193                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_U_NotS",
11194                            new String[] {
11195                                    Long.class.getName(), Long.class.getName(),
11196                                    Integer.class.getName()
11197                            });
11198    
11199            /**
11200             * Returns all the blogs entries where groupId = &#63; and userId = &#63; and status &ne; &#63;.
11201             *
11202             * @param groupId the group ID
11203             * @param userId the user ID
11204             * @param status the status
11205             * @return the matching blogs entries
11206             */
11207            @Override
11208            public List<BlogsEntry> findByG_U_NotS(long groupId, long userId, int status) {
11209                    return findByG_U_NotS(groupId, userId, status, QueryUtil.ALL_POS,
11210                            QueryUtil.ALL_POS, null);
11211            }
11212    
11213            /**
11214             * Returns a range of all the blogs entries where groupId = &#63; and userId = &#63; and status &ne; &#63;.
11215             *
11216             * <p>
11217             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11218             * </p>
11219             *
11220             * @param groupId the group ID
11221             * @param userId the user ID
11222             * @param status the status
11223             * @param start the lower bound of the range of blogs entries
11224             * @param end the upper bound of the range of blogs entries (not inclusive)
11225             * @return the range of matching blogs entries
11226             */
11227            @Override
11228            public List<BlogsEntry> findByG_U_NotS(long groupId, long userId,
11229                    int status, int start, int end) {
11230                    return findByG_U_NotS(groupId, userId, status, start, end, null);
11231            }
11232    
11233            /**
11234             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and status &ne; &#63;.
11235             *
11236             * <p>
11237             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11238             * </p>
11239             *
11240             * @param groupId the group ID
11241             * @param userId the user ID
11242             * @param status the status
11243             * @param start the lower bound of the range of blogs entries
11244             * @param end the upper bound of the range of blogs entries (not inclusive)
11245             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11246             * @return the ordered range of matching blogs entries
11247             */
11248            @Override
11249            public List<BlogsEntry> findByG_U_NotS(long groupId, long userId,
11250                    int status, int start, int end,
11251                    OrderByComparator<BlogsEntry> orderByComparator) {
11252                    return findByG_U_NotS(groupId, userId, status, start, end,
11253                            orderByComparator, true);
11254            }
11255    
11256            /**
11257             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and status &ne; &#63;.
11258             *
11259             * <p>
11260             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11261             * </p>
11262             *
11263             * @param groupId the group ID
11264             * @param userId the user ID
11265             * @param status the status
11266             * @param start the lower bound of the range of blogs entries
11267             * @param end the upper bound of the range of blogs entries (not inclusive)
11268             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11269             * @param retrieveFromCache whether to retrieve from the finder cache
11270             * @return the ordered range of matching blogs entries
11271             */
11272            @Override
11273            public List<BlogsEntry> findByG_U_NotS(long groupId, long userId,
11274                    int status, int start, int end,
11275                    OrderByComparator<BlogsEntry> orderByComparator,
11276                    boolean retrieveFromCache) {
11277                    boolean pagination = true;
11278                    FinderPath finderPath = null;
11279                    Object[] finderArgs = null;
11280    
11281                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_NOTS;
11282                    finderArgs = new Object[] {
11283                                    groupId, userId, status,
11284                                    
11285                                    start, end, orderByComparator
11286                            };
11287    
11288                    List<BlogsEntry> list = null;
11289    
11290                    if (retrieveFromCache) {
11291                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
11292                                            finderArgs, this);
11293    
11294                            if ((list != null) && !list.isEmpty()) {
11295                                    for (BlogsEntry blogsEntry : list) {
11296                                            if ((groupId != blogsEntry.getGroupId()) ||
11297                                                            (userId != blogsEntry.getUserId()) ||
11298                                                            (status == blogsEntry.getStatus())) {
11299                                                    list = null;
11300    
11301                                                    break;
11302                                            }
11303                                    }
11304                            }
11305                    }
11306    
11307                    if (list == null) {
11308                            StringBundler query = null;
11309    
11310                            if (orderByComparator != null) {
11311                                    query = new StringBundler(5 +
11312                                                    (orderByComparator.getOrderByFields().length * 2));
11313                            }
11314                            else {
11315                                    query = new StringBundler(5);
11316                            }
11317    
11318                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
11319    
11320                            query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
11321    
11322                            query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
11323    
11324                            query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
11325    
11326                            if (orderByComparator != null) {
11327                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11328                                            orderByComparator);
11329                            }
11330                            else
11331                             if (pagination) {
11332                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
11333                            }
11334    
11335                            String sql = query.toString();
11336    
11337                            Session session = null;
11338    
11339                            try {
11340                                    session = openSession();
11341    
11342                                    Query q = session.createQuery(sql);
11343    
11344                                    QueryPos qPos = QueryPos.getInstance(q);
11345    
11346                                    qPos.add(groupId);
11347    
11348                                    qPos.add(userId);
11349    
11350                                    qPos.add(status);
11351    
11352                                    if (!pagination) {
11353                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
11354                                                            start, end, false);
11355    
11356                                            Collections.sort(list);
11357    
11358                                            list = Collections.unmodifiableList(list);
11359                                    }
11360                                    else {
11361                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
11362                                                            start, end);
11363                                    }
11364    
11365                                    cacheResult(list);
11366    
11367                                    finderCache.putResult(finderPath, finderArgs, list);
11368                            }
11369                            catch (Exception e) {
11370                                    finderCache.removeResult(finderPath, finderArgs);
11371    
11372                                    throw processException(e);
11373                            }
11374                            finally {
11375                                    closeSession(session);
11376                            }
11377                    }
11378    
11379                    return list;
11380            }
11381    
11382            /**
11383             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status &ne; &#63;.
11384             *
11385             * @param groupId the group ID
11386             * @param userId the user ID
11387             * @param status the status
11388             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11389             * @return the first matching blogs entry
11390             * @throws NoSuchEntryException if a matching blogs entry could not be found
11391             */
11392            @Override
11393            public BlogsEntry findByG_U_NotS_First(long groupId, long userId,
11394                    int status, OrderByComparator<BlogsEntry> orderByComparator)
11395                    throws NoSuchEntryException {
11396                    BlogsEntry blogsEntry = fetchByG_U_NotS_First(groupId, userId, status,
11397                                    orderByComparator);
11398    
11399                    if (blogsEntry != null) {
11400                            return blogsEntry;
11401                    }
11402    
11403                    StringBundler msg = new StringBundler(8);
11404    
11405                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11406    
11407                    msg.append("groupId=");
11408                    msg.append(groupId);
11409    
11410                    msg.append(", userId=");
11411                    msg.append(userId);
11412    
11413                    msg.append(", status=");
11414                    msg.append(status);
11415    
11416                    msg.append(StringPool.CLOSE_CURLY_BRACE);
11417    
11418                    throw new NoSuchEntryException(msg.toString());
11419            }
11420    
11421            /**
11422             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status &ne; &#63;.
11423             *
11424             * @param groupId the group ID
11425             * @param userId the user ID
11426             * @param status the status
11427             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11428             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
11429             */
11430            @Override
11431            public BlogsEntry fetchByG_U_NotS_First(long groupId, long userId,
11432                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
11433                    List<BlogsEntry> list = findByG_U_NotS(groupId, userId, status, 0, 1,
11434                                    orderByComparator);
11435    
11436                    if (!list.isEmpty()) {
11437                            return list.get(0);
11438                    }
11439    
11440                    return null;
11441            }
11442    
11443            /**
11444             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status &ne; &#63;.
11445             *
11446             * @param groupId the group ID
11447             * @param userId the user ID
11448             * @param status the status
11449             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11450             * @return the last matching blogs entry
11451             * @throws NoSuchEntryException if a matching blogs entry could not be found
11452             */
11453            @Override
11454            public BlogsEntry findByG_U_NotS_Last(long groupId, long userId,
11455                    int status, OrderByComparator<BlogsEntry> orderByComparator)
11456                    throws NoSuchEntryException {
11457                    BlogsEntry blogsEntry = fetchByG_U_NotS_Last(groupId, userId, status,
11458                                    orderByComparator);
11459    
11460                    if (blogsEntry != null) {
11461                            return blogsEntry;
11462                    }
11463    
11464                    StringBundler msg = new StringBundler(8);
11465    
11466                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11467    
11468                    msg.append("groupId=");
11469                    msg.append(groupId);
11470    
11471                    msg.append(", userId=");
11472                    msg.append(userId);
11473    
11474                    msg.append(", status=");
11475                    msg.append(status);
11476    
11477                    msg.append(StringPool.CLOSE_CURLY_BRACE);
11478    
11479                    throw new NoSuchEntryException(msg.toString());
11480            }
11481    
11482            /**
11483             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status &ne; &#63;.
11484             *
11485             * @param groupId the group ID
11486             * @param userId the user ID
11487             * @param status the status
11488             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11489             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
11490             */
11491            @Override
11492            public BlogsEntry fetchByG_U_NotS_Last(long groupId, long userId,
11493                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
11494                    int count = countByG_U_NotS(groupId, userId, status);
11495    
11496                    if (count == 0) {
11497                            return null;
11498                    }
11499    
11500                    List<BlogsEntry> list = findByG_U_NotS(groupId, userId, status,
11501                                    count - 1, count, orderByComparator);
11502    
11503                    if (!list.isEmpty()) {
11504                            return list.get(0);
11505                    }
11506    
11507                    return null;
11508            }
11509    
11510            /**
11511             * 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;.
11512             *
11513             * @param entryId the primary key of the current blogs entry
11514             * @param groupId the group ID
11515             * @param userId the user ID
11516             * @param status the status
11517             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11518             * @return the previous, current, and next blogs entry
11519             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
11520             */
11521            @Override
11522            public BlogsEntry[] findByG_U_NotS_PrevAndNext(long entryId, long groupId,
11523                    long userId, int status, OrderByComparator<BlogsEntry> orderByComparator)
11524                    throws NoSuchEntryException {
11525                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
11526    
11527                    Session session = null;
11528    
11529                    try {
11530                            session = openSession();
11531    
11532                            BlogsEntry[] array = new BlogsEntryImpl[3];
11533    
11534                            array[0] = getByG_U_NotS_PrevAndNext(session, blogsEntry, groupId,
11535                                            userId, status, orderByComparator, true);
11536    
11537                            array[1] = blogsEntry;
11538    
11539                            array[2] = getByG_U_NotS_PrevAndNext(session, blogsEntry, groupId,
11540                                            userId, status, orderByComparator, false);
11541    
11542                            return array;
11543                    }
11544                    catch (Exception e) {
11545                            throw processException(e);
11546                    }
11547                    finally {
11548                            closeSession(session);
11549                    }
11550            }
11551    
11552            protected BlogsEntry getByG_U_NotS_PrevAndNext(Session session,
11553                    BlogsEntry blogsEntry, long groupId, long userId, int status,
11554                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
11555                    StringBundler query = null;
11556    
11557                    if (orderByComparator != null) {
11558                            query = new StringBundler(6 +
11559                                            (orderByComparator.getOrderByConditionFields().length * 3) +
11560                                            (orderByComparator.getOrderByFields().length * 3));
11561                    }
11562                    else {
11563                            query = new StringBundler(5);
11564                    }
11565    
11566                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
11567    
11568                    query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
11569    
11570                    query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
11571    
11572                    query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
11573    
11574                    if (orderByComparator != null) {
11575                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11576    
11577                            if (orderByConditionFields.length > 0) {
11578                                    query.append(WHERE_AND);
11579                            }
11580    
11581                            for (int i = 0; i < orderByConditionFields.length; i++) {
11582                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11583                                    query.append(orderByConditionFields[i]);
11584    
11585                                    if ((i + 1) < orderByConditionFields.length) {
11586                                            if (orderByComparator.isAscending() ^ previous) {
11587                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
11588                                            }
11589                                            else {
11590                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
11591                                            }
11592                                    }
11593                                    else {
11594                                            if (orderByComparator.isAscending() ^ previous) {
11595                                                    query.append(WHERE_GREATER_THAN);
11596                                            }
11597                                            else {
11598                                                    query.append(WHERE_LESSER_THAN);
11599                                            }
11600                                    }
11601                            }
11602    
11603                            query.append(ORDER_BY_CLAUSE);
11604    
11605                            String[] orderByFields = orderByComparator.getOrderByFields();
11606    
11607                            for (int i = 0; i < orderByFields.length; i++) {
11608                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11609                                    query.append(orderByFields[i]);
11610    
11611                                    if ((i + 1) < orderByFields.length) {
11612                                            if (orderByComparator.isAscending() ^ previous) {
11613                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
11614                                            }
11615                                            else {
11616                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
11617                                            }
11618                                    }
11619                                    else {
11620                                            if (orderByComparator.isAscending() ^ previous) {
11621                                                    query.append(ORDER_BY_ASC);
11622                                            }
11623                                            else {
11624                                                    query.append(ORDER_BY_DESC);
11625                                            }
11626                                    }
11627                            }
11628                    }
11629                    else {
11630                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
11631                    }
11632    
11633                    String sql = query.toString();
11634    
11635                    Query q = session.createQuery(sql);
11636    
11637                    q.setFirstResult(0);
11638                    q.setMaxResults(2);
11639    
11640                    QueryPos qPos = QueryPos.getInstance(q);
11641    
11642                    qPos.add(groupId);
11643    
11644                    qPos.add(userId);
11645    
11646                    qPos.add(status);
11647    
11648                    if (orderByComparator != null) {
11649                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
11650    
11651                            for (Object value : values) {
11652                                    qPos.add(value);
11653                            }
11654                    }
11655    
11656                    List<BlogsEntry> list = q.list();
11657    
11658                    if (list.size() == 2) {
11659                            return list.get(1);
11660                    }
11661                    else {
11662                            return null;
11663                    }
11664            }
11665    
11666            /**
11667             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status &ne; &#63;.
11668             *
11669             * @param groupId the group ID
11670             * @param userId the user ID
11671             * @param status the status
11672             * @return the matching blogs entries that the user has permission to view
11673             */
11674            @Override
11675            public List<BlogsEntry> filterFindByG_U_NotS(long groupId, long userId,
11676                    int status) {
11677                    return filterFindByG_U_NotS(groupId, userId, status, QueryUtil.ALL_POS,
11678                            QueryUtil.ALL_POS, null);
11679            }
11680    
11681            /**
11682             * 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;.
11683             *
11684             * <p>
11685             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11686             * </p>
11687             *
11688             * @param groupId the group ID
11689             * @param userId the user ID
11690             * @param status the status
11691             * @param start the lower bound of the range of blogs entries
11692             * @param end the upper bound of the range of blogs entries (not inclusive)
11693             * @return the range of matching blogs entries that the user has permission to view
11694             */
11695            @Override
11696            public List<BlogsEntry> filterFindByG_U_NotS(long groupId, long userId,
11697                    int status, int start, int end) {
11698                    return filterFindByG_U_NotS(groupId, userId, status, start, end, null);
11699            }
11700    
11701            /**
11702             * 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;.
11703             *
11704             * <p>
11705             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11706             * </p>
11707             *
11708             * @param groupId the group ID
11709             * @param userId the user ID
11710             * @param status the status
11711             * @param start the lower bound of the range of blogs entries
11712             * @param end the upper bound of the range of blogs entries (not inclusive)
11713             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11714             * @return the ordered range of matching blogs entries that the user has permission to view
11715             */
11716            @Override
11717            public List<BlogsEntry> filterFindByG_U_NotS(long groupId, long userId,
11718                    int status, int start, int end,
11719                    OrderByComparator<BlogsEntry> orderByComparator) {
11720                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11721                            return findByG_U_NotS(groupId, userId, status, start, end,
11722                                    orderByComparator);
11723                    }
11724    
11725                    StringBundler query = null;
11726    
11727                    if (orderByComparator != null) {
11728                            query = new StringBundler(5 +
11729                                            (orderByComparator.getOrderByFields().length * 2));
11730                    }
11731                    else {
11732                            query = new StringBundler(6);
11733                    }
11734    
11735                    if (getDB().isSupportsInlineDistinct()) {
11736                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
11737                    }
11738                    else {
11739                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
11740                    }
11741    
11742                    query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
11743    
11744                    query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
11745    
11746                    query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
11747    
11748                    if (!getDB().isSupportsInlineDistinct()) {
11749                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
11750                    }
11751    
11752                    if (orderByComparator != null) {
11753                            if (getDB().isSupportsInlineDistinct()) {
11754                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11755                                            orderByComparator, true);
11756                            }
11757                            else {
11758                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
11759                                            orderByComparator, true);
11760                            }
11761                    }
11762                    else {
11763                            if (getDB().isSupportsInlineDistinct()) {
11764                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
11765                            }
11766                            else {
11767                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
11768                            }
11769                    }
11770    
11771                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11772                                    BlogsEntry.class.getName(),
11773                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11774    
11775                    Session session = null;
11776    
11777                    try {
11778                            session = openSession();
11779    
11780                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
11781    
11782                            if (getDB().isSupportsInlineDistinct()) {
11783                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
11784                            }
11785                            else {
11786                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
11787                            }
11788    
11789                            QueryPos qPos = QueryPos.getInstance(q);
11790    
11791                            qPos.add(groupId);
11792    
11793                            qPos.add(userId);
11794    
11795                            qPos.add(status);
11796    
11797                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
11798                    }
11799                    catch (Exception e) {
11800                            throw processException(e);
11801                    }
11802                    finally {
11803                            closeSession(session);
11804                    }
11805            }
11806    
11807            /**
11808             * 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;.
11809             *
11810             * @param entryId the primary key of the current blogs entry
11811             * @param groupId the group ID
11812             * @param userId the user ID
11813             * @param status the status
11814             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11815             * @return the previous, current, and next blogs entry
11816             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
11817             */
11818            @Override
11819            public BlogsEntry[] filterFindByG_U_NotS_PrevAndNext(long entryId,
11820                    long groupId, long userId, int status,
11821                    OrderByComparator<BlogsEntry> orderByComparator)
11822                    throws NoSuchEntryException {
11823                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11824                            return findByG_U_NotS_PrevAndNext(entryId, groupId, userId, status,
11825                                    orderByComparator);
11826                    }
11827    
11828                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
11829    
11830                    Session session = null;
11831    
11832                    try {
11833                            session = openSession();
11834    
11835                            BlogsEntry[] array = new BlogsEntryImpl[3];
11836    
11837                            array[0] = filterGetByG_U_NotS_PrevAndNext(session, blogsEntry,
11838                                            groupId, userId, status, orderByComparator, true);
11839    
11840                            array[1] = blogsEntry;
11841    
11842                            array[2] = filterGetByG_U_NotS_PrevAndNext(session, blogsEntry,
11843                                            groupId, userId, status, orderByComparator, false);
11844    
11845                            return array;
11846                    }
11847                    catch (Exception e) {
11848                            throw processException(e);
11849                    }
11850                    finally {
11851                            closeSession(session);
11852                    }
11853            }
11854    
11855            protected BlogsEntry filterGetByG_U_NotS_PrevAndNext(Session session,
11856                    BlogsEntry blogsEntry, long groupId, long userId, int status,
11857                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
11858                    StringBundler query = null;
11859    
11860                    if (orderByComparator != null) {
11861                            query = new StringBundler(7 +
11862                                            (orderByComparator.getOrderByConditionFields().length * 3) +
11863                                            (orderByComparator.getOrderByFields().length * 3));
11864                    }
11865                    else {
11866                            query = new StringBundler(6);
11867                    }
11868    
11869                    if (getDB().isSupportsInlineDistinct()) {
11870                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
11871                    }
11872                    else {
11873                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
11874                    }
11875    
11876                    query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
11877    
11878                    query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
11879    
11880                    query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
11881    
11882                    if (!getDB().isSupportsInlineDistinct()) {
11883                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
11884                    }
11885    
11886                    if (orderByComparator != null) {
11887                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11888    
11889                            if (orderByConditionFields.length > 0) {
11890                                    query.append(WHERE_AND);
11891                            }
11892    
11893                            for (int i = 0; i < orderByConditionFields.length; i++) {
11894                                    if (getDB().isSupportsInlineDistinct()) {
11895                                            query.append(_ORDER_BY_ENTITY_ALIAS);
11896                                    }
11897                                    else {
11898                                            query.append(_ORDER_BY_ENTITY_TABLE);
11899                                    }
11900    
11901                                    query.append(orderByConditionFields[i]);
11902    
11903                                    if ((i + 1) < orderByConditionFields.length) {
11904                                            if (orderByComparator.isAscending() ^ previous) {
11905                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
11906                                            }
11907                                            else {
11908                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
11909                                            }
11910                                    }
11911                                    else {
11912                                            if (orderByComparator.isAscending() ^ previous) {
11913                                                    query.append(WHERE_GREATER_THAN);
11914                                            }
11915                                            else {
11916                                                    query.append(WHERE_LESSER_THAN);
11917                                            }
11918                                    }
11919                            }
11920    
11921                            query.append(ORDER_BY_CLAUSE);
11922    
11923                            String[] orderByFields = orderByComparator.getOrderByFields();
11924    
11925                            for (int i = 0; i < orderByFields.length; i++) {
11926                                    if (getDB().isSupportsInlineDistinct()) {
11927                                            query.append(_ORDER_BY_ENTITY_ALIAS);
11928                                    }
11929                                    else {
11930                                            query.append(_ORDER_BY_ENTITY_TABLE);
11931                                    }
11932    
11933                                    query.append(orderByFields[i]);
11934    
11935                                    if ((i + 1) < orderByFields.length) {
11936                                            if (orderByComparator.isAscending() ^ previous) {
11937                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
11938                                            }
11939                                            else {
11940                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
11941                                            }
11942                                    }
11943                                    else {
11944                                            if (orderByComparator.isAscending() ^ previous) {
11945                                                    query.append(ORDER_BY_ASC);
11946                                            }
11947                                            else {
11948                                                    query.append(ORDER_BY_DESC);
11949                                            }
11950                                    }
11951                            }
11952                    }
11953                    else {
11954                            if (getDB().isSupportsInlineDistinct()) {
11955                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
11956                            }
11957                            else {
11958                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
11959                            }
11960                    }
11961    
11962                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11963                                    BlogsEntry.class.getName(),
11964                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11965    
11966                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
11967    
11968                    q.setFirstResult(0);
11969                    q.setMaxResults(2);
11970    
11971                    if (getDB().isSupportsInlineDistinct()) {
11972                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
11973                    }
11974                    else {
11975                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
11976                    }
11977    
11978                    QueryPos qPos = QueryPos.getInstance(q);
11979    
11980                    qPos.add(groupId);
11981    
11982                    qPos.add(userId);
11983    
11984                    qPos.add(status);
11985    
11986                    if (orderByComparator != null) {
11987                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
11988    
11989                            for (Object value : values) {
11990                                    qPos.add(value);
11991                            }
11992                    }
11993    
11994                    List<BlogsEntry> list = q.list();
11995    
11996                    if (list.size() == 2) {
11997                            return list.get(1);
11998                    }
11999                    else {
12000                            return null;
12001                    }
12002            }
12003    
12004            /**
12005             * Removes all the blogs entries where groupId = &#63; and userId = &#63; and status &ne; &#63; from the database.
12006             *
12007             * @param groupId the group ID
12008             * @param userId the user ID
12009             * @param status the status
12010             */
12011            @Override
12012            public void removeByG_U_NotS(long groupId, long userId, int status) {
12013                    for (BlogsEntry blogsEntry : findByG_U_NotS(groupId, userId, status,
12014                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
12015                            remove(blogsEntry);
12016                    }
12017            }
12018    
12019            /**
12020             * Returns the number of blogs entries where groupId = &#63; and userId = &#63; and status &ne; &#63;.
12021             *
12022             * @param groupId the group ID
12023             * @param userId the user ID
12024             * @param status the status
12025             * @return the number of matching blogs entries
12026             */
12027            @Override
12028            public int countByG_U_NotS(long groupId, long userId, int status) {
12029                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_NOTS;
12030    
12031                    Object[] finderArgs = new Object[] { groupId, userId, status };
12032    
12033                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
12034    
12035                    if (count == null) {
12036                            StringBundler query = new StringBundler(4);
12037    
12038                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
12039    
12040                            query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
12041    
12042                            query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
12043    
12044                            query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
12045    
12046                            String sql = query.toString();
12047    
12048                            Session session = null;
12049    
12050                            try {
12051                                    session = openSession();
12052    
12053                                    Query q = session.createQuery(sql);
12054    
12055                                    QueryPos qPos = QueryPos.getInstance(q);
12056    
12057                                    qPos.add(groupId);
12058    
12059                                    qPos.add(userId);
12060    
12061                                    qPos.add(status);
12062    
12063                                    count = (Long)q.uniqueResult();
12064    
12065                                    finderCache.putResult(finderPath, finderArgs, count);
12066                            }
12067                            catch (Exception e) {
12068                                    finderCache.removeResult(finderPath, finderArgs);
12069    
12070                                    throw processException(e);
12071                            }
12072                            finally {
12073                                    closeSession(session);
12074                            }
12075                    }
12076    
12077                    return count.intValue();
12078            }
12079    
12080            /**
12081             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status &ne; &#63;.
12082             *
12083             * @param groupId the group ID
12084             * @param userId the user ID
12085             * @param status the status
12086             * @return the number of matching blogs entries that the user has permission to view
12087             */
12088            @Override
12089            public int filterCountByG_U_NotS(long groupId, long userId, int status) {
12090                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12091                            return countByG_U_NotS(groupId, userId, status);
12092                    }
12093    
12094                    StringBundler query = new StringBundler(4);
12095    
12096                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
12097    
12098                    query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
12099    
12100                    query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
12101    
12102                    query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
12103    
12104                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12105                                    BlogsEntry.class.getName(),
12106                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12107    
12108                    Session session = null;
12109    
12110                    try {
12111                            session = openSession();
12112    
12113                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
12114    
12115                            q.addScalar(COUNT_COLUMN_NAME,
12116                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
12117    
12118                            QueryPos qPos = QueryPos.getInstance(q);
12119    
12120                            qPos.add(groupId);
12121    
12122                            qPos.add(userId);
12123    
12124                            qPos.add(status);
12125    
12126                            Long count = (Long)q.uniqueResult();
12127    
12128                            return count.intValue();
12129                    }
12130                    catch (Exception e) {
12131                            throw processException(e);
12132                    }
12133                    finally {
12134                            closeSession(session);
12135                    }
12136            }
12137    
12138            private static final String _FINDER_COLUMN_G_U_NOTS_GROUPID_2 = "blogsEntry.groupId = ? AND ";
12139            private static final String _FINDER_COLUMN_G_U_NOTS_USERID_2 = "blogsEntry.userId = ? AND ";
12140            private static final String _FINDER_COLUMN_G_U_NOTS_STATUS_2 = "blogsEntry.status != ?";
12141            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
12142                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
12143                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_LtD_S",
12144                            new String[] {
12145                                    Long.class.getName(), Date.class.getName(),
12146                                    Integer.class.getName(),
12147                                    
12148                            Integer.class.getName(), Integer.class.getName(),
12149                                    OrderByComparator.class.getName()
12150                            });
12151            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
12152                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
12153                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_LtD_S",
12154                            new String[] {
12155                                    Long.class.getName(), Date.class.getName(),
12156                                    Integer.class.getName()
12157                            });
12158    
12159            /**
12160             * Returns all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
12161             *
12162             * @param groupId the group ID
12163             * @param displayDate the display date
12164             * @param status the status
12165             * @return the matching blogs entries
12166             */
12167            @Override
12168            public List<BlogsEntry> findByG_LtD_S(long groupId, Date displayDate,
12169                    int status) {
12170                    return findByG_LtD_S(groupId, displayDate, status, QueryUtil.ALL_POS,
12171                            QueryUtil.ALL_POS, null);
12172            }
12173    
12174            /**
12175             * Returns a range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
12176             *
12177             * <p>
12178             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
12179             * </p>
12180             *
12181             * @param groupId the group ID
12182             * @param displayDate the display date
12183             * @param status the status
12184             * @param start the lower bound of the range of blogs entries
12185             * @param end the upper bound of the range of blogs entries (not inclusive)
12186             * @return the range of matching blogs entries
12187             */
12188            @Override
12189            public List<BlogsEntry> findByG_LtD_S(long groupId, Date displayDate,
12190                    int status, int start, int end) {
12191                    return findByG_LtD_S(groupId, displayDate, status, start, end, null);
12192            }
12193    
12194            /**
12195             * Returns an ordered range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
12196             *
12197             * <p>
12198             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
12199             * </p>
12200             *
12201             * @param groupId the group ID
12202             * @param displayDate the display date
12203             * @param status the status
12204             * @param start the lower bound of the range of blogs entries
12205             * @param end the upper bound of the range of blogs entries (not inclusive)
12206             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12207             * @return the ordered range of matching blogs entries
12208             */
12209            @Override
12210            public List<BlogsEntry> findByG_LtD_S(long groupId, Date displayDate,
12211                    int status, int start, int end,
12212                    OrderByComparator<BlogsEntry> orderByComparator) {
12213                    return findByG_LtD_S(groupId, displayDate, status, start, end,
12214                            orderByComparator, true);
12215            }
12216    
12217            /**
12218             * Returns an ordered range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
12219             *
12220             * <p>
12221             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
12222             * </p>
12223             *
12224             * @param groupId the group ID
12225             * @param displayDate the display date
12226             * @param status the status
12227             * @param start the lower bound of the range of blogs entries
12228             * @param end the upper bound of the range of blogs entries (not inclusive)
12229             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12230             * @param retrieveFromCache whether to retrieve from the finder cache
12231             * @return the ordered range of matching blogs entries
12232             */
12233            @Override
12234            public List<BlogsEntry> findByG_LtD_S(long groupId, Date displayDate,
12235                    int status, int start, int end,
12236                    OrderByComparator<BlogsEntry> orderByComparator,
12237                    boolean retrieveFromCache) {
12238                    boolean pagination = true;
12239                    FinderPath finderPath = null;
12240                    Object[] finderArgs = null;
12241    
12242                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD_S;
12243                    finderArgs = new Object[] {
12244                                    groupId, displayDate, status,
12245                                    
12246                                    start, end, orderByComparator
12247                            };
12248    
12249                    List<BlogsEntry> list = null;
12250    
12251                    if (retrieveFromCache) {
12252                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
12253                                            finderArgs, this);
12254    
12255                            if ((list != null) && !list.isEmpty()) {
12256                                    for (BlogsEntry blogsEntry : list) {
12257                                            if ((groupId != blogsEntry.getGroupId()) ||
12258                                                            (displayDate.getTime() <= blogsEntry.getDisplayDate()
12259                                                                                                                                            .getTime()) ||
12260                                                            (status != blogsEntry.getStatus())) {
12261                                                    list = null;
12262    
12263                                                    break;
12264                                            }
12265                                    }
12266                            }
12267                    }
12268    
12269                    if (list == null) {
12270                            StringBundler query = null;
12271    
12272                            if (orderByComparator != null) {
12273                                    query = new StringBundler(5 +
12274                                                    (orderByComparator.getOrderByFields().length * 2));
12275                            }
12276                            else {
12277                                    query = new StringBundler(5);
12278                            }
12279    
12280                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
12281    
12282                            query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
12283    
12284                            boolean bindDisplayDate = false;
12285    
12286                            if (displayDate == null) {
12287                                    query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
12288                            }
12289                            else {
12290                                    bindDisplayDate = true;
12291    
12292                                    query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
12293                            }
12294    
12295                            query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
12296    
12297                            if (orderByComparator != null) {
12298                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12299                                            orderByComparator);
12300                            }
12301                            else
12302                             if (pagination) {
12303                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
12304                            }
12305    
12306                            String sql = query.toString();
12307    
12308                            Session session = null;
12309    
12310                            try {
12311                                    session = openSession();
12312    
12313                                    Query q = session.createQuery(sql);
12314    
12315                                    QueryPos qPos = QueryPos.getInstance(q);
12316    
12317                                    qPos.add(groupId);
12318    
12319                                    if (bindDisplayDate) {
12320                                            qPos.add(new Timestamp(displayDate.getTime()));
12321                                    }
12322    
12323                                    qPos.add(status);
12324    
12325                                    if (!pagination) {
12326                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
12327                                                            start, end, false);
12328    
12329                                            Collections.sort(list);
12330    
12331                                            list = Collections.unmodifiableList(list);
12332                                    }
12333                                    else {
12334                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
12335                                                            start, end);
12336                                    }
12337    
12338                                    cacheResult(list);
12339    
12340                                    finderCache.putResult(finderPath, finderArgs, list);
12341                            }
12342                            catch (Exception e) {
12343                                    finderCache.removeResult(finderPath, finderArgs);
12344    
12345                                    throw processException(e);
12346                            }
12347                            finally {
12348                                    closeSession(session);
12349                            }
12350                    }
12351    
12352                    return list;
12353            }
12354    
12355            /**
12356             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
12357             *
12358             * @param groupId the group ID
12359             * @param displayDate the display date
12360             * @param status the status
12361             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12362             * @return the first matching blogs entry
12363             * @throws NoSuchEntryException if a matching blogs entry could not be found
12364             */
12365            @Override
12366            public BlogsEntry findByG_LtD_S_First(long groupId, Date displayDate,
12367                    int status, OrderByComparator<BlogsEntry> orderByComparator)
12368                    throws NoSuchEntryException {
12369                    BlogsEntry blogsEntry = fetchByG_LtD_S_First(groupId, displayDate,
12370                                    status, orderByComparator);
12371    
12372                    if (blogsEntry != null) {
12373                            return blogsEntry;
12374                    }
12375    
12376                    StringBundler msg = new StringBundler(8);
12377    
12378                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12379    
12380                    msg.append("groupId=");
12381                    msg.append(groupId);
12382    
12383                    msg.append(", displayDate=");
12384                    msg.append(displayDate);
12385    
12386                    msg.append(", status=");
12387                    msg.append(status);
12388    
12389                    msg.append(StringPool.CLOSE_CURLY_BRACE);
12390    
12391                    throw new NoSuchEntryException(msg.toString());
12392            }
12393    
12394            /**
12395             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
12396             *
12397             * @param groupId the group ID
12398             * @param displayDate the display date
12399             * @param status the status
12400             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12401             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
12402             */
12403            @Override
12404            public BlogsEntry fetchByG_LtD_S_First(long groupId, Date displayDate,
12405                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
12406                    List<BlogsEntry> list = findByG_LtD_S(groupId, displayDate, status, 0,
12407                                    1, orderByComparator);
12408    
12409                    if (!list.isEmpty()) {
12410                            return list.get(0);
12411                    }
12412    
12413                    return null;
12414            }
12415    
12416            /**
12417             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
12418             *
12419             * @param groupId the group ID
12420             * @param displayDate the display date
12421             * @param status the status
12422             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12423             * @return the last matching blogs entry
12424             * @throws NoSuchEntryException if a matching blogs entry could not be found
12425             */
12426            @Override
12427            public BlogsEntry findByG_LtD_S_Last(long groupId, Date displayDate,
12428                    int status, OrderByComparator<BlogsEntry> orderByComparator)
12429                    throws NoSuchEntryException {
12430                    BlogsEntry blogsEntry = fetchByG_LtD_S_Last(groupId, displayDate,
12431                                    status, orderByComparator);
12432    
12433                    if (blogsEntry != null) {
12434                            return blogsEntry;
12435                    }
12436    
12437                    StringBundler msg = new StringBundler(8);
12438    
12439                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12440    
12441                    msg.append("groupId=");
12442                    msg.append(groupId);
12443    
12444                    msg.append(", displayDate=");
12445                    msg.append(displayDate);
12446    
12447                    msg.append(", status=");
12448                    msg.append(status);
12449    
12450                    msg.append(StringPool.CLOSE_CURLY_BRACE);
12451    
12452                    throw new NoSuchEntryException(msg.toString());
12453            }
12454    
12455            /**
12456             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
12457             *
12458             * @param groupId the group ID
12459             * @param displayDate the display date
12460             * @param status the status
12461             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12462             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
12463             */
12464            @Override
12465            public BlogsEntry fetchByG_LtD_S_Last(long groupId, Date displayDate,
12466                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
12467                    int count = countByG_LtD_S(groupId, displayDate, status);
12468    
12469                    if (count == 0) {
12470                            return null;
12471                    }
12472    
12473                    List<BlogsEntry> list = findByG_LtD_S(groupId, displayDate, status,
12474                                    count - 1, count, orderByComparator);
12475    
12476                    if (!list.isEmpty()) {
12477                            return list.get(0);
12478                    }
12479    
12480                    return null;
12481            }
12482    
12483            /**
12484             * 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;.
12485             *
12486             * @param entryId the primary key of the current blogs entry
12487             * @param groupId the group ID
12488             * @param displayDate the display date
12489             * @param status the status
12490             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12491             * @return the previous, current, and next blogs entry
12492             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
12493             */
12494            @Override
12495            public BlogsEntry[] findByG_LtD_S_PrevAndNext(long entryId, long groupId,
12496                    Date displayDate, int status,
12497                    OrderByComparator<BlogsEntry> orderByComparator)
12498                    throws NoSuchEntryException {
12499                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
12500    
12501                    Session session = null;
12502    
12503                    try {
12504                            session = openSession();
12505    
12506                            BlogsEntry[] array = new BlogsEntryImpl[3];
12507    
12508                            array[0] = getByG_LtD_S_PrevAndNext(session, blogsEntry, groupId,
12509                                            displayDate, status, orderByComparator, true);
12510    
12511                            array[1] = blogsEntry;
12512    
12513                            array[2] = getByG_LtD_S_PrevAndNext(session, blogsEntry, groupId,
12514                                            displayDate, status, orderByComparator, false);
12515    
12516                            return array;
12517                    }
12518                    catch (Exception e) {
12519                            throw processException(e);
12520                    }
12521                    finally {
12522                            closeSession(session);
12523                    }
12524            }
12525    
12526            protected BlogsEntry getByG_LtD_S_PrevAndNext(Session session,
12527                    BlogsEntry blogsEntry, long groupId, Date displayDate, int status,
12528                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
12529                    StringBundler query = null;
12530    
12531                    if (orderByComparator != null) {
12532                            query = new StringBundler(6 +
12533                                            (orderByComparator.getOrderByConditionFields().length * 3) +
12534                                            (orderByComparator.getOrderByFields().length * 3));
12535                    }
12536                    else {
12537                            query = new StringBundler(5);
12538                    }
12539    
12540                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
12541    
12542                    query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
12543    
12544                    boolean bindDisplayDate = false;
12545    
12546                    if (displayDate == null) {
12547                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
12548                    }
12549                    else {
12550                            bindDisplayDate = true;
12551    
12552                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
12553                    }
12554    
12555                    query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
12556    
12557                    if (orderByComparator != null) {
12558                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
12559    
12560                            if (orderByConditionFields.length > 0) {
12561                                    query.append(WHERE_AND);
12562                            }
12563    
12564                            for (int i = 0; i < orderByConditionFields.length; i++) {
12565                                    query.append(_ORDER_BY_ENTITY_ALIAS);
12566                                    query.append(orderByConditionFields[i]);
12567    
12568                                    if ((i + 1) < orderByConditionFields.length) {
12569                                            if (orderByComparator.isAscending() ^ previous) {
12570                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
12571                                            }
12572                                            else {
12573                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
12574                                            }
12575                                    }
12576                                    else {
12577                                            if (orderByComparator.isAscending() ^ previous) {
12578                                                    query.append(WHERE_GREATER_THAN);
12579                                            }
12580                                            else {
12581                                                    query.append(WHERE_LESSER_THAN);
12582                                            }
12583                                    }
12584                            }
12585    
12586                            query.append(ORDER_BY_CLAUSE);
12587    
12588                            String[] orderByFields = orderByComparator.getOrderByFields();
12589    
12590                            for (int i = 0; i < orderByFields.length; i++) {
12591                                    query.append(_ORDER_BY_ENTITY_ALIAS);
12592                                    query.append(orderByFields[i]);
12593    
12594                                    if ((i + 1) < orderByFields.length) {
12595                                            if (orderByComparator.isAscending() ^ previous) {
12596                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
12597                                            }
12598                                            else {
12599                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
12600                                            }
12601                                    }
12602                                    else {
12603                                            if (orderByComparator.isAscending() ^ previous) {
12604                                                    query.append(ORDER_BY_ASC);
12605                                            }
12606                                            else {
12607                                                    query.append(ORDER_BY_DESC);
12608                                            }
12609                                    }
12610                            }
12611                    }
12612                    else {
12613                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
12614                    }
12615    
12616                    String sql = query.toString();
12617    
12618                    Query q = session.createQuery(sql);
12619    
12620                    q.setFirstResult(0);
12621                    q.setMaxResults(2);
12622    
12623                    QueryPos qPos = QueryPos.getInstance(q);
12624    
12625                    qPos.add(groupId);
12626    
12627                    if (bindDisplayDate) {
12628                            qPos.add(new Timestamp(displayDate.getTime()));
12629                    }
12630    
12631                    qPos.add(status);
12632    
12633                    if (orderByComparator != null) {
12634                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
12635    
12636                            for (Object value : values) {
12637                                    qPos.add(value);
12638                            }
12639                    }
12640    
12641                    List<BlogsEntry> list = q.list();
12642    
12643                    if (list.size() == 2) {
12644                            return list.get(1);
12645                    }
12646                    else {
12647                            return null;
12648                    }
12649            }
12650    
12651            /**
12652             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
12653             *
12654             * @param groupId the group ID
12655             * @param displayDate the display date
12656             * @param status the status
12657             * @return the matching blogs entries that the user has permission to view
12658             */
12659            @Override
12660            public List<BlogsEntry> filterFindByG_LtD_S(long groupId, Date displayDate,
12661                    int status) {
12662                    return filterFindByG_LtD_S(groupId, displayDate, status,
12663                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
12664            }
12665    
12666            /**
12667             * 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;.
12668             *
12669             * <p>
12670             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
12671             * </p>
12672             *
12673             * @param groupId the group ID
12674             * @param displayDate the display date
12675             * @param status the status
12676             * @param start the lower bound of the range of blogs entries
12677             * @param end the upper bound of the range of blogs entries (not inclusive)
12678             * @return the range of matching blogs entries that the user has permission to view
12679             */
12680            @Override
12681            public List<BlogsEntry> filterFindByG_LtD_S(long groupId, Date displayDate,
12682                    int status, int start, int end) {
12683                    return filterFindByG_LtD_S(groupId, displayDate, status, start, end,
12684                            null);
12685            }
12686    
12687            /**
12688             * 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;.
12689             *
12690             * <p>
12691             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
12692             * </p>
12693             *
12694             * @param groupId the group ID
12695             * @param displayDate the display date
12696             * @param status the status
12697             * @param start the lower bound of the range of blogs entries
12698             * @param end the upper bound of the range of blogs entries (not inclusive)
12699             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12700             * @return the ordered range of matching blogs entries that the user has permission to view
12701             */
12702            @Override
12703            public List<BlogsEntry> filterFindByG_LtD_S(long groupId, Date displayDate,
12704                    int status, int start, int end,
12705                    OrderByComparator<BlogsEntry> orderByComparator) {
12706                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12707                            return findByG_LtD_S(groupId, displayDate, status, start, end,
12708                                    orderByComparator);
12709                    }
12710    
12711                    StringBundler query = null;
12712    
12713                    if (orderByComparator != null) {
12714                            query = new StringBundler(5 +
12715                                            (orderByComparator.getOrderByFields().length * 2));
12716                    }
12717                    else {
12718                            query = new StringBundler(6);
12719                    }
12720    
12721                    if (getDB().isSupportsInlineDistinct()) {
12722                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
12723                    }
12724                    else {
12725                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
12726                    }
12727    
12728                    query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
12729    
12730                    boolean bindDisplayDate = false;
12731    
12732                    if (displayDate == null) {
12733                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
12734                    }
12735                    else {
12736                            bindDisplayDate = true;
12737    
12738                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
12739                    }
12740    
12741                    query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
12742    
12743                    if (!getDB().isSupportsInlineDistinct()) {
12744                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
12745                    }
12746    
12747                    if (orderByComparator != null) {
12748                            if (getDB().isSupportsInlineDistinct()) {
12749                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12750                                            orderByComparator, true);
12751                            }
12752                            else {
12753                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
12754                                            orderByComparator, true);
12755                            }
12756                    }
12757                    else {
12758                            if (getDB().isSupportsInlineDistinct()) {
12759                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
12760                            }
12761                            else {
12762                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
12763                            }
12764                    }
12765    
12766                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12767                                    BlogsEntry.class.getName(),
12768                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12769    
12770                    Session session = null;
12771    
12772                    try {
12773                            session = openSession();
12774    
12775                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
12776    
12777                            if (getDB().isSupportsInlineDistinct()) {
12778                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
12779                            }
12780                            else {
12781                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
12782                            }
12783    
12784                            QueryPos qPos = QueryPos.getInstance(q);
12785    
12786                            qPos.add(groupId);
12787    
12788                            if (bindDisplayDate) {
12789                                    qPos.add(new Timestamp(displayDate.getTime()));
12790                            }
12791    
12792                            qPos.add(status);
12793    
12794                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
12795                    }
12796                    catch (Exception e) {
12797                            throw processException(e);
12798                    }
12799                    finally {
12800                            closeSession(session);
12801                    }
12802            }
12803    
12804            /**
12805             * 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;.
12806             *
12807             * @param entryId the primary key of the current blogs entry
12808             * @param groupId the group ID
12809             * @param displayDate the display date
12810             * @param status the status
12811             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12812             * @return the previous, current, and next blogs entry
12813             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
12814             */
12815            @Override
12816            public BlogsEntry[] filterFindByG_LtD_S_PrevAndNext(long entryId,
12817                    long groupId, Date displayDate, int status,
12818                    OrderByComparator<BlogsEntry> orderByComparator)
12819                    throws NoSuchEntryException {
12820                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12821                            return findByG_LtD_S_PrevAndNext(entryId, groupId, displayDate,
12822                                    status, orderByComparator);
12823                    }
12824    
12825                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
12826    
12827                    Session session = null;
12828    
12829                    try {
12830                            session = openSession();
12831    
12832                            BlogsEntry[] array = new BlogsEntryImpl[3];
12833    
12834                            array[0] = filterGetByG_LtD_S_PrevAndNext(session, blogsEntry,
12835                                            groupId, displayDate, status, orderByComparator, true);
12836    
12837                            array[1] = blogsEntry;
12838    
12839                            array[2] = filterGetByG_LtD_S_PrevAndNext(session, blogsEntry,
12840                                            groupId, displayDate, status, orderByComparator, false);
12841    
12842                            return array;
12843                    }
12844                    catch (Exception e) {
12845                            throw processException(e);
12846                    }
12847                    finally {
12848                            closeSession(session);
12849                    }
12850            }
12851    
12852            protected BlogsEntry filterGetByG_LtD_S_PrevAndNext(Session session,
12853                    BlogsEntry blogsEntry, long groupId, Date displayDate, int status,
12854                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
12855                    StringBundler query = null;
12856    
12857                    if (orderByComparator != null) {
12858                            query = new StringBundler(7 +
12859                                            (orderByComparator.getOrderByConditionFields().length * 3) +
12860                                            (orderByComparator.getOrderByFields().length * 3));
12861                    }
12862                    else {
12863                            query = new StringBundler(6);
12864                    }
12865    
12866                    if (getDB().isSupportsInlineDistinct()) {
12867                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
12868                    }
12869                    else {
12870                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
12871                    }
12872    
12873                    query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
12874    
12875                    boolean bindDisplayDate = false;
12876    
12877                    if (displayDate == null) {
12878                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
12879                    }
12880                    else {
12881                            bindDisplayDate = true;
12882    
12883                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
12884                    }
12885    
12886                    query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
12887    
12888                    if (!getDB().isSupportsInlineDistinct()) {
12889                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
12890                    }
12891    
12892                    if (orderByComparator != null) {
12893                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
12894    
12895                            if (orderByConditionFields.length > 0) {
12896                                    query.append(WHERE_AND);
12897                            }
12898    
12899                            for (int i = 0; i < orderByConditionFields.length; i++) {
12900                                    if (getDB().isSupportsInlineDistinct()) {
12901                                            query.append(_ORDER_BY_ENTITY_ALIAS);
12902                                    }
12903                                    else {
12904                                            query.append(_ORDER_BY_ENTITY_TABLE);
12905                                    }
12906    
12907                                    query.append(orderByConditionFields[i]);
12908    
12909                                    if ((i + 1) < orderByConditionFields.length) {
12910                                            if (orderByComparator.isAscending() ^ previous) {
12911                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
12912                                            }
12913                                            else {
12914                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
12915                                            }
12916                                    }
12917                                    else {
12918                                            if (orderByComparator.isAscending() ^ previous) {
12919                                                    query.append(WHERE_GREATER_THAN);
12920                                            }
12921                                            else {
12922                                                    query.append(WHERE_LESSER_THAN);
12923                                            }
12924                                    }
12925                            }
12926    
12927                            query.append(ORDER_BY_CLAUSE);
12928    
12929                            String[] orderByFields = orderByComparator.getOrderByFields();
12930    
12931                            for (int i = 0; i < orderByFields.length; i++) {
12932                                    if (getDB().isSupportsInlineDistinct()) {
12933                                            query.append(_ORDER_BY_ENTITY_ALIAS);
12934                                    }
12935                                    else {
12936                                            query.append(_ORDER_BY_ENTITY_TABLE);
12937                                    }
12938    
12939                                    query.append(orderByFields[i]);
12940    
12941                                    if ((i + 1) < orderByFields.length) {
12942                                            if (orderByComparator.isAscending() ^ previous) {
12943                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
12944                                            }
12945                                            else {
12946                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
12947                                            }
12948                                    }
12949                                    else {
12950                                            if (orderByComparator.isAscending() ^ previous) {
12951                                                    query.append(ORDER_BY_ASC);
12952                                            }
12953                                            else {
12954                                                    query.append(ORDER_BY_DESC);
12955                                            }
12956                                    }
12957                            }
12958                    }
12959                    else {
12960                            if (getDB().isSupportsInlineDistinct()) {
12961                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
12962                            }
12963                            else {
12964                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
12965                            }
12966                    }
12967    
12968                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12969                                    BlogsEntry.class.getName(),
12970                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12971    
12972                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
12973    
12974                    q.setFirstResult(0);
12975                    q.setMaxResults(2);
12976    
12977                    if (getDB().isSupportsInlineDistinct()) {
12978                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
12979                    }
12980                    else {
12981                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
12982                    }
12983    
12984                    QueryPos qPos = QueryPos.getInstance(q);
12985    
12986                    qPos.add(groupId);
12987    
12988                    if (bindDisplayDate) {
12989                            qPos.add(new Timestamp(displayDate.getTime()));
12990                    }
12991    
12992                    qPos.add(status);
12993    
12994                    if (orderByComparator != null) {
12995                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
12996    
12997                            for (Object value : values) {
12998                                    qPos.add(value);
12999                            }
13000                    }
13001    
13002                    List<BlogsEntry> list = q.list();
13003    
13004                    if (list.size() == 2) {
13005                            return list.get(1);
13006                    }
13007                    else {
13008                            return null;
13009                    }
13010            }
13011    
13012            /**
13013             * Removes all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63; from the database.
13014             *
13015             * @param groupId the group ID
13016             * @param displayDate the display date
13017             * @param status the status
13018             */
13019            @Override
13020            public void removeByG_LtD_S(long groupId, Date displayDate, int status) {
13021                    for (BlogsEntry blogsEntry : findByG_LtD_S(groupId, displayDate,
13022                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
13023                            remove(blogsEntry);
13024                    }
13025            }
13026    
13027            /**
13028             * Returns the number of blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
13029             *
13030             * @param groupId the group ID
13031             * @param displayDate the display date
13032             * @param status the status
13033             * @return the number of matching blogs entries
13034             */
13035            @Override
13036            public int countByG_LtD_S(long groupId, Date displayDate, int status) {
13037                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD_S;
13038    
13039                    Object[] finderArgs = new Object[] { groupId, displayDate, status };
13040    
13041                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
13042    
13043                    if (count == null) {
13044                            StringBundler query = new StringBundler(4);
13045    
13046                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
13047    
13048                            query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
13049    
13050                            boolean bindDisplayDate = false;
13051    
13052                            if (displayDate == null) {
13053                                    query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
13054                            }
13055                            else {
13056                                    bindDisplayDate = true;
13057    
13058                                    query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
13059                            }
13060    
13061                            query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
13062    
13063                            String sql = query.toString();
13064    
13065                            Session session = null;
13066    
13067                            try {
13068                                    session = openSession();
13069    
13070                                    Query q = session.createQuery(sql);
13071    
13072                                    QueryPos qPos = QueryPos.getInstance(q);
13073    
13074                                    qPos.add(groupId);
13075    
13076                                    if (bindDisplayDate) {
13077                                            qPos.add(new Timestamp(displayDate.getTime()));
13078                                    }
13079    
13080                                    qPos.add(status);
13081    
13082                                    count = (Long)q.uniqueResult();
13083    
13084                                    finderCache.putResult(finderPath, finderArgs, count);
13085                            }
13086                            catch (Exception e) {
13087                                    finderCache.removeResult(finderPath, finderArgs);
13088    
13089                                    throw processException(e);
13090                            }
13091                            finally {
13092                                    closeSession(session);
13093                            }
13094                    }
13095    
13096                    return count.intValue();
13097            }
13098    
13099            /**
13100             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
13101             *
13102             * @param groupId the group ID
13103             * @param displayDate the display date
13104             * @param status the status
13105             * @return the number of matching blogs entries that the user has permission to view
13106             */
13107            @Override
13108            public int filterCountByG_LtD_S(long groupId, Date displayDate, int status) {
13109                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13110                            return countByG_LtD_S(groupId, displayDate, status);
13111                    }
13112    
13113                    StringBundler query = new StringBundler(4);
13114    
13115                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
13116    
13117                    query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
13118    
13119                    boolean bindDisplayDate = false;
13120    
13121                    if (displayDate == null) {
13122                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
13123                    }
13124                    else {
13125                            bindDisplayDate = true;
13126    
13127                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
13128                    }
13129    
13130                    query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
13131    
13132                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13133                                    BlogsEntry.class.getName(),
13134                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13135    
13136                    Session session = null;
13137    
13138                    try {
13139                            session = openSession();
13140    
13141                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
13142    
13143                            q.addScalar(COUNT_COLUMN_NAME,
13144                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
13145    
13146                            QueryPos qPos = QueryPos.getInstance(q);
13147    
13148                            qPos.add(groupId);
13149    
13150                            if (bindDisplayDate) {
13151                                    qPos.add(new Timestamp(displayDate.getTime()));
13152                            }
13153    
13154                            qPos.add(status);
13155    
13156                            Long count = (Long)q.uniqueResult();
13157    
13158                            return count.intValue();
13159                    }
13160                    catch (Exception e) {
13161                            throw processException(e);
13162                    }
13163                    finally {
13164                            closeSession(session);
13165                    }
13166            }
13167    
13168            private static final String _FINDER_COLUMN_G_LTD_S_GROUPID_2 = "blogsEntry.groupId = ? AND ";
13169            private static final String _FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1 = "blogsEntry.displayDate IS NULL AND ";
13170            private static final String _FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
13171            private static final String _FINDER_COLUMN_G_LTD_S_STATUS_2 = "blogsEntry.status = ?";
13172            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD_NOTS =
13173                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
13174                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
13175                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_LtD_NotS",
13176                            new String[] {
13177                                    Long.class.getName(), Date.class.getName(),
13178                                    Integer.class.getName(),
13179                                    
13180                            Integer.class.getName(), Integer.class.getName(),
13181                                    OrderByComparator.class.getName()
13182                            });
13183            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD_NOTS =
13184                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
13185                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
13186                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_LtD_NotS",
13187                            new String[] {
13188                                    Long.class.getName(), Date.class.getName(),
13189                                    Integer.class.getName()
13190                            });
13191    
13192            /**
13193             * Returns all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13194             *
13195             * @param groupId the group ID
13196             * @param displayDate the display date
13197             * @param status the status
13198             * @return the matching blogs entries
13199             */
13200            @Override
13201            public List<BlogsEntry> findByG_LtD_NotS(long groupId, Date displayDate,
13202                    int status) {
13203                    return findByG_LtD_NotS(groupId, displayDate, status,
13204                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
13205            }
13206    
13207            /**
13208             * Returns a range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13209             *
13210             * <p>
13211             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
13212             * </p>
13213             *
13214             * @param groupId the group ID
13215             * @param displayDate the display date
13216             * @param status the status
13217             * @param start the lower bound of the range of blogs entries
13218             * @param end the upper bound of the range of blogs entries (not inclusive)
13219             * @return the range of matching blogs entries
13220             */
13221            @Override
13222            public List<BlogsEntry> findByG_LtD_NotS(long groupId, Date displayDate,
13223                    int status, int start, int end) {
13224                    return findByG_LtD_NotS(groupId, displayDate, status, start, end, null);
13225            }
13226    
13227            /**
13228             * Returns an ordered range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13229             *
13230             * <p>
13231             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
13232             * </p>
13233             *
13234             * @param groupId the group ID
13235             * @param displayDate the display date
13236             * @param status the status
13237             * @param start the lower bound of the range of blogs entries
13238             * @param end the upper bound of the range of blogs entries (not inclusive)
13239             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13240             * @return the ordered range of matching blogs entries
13241             */
13242            @Override
13243            public List<BlogsEntry> findByG_LtD_NotS(long groupId, Date displayDate,
13244                    int status, int start, int end,
13245                    OrderByComparator<BlogsEntry> orderByComparator) {
13246                    return findByG_LtD_NotS(groupId, displayDate, status, start, end,
13247                            orderByComparator, true);
13248            }
13249    
13250            /**
13251             * Returns an ordered range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13252             *
13253             * <p>
13254             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
13255             * </p>
13256             *
13257             * @param groupId the group ID
13258             * @param displayDate the display date
13259             * @param status the status
13260             * @param start the lower bound of the range of blogs entries
13261             * @param end the upper bound of the range of blogs entries (not inclusive)
13262             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13263             * @param retrieveFromCache whether to retrieve from the finder cache
13264             * @return the ordered range of matching blogs entries
13265             */
13266            @Override
13267            public List<BlogsEntry> findByG_LtD_NotS(long groupId, Date displayDate,
13268                    int status, int start, int end,
13269                    OrderByComparator<BlogsEntry> orderByComparator,
13270                    boolean retrieveFromCache) {
13271                    boolean pagination = true;
13272                    FinderPath finderPath = null;
13273                    Object[] finderArgs = null;
13274    
13275                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD_NOTS;
13276                    finderArgs = new Object[] {
13277                                    groupId, displayDate, status,
13278                                    
13279                                    start, end, orderByComparator
13280                            };
13281    
13282                    List<BlogsEntry> list = null;
13283    
13284                    if (retrieveFromCache) {
13285                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
13286                                            finderArgs, this);
13287    
13288                            if ((list != null) && !list.isEmpty()) {
13289                                    for (BlogsEntry blogsEntry : list) {
13290                                            if ((groupId != blogsEntry.getGroupId()) ||
13291                                                            (displayDate.getTime() <= blogsEntry.getDisplayDate()
13292                                                                                                                                            .getTime()) ||
13293                                                            (status == blogsEntry.getStatus())) {
13294                                                    list = null;
13295    
13296                                                    break;
13297                                            }
13298                                    }
13299                            }
13300                    }
13301    
13302                    if (list == null) {
13303                            StringBundler query = null;
13304    
13305                            if (orderByComparator != null) {
13306                                    query = new StringBundler(5 +
13307                                                    (orderByComparator.getOrderByFields().length * 2));
13308                            }
13309                            else {
13310                                    query = new StringBundler(5);
13311                            }
13312    
13313                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
13314    
13315                            query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
13316    
13317                            boolean bindDisplayDate = false;
13318    
13319                            if (displayDate == null) {
13320                                    query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
13321                            }
13322                            else {
13323                                    bindDisplayDate = true;
13324    
13325                                    query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
13326                            }
13327    
13328                            query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
13329    
13330                            if (orderByComparator != null) {
13331                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13332                                            orderByComparator);
13333                            }
13334                            else
13335                             if (pagination) {
13336                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
13337                            }
13338    
13339                            String sql = query.toString();
13340    
13341                            Session session = null;
13342    
13343                            try {
13344                                    session = openSession();
13345    
13346                                    Query q = session.createQuery(sql);
13347    
13348                                    QueryPos qPos = QueryPos.getInstance(q);
13349    
13350                                    qPos.add(groupId);
13351    
13352                                    if (bindDisplayDate) {
13353                                            qPos.add(new Timestamp(displayDate.getTime()));
13354                                    }
13355    
13356                                    qPos.add(status);
13357    
13358                                    if (!pagination) {
13359                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
13360                                                            start, end, false);
13361    
13362                                            Collections.sort(list);
13363    
13364                                            list = Collections.unmodifiableList(list);
13365                                    }
13366                                    else {
13367                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
13368                                                            start, end);
13369                                    }
13370    
13371                                    cacheResult(list);
13372    
13373                                    finderCache.putResult(finderPath, finderArgs, list);
13374                            }
13375                            catch (Exception e) {
13376                                    finderCache.removeResult(finderPath, finderArgs);
13377    
13378                                    throw processException(e);
13379                            }
13380                            finally {
13381                                    closeSession(session);
13382                            }
13383                    }
13384    
13385                    return list;
13386            }
13387    
13388            /**
13389             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13390             *
13391             * @param groupId the group ID
13392             * @param displayDate the display date
13393             * @param status the status
13394             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13395             * @return the first matching blogs entry
13396             * @throws NoSuchEntryException if a matching blogs entry could not be found
13397             */
13398            @Override
13399            public BlogsEntry findByG_LtD_NotS_First(long groupId, Date displayDate,
13400                    int status, OrderByComparator<BlogsEntry> orderByComparator)
13401                    throws NoSuchEntryException {
13402                    BlogsEntry blogsEntry = fetchByG_LtD_NotS_First(groupId, displayDate,
13403                                    status, orderByComparator);
13404    
13405                    if (blogsEntry != null) {
13406                            return blogsEntry;
13407                    }
13408    
13409                    StringBundler msg = new StringBundler(8);
13410    
13411                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13412    
13413                    msg.append("groupId=");
13414                    msg.append(groupId);
13415    
13416                    msg.append(", displayDate=");
13417                    msg.append(displayDate);
13418    
13419                    msg.append(", status=");
13420                    msg.append(status);
13421    
13422                    msg.append(StringPool.CLOSE_CURLY_BRACE);
13423    
13424                    throw new NoSuchEntryException(msg.toString());
13425            }
13426    
13427            /**
13428             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13429             *
13430             * @param groupId the group ID
13431             * @param displayDate the display date
13432             * @param status the status
13433             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13434             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
13435             */
13436            @Override
13437            public BlogsEntry fetchByG_LtD_NotS_First(long groupId, Date displayDate,
13438                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
13439                    List<BlogsEntry> list = findByG_LtD_NotS(groupId, displayDate, status,
13440                                    0, 1, orderByComparator);
13441    
13442                    if (!list.isEmpty()) {
13443                            return list.get(0);
13444                    }
13445    
13446                    return null;
13447            }
13448    
13449            /**
13450             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13451             *
13452             * @param groupId the group ID
13453             * @param displayDate the display date
13454             * @param status the status
13455             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13456             * @return the last matching blogs entry
13457             * @throws NoSuchEntryException if a matching blogs entry could not be found
13458             */
13459            @Override
13460            public BlogsEntry findByG_LtD_NotS_Last(long groupId, Date displayDate,
13461                    int status, OrderByComparator<BlogsEntry> orderByComparator)
13462                    throws NoSuchEntryException {
13463                    BlogsEntry blogsEntry = fetchByG_LtD_NotS_Last(groupId, displayDate,
13464                                    status, orderByComparator);
13465    
13466                    if (blogsEntry != null) {
13467                            return blogsEntry;
13468                    }
13469    
13470                    StringBundler msg = new StringBundler(8);
13471    
13472                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13473    
13474                    msg.append("groupId=");
13475                    msg.append(groupId);
13476    
13477                    msg.append(", displayDate=");
13478                    msg.append(displayDate);
13479    
13480                    msg.append(", status=");
13481                    msg.append(status);
13482    
13483                    msg.append(StringPool.CLOSE_CURLY_BRACE);
13484    
13485                    throw new NoSuchEntryException(msg.toString());
13486            }
13487    
13488            /**
13489             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13490             *
13491             * @param groupId the group ID
13492             * @param displayDate the display date
13493             * @param status the status
13494             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13495             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
13496             */
13497            @Override
13498            public BlogsEntry fetchByG_LtD_NotS_Last(long groupId, Date displayDate,
13499                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
13500                    int count = countByG_LtD_NotS(groupId, displayDate, status);
13501    
13502                    if (count == 0) {
13503                            return null;
13504                    }
13505    
13506                    List<BlogsEntry> list = findByG_LtD_NotS(groupId, displayDate, status,
13507                                    count - 1, count, orderByComparator);
13508    
13509                    if (!list.isEmpty()) {
13510                            return list.get(0);
13511                    }
13512    
13513                    return null;
13514            }
13515    
13516            /**
13517             * 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;.
13518             *
13519             * @param entryId the primary key of the current blogs entry
13520             * @param groupId the group ID
13521             * @param displayDate the display date
13522             * @param status the status
13523             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13524             * @return the previous, current, and next blogs entry
13525             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
13526             */
13527            @Override
13528            public BlogsEntry[] findByG_LtD_NotS_PrevAndNext(long entryId,
13529                    long groupId, Date displayDate, int status,
13530                    OrderByComparator<BlogsEntry> orderByComparator)
13531                    throws NoSuchEntryException {
13532                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
13533    
13534                    Session session = null;
13535    
13536                    try {
13537                            session = openSession();
13538    
13539                            BlogsEntry[] array = new BlogsEntryImpl[3];
13540    
13541                            array[0] = getByG_LtD_NotS_PrevAndNext(session, blogsEntry,
13542                                            groupId, displayDate, status, orderByComparator, true);
13543    
13544                            array[1] = blogsEntry;
13545    
13546                            array[2] = getByG_LtD_NotS_PrevAndNext(session, blogsEntry,
13547                                            groupId, displayDate, status, orderByComparator, false);
13548    
13549                            return array;
13550                    }
13551                    catch (Exception e) {
13552                            throw processException(e);
13553                    }
13554                    finally {
13555                            closeSession(session);
13556                    }
13557            }
13558    
13559            protected BlogsEntry getByG_LtD_NotS_PrevAndNext(Session session,
13560                    BlogsEntry blogsEntry, long groupId, Date displayDate, int status,
13561                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
13562                    StringBundler query = null;
13563    
13564                    if (orderByComparator != null) {
13565                            query = new StringBundler(6 +
13566                                            (orderByComparator.getOrderByConditionFields().length * 3) +
13567                                            (orderByComparator.getOrderByFields().length * 3));
13568                    }
13569                    else {
13570                            query = new StringBundler(5);
13571                    }
13572    
13573                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
13574    
13575                    query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
13576    
13577                    boolean bindDisplayDate = false;
13578    
13579                    if (displayDate == null) {
13580                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
13581                    }
13582                    else {
13583                            bindDisplayDate = true;
13584    
13585                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
13586                    }
13587    
13588                    query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
13589    
13590                    if (orderByComparator != null) {
13591                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
13592    
13593                            if (orderByConditionFields.length > 0) {
13594                                    query.append(WHERE_AND);
13595                            }
13596    
13597                            for (int i = 0; i < orderByConditionFields.length; i++) {
13598                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13599                                    query.append(orderByConditionFields[i]);
13600    
13601                                    if ((i + 1) < orderByConditionFields.length) {
13602                                            if (orderByComparator.isAscending() ^ previous) {
13603                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
13604                                            }
13605                                            else {
13606                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
13607                                            }
13608                                    }
13609                                    else {
13610                                            if (orderByComparator.isAscending() ^ previous) {
13611                                                    query.append(WHERE_GREATER_THAN);
13612                                            }
13613                                            else {
13614                                                    query.append(WHERE_LESSER_THAN);
13615                                            }
13616                                    }
13617                            }
13618    
13619                            query.append(ORDER_BY_CLAUSE);
13620    
13621                            String[] orderByFields = orderByComparator.getOrderByFields();
13622    
13623                            for (int i = 0; i < orderByFields.length; i++) {
13624                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13625                                    query.append(orderByFields[i]);
13626    
13627                                    if ((i + 1) < orderByFields.length) {
13628                                            if (orderByComparator.isAscending() ^ previous) {
13629                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
13630                                            }
13631                                            else {
13632                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
13633                                            }
13634                                    }
13635                                    else {
13636                                            if (orderByComparator.isAscending() ^ previous) {
13637                                                    query.append(ORDER_BY_ASC);
13638                                            }
13639                                            else {
13640                                                    query.append(ORDER_BY_DESC);
13641                                            }
13642                                    }
13643                            }
13644                    }
13645                    else {
13646                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
13647                    }
13648    
13649                    String sql = query.toString();
13650    
13651                    Query q = session.createQuery(sql);
13652    
13653                    q.setFirstResult(0);
13654                    q.setMaxResults(2);
13655    
13656                    QueryPos qPos = QueryPos.getInstance(q);
13657    
13658                    qPos.add(groupId);
13659    
13660                    if (bindDisplayDate) {
13661                            qPos.add(new Timestamp(displayDate.getTime()));
13662                    }
13663    
13664                    qPos.add(status);
13665    
13666                    if (orderByComparator != null) {
13667                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
13668    
13669                            for (Object value : values) {
13670                                    qPos.add(value);
13671                            }
13672                    }
13673    
13674                    List<BlogsEntry> list = q.list();
13675    
13676                    if (list.size() == 2) {
13677                            return list.get(1);
13678                    }
13679                    else {
13680                            return null;
13681                    }
13682            }
13683    
13684            /**
13685             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13686             *
13687             * @param groupId the group ID
13688             * @param displayDate the display date
13689             * @param status the status
13690             * @return the matching blogs entries that the user has permission to view
13691             */
13692            @Override
13693            public List<BlogsEntry> filterFindByG_LtD_NotS(long groupId,
13694                    Date displayDate, int status) {
13695                    return filterFindByG_LtD_NotS(groupId, displayDate, status,
13696                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
13697            }
13698    
13699            /**
13700             * 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;.
13701             *
13702             * <p>
13703             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
13704             * </p>
13705             *
13706             * @param groupId the group ID
13707             * @param displayDate the display date
13708             * @param status the status
13709             * @param start the lower bound of the range of blogs entries
13710             * @param end the upper bound of the range of blogs entries (not inclusive)
13711             * @return the range of matching blogs entries that the user has permission to view
13712             */
13713            @Override
13714            public List<BlogsEntry> filterFindByG_LtD_NotS(long groupId,
13715                    Date displayDate, int status, int start, int end) {
13716                    return filterFindByG_LtD_NotS(groupId, displayDate, status, start, end,
13717                            null);
13718            }
13719    
13720            /**
13721             * 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;.
13722             *
13723             * <p>
13724             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
13725             * </p>
13726             *
13727             * @param groupId the group ID
13728             * @param displayDate the display date
13729             * @param status the status
13730             * @param start the lower bound of the range of blogs entries
13731             * @param end the upper bound of the range of blogs entries (not inclusive)
13732             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13733             * @return the ordered range of matching blogs entries that the user has permission to view
13734             */
13735            @Override
13736            public List<BlogsEntry> filterFindByG_LtD_NotS(long groupId,
13737                    Date displayDate, int status, int start, int end,
13738                    OrderByComparator<BlogsEntry> orderByComparator) {
13739                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13740                            return findByG_LtD_NotS(groupId, displayDate, status, start, end,
13741                                    orderByComparator);
13742                    }
13743    
13744                    StringBundler query = null;
13745    
13746                    if (orderByComparator != null) {
13747                            query = new StringBundler(5 +
13748                                            (orderByComparator.getOrderByFields().length * 2));
13749                    }
13750                    else {
13751                            query = new StringBundler(6);
13752                    }
13753    
13754                    if (getDB().isSupportsInlineDistinct()) {
13755                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
13756                    }
13757                    else {
13758                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
13759                    }
13760    
13761                    query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
13762    
13763                    boolean bindDisplayDate = false;
13764    
13765                    if (displayDate == null) {
13766                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
13767                    }
13768                    else {
13769                            bindDisplayDate = true;
13770    
13771                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
13772                    }
13773    
13774                    query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
13775    
13776                    if (!getDB().isSupportsInlineDistinct()) {
13777                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
13778                    }
13779    
13780                    if (orderByComparator != null) {
13781                            if (getDB().isSupportsInlineDistinct()) {
13782                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13783                                            orderByComparator, true);
13784                            }
13785                            else {
13786                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
13787                                            orderByComparator, true);
13788                            }
13789                    }
13790                    else {
13791                            if (getDB().isSupportsInlineDistinct()) {
13792                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
13793                            }
13794                            else {
13795                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
13796                            }
13797                    }
13798    
13799                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13800                                    BlogsEntry.class.getName(),
13801                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13802    
13803                    Session session = null;
13804    
13805                    try {
13806                            session = openSession();
13807    
13808                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
13809    
13810                            if (getDB().isSupportsInlineDistinct()) {
13811                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
13812                            }
13813                            else {
13814                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
13815                            }
13816    
13817                            QueryPos qPos = QueryPos.getInstance(q);
13818    
13819                            qPos.add(groupId);
13820    
13821                            if (bindDisplayDate) {
13822                                    qPos.add(new Timestamp(displayDate.getTime()));
13823                            }
13824    
13825                            qPos.add(status);
13826    
13827                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
13828                    }
13829                    catch (Exception e) {
13830                            throw processException(e);
13831                    }
13832                    finally {
13833                            closeSession(session);
13834                    }
13835            }
13836    
13837            /**
13838             * 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;.
13839             *
13840             * @param entryId the primary key of the current blogs entry
13841             * @param groupId the group ID
13842             * @param displayDate the display date
13843             * @param status the status
13844             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13845             * @return the previous, current, and next blogs entry
13846             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
13847             */
13848            @Override
13849            public BlogsEntry[] filterFindByG_LtD_NotS_PrevAndNext(long entryId,
13850                    long groupId, Date displayDate, int status,
13851                    OrderByComparator<BlogsEntry> orderByComparator)
13852                    throws NoSuchEntryException {
13853                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13854                            return findByG_LtD_NotS_PrevAndNext(entryId, groupId, displayDate,
13855                                    status, orderByComparator);
13856                    }
13857    
13858                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
13859    
13860                    Session session = null;
13861    
13862                    try {
13863                            session = openSession();
13864    
13865                            BlogsEntry[] array = new BlogsEntryImpl[3];
13866    
13867                            array[0] = filterGetByG_LtD_NotS_PrevAndNext(session, blogsEntry,
13868                                            groupId, displayDate, status, orderByComparator, true);
13869    
13870                            array[1] = blogsEntry;
13871    
13872                            array[2] = filterGetByG_LtD_NotS_PrevAndNext(session, blogsEntry,
13873                                            groupId, displayDate, status, orderByComparator, false);
13874    
13875                            return array;
13876                    }
13877                    catch (Exception e) {
13878                            throw processException(e);
13879                    }
13880                    finally {
13881                            closeSession(session);
13882                    }
13883            }
13884    
13885            protected BlogsEntry filterGetByG_LtD_NotS_PrevAndNext(Session session,
13886                    BlogsEntry blogsEntry, long groupId, Date displayDate, int status,
13887                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
13888                    StringBundler query = null;
13889    
13890                    if (orderByComparator != null) {
13891                            query = new StringBundler(7 +
13892                                            (orderByComparator.getOrderByConditionFields().length * 3) +
13893                                            (orderByComparator.getOrderByFields().length * 3));
13894                    }
13895                    else {
13896                            query = new StringBundler(6);
13897                    }
13898    
13899                    if (getDB().isSupportsInlineDistinct()) {
13900                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
13901                    }
13902                    else {
13903                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
13904                    }
13905    
13906                    query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
13907    
13908                    boolean bindDisplayDate = false;
13909    
13910                    if (displayDate == null) {
13911                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
13912                    }
13913                    else {
13914                            bindDisplayDate = true;
13915    
13916                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
13917                    }
13918    
13919                    query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
13920    
13921                    if (!getDB().isSupportsInlineDistinct()) {
13922                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
13923                    }
13924    
13925                    if (orderByComparator != null) {
13926                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
13927    
13928                            if (orderByConditionFields.length > 0) {
13929                                    query.append(WHERE_AND);
13930                            }
13931    
13932                            for (int i = 0; i < orderByConditionFields.length; i++) {
13933                                    if (getDB().isSupportsInlineDistinct()) {
13934                                            query.append(_ORDER_BY_ENTITY_ALIAS);
13935                                    }
13936                                    else {
13937                                            query.append(_ORDER_BY_ENTITY_TABLE);
13938                                    }
13939    
13940                                    query.append(orderByConditionFields[i]);
13941    
13942                                    if ((i + 1) < orderByConditionFields.length) {
13943                                            if (orderByComparator.isAscending() ^ previous) {
13944                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
13945                                            }
13946                                            else {
13947                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
13948                                            }
13949                                    }
13950                                    else {
13951                                            if (orderByComparator.isAscending() ^ previous) {
13952                                                    query.append(WHERE_GREATER_THAN);
13953                                            }
13954                                            else {
13955                                                    query.append(WHERE_LESSER_THAN);
13956                                            }
13957                                    }
13958                            }
13959    
13960                            query.append(ORDER_BY_CLAUSE);
13961    
13962                            String[] orderByFields = orderByComparator.getOrderByFields();
13963    
13964                            for (int i = 0; i < orderByFields.length; i++) {
13965                                    if (getDB().isSupportsInlineDistinct()) {
13966                                            query.append(_ORDER_BY_ENTITY_ALIAS);
13967                                    }
13968                                    else {
13969                                            query.append(_ORDER_BY_ENTITY_TABLE);
13970                                    }
13971    
13972                                    query.append(orderByFields[i]);
13973    
13974                                    if ((i + 1) < orderByFields.length) {
13975                                            if (orderByComparator.isAscending() ^ previous) {
13976                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
13977                                            }
13978                                            else {
13979                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
13980                                            }
13981                                    }
13982                                    else {
13983                                            if (orderByComparator.isAscending() ^ previous) {
13984                                                    query.append(ORDER_BY_ASC);
13985                                            }
13986                                            else {
13987                                                    query.append(ORDER_BY_DESC);
13988                                            }
13989                                    }
13990                            }
13991                    }
13992                    else {
13993                            if (getDB().isSupportsInlineDistinct()) {
13994                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
13995                            }
13996                            else {
13997                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
13998                            }
13999                    }
14000    
14001                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
14002                                    BlogsEntry.class.getName(),
14003                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
14004    
14005                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
14006    
14007                    q.setFirstResult(0);
14008                    q.setMaxResults(2);
14009    
14010                    if (getDB().isSupportsInlineDistinct()) {
14011                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
14012                    }
14013                    else {
14014                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
14015                    }
14016    
14017                    QueryPos qPos = QueryPos.getInstance(q);
14018    
14019                    qPos.add(groupId);
14020    
14021                    if (bindDisplayDate) {
14022                            qPos.add(new Timestamp(displayDate.getTime()));
14023                    }
14024    
14025                    qPos.add(status);
14026    
14027                    if (orderByComparator != null) {
14028                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
14029    
14030                            for (Object value : values) {
14031                                    qPos.add(value);
14032                            }
14033                    }
14034    
14035                    List<BlogsEntry> list = q.list();
14036    
14037                    if (list.size() == 2) {
14038                            return list.get(1);
14039                    }
14040                    else {
14041                            return null;
14042                    }
14043            }
14044    
14045            /**
14046             * Removes all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63; from the database.
14047             *
14048             * @param groupId the group ID
14049             * @param displayDate the display date
14050             * @param status the status
14051             */
14052            @Override
14053            public void removeByG_LtD_NotS(long groupId, Date displayDate, int status) {
14054                    for (BlogsEntry blogsEntry : findByG_LtD_NotS(groupId, displayDate,
14055                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
14056                            remove(blogsEntry);
14057                    }
14058            }
14059    
14060            /**
14061             * Returns the number of blogs entries where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
14062             *
14063             * @param groupId the group ID
14064             * @param displayDate the display date
14065             * @param status the status
14066             * @return the number of matching blogs entries
14067             */
14068            @Override
14069            public int countByG_LtD_NotS(long groupId, Date displayDate, int status) {
14070                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD_NOTS;
14071    
14072                    Object[] finderArgs = new Object[] { groupId, displayDate, status };
14073    
14074                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
14075    
14076                    if (count == null) {
14077                            StringBundler query = new StringBundler(4);
14078    
14079                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
14080    
14081                            query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
14082    
14083                            boolean bindDisplayDate = false;
14084    
14085                            if (displayDate == null) {
14086                                    query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
14087                            }
14088                            else {
14089                                    bindDisplayDate = true;
14090    
14091                                    query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
14092                            }
14093    
14094                            query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
14095    
14096                            String sql = query.toString();
14097    
14098                            Session session = null;
14099    
14100                            try {
14101                                    session = openSession();
14102    
14103                                    Query q = session.createQuery(sql);
14104    
14105                                    QueryPos qPos = QueryPos.getInstance(q);
14106    
14107                                    qPos.add(groupId);
14108    
14109                                    if (bindDisplayDate) {
14110                                            qPos.add(new Timestamp(displayDate.getTime()));
14111                                    }
14112    
14113                                    qPos.add(status);
14114    
14115                                    count = (Long)q.uniqueResult();
14116    
14117                                    finderCache.putResult(finderPath, finderArgs, count);
14118                            }
14119                            catch (Exception e) {
14120                                    finderCache.removeResult(finderPath, finderArgs);
14121    
14122                                    throw processException(e);
14123                            }
14124                            finally {
14125                                    closeSession(session);
14126                            }
14127                    }
14128    
14129                    return count.intValue();
14130            }
14131    
14132            /**
14133             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
14134             *
14135             * @param groupId the group ID
14136             * @param displayDate the display date
14137             * @param status the status
14138             * @return the number of matching blogs entries that the user has permission to view
14139             */
14140            @Override
14141            public int filterCountByG_LtD_NotS(long groupId, Date displayDate,
14142                    int status) {
14143                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
14144                            return countByG_LtD_NotS(groupId, displayDate, status);
14145                    }
14146    
14147                    StringBundler query = new StringBundler(4);
14148    
14149                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
14150    
14151                    query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
14152    
14153                    boolean bindDisplayDate = false;
14154    
14155                    if (displayDate == null) {
14156                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
14157                    }
14158                    else {
14159                            bindDisplayDate = true;
14160    
14161                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
14162                    }
14163    
14164                    query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
14165    
14166                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
14167                                    BlogsEntry.class.getName(),
14168                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
14169    
14170                    Session session = null;
14171    
14172                    try {
14173                            session = openSession();
14174    
14175                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
14176    
14177                            q.addScalar(COUNT_COLUMN_NAME,
14178                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
14179    
14180                            QueryPos qPos = QueryPos.getInstance(q);
14181    
14182                            qPos.add(groupId);
14183    
14184                            if (bindDisplayDate) {
14185                                    qPos.add(new Timestamp(displayDate.getTime()));
14186                            }
14187    
14188                            qPos.add(status);
14189    
14190                            Long count = (Long)q.uniqueResult();
14191    
14192                            return count.intValue();
14193                    }
14194                    catch (Exception e) {
14195                            throw processException(e);
14196                    }
14197                    finally {
14198                            closeSession(session);
14199                    }
14200            }
14201    
14202            private static final String _FINDER_COLUMN_G_LTD_NOTS_GROUPID_2 = "blogsEntry.groupId = ? AND ";
14203            private static final String _FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1 = "blogsEntry.displayDate IS NULL AND ";
14204            private static final String _FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
14205            private static final String _FINDER_COLUMN_G_LTD_NOTS_STATUS_2 = "blogsEntry.status != ?";
14206            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
14207                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
14208                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_U_S",
14209                            new String[] {
14210                                    Long.class.getName(), Long.class.getName(),
14211                                    Integer.class.getName(),
14212                                    
14213                            Integer.class.getName(), Integer.class.getName(),
14214                                    OrderByComparator.class.getName()
14215                            });
14216            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
14217                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
14218                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_U_S",
14219                            new String[] {
14220                                    Long.class.getName(), Long.class.getName(),
14221                                    Integer.class.getName()
14222                            },
14223                            BlogsEntryModelImpl.COMPANYID_COLUMN_BITMASK |
14224                            BlogsEntryModelImpl.USERID_COLUMN_BITMASK |
14225                            BlogsEntryModelImpl.STATUS_COLUMN_BITMASK |
14226                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
14227                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
14228            public static final FinderPath FINDER_PATH_COUNT_BY_C_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
14229                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
14230                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_U_S",
14231                            new String[] {
14232                                    Long.class.getName(), Long.class.getName(),
14233                                    Integer.class.getName()
14234                            });
14235    
14236            /**
14237             * Returns all the blogs entries where companyId = &#63; and userId = &#63; and status = &#63;.
14238             *
14239             * @param companyId the company ID
14240             * @param userId the user ID
14241             * @param status the status
14242             * @return the matching blogs entries
14243             */
14244            @Override
14245            public List<BlogsEntry> findByC_U_S(long companyId, long userId, int status) {
14246                    return findByC_U_S(companyId, userId, status, QueryUtil.ALL_POS,
14247                            QueryUtil.ALL_POS, null);
14248            }
14249    
14250            /**
14251             * Returns a range of all the blogs entries where companyId = &#63; and userId = &#63; and status = &#63;.
14252             *
14253             * <p>
14254             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
14255             * </p>
14256             *
14257             * @param companyId the company ID
14258             * @param userId the user ID
14259             * @param status the status
14260             * @param start the lower bound of the range of blogs entries
14261             * @param end the upper bound of the range of blogs entries (not inclusive)
14262             * @return the range of matching blogs entries
14263             */
14264            @Override
14265            public List<BlogsEntry> findByC_U_S(long companyId, long userId,
14266                    int status, int start, int end) {
14267                    return findByC_U_S(companyId, userId, status, start, end, null);
14268            }
14269    
14270            /**
14271             * Returns an ordered range of all the blogs entries where companyId = &#63; and userId = &#63; and status = &#63;.
14272             *
14273             * <p>
14274             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
14275             * </p>
14276             *
14277             * @param companyId the company ID
14278             * @param userId the user ID
14279             * @param status the status
14280             * @param start the lower bound of the range of blogs entries
14281             * @param end the upper bound of the range of blogs entries (not inclusive)
14282             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14283             * @return the ordered range of matching blogs entries
14284             */
14285            @Override
14286            public List<BlogsEntry> findByC_U_S(long companyId, long userId,
14287                    int status, int start, int end,
14288                    OrderByComparator<BlogsEntry> orderByComparator) {
14289                    return findByC_U_S(companyId, userId, status, start, end,
14290                            orderByComparator, true);
14291            }
14292    
14293            /**
14294             * Returns an ordered range of all the blogs entries where companyId = &#63; and userId = &#63; and status = &#63;.
14295             *
14296             * <p>
14297             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
14298             * </p>
14299             *
14300             * @param companyId the company ID
14301             * @param userId the user ID
14302             * @param status the status
14303             * @param start the lower bound of the range of blogs entries
14304             * @param end the upper bound of the range of blogs entries (not inclusive)
14305             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14306             * @param retrieveFromCache whether to retrieve from the finder cache
14307             * @return the ordered range of matching blogs entries
14308             */
14309            @Override
14310            public List<BlogsEntry> findByC_U_S(long companyId, long userId,
14311                    int status, int start, int end,
14312                    OrderByComparator<BlogsEntry> orderByComparator,
14313                    boolean retrieveFromCache) {
14314                    boolean pagination = true;
14315                    FinderPath finderPath = null;
14316                    Object[] finderArgs = null;
14317    
14318                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
14319                                    (orderByComparator == null)) {
14320                            pagination = false;
14321                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U_S;
14322                            finderArgs = new Object[] { companyId, userId, status };
14323                    }
14324                    else {
14325                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U_S;
14326                            finderArgs = new Object[] {
14327                                            companyId, userId, status,
14328                                            
14329                                            start, end, orderByComparator
14330                                    };
14331                    }
14332    
14333                    List<BlogsEntry> list = null;
14334    
14335                    if (retrieveFromCache) {
14336                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
14337                                            finderArgs, this);
14338    
14339                            if ((list != null) && !list.isEmpty()) {
14340                                    for (BlogsEntry blogsEntry : list) {
14341                                            if ((companyId != blogsEntry.getCompanyId()) ||
14342                                                            (userId != blogsEntry.getUserId()) ||
14343                                                            (status != blogsEntry.getStatus())) {
14344                                                    list = null;
14345    
14346                                                    break;
14347                                            }
14348                                    }
14349                            }
14350                    }
14351    
14352                    if (list == null) {
14353                            StringBundler query = null;
14354    
14355                            if (orderByComparator != null) {
14356                                    query = new StringBundler(5 +
14357                                                    (orderByComparator.getOrderByFields().length * 2));
14358                            }
14359                            else {
14360                                    query = new StringBundler(5);
14361                            }
14362    
14363                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
14364    
14365                            query.append(_FINDER_COLUMN_C_U_S_COMPANYID_2);
14366    
14367                            query.append(_FINDER_COLUMN_C_U_S_USERID_2);
14368    
14369                            query.append(_FINDER_COLUMN_C_U_S_STATUS_2);
14370    
14371                            if (orderByComparator != null) {
14372                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
14373                                            orderByComparator);
14374                            }
14375                            else
14376                             if (pagination) {
14377                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
14378                            }
14379    
14380                            String sql = query.toString();
14381    
14382                            Session session = null;
14383    
14384                            try {
14385                                    session = openSession();
14386    
14387                                    Query q = session.createQuery(sql);
14388    
14389                                    QueryPos qPos = QueryPos.getInstance(q);
14390    
14391                                    qPos.add(companyId);
14392    
14393                                    qPos.add(userId);
14394    
14395                                    qPos.add(status);
14396    
14397                                    if (!pagination) {
14398                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
14399                                                            start, end, false);
14400    
14401                                            Collections.sort(list);
14402    
14403                                            list = Collections.unmodifiableList(list);
14404                                    }
14405                                    else {
14406                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
14407                                                            start, end);
14408                                    }
14409    
14410                                    cacheResult(list);
14411    
14412                                    finderCache.putResult(finderPath, finderArgs, list);
14413                            }
14414                            catch (Exception e) {
14415                                    finderCache.removeResult(finderPath, finderArgs);
14416    
14417                                    throw processException(e);
14418                            }
14419                            finally {
14420                                    closeSession(session);
14421                            }
14422                    }
14423    
14424                    return list;
14425            }
14426    
14427            /**
14428             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status = &#63;.
14429             *
14430             * @param companyId the company ID
14431             * @param userId the user ID
14432             * @param status the status
14433             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14434             * @return the first matching blogs entry
14435             * @throws NoSuchEntryException if a matching blogs entry could not be found
14436             */
14437            @Override
14438            public BlogsEntry findByC_U_S_First(long companyId, long userId,
14439                    int status, OrderByComparator<BlogsEntry> orderByComparator)
14440                    throws NoSuchEntryException {
14441                    BlogsEntry blogsEntry = fetchByC_U_S_First(companyId, userId, status,
14442                                    orderByComparator);
14443    
14444                    if (blogsEntry != null) {
14445                            return blogsEntry;
14446                    }
14447    
14448                    StringBundler msg = new StringBundler(8);
14449    
14450                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
14451    
14452                    msg.append("companyId=");
14453                    msg.append(companyId);
14454    
14455                    msg.append(", userId=");
14456                    msg.append(userId);
14457    
14458                    msg.append(", status=");
14459                    msg.append(status);
14460    
14461                    msg.append(StringPool.CLOSE_CURLY_BRACE);
14462    
14463                    throw new NoSuchEntryException(msg.toString());
14464            }
14465    
14466            /**
14467             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status = &#63;.
14468             *
14469             * @param companyId the company ID
14470             * @param userId the user ID
14471             * @param status the status
14472             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14473             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
14474             */
14475            @Override
14476            public BlogsEntry fetchByC_U_S_First(long companyId, long userId,
14477                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
14478                    List<BlogsEntry> list = findByC_U_S(companyId, userId, status, 0, 1,
14479                                    orderByComparator);
14480    
14481                    if (!list.isEmpty()) {
14482                            return list.get(0);
14483                    }
14484    
14485                    return null;
14486            }
14487    
14488            /**
14489             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status = &#63;.
14490             *
14491             * @param companyId the company ID
14492             * @param userId the user ID
14493             * @param status the status
14494             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14495             * @return the last matching blogs entry
14496             * @throws NoSuchEntryException if a matching blogs entry could not be found
14497             */
14498            @Override
14499            public BlogsEntry findByC_U_S_Last(long companyId, long userId, int status,
14500                    OrderByComparator<BlogsEntry> orderByComparator)
14501                    throws NoSuchEntryException {
14502                    BlogsEntry blogsEntry = fetchByC_U_S_Last(companyId, userId, status,
14503                                    orderByComparator);
14504    
14505                    if (blogsEntry != null) {
14506                            return blogsEntry;
14507                    }
14508    
14509                    StringBundler msg = new StringBundler(8);
14510    
14511                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
14512    
14513                    msg.append("companyId=");
14514                    msg.append(companyId);
14515    
14516                    msg.append(", userId=");
14517                    msg.append(userId);
14518    
14519                    msg.append(", status=");
14520                    msg.append(status);
14521    
14522                    msg.append(StringPool.CLOSE_CURLY_BRACE);
14523    
14524                    throw new NoSuchEntryException(msg.toString());
14525            }
14526    
14527            /**
14528             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status = &#63;.
14529             *
14530             * @param companyId the company ID
14531             * @param userId the user ID
14532             * @param status the status
14533             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14534             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
14535             */
14536            @Override
14537            public BlogsEntry fetchByC_U_S_Last(long companyId, long userId,
14538                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
14539                    int count = countByC_U_S(companyId, userId, status);
14540    
14541                    if (count == 0) {
14542                            return null;
14543                    }
14544    
14545                    List<BlogsEntry> list = findByC_U_S(companyId, userId, status,
14546                                    count - 1, count, orderByComparator);
14547    
14548                    if (!list.isEmpty()) {
14549                            return list.get(0);
14550                    }
14551    
14552                    return null;
14553            }
14554    
14555            /**
14556             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status = &#63;.
14557             *
14558             * @param entryId the primary key of the current blogs entry
14559             * @param companyId the company ID
14560             * @param userId the user ID
14561             * @param status the status
14562             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14563             * @return the previous, current, and next blogs entry
14564             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
14565             */
14566            @Override
14567            public BlogsEntry[] findByC_U_S_PrevAndNext(long entryId, long companyId,
14568                    long userId, int status, OrderByComparator<BlogsEntry> orderByComparator)
14569                    throws NoSuchEntryException {
14570                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
14571    
14572                    Session session = null;
14573    
14574                    try {
14575                            session = openSession();
14576    
14577                            BlogsEntry[] array = new BlogsEntryImpl[3];
14578    
14579                            array[0] = getByC_U_S_PrevAndNext(session, blogsEntry, companyId,
14580                                            userId, status, orderByComparator, true);
14581    
14582                            array[1] = blogsEntry;
14583    
14584                            array[2] = getByC_U_S_PrevAndNext(session, blogsEntry, companyId,
14585                                            userId, status, orderByComparator, false);
14586    
14587                            return array;
14588                    }
14589                    catch (Exception e) {
14590                            throw processException(e);
14591                    }
14592                    finally {
14593                            closeSession(session);
14594                    }
14595            }
14596    
14597            protected BlogsEntry getByC_U_S_PrevAndNext(Session session,
14598                    BlogsEntry blogsEntry, long companyId, long userId, int status,
14599                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
14600                    StringBundler query = null;
14601    
14602                    if (orderByComparator != null) {
14603                            query = new StringBundler(6 +
14604                                            (orderByComparator.getOrderByConditionFields().length * 3) +
14605                                            (orderByComparator.getOrderByFields().length * 3));
14606                    }
14607                    else {
14608                            query = new StringBundler(5);
14609                    }
14610    
14611                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
14612    
14613                    query.append(_FINDER_COLUMN_C_U_S_COMPANYID_2);
14614    
14615                    query.append(_FINDER_COLUMN_C_U_S_USERID_2);
14616    
14617                    query.append(_FINDER_COLUMN_C_U_S_STATUS_2);
14618    
14619                    if (orderByComparator != null) {
14620                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
14621    
14622                            if (orderByConditionFields.length > 0) {
14623                                    query.append(WHERE_AND);
14624                            }
14625    
14626                            for (int i = 0; i < orderByConditionFields.length; i++) {
14627                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14628                                    query.append(orderByConditionFields[i]);
14629    
14630                                    if ((i + 1) < orderByConditionFields.length) {
14631                                            if (orderByComparator.isAscending() ^ previous) {
14632                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
14633                                            }
14634                                            else {
14635                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
14636                                            }
14637                                    }
14638                                    else {
14639                                            if (orderByComparator.isAscending() ^ previous) {
14640                                                    query.append(WHERE_GREATER_THAN);
14641                                            }
14642                                            else {
14643                                                    query.append(WHERE_LESSER_THAN);
14644                                            }
14645                                    }
14646                            }
14647    
14648                            query.append(ORDER_BY_CLAUSE);
14649    
14650                            String[] orderByFields = orderByComparator.getOrderByFields();
14651    
14652                            for (int i = 0; i < orderByFields.length; i++) {
14653                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14654                                    query.append(orderByFields[i]);
14655    
14656                                    if ((i + 1) < orderByFields.length) {
14657                                            if (orderByComparator.isAscending() ^ previous) {
14658                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
14659                                            }
14660                                            else {
14661                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
14662                                            }
14663                                    }
14664                                    else {
14665                                            if (orderByComparator.isAscending() ^ previous) {
14666                                                    query.append(ORDER_BY_ASC);
14667                                            }
14668                                            else {
14669                                                    query.append(ORDER_BY_DESC);
14670                                            }
14671                                    }
14672                            }
14673                    }
14674                    else {
14675                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
14676                    }
14677    
14678                    String sql = query.toString();
14679    
14680                    Query q = session.createQuery(sql);
14681    
14682                    q.setFirstResult(0);
14683                    q.setMaxResults(2);
14684    
14685                    QueryPos qPos = QueryPos.getInstance(q);
14686    
14687                    qPos.add(companyId);
14688    
14689                    qPos.add(userId);
14690    
14691                    qPos.add(status);
14692    
14693                    if (orderByComparator != null) {
14694                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
14695    
14696                            for (Object value : values) {
14697                                    qPos.add(value);
14698                            }
14699                    }
14700    
14701                    List<BlogsEntry> list = q.list();
14702    
14703                    if (list.size() == 2) {
14704                            return list.get(1);
14705                    }
14706                    else {
14707                            return null;
14708                    }
14709            }
14710    
14711            /**
14712             * Removes all the blogs entries where companyId = &#63; and userId = &#63; and status = &#63; from the database.
14713             *
14714             * @param companyId the company ID
14715             * @param userId the user ID
14716             * @param status the status
14717             */
14718            @Override
14719            public void removeByC_U_S(long companyId, long userId, int status) {
14720                    for (BlogsEntry blogsEntry : findByC_U_S(companyId, userId, status,
14721                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
14722                            remove(blogsEntry);
14723                    }
14724            }
14725    
14726            /**
14727             * Returns the number of blogs entries where companyId = &#63; and userId = &#63; and status = &#63;.
14728             *
14729             * @param companyId the company ID
14730             * @param userId the user ID
14731             * @param status the status
14732             * @return the number of matching blogs entries
14733             */
14734            @Override
14735            public int countByC_U_S(long companyId, long userId, int status) {
14736                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_U_S;
14737    
14738                    Object[] finderArgs = new Object[] { companyId, userId, status };
14739    
14740                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
14741    
14742                    if (count == null) {
14743                            StringBundler query = new StringBundler(4);
14744    
14745                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
14746    
14747                            query.append(_FINDER_COLUMN_C_U_S_COMPANYID_2);
14748    
14749                            query.append(_FINDER_COLUMN_C_U_S_USERID_2);
14750    
14751                            query.append(_FINDER_COLUMN_C_U_S_STATUS_2);
14752    
14753                            String sql = query.toString();
14754    
14755                            Session session = null;
14756    
14757                            try {
14758                                    session = openSession();
14759    
14760                                    Query q = session.createQuery(sql);
14761    
14762                                    QueryPos qPos = QueryPos.getInstance(q);
14763    
14764                                    qPos.add(companyId);
14765    
14766                                    qPos.add(userId);
14767    
14768                                    qPos.add(status);
14769    
14770                                    count = (Long)q.uniqueResult();
14771    
14772                                    finderCache.putResult(finderPath, finderArgs, count);
14773                            }
14774                            catch (Exception e) {
14775                                    finderCache.removeResult(finderPath, finderArgs);
14776    
14777                                    throw processException(e);
14778                            }
14779                            finally {
14780                                    closeSession(session);
14781                            }
14782                    }
14783    
14784                    return count.intValue();
14785            }
14786    
14787            private static final String _FINDER_COLUMN_C_U_S_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
14788            private static final String _FINDER_COLUMN_C_U_S_USERID_2 = "blogsEntry.userId = ? AND ";
14789            private static final String _FINDER_COLUMN_C_U_S_STATUS_2 = "blogsEntry.status = ?";
14790            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U_NOTS = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
14791                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
14792                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_U_NotS",
14793                            new String[] {
14794                                    Long.class.getName(), Long.class.getName(),
14795                                    Integer.class.getName(),
14796                                    
14797                            Integer.class.getName(), Integer.class.getName(),
14798                                    OrderByComparator.class.getName()
14799                            });
14800            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_U_NOTS =
14801                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
14802                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
14803                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_U_NotS",
14804                            new String[] {
14805                                    Long.class.getName(), Long.class.getName(),
14806                                    Integer.class.getName()
14807                            });
14808    
14809            /**
14810             * Returns all the blogs entries where companyId = &#63; and userId = &#63; and status &ne; &#63;.
14811             *
14812             * @param companyId the company ID
14813             * @param userId the user ID
14814             * @param status the status
14815             * @return the matching blogs entries
14816             */
14817            @Override
14818            public List<BlogsEntry> findByC_U_NotS(long companyId, long userId,
14819                    int status) {
14820                    return findByC_U_NotS(companyId, userId, status, QueryUtil.ALL_POS,
14821                            QueryUtil.ALL_POS, null);
14822            }
14823    
14824            /**
14825             * Returns a range of all the blogs entries where companyId = &#63; and userId = &#63; and status &ne; &#63;.
14826             *
14827             * <p>
14828             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
14829             * </p>
14830             *
14831             * @param companyId the company ID
14832             * @param userId the user ID
14833             * @param status the status
14834             * @param start the lower bound of the range of blogs entries
14835             * @param end the upper bound of the range of blogs entries (not inclusive)
14836             * @return the range of matching blogs entries
14837             */
14838            @Override
14839            public List<BlogsEntry> findByC_U_NotS(long companyId, long userId,
14840                    int status, int start, int end) {
14841                    return findByC_U_NotS(companyId, userId, status, start, end, null);
14842            }
14843    
14844            /**
14845             * Returns an ordered range of all the blogs entries where companyId = &#63; and userId = &#63; and status &ne; &#63;.
14846             *
14847             * <p>
14848             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
14849             * </p>
14850             *
14851             * @param companyId the company ID
14852             * @param userId the user ID
14853             * @param status the status
14854             * @param start the lower bound of the range of blogs entries
14855             * @param end the upper bound of the range of blogs entries (not inclusive)
14856             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14857             * @return the ordered range of matching blogs entries
14858             */
14859            @Override
14860            public List<BlogsEntry> findByC_U_NotS(long companyId, long userId,
14861                    int status, int start, int end,
14862                    OrderByComparator<BlogsEntry> orderByComparator) {
14863                    return findByC_U_NotS(companyId, userId, status, start, end,
14864                            orderByComparator, true);
14865            }
14866    
14867            /**
14868             * Returns an ordered range of all the blogs entries where companyId = &#63; and userId = &#63; and status &ne; &#63;.
14869             *
14870             * <p>
14871             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
14872             * </p>
14873             *
14874             * @param companyId the company ID
14875             * @param userId the user ID
14876             * @param status the status
14877             * @param start the lower bound of the range of blogs entries
14878             * @param end the upper bound of the range of blogs entries (not inclusive)
14879             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14880             * @param retrieveFromCache whether to retrieve from the finder cache
14881             * @return the ordered range of matching blogs entries
14882             */
14883            @Override
14884            public List<BlogsEntry> findByC_U_NotS(long companyId, long userId,
14885                    int status, int start, int end,
14886                    OrderByComparator<BlogsEntry> orderByComparator,
14887                    boolean retrieveFromCache) {
14888                    boolean pagination = true;
14889                    FinderPath finderPath = null;
14890                    Object[] finderArgs = null;
14891    
14892                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U_NOTS;
14893                    finderArgs = new Object[] {
14894                                    companyId, userId, status,
14895                                    
14896                                    start, end, orderByComparator
14897                            };
14898    
14899                    List<BlogsEntry> list = null;
14900    
14901                    if (retrieveFromCache) {
14902                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
14903                                            finderArgs, this);
14904    
14905                            if ((list != null) && !list.isEmpty()) {
14906                                    for (BlogsEntry blogsEntry : list) {
14907                                            if ((companyId != blogsEntry.getCompanyId()) ||
14908                                                            (userId != blogsEntry.getUserId()) ||
14909                                                            (status == blogsEntry.getStatus())) {
14910                                                    list = null;
14911    
14912                                                    break;
14913                                            }
14914                                    }
14915                            }
14916                    }
14917    
14918                    if (list == null) {
14919                            StringBundler query = null;
14920    
14921                            if (orderByComparator != null) {
14922                                    query = new StringBundler(5 +
14923                                                    (orderByComparator.getOrderByFields().length * 2));
14924                            }
14925                            else {
14926                                    query = new StringBundler(5);
14927                            }
14928    
14929                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
14930    
14931                            query.append(_FINDER_COLUMN_C_U_NOTS_COMPANYID_2);
14932    
14933                            query.append(_FINDER_COLUMN_C_U_NOTS_USERID_2);
14934    
14935                            query.append(_FINDER_COLUMN_C_U_NOTS_STATUS_2);
14936    
14937                            if (orderByComparator != null) {
14938                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
14939                                            orderByComparator);
14940                            }
14941                            else
14942                             if (pagination) {
14943                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
14944                            }
14945    
14946                            String sql = query.toString();
14947    
14948                            Session session = null;
14949    
14950                            try {
14951                                    session = openSession();
14952    
14953                                    Query q = session.createQuery(sql);
14954    
14955                                    QueryPos qPos = QueryPos.getInstance(q);
14956    
14957                                    qPos.add(companyId);
14958    
14959                                    qPos.add(userId);
14960    
14961                                    qPos.add(status);
14962    
14963                                    if (!pagination) {
14964                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
14965                                                            start, end, false);
14966    
14967                                            Collections.sort(list);
14968    
14969                                            list = Collections.unmodifiableList(list);
14970                                    }
14971                                    else {
14972                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
14973                                                            start, end);
14974                                    }
14975    
14976                                    cacheResult(list);
14977    
14978                                    finderCache.putResult(finderPath, finderArgs, list);
14979                            }
14980                            catch (Exception e) {
14981                                    finderCache.removeResult(finderPath, finderArgs);
14982    
14983                                    throw processException(e);
14984                            }
14985                            finally {
14986                                    closeSession(session);
14987                            }
14988                    }
14989    
14990                    return list;
14991            }
14992    
14993            /**
14994             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status &ne; &#63;.
14995             *
14996             * @param companyId the company ID
14997             * @param userId the user ID
14998             * @param status the status
14999             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15000             * @return the first matching blogs entry
15001             * @throws NoSuchEntryException if a matching blogs entry could not be found
15002             */
15003            @Override
15004            public BlogsEntry findByC_U_NotS_First(long companyId, long userId,
15005                    int status, OrderByComparator<BlogsEntry> orderByComparator)
15006                    throws NoSuchEntryException {
15007                    BlogsEntry blogsEntry = fetchByC_U_NotS_First(companyId, userId,
15008                                    status, orderByComparator);
15009    
15010                    if (blogsEntry != null) {
15011                            return blogsEntry;
15012                    }
15013    
15014                    StringBundler msg = new StringBundler(8);
15015    
15016                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15017    
15018                    msg.append("companyId=");
15019                    msg.append(companyId);
15020    
15021                    msg.append(", userId=");
15022                    msg.append(userId);
15023    
15024                    msg.append(", status=");
15025                    msg.append(status);
15026    
15027                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15028    
15029                    throw new NoSuchEntryException(msg.toString());
15030            }
15031    
15032            /**
15033             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status &ne; &#63;.
15034             *
15035             * @param companyId the company ID
15036             * @param userId the user ID
15037             * @param status the status
15038             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15039             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
15040             */
15041            @Override
15042            public BlogsEntry fetchByC_U_NotS_First(long companyId, long userId,
15043                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
15044                    List<BlogsEntry> list = findByC_U_NotS(companyId, userId, status, 0, 1,
15045                                    orderByComparator);
15046    
15047                    if (!list.isEmpty()) {
15048                            return list.get(0);
15049                    }
15050    
15051                    return null;
15052            }
15053    
15054            /**
15055             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status &ne; &#63;.
15056             *
15057             * @param companyId the company ID
15058             * @param userId the user ID
15059             * @param status the status
15060             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15061             * @return the last matching blogs entry
15062             * @throws NoSuchEntryException if a matching blogs entry could not be found
15063             */
15064            @Override
15065            public BlogsEntry findByC_U_NotS_Last(long companyId, long userId,
15066                    int status, OrderByComparator<BlogsEntry> orderByComparator)
15067                    throws NoSuchEntryException {
15068                    BlogsEntry blogsEntry = fetchByC_U_NotS_Last(companyId, userId, status,
15069                                    orderByComparator);
15070    
15071                    if (blogsEntry != null) {
15072                            return blogsEntry;
15073                    }
15074    
15075                    StringBundler msg = new StringBundler(8);
15076    
15077                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15078    
15079                    msg.append("companyId=");
15080                    msg.append(companyId);
15081    
15082                    msg.append(", userId=");
15083                    msg.append(userId);
15084    
15085                    msg.append(", status=");
15086                    msg.append(status);
15087    
15088                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15089    
15090                    throw new NoSuchEntryException(msg.toString());
15091            }
15092    
15093            /**
15094             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status &ne; &#63;.
15095             *
15096             * @param companyId the company ID
15097             * @param userId the user ID
15098             * @param status the status
15099             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15100             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
15101             */
15102            @Override
15103            public BlogsEntry fetchByC_U_NotS_Last(long companyId, long userId,
15104                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
15105                    int count = countByC_U_NotS(companyId, userId, status);
15106    
15107                    if (count == 0) {
15108                            return null;
15109                    }
15110    
15111                    List<BlogsEntry> list = findByC_U_NotS(companyId, userId, status,
15112                                    count - 1, count, orderByComparator);
15113    
15114                    if (!list.isEmpty()) {
15115                            return list.get(0);
15116                    }
15117    
15118                    return null;
15119            }
15120    
15121            /**
15122             * 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;.
15123             *
15124             * @param entryId the primary key of the current blogs entry
15125             * @param companyId the company ID
15126             * @param userId the user ID
15127             * @param status the status
15128             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15129             * @return the previous, current, and next blogs entry
15130             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
15131             */
15132            @Override
15133            public BlogsEntry[] findByC_U_NotS_PrevAndNext(long entryId,
15134                    long companyId, long userId, int status,
15135                    OrderByComparator<BlogsEntry> orderByComparator)
15136                    throws NoSuchEntryException {
15137                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
15138    
15139                    Session session = null;
15140    
15141                    try {
15142                            session = openSession();
15143    
15144                            BlogsEntry[] array = new BlogsEntryImpl[3];
15145    
15146                            array[0] = getByC_U_NotS_PrevAndNext(session, blogsEntry,
15147                                            companyId, userId, status, orderByComparator, true);
15148    
15149                            array[1] = blogsEntry;
15150    
15151                            array[2] = getByC_U_NotS_PrevAndNext(session, blogsEntry,
15152                                            companyId, userId, status, orderByComparator, false);
15153    
15154                            return array;
15155                    }
15156                    catch (Exception e) {
15157                            throw processException(e);
15158                    }
15159                    finally {
15160                            closeSession(session);
15161                    }
15162            }
15163    
15164            protected BlogsEntry getByC_U_NotS_PrevAndNext(Session session,
15165                    BlogsEntry blogsEntry, long companyId, long userId, int status,
15166                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
15167                    StringBundler query = null;
15168    
15169                    if (orderByComparator != null) {
15170                            query = new StringBundler(6 +
15171                                            (orderByComparator.getOrderByConditionFields().length * 3) +
15172                                            (orderByComparator.getOrderByFields().length * 3));
15173                    }
15174                    else {
15175                            query = new StringBundler(5);
15176                    }
15177    
15178                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
15179    
15180                    query.append(_FINDER_COLUMN_C_U_NOTS_COMPANYID_2);
15181    
15182                    query.append(_FINDER_COLUMN_C_U_NOTS_USERID_2);
15183    
15184                    query.append(_FINDER_COLUMN_C_U_NOTS_STATUS_2);
15185    
15186                    if (orderByComparator != null) {
15187                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
15188    
15189                            if (orderByConditionFields.length > 0) {
15190                                    query.append(WHERE_AND);
15191                            }
15192    
15193                            for (int i = 0; i < orderByConditionFields.length; i++) {
15194                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15195                                    query.append(orderByConditionFields[i]);
15196    
15197                                    if ((i + 1) < orderByConditionFields.length) {
15198                                            if (orderByComparator.isAscending() ^ previous) {
15199                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
15200                                            }
15201                                            else {
15202                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
15203                                            }
15204                                    }
15205                                    else {
15206                                            if (orderByComparator.isAscending() ^ previous) {
15207                                                    query.append(WHERE_GREATER_THAN);
15208                                            }
15209                                            else {
15210                                                    query.append(WHERE_LESSER_THAN);
15211                                            }
15212                                    }
15213                            }
15214    
15215                            query.append(ORDER_BY_CLAUSE);
15216    
15217                            String[] orderByFields = orderByComparator.getOrderByFields();
15218    
15219                            for (int i = 0; i < orderByFields.length; i++) {
15220                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15221                                    query.append(orderByFields[i]);
15222    
15223                                    if ((i + 1) < orderByFields.length) {
15224                                            if (orderByComparator.isAscending() ^ previous) {
15225                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
15226                                            }
15227                                            else {
15228                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
15229                                            }
15230                                    }
15231                                    else {
15232                                            if (orderByComparator.isAscending() ^ previous) {
15233                                                    query.append(ORDER_BY_ASC);
15234                                            }
15235                                            else {
15236                                                    query.append(ORDER_BY_DESC);
15237                                            }
15238                                    }
15239                            }
15240                    }
15241                    else {
15242                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
15243                    }
15244    
15245                    String sql = query.toString();
15246    
15247                    Query q = session.createQuery(sql);
15248    
15249                    q.setFirstResult(0);
15250                    q.setMaxResults(2);
15251    
15252                    QueryPos qPos = QueryPos.getInstance(q);
15253    
15254                    qPos.add(companyId);
15255    
15256                    qPos.add(userId);
15257    
15258                    qPos.add(status);
15259    
15260                    if (orderByComparator != null) {
15261                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
15262    
15263                            for (Object value : values) {
15264                                    qPos.add(value);
15265                            }
15266                    }
15267    
15268                    List<BlogsEntry> list = q.list();
15269    
15270                    if (list.size() == 2) {
15271                            return list.get(1);
15272                    }
15273                    else {
15274                            return null;
15275                    }
15276            }
15277    
15278            /**
15279             * Removes all the blogs entries where companyId = &#63; and userId = &#63; and status &ne; &#63; from the database.
15280             *
15281             * @param companyId the company ID
15282             * @param userId the user ID
15283             * @param status the status
15284             */
15285            @Override
15286            public void removeByC_U_NotS(long companyId, long userId, int status) {
15287                    for (BlogsEntry blogsEntry : findByC_U_NotS(companyId, userId, status,
15288                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
15289                            remove(blogsEntry);
15290                    }
15291            }
15292    
15293            /**
15294             * Returns the number of blogs entries where companyId = &#63; and userId = &#63; and status &ne; &#63;.
15295             *
15296             * @param companyId the company ID
15297             * @param userId the user ID
15298             * @param status the status
15299             * @return the number of matching blogs entries
15300             */
15301            @Override
15302            public int countByC_U_NotS(long companyId, long userId, int status) {
15303                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_U_NOTS;
15304    
15305                    Object[] finderArgs = new Object[] { companyId, userId, status };
15306    
15307                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
15308    
15309                    if (count == null) {
15310                            StringBundler query = new StringBundler(4);
15311    
15312                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
15313    
15314                            query.append(_FINDER_COLUMN_C_U_NOTS_COMPANYID_2);
15315    
15316                            query.append(_FINDER_COLUMN_C_U_NOTS_USERID_2);
15317    
15318                            query.append(_FINDER_COLUMN_C_U_NOTS_STATUS_2);
15319    
15320                            String sql = query.toString();
15321    
15322                            Session session = null;
15323    
15324                            try {
15325                                    session = openSession();
15326    
15327                                    Query q = session.createQuery(sql);
15328    
15329                                    QueryPos qPos = QueryPos.getInstance(q);
15330    
15331                                    qPos.add(companyId);
15332    
15333                                    qPos.add(userId);
15334    
15335                                    qPos.add(status);
15336    
15337                                    count = (Long)q.uniqueResult();
15338    
15339                                    finderCache.putResult(finderPath, finderArgs, count);
15340                            }
15341                            catch (Exception e) {
15342                                    finderCache.removeResult(finderPath, finderArgs);
15343    
15344                                    throw processException(e);
15345                            }
15346                            finally {
15347                                    closeSession(session);
15348                            }
15349                    }
15350    
15351                    return count.intValue();
15352            }
15353    
15354            private static final String _FINDER_COLUMN_C_U_NOTS_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
15355            private static final String _FINDER_COLUMN_C_U_NOTS_USERID_2 = "blogsEntry.userId = ? AND ";
15356            private static final String _FINDER_COLUMN_C_U_NOTS_STATUS_2 = "blogsEntry.status != ?";
15357            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
15358                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
15359                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_LtD_S",
15360                            new String[] {
15361                                    Long.class.getName(), Date.class.getName(),
15362                                    Integer.class.getName(),
15363                                    
15364                            Integer.class.getName(), Integer.class.getName(),
15365                                    OrderByComparator.class.getName()
15366                            });
15367            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
15368                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
15369                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_LtD_S",
15370                            new String[] {
15371                                    Long.class.getName(), Date.class.getName(),
15372                                    Integer.class.getName()
15373                            });
15374    
15375            /**
15376             * Returns all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
15377             *
15378             * @param companyId the company ID
15379             * @param displayDate the display date
15380             * @param status the status
15381             * @return the matching blogs entries
15382             */
15383            @Override
15384            public List<BlogsEntry> findByC_LtD_S(long companyId, Date displayDate,
15385                    int status) {
15386                    return findByC_LtD_S(companyId, displayDate, status, QueryUtil.ALL_POS,
15387                            QueryUtil.ALL_POS, null);
15388            }
15389    
15390            /**
15391             * Returns a range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
15392             *
15393             * <p>
15394             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
15395             * </p>
15396             *
15397             * @param companyId the company ID
15398             * @param displayDate the display date
15399             * @param status the status
15400             * @param start the lower bound of the range of blogs entries
15401             * @param end the upper bound of the range of blogs entries (not inclusive)
15402             * @return the range of matching blogs entries
15403             */
15404            @Override
15405            public List<BlogsEntry> findByC_LtD_S(long companyId, Date displayDate,
15406                    int status, int start, int end) {
15407                    return findByC_LtD_S(companyId, displayDate, status, start, end, null);
15408            }
15409    
15410            /**
15411             * Returns an ordered range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
15412             *
15413             * <p>
15414             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
15415             * </p>
15416             *
15417             * @param companyId the company ID
15418             * @param displayDate the display date
15419             * @param status the status
15420             * @param start the lower bound of the range of blogs entries
15421             * @param end the upper bound of the range of blogs entries (not inclusive)
15422             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
15423             * @return the ordered range of matching blogs entries
15424             */
15425            @Override
15426            public List<BlogsEntry> findByC_LtD_S(long companyId, Date displayDate,
15427                    int status, int start, int end,
15428                    OrderByComparator<BlogsEntry> orderByComparator) {
15429                    return findByC_LtD_S(companyId, displayDate, status, start, end,
15430                            orderByComparator, true);
15431            }
15432    
15433            /**
15434             * Returns an ordered range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
15435             *
15436             * <p>
15437             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
15438             * </p>
15439             *
15440             * @param companyId the company ID
15441             * @param displayDate the display date
15442             * @param status the status
15443             * @param start the lower bound of the range of blogs entries
15444             * @param end the upper bound of the range of blogs entries (not inclusive)
15445             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
15446             * @param retrieveFromCache whether to retrieve from the finder cache
15447             * @return the ordered range of matching blogs entries
15448             */
15449            @Override
15450            public List<BlogsEntry> findByC_LtD_S(long companyId, Date displayDate,
15451                    int status, int start, int end,
15452                    OrderByComparator<BlogsEntry> orderByComparator,
15453                    boolean retrieveFromCache) {
15454                    boolean pagination = true;
15455                    FinderPath finderPath = null;
15456                    Object[] finderArgs = null;
15457    
15458                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD_S;
15459                    finderArgs = new Object[] {
15460                                    companyId, displayDate, status,
15461                                    
15462                                    start, end, orderByComparator
15463                            };
15464    
15465                    List<BlogsEntry> list = null;
15466    
15467                    if (retrieveFromCache) {
15468                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
15469                                            finderArgs, this);
15470    
15471                            if ((list != null) && !list.isEmpty()) {
15472                                    for (BlogsEntry blogsEntry : list) {
15473                                            if ((companyId != blogsEntry.getCompanyId()) ||
15474                                                            (displayDate.getTime() <= blogsEntry.getDisplayDate()
15475                                                                                                                                            .getTime()) ||
15476                                                            (status != blogsEntry.getStatus())) {
15477                                                    list = null;
15478    
15479                                                    break;
15480                                            }
15481                                    }
15482                            }
15483                    }
15484    
15485                    if (list == null) {
15486                            StringBundler query = null;
15487    
15488                            if (orderByComparator != null) {
15489                                    query = new StringBundler(5 +
15490                                                    (orderByComparator.getOrderByFields().length * 2));
15491                            }
15492                            else {
15493                                    query = new StringBundler(5);
15494                            }
15495    
15496                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
15497    
15498                            query.append(_FINDER_COLUMN_C_LTD_S_COMPANYID_2);
15499    
15500                            boolean bindDisplayDate = false;
15501    
15502                            if (displayDate == null) {
15503                                    query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_1);
15504                            }
15505                            else {
15506                                    bindDisplayDate = true;
15507    
15508                                    query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_2);
15509                            }
15510    
15511                            query.append(_FINDER_COLUMN_C_LTD_S_STATUS_2);
15512    
15513                            if (orderByComparator != null) {
15514                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
15515                                            orderByComparator);
15516                            }
15517                            else
15518                             if (pagination) {
15519                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
15520                            }
15521    
15522                            String sql = query.toString();
15523    
15524                            Session session = null;
15525    
15526                            try {
15527                                    session = openSession();
15528    
15529                                    Query q = session.createQuery(sql);
15530    
15531                                    QueryPos qPos = QueryPos.getInstance(q);
15532    
15533                                    qPos.add(companyId);
15534    
15535                                    if (bindDisplayDate) {
15536                                            qPos.add(new Timestamp(displayDate.getTime()));
15537                                    }
15538    
15539                                    qPos.add(status);
15540    
15541                                    if (!pagination) {
15542                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
15543                                                            start, end, false);
15544    
15545                                            Collections.sort(list);
15546    
15547                                            list = Collections.unmodifiableList(list);
15548                                    }
15549                                    else {
15550                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
15551                                                            start, end);
15552                                    }
15553    
15554                                    cacheResult(list);
15555    
15556                                    finderCache.putResult(finderPath, finderArgs, list);
15557                            }
15558                            catch (Exception e) {
15559                                    finderCache.removeResult(finderPath, finderArgs);
15560    
15561                                    throw processException(e);
15562                            }
15563                            finally {
15564                                    closeSession(session);
15565                            }
15566                    }
15567    
15568                    return list;
15569            }
15570    
15571            /**
15572             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
15573             *
15574             * @param companyId the company ID
15575             * @param displayDate the display date
15576             * @param status the status
15577             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15578             * @return the first matching blogs entry
15579             * @throws NoSuchEntryException if a matching blogs entry could not be found
15580             */
15581            @Override
15582            public BlogsEntry findByC_LtD_S_First(long companyId, Date displayDate,
15583                    int status, OrderByComparator<BlogsEntry> orderByComparator)
15584                    throws NoSuchEntryException {
15585                    BlogsEntry blogsEntry = fetchByC_LtD_S_First(companyId, displayDate,
15586                                    status, orderByComparator);
15587    
15588                    if (blogsEntry != null) {
15589                            return blogsEntry;
15590                    }
15591    
15592                    StringBundler msg = new StringBundler(8);
15593    
15594                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15595    
15596                    msg.append("companyId=");
15597                    msg.append(companyId);
15598    
15599                    msg.append(", displayDate=");
15600                    msg.append(displayDate);
15601    
15602                    msg.append(", status=");
15603                    msg.append(status);
15604    
15605                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15606    
15607                    throw new NoSuchEntryException(msg.toString());
15608            }
15609    
15610            /**
15611             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
15612             *
15613             * @param companyId the company ID
15614             * @param displayDate the display date
15615             * @param status the status
15616             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15617             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
15618             */
15619            @Override
15620            public BlogsEntry fetchByC_LtD_S_First(long companyId, Date displayDate,
15621                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
15622                    List<BlogsEntry> list = findByC_LtD_S(companyId, displayDate, status,
15623                                    0, 1, orderByComparator);
15624    
15625                    if (!list.isEmpty()) {
15626                            return list.get(0);
15627                    }
15628    
15629                    return null;
15630            }
15631    
15632            /**
15633             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
15634             *
15635             * @param companyId the company ID
15636             * @param displayDate the display date
15637             * @param status the status
15638             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15639             * @return the last matching blogs entry
15640             * @throws NoSuchEntryException if a matching blogs entry could not be found
15641             */
15642            @Override
15643            public BlogsEntry findByC_LtD_S_Last(long companyId, Date displayDate,
15644                    int status, OrderByComparator<BlogsEntry> orderByComparator)
15645                    throws NoSuchEntryException {
15646                    BlogsEntry blogsEntry = fetchByC_LtD_S_Last(companyId, displayDate,
15647                                    status, orderByComparator);
15648    
15649                    if (blogsEntry != null) {
15650                            return blogsEntry;
15651                    }
15652    
15653                    StringBundler msg = new StringBundler(8);
15654    
15655                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15656    
15657                    msg.append("companyId=");
15658                    msg.append(companyId);
15659    
15660                    msg.append(", displayDate=");
15661                    msg.append(displayDate);
15662    
15663                    msg.append(", status=");
15664                    msg.append(status);
15665    
15666                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15667    
15668                    throw new NoSuchEntryException(msg.toString());
15669            }
15670    
15671            /**
15672             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
15673             *
15674             * @param companyId the company ID
15675             * @param displayDate the display date
15676             * @param status the status
15677             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15678             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
15679             */
15680            @Override
15681            public BlogsEntry fetchByC_LtD_S_Last(long companyId, Date displayDate,
15682                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
15683                    int count = countByC_LtD_S(companyId, displayDate, status);
15684    
15685                    if (count == 0) {
15686                            return null;
15687                    }
15688    
15689                    List<BlogsEntry> list = findByC_LtD_S(companyId, displayDate, status,
15690                                    count - 1, count, orderByComparator);
15691    
15692                    if (!list.isEmpty()) {
15693                            return list.get(0);
15694                    }
15695    
15696                    return null;
15697            }
15698    
15699            /**
15700             * 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;.
15701             *
15702             * @param entryId the primary key of the current blogs entry
15703             * @param companyId the company ID
15704             * @param displayDate the display date
15705             * @param status the status
15706             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15707             * @return the previous, current, and next blogs entry
15708             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
15709             */
15710            @Override
15711            public BlogsEntry[] findByC_LtD_S_PrevAndNext(long entryId, long companyId,
15712                    Date displayDate, int status,
15713                    OrderByComparator<BlogsEntry> orderByComparator)
15714                    throws NoSuchEntryException {
15715                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
15716    
15717                    Session session = null;
15718    
15719                    try {
15720                            session = openSession();
15721    
15722                            BlogsEntry[] array = new BlogsEntryImpl[3];
15723    
15724                            array[0] = getByC_LtD_S_PrevAndNext(session, blogsEntry, companyId,
15725                                            displayDate, status, orderByComparator, true);
15726    
15727                            array[1] = blogsEntry;
15728    
15729                            array[2] = getByC_LtD_S_PrevAndNext(session, blogsEntry, companyId,
15730                                            displayDate, status, orderByComparator, false);
15731    
15732                            return array;
15733                    }
15734                    catch (Exception e) {
15735                            throw processException(e);
15736                    }
15737                    finally {
15738                            closeSession(session);
15739                    }
15740            }
15741    
15742            protected BlogsEntry getByC_LtD_S_PrevAndNext(Session session,
15743                    BlogsEntry blogsEntry, long companyId, Date displayDate, int status,
15744                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
15745                    StringBundler query = null;
15746    
15747                    if (orderByComparator != null) {
15748                            query = new StringBundler(6 +
15749                                            (orderByComparator.getOrderByConditionFields().length * 3) +
15750                                            (orderByComparator.getOrderByFields().length * 3));
15751                    }
15752                    else {
15753                            query = new StringBundler(5);
15754                    }
15755    
15756                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
15757    
15758                    query.append(_FINDER_COLUMN_C_LTD_S_COMPANYID_2);
15759    
15760                    boolean bindDisplayDate = false;
15761    
15762                    if (displayDate == null) {
15763                            query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_1);
15764                    }
15765                    else {
15766                            bindDisplayDate = true;
15767    
15768                            query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_2);
15769                    }
15770    
15771                    query.append(_FINDER_COLUMN_C_LTD_S_STATUS_2);
15772    
15773                    if (orderByComparator != null) {
15774                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
15775    
15776                            if (orderByConditionFields.length > 0) {
15777                                    query.append(WHERE_AND);
15778                            }
15779    
15780                            for (int i = 0; i < orderByConditionFields.length; i++) {
15781                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15782                                    query.append(orderByConditionFields[i]);
15783    
15784                                    if ((i + 1) < orderByConditionFields.length) {
15785                                            if (orderByComparator.isAscending() ^ previous) {
15786                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
15787                                            }
15788                                            else {
15789                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
15790                                            }
15791                                    }
15792                                    else {
15793                                            if (orderByComparator.isAscending() ^ previous) {
15794                                                    query.append(WHERE_GREATER_THAN);
15795                                            }
15796                                            else {
15797                                                    query.append(WHERE_LESSER_THAN);
15798                                            }
15799                                    }
15800                            }
15801    
15802                            query.append(ORDER_BY_CLAUSE);
15803    
15804                            String[] orderByFields = orderByComparator.getOrderByFields();
15805    
15806                            for (int i = 0; i < orderByFields.length; i++) {
15807                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15808                                    query.append(orderByFields[i]);
15809    
15810                                    if ((i + 1) < orderByFields.length) {
15811                                            if (orderByComparator.isAscending() ^ previous) {
15812                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
15813                                            }
15814                                            else {
15815                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
15816                                            }
15817                                    }
15818                                    else {
15819                                            if (orderByComparator.isAscending() ^ previous) {
15820                                                    query.append(ORDER_BY_ASC);
15821                                            }
15822                                            else {
15823                                                    query.append(ORDER_BY_DESC);
15824                                            }
15825                                    }
15826                            }
15827                    }
15828                    else {
15829                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
15830                    }
15831    
15832                    String sql = query.toString();
15833    
15834                    Query q = session.createQuery(sql);
15835    
15836                    q.setFirstResult(0);
15837                    q.setMaxResults(2);
15838    
15839                    QueryPos qPos = QueryPos.getInstance(q);
15840    
15841                    qPos.add(companyId);
15842    
15843                    if (bindDisplayDate) {
15844                            qPos.add(new Timestamp(displayDate.getTime()));
15845                    }
15846    
15847                    qPos.add(status);
15848    
15849                    if (orderByComparator != null) {
15850                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
15851    
15852                            for (Object value : values) {
15853                                    qPos.add(value);
15854                            }
15855                    }
15856    
15857                    List<BlogsEntry> list = q.list();
15858    
15859                    if (list.size() == 2) {
15860                            return list.get(1);
15861                    }
15862                    else {
15863                            return null;
15864                    }
15865            }
15866    
15867            /**
15868             * Removes all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63; from the database.
15869             *
15870             * @param companyId the company ID
15871             * @param displayDate the display date
15872             * @param status the status
15873             */
15874            @Override
15875            public void removeByC_LtD_S(long companyId, Date displayDate, int status) {
15876                    for (BlogsEntry blogsEntry : findByC_LtD_S(companyId, displayDate,
15877                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
15878                            remove(blogsEntry);
15879                    }
15880            }
15881    
15882            /**
15883             * Returns the number of blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
15884             *
15885             * @param companyId the company ID
15886             * @param displayDate the display date
15887             * @param status the status
15888             * @return the number of matching blogs entries
15889             */
15890            @Override
15891            public int countByC_LtD_S(long companyId, Date displayDate, int status) {
15892                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD_S;
15893    
15894                    Object[] finderArgs = new Object[] { companyId, displayDate, status };
15895    
15896                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
15897    
15898                    if (count == null) {
15899                            StringBundler query = new StringBundler(4);
15900    
15901                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
15902    
15903                            query.append(_FINDER_COLUMN_C_LTD_S_COMPANYID_2);
15904    
15905                            boolean bindDisplayDate = false;
15906    
15907                            if (displayDate == null) {
15908                                    query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_1);
15909                            }
15910                            else {
15911                                    bindDisplayDate = true;
15912    
15913                                    query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_2);
15914                            }
15915    
15916                            query.append(_FINDER_COLUMN_C_LTD_S_STATUS_2);
15917    
15918                            String sql = query.toString();
15919    
15920                            Session session = null;
15921    
15922                            try {
15923                                    session = openSession();
15924    
15925                                    Query q = session.createQuery(sql);
15926    
15927                                    QueryPos qPos = QueryPos.getInstance(q);
15928    
15929                                    qPos.add(companyId);
15930    
15931                                    if (bindDisplayDate) {
15932                                            qPos.add(new Timestamp(displayDate.getTime()));
15933                                    }
15934    
15935                                    qPos.add(status);
15936    
15937                                    count = (Long)q.uniqueResult();
15938    
15939                                    finderCache.putResult(finderPath, finderArgs, count);
15940                            }
15941                            catch (Exception e) {
15942                                    finderCache.removeResult(finderPath, finderArgs);
15943    
15944                                    throw processException(e);
15945                            }
15946                            finally {
15947                                    closeSession(session);
15948                            }
15949                    }
15950    
15951                    return count.intValue();
15952            }
15953    
15954            private static final String _FINDER_COLUMN_C_LTD_S_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
15955            private static final String _FINDER_COLUMN_C_LTD_S_DISPLAYDATE_1 = "blogsEntry.displayDate IS NULL AND ";
15956            private static final String _FINDER_COLUMN_C_LTD_S_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
15957            private static final String _FINDER_COLUMN_C_LTD_S_STATUS_2 = "blogsEntry.status = ?";
15958            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD_NOTS =
15959                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
15960                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
15961                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_LtD_NotS",
15962                            new String[] {
15963                                    Long.class.getName(), Date.class.getName(),
15964                                    Integer.class.getName(),
15965                                    
15966                            Integer.class.getName(), Integer.class.getName(),
15967                                    OrderByComparator.class.getName()
15968                            });
15969            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD_NOTS =
15970                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
15971                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
15972                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_LtD_NotS",
15973                            new String[] {
15974                                    Long.class.getName(), Date.class.getName(),
15975                                    Integer.class.getName()
15976                            });
15977    
15978            /**
15979             * Returns all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
15980             *
15981             * @param companyId the company ID
15982             * @param displayDate the display date
15983             * @param status the status
15984             * @return the matching blogs entries
15985             */
15986            @Override
15987            public List<BlogsEntry> findByC_LtD_NotS(long companyId, Date displayDate,
15988                    int status) {
15989                    return findByC_LtD_NotS(companyId, displayDate, status,
15990                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
15991            }
15992    
15993            /**
15994             * Returns a range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
15995             *
15996             * <p>
15997             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
15998             * </p>
15999             *
16000             * @param companyId the company ID
16001             * @param displayDate the display date
16002             * @param status the status
16003             * @param start the lower bound of the range of blogs entries
16004             * @param end the upper bound of the range of blogs entries (not inclusive)
16005             * @return the range of matching blogs entries
16006             */
16007            @Override
16008            public List<BlogsEntry> findByC_LtD_NotS(long companyId, Date displayDate,
16009                    int status, int start, int end) {
16010                    return findByC_LtD_NotS(companyId, displayDate, status, start, end, null);
16011            }
16012    
16013            /**
16014             * Returns an ordered range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
16015             *
16016             * <p>
16017             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
16018             * </p>
16019             *
16020             * @param companyId the company ID
16021             * @param displayDate the display date
16022             * @param status the status
16023             * @param start the lower bound of the range of blogs entries
16024             * @param end the upper bound of the range of blogs entries (not inclusive)
16025             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
16026             * @return the ordered range of matching blogs entries
16027             */
16028            @Override
16029            public List<BlogsEntry> findByC_LtD_NotS(long companyId, Date displayDate,
16030                    int status, int start, int end,
16031                    OrderByComparator<BlogsEntry> orderByComparator) {
16032                    return findByC_LtD_NotS(companyId, displayDate, status, start, end,
16033                            orderByComparator, true);
16034            }
16035    
16036            /**
16037             * Returns an ordered range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
16038             *
16039             * <p>
16040             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
16041             * </p>
16042             *
16043             * @param companyId the company ID
16044             * @param displayDate the display date
16045             * @param status the status
16046             * @param start the lower bound of the range of blogs entries
16047             * @param end the upper bound of the range of blogs entries (not inclusive)
16048             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
16049             * @param retrieveFromCache whether to retrieve from the finder cache
16050             * @return the ordered range of matching blogs entries
16051             */
16052            @Override
16053            public List<BlogsEntry> findByC_LtD_NotS(long companyId, Date displayDate,
16054                    int status, int start, int end,
16055                    OrderByComparator<BlogsEntry> orderByComparator,
16056                    boolean retrieveFromCache) {
16057                    boolean pagination = true;
16058                    FinderPath finderPath = null;
16059                    Object[] finderArgs = null;
16060    
16061                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD_NOTS;
16062                    finderArgs = new Object[] {
16063                                    companyId, displayDate, status,
16064                                    
16065                                    start, end, orderByComparator
16066                            };
16067    
16068                    List<BlogsEntry> list = null;
16069    
16070                    if (retrieveFromCache) {
16071                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
16072                                            finderArgs, this);
16073    
16074                            if ((list != null) && !list.isEmpty()) {
16075                                    for (BlogsEntry blogsEntry : list) {
16076                                            if ((companyId != blogsEntry.getCompanyId()) ||
16077                                                            (displayDate.getTime() <= blogsEntry.getDisplayDate()
16078                                                                                                                                            .getTime()) ||
16079                                                            (status == blogsEntry.getStatus())) {
16080                                                    list = null;
16081    
16082                                                    break;
16083                                            }
16084                                    }
16085                            }
16086                    }
16087    
16088                    if (list == null) {
16089                            StringBundler query = null;
16090    
16091                            if (orderByComparator != null) {
16092                                    query = new StringBundler(5 +
16093                                                    (orderByComparator.getOrderByFields().length * 2));
16094                            }
16095                            else {
16096                                    query = new StringBundler(5);
16097                            }
16098    
16099                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
16100    
16101                            query.append(_FINDER_COLUMN_C_LTD_NOTS_COMPANYID_2);
16102    
16103                            boolean bindDisplayDate = false;
16104    
16105                            if (displayDate == null) {
16106                                    query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_1);
16107                            }
16108                            else {
16109                                    bindDisplayDate = true;
16110    
16111                                    query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_2);
16112                            }
16113    
16114                            query.append(_FINDER_COLUMN_C_LTD_NOTS_STATUS_2);
16115    
16116                            if (orderByComparator != null) {
16117                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
16118                                            orderByComparator);
16119                            }
16120                            else
16121                             if (pagination) {
16122                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
16123                            }
16124    
16125                            String sql = query.toString();
16126    
16127                            Session session = null;
16128    
16129                            try {
16130                                    session = openSession();
16131    
16132                                    Query q = session.createQuery(sql);
16133    
16134                                    QueryPos qPos = QueryPos.getInstance(q);
16135    
16136                                    qPos.add(companyId);
16137    
16138                                    if (bindDisplayDate) {
16139                                            qPos.add(new Timestamp(displayDate.getTime()));
16140                                    }
16141    
16142                                    qPos.add(status);
16143    
16144                                    if (!pagination) {
16145                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
16146                                                            start, end, false);
16147    
16148                                            Collections.sort(list);
16149    
16150                                            list = Collections.unmodifiableList(list);
16151                                    }
16152                                    else {
16153                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
16154                                                            start, end);
16155                                    }
16156    
16157                                    cacheResult(list);
16158    
16159                                    finderCache.putResult(finderPath, finderArgs, list);
16160                            }
16161                            catch (Exception e) {
16162                                    finderCache.removeResult(finderPath, finderArgs);
16163    
16164                                    throw processException(e);
16165                            }
16166                            finally {
16167                                    closeSession(session);
16168                            }
16169                    }
16170    
16171                    return list;
16172            }
16173    
16174            /**
16175             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
16176             *
16177             * @param companyId the company ID
16178             * @param displayDate the display date
16179             * @param status the status
16180             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16181             * @return the first matching blogs entry
16182             * @throws NoSuchEntryException if a matching blogs entry could not be found
16183             */
16184            @Override
16185            public BlogsEntry findByC_LtD_NotS_First(long companyId, Date displayDate,
16186                    int status, OrderByComparator<BlogsEntry> orderByComparator)
16187                    throws NoSuchEntryException {
16188                    BlogsEntry blogsEntry = fetchByC_LtD_NotS_First(companyId, displayDate,
16189                                    status, orderByComparator);
16190    
16191                    if (blogsEntry != null) {
16192                            return blogsEntry;
16193                    }
16194    
16195                    StringBundler msg = new StringBundler(8);
16196    
16197                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
16198    
16199                    msg.append("companyId=");
16200                    msg.append(companyId);
16201    
16202                    msg.append(", displayDate=");
16203                    msg.append(displayDate);
16204    
16205                    msg.append(", status=");
16206                    msg.append(status);
16207    
16208                    msg.append(StringPool.CLOSE_CURLY_BRACE);
16209    
16210                    throw new NoSuchEntryException(msg.toString());
16211            }
16212    
16213            /**
16214             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
16215             *
16216             * @param companyId the company ID
16217             * @param displayDate the display date
16218             * @param status the status
16219             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16220             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
16221             */
16222            @Override
16223            public BlogsEntry fetchByC_LtD_NotS_First(long companyId, Date displayDate,
16224                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
16225                    List<BlogsEntry> list = findByC_LtD_NotS(companyId, displayDate,
16226                                    status, 0, 1, orderByComparator);
16227    
16228                    if (!list.isEmpty()) {
16229                            return list.get(0);
16230                    }
16231    
16232                    return null;
16233            }
16234    
16235            /**
16236             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
16237             *
16238             * @param companyId the company ID
16239             * @param displayDate the display date
16240             * @param status the status
16241             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16242             * @return the last matching blogs entry
16243             * @throws NoSuchEntryException if a matching blogs entry could not be found
16244             */
16245            @Override
16246            public BlogsEntry findByC_LtD_NotS_Last(long companyId, Date displayDate,
16247                    int status, OrderByComparator<BlogsEntry> orderByComparator)
16248                    throws NoSuchEntryException {
16249                    BlogsEntry blogsEntry = fetchByC_LtD_NotS_Last(companyId, displayDate,
16250                                    status, orderByComparator);
16251    
16252                    if (blogsEntry != null) {
16253                            return blogsEntry;
16254                    }
16255    
16256                    StringBundler msg = new StringBundler(8);
16257    
16258                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
16259    
16260                    msg.append("companyId=");
16261                    msg.append(companyId);
16262    
16263                    msg.append(", displayDate=");
16264                    msg.append(displayDate);
16265    
16266                    msg.append(", status=");
16267                    msg.append(status);
16268    
16269                    msg.append(StringPool.CLOSE_CURLY_BRACE);
16270    
16271                    throw new NoSuchEntryException(msg.toString());
16272            }
16273    
16274            /**
16275             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
16276             *
16277             * @param companyId the company ID
16278             * @param displayDate the display date
16279             * @param status the status
16280             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16281             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
16282             */
16283            @Override
16284            public BlogsEntry fetchByC_LtD_NotS_Last(long companyId, Date displayDate,
16285                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
16286                    int count = countByC_LtD_NotS(companyId, displayDate, status);
16287    
16288                    if (count == 0) {
16289                            return null;
16290                    }
16291    
16292                    List<BlogsEntry> list = findByC_LtD_NotS(companyId, displayDate,
16293                                    status, count - 1, count, orderByComparator);
16294    
16295                    if (!list.isEmpty()) {
16296                            return list.get(0);
16297                    }
16298    
16299                    return null;
16300            }
16301    
16302            /**
16303             * 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;.
16304             *
16305             * @param entryId the primary key of the current blogs entry
16306             * @param companyId the company ID
16307             * @param displayDate the display date
16308             * @param status the status
16309             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16310             * @return the previous, current, and next blogs entry
16311             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
16312             */
16313            @Override
16314            public BlogsEntry[] findByC_LtD_NotS_PrevAndNext(long entryId,
16315                    long companyId, Date displayDate, int status,
16316                    OrderByComparator<BlogsEntry> orderByComparator)
16317                    throws NoSuchEntryException {
16318                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
16319    
16320                    Session session = null;
16321    
16322                    try {
16323                            session = openSession();
16324    
16325                            BlogsEntry[] array = new BlogsEntryImpl[3];
16326    
16327                            array[0] = getByC_LtD_NotS_PrevAndNext(session, blogsEntry,
16328                                            companyId, displayDate, status, orderByComparator, true);
16329    
16330                            array[1] = blogsEntry;
16331    
16332                            array[2] = getByC_LtD_NotS_PrevAndNext(session, blogsEntry,
16333                                            companyId, displayDate, status, orderByComparator, false);
16334    
16335                            return array;
16336                    }
16337                    catch (Exception e) {
16338                            throw processException(e);
16339                    }
16340                    finally {
16341                            closeSession(session);
16342                    }
16343            }
16344    
16345            protected BlogsEntry getByC_LtD_NotS_PrevAndNext(Session session,
16346                    BlogsEntry blogsEntry, long companyId, Date displayDate, int status,
16347                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
16348                    StringBundler query = null;
16349    
16350                    if (orderByComparator != null) {
16351                            query = new StringBundler(6 +
16352                                            (orderByComparator.getOrderByConditionFields().length * 3) +
16353                                            (orderByComparator.getOrderByFields().length * 3));
16354                    }
16355                    else {
16356                            query = new StringBundler(5);
16357                    }
16358    
16359                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
16360    
16361                    query.append(_FINDER_COLUMN_C_LTD_NOTS_COMPANYID_2);
16362    
16363                    boolean bindDisplayDate = false;
16364    
16365                    if (displayDate == null) {
16366                            query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_1);
16367                    }
16368                    else {
16369                            bindDisplayDate = true;
16370    
16371                            query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_2);
16372                    }
16373    
16374                    query.append(_FINDER_COLUMN_C_LTD_NOTS_STATUS_2);
16375    
16376                    if (orderByComparator != null) {
16377                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
16378    
16379                            if (orderByConditionFields.length > 0) {
16380                                    query.append(WHERE_AND);
16381                            }
16382    
16383                            for (int i = 0; i < orderByConditionFields.length; i++) {
16384                                    query.append(_ORDER_BY_ENTITY_ALIAS);
16385                                    query.append(orderByConditionFields[i]);
16386    
16387                                    if ((i + 1) < orderByConditionFields.length) {
16388                                            if (orderByComparator.isAscending() ^ previous) {
16389                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
16390                                            }
16391                                            else {
16392                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
16393                                            }
16394                                    }
16395                                    else {
16396                                            if (orderByComparator.isAscending() ^ previous) {
16397                                                    query.append(WHERE_GREATER_THAN);
16398                                            }
16399                                            else {
16400                                                    query.append(WHERE_LESSER_THAN);
16401                                            }
16402                                    }
16403                            }
16404    
16405                            query.append(ORDER_BY_CLAUSE);
16406    
16407                            String[] orderByFields = orderByComparator.getOrderByFields();
16408    
16409                            for (int i = 0; i < orderByFields.length; i++) {
16410                                    query.append(_ORDER_BY_ENTITY_ALIAS);
16411                                    query.append(orderByFields[i]);
16412    
16413                                    if ((i + 1) < orderByFields.length) {
16414                                            if (orderByComparator.isAscending() ^ previous) {
16415                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
16416                                            }
16417                                            else {
16418                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
16419                                            }
16420                                    }
16421                                    else {
16422                                            if (orderByComparator.isAscending() ^ previous) {
16423                                                    query.append(ORDER_BY_ASC);
16424                                            }
16425                                            else {
16426                                                    query.append(ORDER_BY_DESC);
16427                                            }
16428                                    }
16429                            }
16430                    }
16431                    else {
16432                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
16433                    }
16434    
16435                    String sql = query.toString();
16436    
16437                    Query q = session.createQuery(sql);
16438    
16439                    q.setFirstResult(0);
16440                    q.setMaxResults(2);
16441    
16442                    QueryPos qPos = QueryPos.getInstance(q);
16443    
16444                    qPos.add(companyId);
16445    
16446                    if (bindDisplayDate) {
16447                            qPos.add(new Timestamp(displayDate.getTime()));
16448                    }
16449    
16450                    qPos.add(status);
16451    
16452                    if (orderByComparator != null) {
16453                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
16454    
16455                            for (Object value : values) {
16456                                    qPos.add(value);
16457                            }
16458                    }
16459    
16460                    List<BlogsEntry> list = q.list();
16461    
16462                    if (list.size() == 2) {
16463                            return list.get(1);
16464                    }
16465                    else {
16466                            return null;
16467                    }
16468            }
16469    
16470            /**
16471             * Removes all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63; from the database.
16472             *
16473             * @param companyId the company ID
16474             * @param displayDate the display date
16475             * @param status the status
16476             */
16477            @Override
16478            public void removeByC_LtD_NotS(long companyId, Date displayDate, int status) {
16479                    for (BlogsEntry blogsEntry : findByC_LtD_NotS(companyId, displayDate,
16480                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
16481                            remove(blogsEntry);
16482                    }
16483            }
16484    
16485            /**
16486             * Returns the number of blogs entries where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
16487             *
16488             * @param companyId the company ID
16489             * @param displayDate the display date
16490             * @param status the status
16491             * @return the number of matching blogs entries
16492             */
16493            @Override
16494            public int countByC_LtD_NotS(long companyId, Date displayDate, int status) {
16495                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD_NOTS;
16496    
16497                    Object[] finderArgs = new Object[] { companyId, displayDate, status };
16498    
16499                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
16500    
16501                    if (count == null) {
16502                            StringBundler query = new StringBundler(4);
16503    
16504                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
16505    
16506                            query.append(_FINDER_COLUMN_C_LTD_NOTS_COMPANYID_2);
16507    
16508                            boolean bindDisplayDate = false;
16509    
16510                            if (displayDate == null) {
16511                                    query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_1);
16512                            }
16513                            else {
16514                                    bindDisplayDate = true;
16515    
16516                                    query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_2);
16517                            }
16518    
16519                            query.append(_FINDER_COLUMN_C_LTD_NOTS_STATUS_2);
16520    
16521                            String sql = query.toString();
16522    
16523                            Session session = null;
16524    
16525                            try {
16526                                    session = openSession();
16527    
16528                                    Query q = session.createQuery(sql);
16529    
16530                                    QueryPos qPos = QueryPos.getInstance(q);
16531    
16532                                    qPos.add(companyId);
16533    
16534                                    if (bindDisplayDate) {
16535                                            qPos.add(new Timestamp(displayDate.getTime()));
16536                                    }
16537    
16538                                    qPos.add(status);
16539    
16540                                    count = (Long)q.uniqueResult();
16541    
16542                                    finderCache.putResult(finderPath, finderArgs, count);
16543                            }
16544                            catch (Exception e) {
16545                                    finderCache.removeResult(finderPath, finderArgs);
16546    
16547                                    throw processException(e);
16548                            }
16549                            finally {
16550                                    closeSession(session);
16551                            }
16552                    }
16553    
16554                    return count.intValue();
16555            }
16556    
16557            private static final String _FINDER_COLUMN_C_LTD_NOTS_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
16558            private static final String _FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_1 = "blogsEntry.displayDate IS NULL AND ";
16559            private static final String _FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
16560            private static final String _FINDER_COLUMN_C_LTD_NOTS_STATUS_2 = "blogsEntry.status != ?";
16561            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD_S =
16562                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
16563                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
16564                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_LtD_S",
16565                            new String[] {
16566                                    Long.class.getName(), Long.class.getName(), Date.class.getName(),
16567                                    Integer.class.getName(),
16568                                    
16569                            Integer.class.getName(), Integer.class.getName(),
16570                                    OrderByComparator.class.getName()
16571                            });
16572            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD_S =
16573                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
16574                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
16575                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_U_LtD_S",
16576                            new String[] {
16577                                    Long.class.getName(), Long.class.getName(), Date.class.getName(),
16578                                    Integer.class.getName()
16579                            });
16580    
16581            /**
16582             * Returns all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16583             *
16584             * @param groupId the group ID
16585             * @param userId the user ID
16586             * @param displayDate the display date
16587             * @param status the status
16588             * @return the matching blogs entries
16589             */
16590            @Override
16591            public List<BlogsEntry> findByG_U_LtD_S(long groupId, long userId,
16592                    Date displayDate, int status) {
16593                    return findByG_U_LtD_S(groupId, userId, displayDate, status,
16594                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
16595            }
16596    
16597            /**
16598             * Returns a range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16599             *
16600             * <p>
16601             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
16602             * </p>
16603             *
16604             * @param groupId the group ID
16605             * @param userId the user ID
16606             * @param displayDate the display date
16607             * @param status the status
16608             * @param start the lower bound of the range of blogs entries
16609             * @param end the upper bound of the range of blogs entries (not inclusive)
16610             * @return the range of matching blogs entries
16611             */
16612            @Override
16613            public List<BlogsEntry> findByG_U_LtD_S(long groupId, long userId,
16614                    Date displayDate, int status, int start, int end) {
16615                    return findByG_U_LtD_S(groupId, userId, displayDate, status, start,
16616                            end, null);
16617            }
16618    
16619            /**
16620             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16621             *
16622             * <p>
16623             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
16624             * </p>
16625             *
16626             * @param groupId the group ID
16627             * @param userId the user ID
16628             * @param displayDate the display date
16629             * @param status the status
16630             * @param start the lower bound of the range of blogs entries
16631             * @param end the upper bound of the range of blogs entries (not inclusive)
16632             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
16633             * @return the ordered range of matching blogs entries
16634             */
16635            @Override
16636            public List<BlogsEntry> findByG_U_LtD_S(long groupId, long userId,
16637                    Date displayDate, int status, int start, int end,
16638                    OrderByComparator<BlogsEntry> orderByComparator) {
16639                    return findByG_U_LtD_S(groupId, userId, displayDate, status, start,
16640                            end, orderByComparator, true);
16641            }
16642    
16643            /**
16644             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16645             *
16646             * <p>
16647             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
16648             * </p>
16649             *
16650             * @param groupId the group ID
16651             * @param userId the user ID
16652             * @param displayDate the display date
16653             * @param status the status
16654             * @param start the lower bound of the range of blogs entries
16655             * @param end the upper bound of the range of blogs entries (not inclusive)
16656             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
16657             * @param retrieveFromCache whether to retrieve from the finder cache
16658             * @return the ordered range of matching blogs entries
16659             */
16660            @Override
16661            public List<BlogsEntry> findByG_U_LtD_S(long groupId, long userId,
16662                    Date displayDate, int status, int start, int end,
16663                    OrderByComparator<BlogsEntry> orderByComparator,
16664                    boolean retrieveFromCache) {
16665                    boolean pagination = true;
16666                    FinderPath finderPath = null;
16667                    Object[] finderArgs = null;
16668    
16669                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD_S;
16670                    finderArgs = new Object[] {
16671                                    groupId, userId, displayDate, status,
16672                                    
16673                                    start, end, orderByComparator
16674                            };
16675    
16676                    List<BlogsEntry> list = null;
16677    
16678                    if (retrieveFromCache) {
16679                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
16680                                            finderArgs, this);
16681    
16682                            if ((list != null) && !list.isEmpty()) {
16683                                    for (BlogsEntry blogsEntry : list) {
16684                                            if ((groupId != blogsEntry.getGroupId()) ||
16685                                                            (userId != blogsEntry.getUserId()) ||
16686                                                            (displayDate.getTime() <= blogsEntry.getDisplayDate()
16687                                                                                                                                            .getTime()) ||
16688                                                            (status != blogsEntry.getStatus())) {
16689                                                    list = null;
16690    
16691                                                    break;
16692                                            }
16693                                    }
16694                            }
16695                    }
16696    
16697                    if (list == null) {
16698                            StringBundler query = null;
16699    
16700                            if (orderByComparator != null) {
16701                                    query = new StringBundler(6 +
16702                                                    (orderByComparator.getOrderByFields().length * 2));
16703                            }
16704                            else {
16705                                    query = new StringBundler(6);
16706                            }
16707    
16708                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
16709    
16710                            query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
16711    
16712                            query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
16713    
16714                            boolean bindDisplayDate = false;
16715    
16716                            if (displayDate == null) {
16717                                    query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
16718                            }
16719                            else {
16720                                    bindDisplayDate = true;
16721    
16722                                    query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
16723                            }
16724    
16725                            query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
16726    
16727                            if (orderByComparator != null) {
16728                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
16729                                            orderByComparator);
16730                            }
16731                            else
16732                             if (pagination) {
16733                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
16734                            }
16735    
16736                            String sql = query.toString();
16737    
16738                            Session session = null;
16739    
16740                            try {
16741                                    session = openSession();
16742    
16743                                    Query q = session.createQuery(sql);
16744    
16745                                    QueryPos qPos = QueryPos.getInstance(q);
16746    
16747                                    qPos.add(groupId);
16748    
16749                                    qPos.add(userId);
16750    
16751                                    if (bindDisplayDate) {
16752                                            qPos.add(new Timestamp(displayDate.getTime()));
16753                                    }
16754    
16755                                    qPos.add(status);
16756    
16757                                    if (!pagination) {
16758                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
16759                                                            start, end, false);
16760    
16761                                            Collections.sort(list);
16762    
16763                                            list = Collections.unmodifiableList(list);
16764                                    }
16765                                    else {
16766                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
16767                                                            start, end);
16768                                    }
16769    
16770                                    cacheResult(list);
16771    
16772                                    finderCache.putResult(finderPath, finderArgs, list);
16773                            }
16774                            catch (Exception e) {
16775                                    finderCache.removeResult(finderPath, finderArgs);
16776    
16777                                    throw processException(e);
16778                            }
16779                            finally {
16780                                    closeSession(session);
16781                            }
16782                    }
16783    
16784                    return list;
16785            }
16786    
16787            /**
16788             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16789             *
16790             * @param groupId the group ID
16791             * @param userId the user ID
16792             * @param displayDate the display date
16793             * @param status the status
16794             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16795             * @return the first matching blogs entry
16796             * @throws NoSuchEntryException if a matching blogs entry could not be found
16797             */
16798            @Override
16799            public BlogsEntry findByG_U_LtD_S_First(long groupId, long userId,
16800                    Date displayDate, int status,
16801                    OrderByComparator<BlogsEntry> orderByComparator)
16802                    throws NoSuchEntryException {
16803                    BlogsEntry blogsEntry = fetchByG_U_LtD_S_First(groupId, userId,
16804                                    displayDate, status, orderByComparator);
16805    
16806                    if (blogsEntry != null) {
16807                            return blogsEntry;
16808                    }
16809    
16810                    StringBundler msg = new StringBundler(10);
16811    
16812                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
16813    
16814                    msg.append("groupId=");
16815                    msg.append(groupId);
16816    
16817                    msg.append(", userId=");
16818                    msg.append(userId);
16819    
16820                    msg.append(", displayDate=");
16821                    msg.append(displayDate);
16822    
16823                    msg.append(", status=");
16824                    msg.append(status);
16825    
16826                    msg.append(StringPool.CLOSE_CURLY_BRACE);
16827    
16828                    throw new NoSuchEntryException(msg.toString());
16829            }
16830    
16831            /**
16832             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16833             *
16834             * @param groupId the group ID
16835             * @param userId the user ID
16836             * @param displayDate the display date
16837             * @param status the status
16838             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16839             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
16840             */
16841            @Override
16842            public BlogsEntry fetchByG_U_LtD_S_First(long groupId, long userId,
16843                    Date displayDate, int status,
16844                    OrderByComparator<BlogsEntry> orderByComparator) {
16845                    List<BlogsEntry> list = findByG_U_LtD_S(groupId, userId, displayDate,
16846                                    status, 0, 1, orderByComparator);
16847    
16848                    if (!list.isEmpty()) {
16849                            return list.get(0);
16850                    }
16851    
16852                    return null;
16853            }
16854    
16855            /**
16856             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16857             *
16858             * @param groupId the group ID
16859             * @param userId the user ID
16860             * @param displayDate the display date
16861             * @param status the status
16862             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16863             * @return the last matching blogs entry
16864             * @throws NoSuchEntryException if a matching blogs entry could not be found
16865             */
16866            @Override
16867            public BlogsEntry findByG_U_LtD_S_Last(long groupId, long userId,
16868                    Date displayDate, int status,
16869                    OrderByComparator<BlogsEntry> orderByComparator)
16870                    throws NoSuchEntryException {
16871                    BlogsEntry blogsEntry = fetchByG_U_LtD_S_Last(groupId, userId,
16872                                    displayDate, status, orderByComparator);
16873    
16874                    if (blogsEntry != null) {
16875                            return blogsEntry;
16876                    }
16877    
16878                    StringBundler msg = new StringBundler(10);
16879    
16880                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
16881    
16882                    msg.append("groupId=");
16883                    msg.append(groupId);
16884    
16885                    msg.append(", userId=");
16886                    msg.append(userId);
16887    
16888                    msg.append(", displayDate=");
16889                    msg.append(displayDate);
16890    
16891                    msg.append(", status=");
16892                    msg.append(status);
16893    
16894                    msg.append(StringPool.CLOSE_CURLY_BRACE);
16895    
16896                    throw new NoSuchEntryException(msg.toString());
16897            }
16898    
16899            /**
16900             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16901             *
16902             * @param groupId the group ID
16903             * @param userId the user ID
16904             * @param displayDate the display date
16905             * @param status the status
16906             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16907             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
16908             */
16909            @Override
16910            public BlogsEntry fetchByG_U_LtD_S_Last(long groupId, long userId,
16911                    Date displayDate, int status,
16912                    OrderByComparator<BlogsEntry> orderByComparator) {
16913                    int count = countByG_U_LtD_S(groupId, userId, displayDate, status);
16914    
16915                    if (count == 0) {
16916                            return null;
16917                    }
16918    
16919                    List<BlogsEntry> list = findByG_U_LtD_S(groupId, userId, displayDate,
16920                                    status, count - 1, count, orderByComparator);
16921    
16922                    if (!list.isEmpty()) {
16923                            return list.get(0);
16924                    }
16925    
16926                    return null;
16927            }
16928    
16929            /**
16930             * 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;.
16931             *
16932             * @param entryId the primary key of the current blogs entry
16933             * @param groupId the group ID
16934             * @param userId the user ID
16935             * @param displayDate the display date
16936             * @param status the status
16937             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16938             * @return the previous, current, and next blogs entry
16939             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
16940             */
16941            @Override
16942            public BlogsEntry[] findByG_U_LtD_S_PrevAndNext(long entryId, long groupId,
16943                    long userId, Date displayDate, int status,
16944                    OrderByComparator<BlogsEntry> orderByComparator)
16945                    throws NoSuchEntryException {
16946                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
16947    
16948                    Session session = null;
16949    
16950                    try {
16951                            session = openSession();
16952    
16953                            BlogsEntry[] array = new BlogsEntryImpl[3];
16954    
16955                            array[0] = getByG_U_LtD_S_PrevAndNext(session, blogsEntry, groupId,
16956                                            userId, displayDate, status, orderByComparator, true);
16957    
16958                            array[1] = blogsEntry;
16959    
16960                            array[2] = getByG_U_LtD_S_PrevAndNext(session, blogsEntry, groupId,
16961                                            userId, displayDate, status, orderByComparator, false);
16962    
16963                            return array;
16964                    }
16965                    catch (Exception e) {
16966                            throw processException(e);
16967                    }
16968                    finally {
16969                            closeSession(session);
16970                    }
16971            }
16972    
16973            protected BlogsEntry getByG_U_LtD_S_PrevAndNext(Session session,
16974                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
16975                    int status, OrderByComparator<BlogsEntry> orderByComparator,
16976                    boolean previous) {
16977                    StringBundler query = null;
16978    
16979                    if (orderByComparator != null) {
16980                            query = new StringBundler(7 +
16981                                            (orderByComparator.getOrderByConditionFields().length * 3) +
16982                                            (orderByComparator.getOrderByFields().length * 3));
16983                    }
16984                    else {
16985                            query = new StringBundler(6);
16986                    }
16987    
16988                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
16989    
16990                    query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
16991    
16992                    query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
16993    
16994                    boolean bindDisplayDate = false;
16995    
16996                    if (displayDate == null) {
16997                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
16998                    }
16999                    else {
17000                            bindDisplayDate = true;
17001    
17002                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
17003                    }
17004    
17005                    query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
17006    
17007                    if (orderByComparator != null) {
17008                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
17009    
17010                            if (orderByConditionFields.length > 0) {
17011                                    query.append(WHERE_AND);
17012                            }
17013    
17014                            for (int i = 0; i < orderByConditionFields.length; i++) {
17015                                    query.append(_ORDER_BY_ENTITY_ALIAS);
17016                                    query.append(orderByConditionFields[i]);
17017    
17018                                    if ((i + 1) < orderByConditionFields.length) {
17019                                            if (orderByComparator.isAscending() ^ previous) {
17020                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
17021                                            }
17022                                            else {
17023                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
17024                                            }
17025                                    }
17026                                    else {
17027                                            if (orderByComparator.isAscending() ^ previous) {
17028                                                    query.append(WHERE_GREATER_THAN);
17029                                            }
17030                                            else {
17031                                                    query.append(WHERE_LESSER_THAN);
17032                                            }
17033                                    }
17034                            }
17035    
17036                            query.append(ORDER_BY_CLAUSE);
17037    
17038                            String[] orderByFields = orderByComparator.getOrderByFields();
17039    
17040                            for (int i = 0; i < orderByFields.length; i++) {
17041                                    query.append(_ORDER_BY_ENTITY_ALIAS);
17042                                    query.append(orderByFields[i]);
17043    
17044                                    if ((i + 1) < orderByFields.length) {
17045                                            if (orderByComparator.isAscending() ^ previous) {
17046                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
17047                                            }
17048                                            else {
17049                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
17050                                            }
17051                                    }
17052                                    else {
17053                                            if (orderByComparator.isAscending() ^ previous) {
17054                                                    query.append(ORDER_BY_ASC);
17055                                            }
17056                                            else {
17057                                                    query.append(ORDER_BY_DESC);
17058                                            }
17059                                    }
17060                            }
17061                    }
17062                    else {
17063                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
17064                    }
17065    
17066                    String sql = query.toString();
17067    
17068                    Query q = session.createQuery(sql);
17069    
17070                    q.setFirstResult(0);
17071                    q.setMaxResults(2);
17072    
17073                    QueryPos qPos = QueryPos.getInstance(q);
17074    
17075                    qPos.add(groupId);
17076    
17077                    qPos.add(userId);
17078    
17079                    if (bindDisplayDate) {
17080                            qPos.add(new Timestamp(displayDate.getTime()));
17081                    }
17082    
17083                    qPos.add(status);
17084    
17085                    if (orderByComparator != null) {
17086                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
17087    
17088                            for (Object value : values) {
17089                                    qPos.add(value);
17090                            }
17091                    }
17092    
17093                    List<BlogsEntry> list = q.list();
17094    
17095                    if (list.size() == 2) {
17096                            return list.get(1);
17097                    }
17098                    else {
17099                            return null;
17100                    }
17101            }
17102    
17103            /**
17104             * 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;.
17105             *
17106             * @param groupId the group ID
17107             * @param userId the user ID
17108             * @param displayDate the display date
17109             * @param status the status
17110             * @return the matching blogs entries that the user has permission to view
17111             */
17112            @Override
17113            public List<BlogsEntry> filterFindByG_U_LtD_S(long groupId, long userId,
17114                    Date displayDate, int status) {
17115                    return filterFindByG_U_LtD_S(groupId, userId, displayDate, status,
17116                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
17117            }
17118    
17119            /**
17120             * 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;.
17121             *
17122             * <p>
17123             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
17124             * </p>
17125             *
17126             * @param groupId the group ID
17127             * @param userId the user ID
17128             * @param displayDate the display date
17129             * @param status the status
17130             * @param start the lower bound of the range of blogs entries
17131             * @param end the upper bound of the range of blogs entries (not inclusive)
17132             * @return the range of matching blogs entries that the user has permission to view
17133             */
17134            @Override
17135            public List<BlogsEntry> filterFindByG_U_LtD_S(long groupId, long userId,
17136                    Date displayDate, int status, int start, int end) {
17137                    return filterFindByG_U_LtD_S(groupId, userId, displayDate, status,
17138                            start, end, null);
17139            }
17140    
17141            /**
17142             * 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;.
17143             *
17144             * <p>
17145             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
17146             * </p>
17147             *
17148             * @param groupId the group ID
17149             * @param userId the user ID
17150             * @param displayDate the display date
17151             * @param status the status
17152             * @param start the lower bound of the range of blogs entries
17153             * @param end the upper bound of the range of blogs entries (not inclusive)
17154             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
17155             * @return the ordered range of matching blogs entries that the user has permission to view
17156             */
17157            @Override
17158            public List<BlogsEntry> filterFindByG_U_LtD_S(long groupId, long userId,
17159                    Date displayDate, int status, int start, int end,
17160                    OrderByComparator<BlogsEntry> orderByComparator) {
17161                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17162                            return findByG_U_LtD_S(groupId, userId, displayDate, status, start,
17163                                    end, orderByComparator);
17164                    }
17165    
17166                    StringBundler query = null;
17167    
17168                    if (orderByComparator != null) {
17169                            query = new StringBundler(6 +
17170                                            (orderByComparator.getOrderByFields().length * 2));
17171                    }
17172                    else {
17173                            query = new StringBundler(7);
17174                    }
17175    
17176                    if (getDB().isSupportsInlineDistinct()) {
17177                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
17178                    }
17179                    else {
17180                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
17181                    }
17182    
17183                    query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
17184    
17185                    query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
17186    
17187                    boolean bindDisplayDate = false;
17188    
17189                    if (displayDate == null) {
17190                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
17191                    }
17192                    else {
17193                            bindDisplayDate = true;
17194    
17195                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
17196                    }
17197    
17198                    query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
17199    
17200                    if (!getDB().isSupportsInlineDistinct()) {
17201                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
17202                    }
17203    
17204                    if (orderByComparator != null) {
17205                            if (getDB().isSupportsInlineDistinct()) {
17206                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
17207                                            orderByComparator, true);
17208                            }
17209                            else {
17210                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
17211                                            orderByComparator, true);
17212                            }
17213                    }
17214                    else {
17215                            if (getDB().isSupportsInlineDistinct()) {
17216                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
17217                            }
17218                            else {
17219                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
17220                            }
17221                    }
17222    
17223                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17224                                    BlogsEntry.class.getName(),
17225                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17226    
17227                    Session session = null;
17228    
17229                    try {
17230                            session = openSession();
17231    
17232                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
17233    
17234                            if (getDB().isSupportsInlineDistinct()) {
17235                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
17236                            }
17237                            else {
17238                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
17239                            }
17240    
17241                            QueryPos qPos = QueryPos.getInstance(q);
17242    
17243                            qPos.add(groupId);
17244    
17245                            qPos.add(userId);
17246    
17247                            if (bindDisplayDate) {
17248                                    qPos.add(new Timestamp(displayDate.getTime()));
17249                            }
17250    
17251                            qPos.add(status);
17252    
17253                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
17254                    }
17255                    catch (Exception e) {
17256                            throw processException(e);
17257                    }
17258                    finally {
17259                            closeSession(session);
17260                    }
17261            }
17262    
17263            /**
17264             * 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;.
17265             *
17266             * @param entryId the primary key of the current blogs entry
17267             * @param groupId the group ID
17268             * @param userId the user ID
17269             * @param displayDate the display date
17270             * @param status the status
17271             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17272             * @return the previous, current, and next blogs entry
17273             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
17274             */
17275            @Override
17276            public BlogsEntry[] filterFindByG_U_LtD_S_PrevAndNext(long entryId,
17277                    long groupId, long userId, Date displayDate, int status,
17278                    OrderByComparator<BlogsEntry> orderByComparator)
17279                    throws NoSuchEntryException {
17280                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17281                            return findByG_U_LtD_S_PrevAndNext(entryId, groupId, userId,
17282                                    displayDate, status, orderByComparator);
17283                    }
17284    
17285                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
17286    
17287                    Session session = null;
17288    
17289                    try {
17290                            session = openSession();
17291    
17292                            BlogsEntry[] array = new BlogsEntryImpl[3];
17293    
17294                            array[0] = filterGetByG_U_LtD_S_PrevAndNext(session, blogsEntry,
17295                                            groupId, userId, displayDate, status, orderByComparator,
17296                                            true);
17297    
17298                            array[1] = blogsEntry;
17299    
17300                            array[2] = filterGetByG_U_LtD_S_PrevAndNext(session, blogsEntry,
17301                                            groupId, userId, displayDate, status, orderByComparator,
17302                                            false);
17303    
17304                            return array;
17305                    }
17306                    catch (Exception e) {
17307                            throw processException(e);
17308                    }
17309                    finally {
17310                            closeSession(session);
17311                    }
17312            }
17313    
17314            protected BlogsEntry filterGetByG_U_LtD_S_PrevAndNext(Session session,
17315                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
17316                    int status, OrderByComparator<BlogsEntry> orderByComparator,
17317                    boolean previous) {
17318                    StringBundler query = null;
17319    
17320                    if (orderByComparator != null) {
17321                            query = new StringBundler(8 +
17322                                            (orderByComparator.getOrderByConditionFields().length * 3) +
17323                                            (orderByComparator.getOrderByFields().length * 3));
17324                    }
17325                    else {
17326                            query = new StringBundler(7);
17327                    }
17328    
17329                    if (getDB().isSupportsInlineDistinct()) {
17330                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
17331                    }
17332                    else {
17333                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
17334                    }
17335    
17336                    query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
17337    
17338                    query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
17339    
17340                    boolean bindDisplayDate = false;
17341    
17342                    if (displayDate == null) {
17343                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
17344                    }
17345                    else {
17346                            bindDisplayDate = true;
17347    
17348                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
17349                    }
17350    
17351                    query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
17352    
17353                    if (!getDB().isSupportsInlineDistinct()) {
17354                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
17355                    }
17356    
17357                    if (orderByComparator != null) {
17358                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
17359    
17360                            if (orderByConditionFields.length > 0) {
17361                                    query.append(WHERE_AND);
17362                            }
17363    
17364                            for (int i = 0; i < orderByConditionFields.length; i++) {
17365                                    if (getDB().isSupportsInlineDistinct()) {
17366                                            query.append(_ORDER_BY_ENTITY_ALIAS);
17367                                    }
17368                                    else {
17369                                            query.append(_ORDER_BY_ENTITY_TABLE);
17370                                    }
17371    
17372                                    query.append(orderByConditionFields[i]);
17373    
17374                                    if ((i + 1) < orderByConditionFields.length) {
17375                                            if (orderByComparator.isAscending() ^ previous) {
17376                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
17377                                            }
17378                                            else {
17379                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
17380                                            }
17381                                    }
17382                                    else {
17383                                            if (orderByComparator.isAscending() ^ previous) {
17384                                                    query.append(WHERE_GREATER_THAN);
17385                                            }
17386                                            else {
17387                                                    query.append(WHERE_LESSER_THAN);
17388                                            }
17389                                    }
17390                            }
17391    
17392                            query.append(ORDER_BY_CLAUSE);
17393    
17394                            String[] orderByFields = orderByComparator.getOrderByFields();
17395    
17396                            for (int i = 0; i < orderByFields.length; i++) {
17397                                    if (getDB().isSupportsInlineDistinct()) {
17398                                            query.append(_ORDER_BY_ENTITY_ALIAS);
17399                                    }
17400                                    else {
17401                                            query.append(_ORDER_BY_ENTITY_TABLE);
17402                                    }
17403    
17404                                    query.append(orderByFields[i]);
17405    
17406                                    if ((i + 1) < orderByFields.length) {
17407                                            if (orderByComparator.isAscending() ^ previous) {
17408                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
17409                                            }
17410                                            else {
17411                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
17412                                            }
17413                                    }
17414                                    else {
17415                                            if (orderByComparator.isAscending() ^ previous) {
17416                                                    query.append(ORDER_BY_ASC);
17417                                            }
17418                                            else {
17419                                                    query.append(ORDER_BY_DESC);
17420                                            }
17421                                    }
17422                            }
17423                    }
17424                    else {
17425                            if (getDB().isSupportsInlineDistinct()) {
17426                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
17427                            }
17428                            else {
17429                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
17430                            }
17431                    }
17432    
17433                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17434                                    BlogsEntry.class.getName(),
17435                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17436    
17437                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
17438    
17439                    q.setFirstResult(0);
17440                    q.setMaxResults(2);
17441    
17442                    if (getDB().isSupportsInlineDistinct()) {
17443                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
17444                    }
17445                    else {
17446                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
17447                    }
17448    
17449                    QueryPos qPos = QueryPos.getInstance(q);
17450    
17451                    qPos.add(groupId);
17452    
17453                    qPos.add(userId);
17454    
17455                    if (bindDisplayDate) {
17456                            qPos.add(new Timestamp(displayDate.getTime()));
17457                    }
17458    
17459                    qPos.add(status);
17460    
17461                    if (orderByComparator != null) {
17462                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
17463    
17464                            for (Object value : values) {
17465                                    qPos.add(value);
17466                            }
17467                    }
17468    
17469                    List<BlogsEntry> list = q.list();
17470    
17471                    if (list.size() == 2) {
17472                            return list.get(1);
17473                    }
17474                    else {
17475                            return null;
17476                    }
17477            }
17478    
17479            /**
17480             * Removes all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63; from the database.
17481             *
17482             * @param groupId the group ID
17483             * @param userId the user ID
17484             * @param displayDate the display date
17485             * @param status the status
17486             */
17487            @Override
17488            public void removeByG_U_LtD_S(long groupId, long userId, Date displayDate,
17489                    int status) {
17490                    for (BlogsEntry blogsEntry : findByG_U_LtD_S(groupId, userId,
17491                                    displayDate, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
17492                            remove(blogsEntry);
17493                    }
17494            }
17495    
17496            /**
17497             * Returns the number of blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
17498             *
17499             * @param groupId the group ID
17500             * @param userId the user ID
17501             * @param displayDate the display date
17502             * @param status the status
17503             * @return the number of matching blogs entries
17504             */
17505            @Override
17506            public int countByG_U_LtD_S(long groupId, long userId, Date displayDate,
17507                    int status) {
17508                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD_S;
17509    
17510                    Object[] finderArgs = new Object[] { groupId, userId, displayDate, status };
17511    
17512                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
17513    
17514                    if (count == null) {
17515                            StringBundler query = new StringBundler(5);
17516    
17517                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
17518    
17519                            query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
17520    
17521                            query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
17522    
17523                            boolean bindDisplayDate = false;
17524    
17525                            if (displayDate == null) {
17526                                    query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
17527                            }
17528                            else {
17529                                    bindDisplayDate = true;
17530    
17531                                    query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
17532                            }
17533    
17534                            query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
17535    
17536                            String sql = query.toString();
17537    
17538                            Session session = null;
17539    
17540                            try {
17541                                    session = openSession();
17542    
17543                                    Query q = session.createQuery(sql);
17544    
17545                                    QueryPos qPos = QueryPos.getInstance(q);
17546    
17547                                    qPos.add(groupId);
17548    
17549                                    qPos.add(userId);
17550    
17551                                    if (bindDisplayDate) {
17552                                            qPos.add(new Timestamp(displayDate.getTime()));
17553                                    }
17554    
17555                                    qPos.add(status);
17556    
17557                                    count = (Long)q.uniqueResult();
17558    
17559                                    finderCache.putResult(finderPath, finderArgs, count);
17560                            }
17561                            catch (Exception e) {
17562                                    finderCache.removeResult(finderPath, finderArgs);
17563    
17564                                    throw processException(e);
17565                            }
17566                            finally {
17567                                    closeSession(session);
17568                            }
17569                    }
17570    
17571                    return count.intValue();
17572            }
17573    
17574            /**
17575             * 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;.
17576             *
17577             * @param groupId the group ID
17578             * @param userId the user ID
17579             * @param displayDate the display date
17580             * @param status the status
17581             * @return the number of matching blogs entries that the user has permission to view
17582             */
17583            @Override
17584            public int filterCountByG_U_LtD_S(long groupId, long userId,
17585                    Date displayDate, int status) {
17586                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17587                            return countByG_U_LtD_S(groupId, userId, displayDate, status);
17588                    }
17589    
17590                    StringBundler query = new StringBundler(5);
17591    
17592                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
17593    
17594                    query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
17595    
17596                    query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
17597    
17598                    boolean bindDisplayDate = false;
17599    
17600                    if (displayDate == null) {
17601                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
17602                    }
17603                    else {
17604                            bindDisplayDate = true;
17605    
17606                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
17607                    }
17608    
17609                    query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
17610    
17611                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17612                                    BlogsEntry.class.getName(),
17613                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17614    
17615                    Session session = null;
17616    
17617                    try {
17618                            session = openSession();
17619    
17620                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
17621    
17622                            q.addScalar(COUNT_COLUMN_NAME,
17623                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
17624    
17625                            QueryPos qPos = QueryPos.getInstance(q);
17626    
17627                            qPos.add(groupId);
17628    
17629                            qPos.add(userId);
17630    
17631                            if (bindDisplayDate) {
17632                                    qPos.add(new Timestamp(displayDate.getTime()));
17633                            }
17634    
17635                            qPos.add(status);
17636    
17637                            Long count = (Long)q.uniqueResult();
17638    
17639                            return count.intValue();
17640                    }
17641                    catch (Exception e) {
17642                            throw processException(e);
17643                    }
17644                    finally {
17645                            closeSession(session);
17646                    }
17647            }
17648    
17649            private static final String _FINDER_COLUMN_G_U_LTD_S_GROUPID_2 = "blogsEntry.groupId = ? AND ";
17650            private static final String _FINDER_COLUMN_G_U_LTD_S_USERID_2 = "blogsEntry.userId = ? AND ";
17651            private static final String _FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1 = "blogsEntry.displayDate IS NULL AND ";
17652            private static final String _FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
17653            private static final String _FINDER_COLUMN_G_U_LTD_S_STATUS_2 = "blogsEntry.status = ?";
17654            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD_NOTS =
17655                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
17656                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
17657                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_LtD_NotS",
17658                            new String[] {
17659                                    Long.class.getName(), Long.class.getName(), Date.class.getName(),
17660                                    Integer.class.getName(),
17661                                    
17662                            Integer.class.getName(), Integer.class.getName(),
17663                                    OrderByComparator.class.getName()
17664                            });
17665            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD_NOTS =
17666                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
17667                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
17668                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_U_LtD_NotS",
17669                            new String[] {
17670                                    Long.class.getName(), Long.class.getName(), Date.class.getName(),
17671                                    Integer.class.getName()
17672                            });
17673    
17674            /**
17675             * Returns all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
17676             *
17677             * @param groupId the group ID
17678             * @param userId the user ID
17679             * @param displayDate the display date
17680             * @param status the status
17681             * @return the matching blogs entries
17682             */
17683            @Override
17684            public List<BlogsEntry> findByG_U_LtD_NotS(long groupId, long userId,
17685                    Date displayDate, int status) {
17686                    return findByG_U_LtD_NotS(groupId, userId, displayDate, status,
17687                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
17688            }
17689    
17690            /**
17691             * Returns a range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
17692             *
17693             * <p>
17694             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
17695             * </p>
17696             *
17697             * @param groupId the group ID
17698             * @param userId the user ID
17699             * @param displayDate the display date
17700             * @param status the status
17701             * @param start the lower bound of the range of blogs entries
17702             * @param end the upper bound of the range of blogs entries (not inclusive)
17703             * @return the range of matching blogs entries
17704             */
17705            @Override
17706            public List<BlogsEntry> findByG_U_LtD_NotS(long groupId, long userId,
17707                    Date displayDate, int status, int start, int end) {
17708                    return findByG_U_LtD_NotS(groupId, userId, displayDate, status, start,
17709                            end, null);
17710            }
17711    
17712            /**
17713             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
17714             *
17715             * <p>
17716             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
17717             * </p>
17718             *
17719             * @param groupId the group ID
17720             * @param userId the user ID
17721             * @param displayDate the display date
17722             * @param status the status
17723             * @param start the lower bound of the range of blogs entries
17724             * @param end the upper bound of the range of blogs entries (not inclusive)
17725             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
17726             * @return the ordered range of matching blogs entries
17727             */
17728            @Override
17729            public List<BlogsEntry> findByG_U_LtD_NotS(long groupId, long userId,
17730                    Date displayDate, int status, int start, int end,
17731                    OrderByComparator<BlogsEntry> orderByComparator) {
17732                    return findByG_U_LtD_NotS(groupId, userId, displayDate, status, start,
17733                            end, orderByComparator, true);
17734            }
17735    
17736            /**
17737             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
17738             *
17739             * <p>
17740             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
17741             * </p>
17742             *
17743             * @param groupId the group ID
17744             * @param userId the user ID
17745             * @param displayDate the display date
17746             * @param status the status
17747             * @param start the lower bound of the range of blogs entries
17748             * @param end the upper bound of the range of blogs entries (not inclusive)
17749             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
17750             * @param retrieveFromCache whether to retrieve from the finder cache
17751             * @return the ordered range of matching blogs entries
17752             */
17753            @Override
17754            public List<BlogsEntry> findByG_U_LtD_NotS(long groupId, long userId,
17755                    Date displayDate, int status, int start, int end,
17756                    OrderByComparator<BlogsEntry> orderByComparator,
17757                    boolean retrieveFromCache) {
17758                    boolean pagination = true;
17759                    FinderPath finderPath = null;
17760                    Object[] finderArgs = null;
17761    
17762                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD_NOTS;
17763                    finderArgs = new Object[] {
17764                                    groupId, userId, displayDate, status,
17765                                    
17766                                    start, end, orderByComparator
17767                            };
17768    
17769                    List<BlogsEntry> list = null;
17770    
17771                    if (retrieveFromCache) {
17772                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
17773                                            finderArgs, this);
17774    
17775                            if ((list != null) && !list.isEmpty()) {
17776                                    for (BlogsEntry blogsEntry : list) {
17777                                            if ((groupId != blogsEntry.getGroupId()) ||
17778                                                            (userId != blogsEntry.getUserId()) ||
17779                                                            (displayDate.getTime() <= blogsEntry.getDisplayDate()
17780                                                                                                                                            .getTime()) ||
17781                                                            (status == blogsEntry.getStatus())) {
17782                                                    list = null;
17783    
17784                                                    break;
17785                                            }
17786                                    }
17787                            }
17788                    }
17789    
17790                    if (list == null) {
17791                            StringBundler query = null;
17792    
17793                            if (orderByComparator != null) {
17794                                    query = new StringBundler(6 +
17795                                                    (orderByComparator.getOrderByFields().length * 2));
17796                            }
17797                            else {
17798                                    query = new StringBundler(6);
17799                            }
17800    
17801                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
17802    
17803                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
17804    
17805                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
17806    
17807                            boolean bindDisplayDate = false;
17808    
17809                            if (displayDate == null) {
17810                                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
17811                            }
17812                            else {
17813                                    bindDisplayDate = true;
17814    
17815                                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
17816                            }
17817    
17818                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
17819    
17820                            if (orderByComparator != null) {
17821                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
17822                                            orderByComparator);
17823                            }
17824                            else
17825                             if (pagination) {
17826                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
17827                            }
17828    
17829                            String sql = query.toString();
17830    
17831                            Session session = null;
17832    
17833                            try {
17834                                    session = openSession();
17835    
17836                                    Query q = session.createQuery(sql);
17837    
17838                                    QueryPos qPos = QueryPos.getInstance(q);
17839    
17840                                    qPos.add(groupId);
17841    
17842                                    qPos.add(userId);
17843    
17844                                    if (bindDisplayDate) {
17845                                            qPos.add(new Timestamp(displayDate.getTime()));
17846                                    }
17847    
17848                                    qPos.add(status);
17849    
17850                                    if (!pagination) {
17851                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
17852                                                            start, end, false);
17853    
17854                                            Collections.sort(list);
17855    
17856                                            list = Collections.unmodifiableList(list);
17857                                    }
17858                                    else {
17859                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
17860                                                            start, end);
17861                                    }
17862    
17863                                    cacheResult(list);
17864    
17865                                    finderCache.putResult(finderPath, finderArgs, list);
17866                            }
17867                            catch (Exception e) {
17868                                    finderCache.removeResult(finderPath, finderArgs);
17869    
17870                                    throw processException(e);
17871                            }
17872                            finally {
17873                                    closeSession(session);
17874                            }
17875                    }
17876    
17877                    return list;
17878            }
17879    
17880            /**
17881             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
17882             *
17883             * @param groupId the group ID
17884             * @param userId the user ID
17885             * @param displayDate the display date
17886             * @param status the status
17887             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17888             * @return the first matching blogs entry
17889             * @throws NoSuchEntryException if a matching blogs entry could not be found
17890             */
17891            @Override
17892            public BlogsEntry findByG_U_LtD_NotS_First(long groupId, long userId,
17893                    Date displayDate, int status,
17894                    OrderByComparator<BlogsEntry> orderByComparator)
17895                    throws NoSuchEntryException {
17896                    BlogsEntry blogsEntry = fetchByG_U_LtD_NotS_First(groupId, userId,
17897                                    displayDate, status, orderByComparator);
17898    
17899                    if (blogsEntry != null) {
17900                            return blogsEntry;
17901                    }
17902    
17903                    StringBundler msg = new StringBundler(10);
17904    
17905                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
17906    
17907                    msg.append("groupId=");
17908                    msg.append(groupId);
17909    
17910                    msg.append(", userId=");
17911                    msg.append(userId);
17912    
17913                    msg.append(", displayDate=");
17914                    msg.append(displayDate);
17915    
17916                    msg.append(", status=");
17917                    msg.append(status);
17918    
17919                    msg.append(StringPool.CLOSE_CURLY_BRACE);
17920    
17921                    throw new NoSuchEntryException(msg.toString());
17922            }
17923    
17924            /**
17925             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
17926             *
17927             * @param groupId the group ID
17928             * @param userId the user ID
17929             * @param displayDate the display date
17930             * @param status the status
17931             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17932             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
17933             */
17934            @Override
17935            public BlogsEntry fetchByG_U_LtD_NotS_First(long groupId, long userId,
17936                    Date displayDate, int status,
17937                    OrderByComparator<BlogsEntry> orderByComparator) {
17938                    List<BlogsEntry> list = findByG_U_LtD_NotS(groupId, userId,
17939                                    displayDate, status, 0, 1, orderByComparator);
17940    
17941                    if (!list.isEmpty()) {
17942                            return list.get(0);
17943                    }
17944    
17945                    return null;
17946            }
17947    
17948            /**
17949             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
17950             *
17951             * @param groupId the group ID
17952             * @param userId the user ID
17953             * @param displayDate the display date
17954             * @param status the status
17955             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17956             * @return the last matching blogs entry
17957             * @throws NoSuchEntryException if a matching blogs entry could not be found
17958             */
17959            @Override
17960            public BlogsEntry findByG_U_LtD_NotS_Last(long groupId, long userId,
17961                    Date displayDate, int status,
17962                    OrderByComparator<BlogsEntry> orderByComparator)
17963                    throws NoSuchEntryException {
17964                    BlogsEntry blogsEntry = fetchByG_U_LtD_NotS_Last(groupId, userId,
17965                                    displayDate, status, orderByComparator);
17966    
17967                    if (blogsEntry != null) {
17968                            return blogsEntry;
17969                    }
17970    
17971                    StringBundler msg = new StringBundler(10);
17972    
17973                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
17974    
17975                    msg.append("groupId=");
17976                    msg.append(groupId);
17977    
17978                    msg.append(", userId=");
17979                    msg.append(userId);
17980    
17981                    msg.append(", displayDate=");
17982                    msg.append(displayDate);
17983    
17984                    msg.append(", status=");
17985                    msg.append(status);
17986    
17987                    msg.append(StringPool.CLOSE_CURLY_BRACE);
17988    
17989                    throw new NoSuchEntryException(msg.toString());
17990            }
17991    
17992            /**
17993             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
17994             *
17995             * @param groupId the group ID
17996             * @param userId the user ID
17997             * @param displayDate the display date
17998             * @param status the status
17999             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18000             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
18001             */
18002            @Override
18003            public BlogsEntry fetchByG_U_LtD_NotS_Last(long groupId, long userId,
18004                    Date displayDate, int status,
18005                    OrderByComparator<BlogsEntry> orderByComparator) {
18006                    int count = countByG_U_LtD_NotS(groupId, userId, displayDate, status);
18007    
18008                    if (count == 0) {
18009                            return null;
18010                    }
18011    
18012                    List<BlogsEntry> list = findByG_U_LtD_NotS(groupId, userId,
18013                                    displayDate, status, count - 1, count, orderByComparator);
18014    
18015                    if (!list.isEmpty()) {
18016                            return list.get(0);
18017                    }
18018    
18019                    return null;
18020            }
18021    
18022            /**
18023             * 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;.
18024             *
18025             * @param entryId the primary key of the current blogs entry
18026             * @param groupId the group ID
18027             * @param userId the user ID
18028             * @param displayDate the display date
18029             * @param status the status
18030             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18031             * @return the previous, current, and next blogs entry
18032             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
18033             */
18034            @Override
18035            public BlogsEntry[] findByG_U_LtD_NotS_PrevAndNext(long entryId,
18036                    long groupId, long userId, Date displayDate, int status,
18037                    OrderByComparator<BlogsEntry> orderByComparator)
18038                    throws NoSuchEntryException {
18039                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
18040    
18041                    Session session = null;
18042    
18043                    try {
18044                            session = openSession();
18045    
18046                            BlogsEntry[] array = new BlogsEntryImpl[3];
18047    
18048                            array[0] = getByG_U_LtD_NotS_PrevAndNext(session, blogsEntry,
18049                                            groupId, userId, displayDate, status, orderByComparator,
18050                                            true);
18051    
18052                            array[1] = blogsEntry;
18053    
18054                            array[2] = getByG_U_LtD_NotS_PrevAndNext(session, blogsEntry,
18055                                            groupId, userId, displayDate, status, orderByComparator,
18056                                            false);
18057    
18058                            return array;
18059                    }
18060                    catch (Exception e) {
18061                            throw processException(e);
18062                    }
18063                    finally {
18064                            closeSession(session);
18065                    }
18066            }
18067    
18068            protected BlogsEntry getByG_U_LtD_NotS_PrevAndNext(Session session,
18069                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
18070                    int status, OrderByComparator<BlogsEntry> orderByComparator,
18071                    boolean previous) {
18072                    StringBundler query = null;
18073    
18074                    if (orderByComparator != null) {
18075                            query = new StringBundler(7 +
18076                                            (orderByComparator.getOrderByConditionFields().length * 3) +
18077                                            (orderByComparator.getOrderByFields().length * 3));
18078                    }
18079                    else {
18080                            query = new StringBundler(6);
18081                    }
18082    
18083                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
18084    
18085                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
18086    
18087                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
18088    
18089                    boolean bindDisplayDate = false;
18090    
18091                    if (displayDate == null) {
18092                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
18093                    }
18094                    else {
18095                            bindDisplayDate = true;
18096    
18097                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
18098                    }
18099    
18100                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
18101    
18102                    if (orderByComparator != null) {
18103                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
18104    
18105                            if (orderByConditionFields.length > 0) {
18106                                    query.append(WHERE_AND);
18107                            }
18108    
18109                            for (int i = 0; i < orderByConditionFields.length; i++) {
18110                                    query.append(_ORDER_BY_ENTITY_ALIAS);
18111                                    query.append(orderByConditionFields[i]);
18112    
18113                                    if ((i + 1) < orderByConditionFields.length) {
18114                                            if (orderByComparator.isAscending() ^ previous) {
18115                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
18116                                            }
18117                                            else {
18118                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
18119                                            }
18120                                    }
18121                                    else {
18122                                            if (orderByComparator.isAscending() ^ previous) {
18123                                                    query.append(WHERE_GREATER_THAN);
18124                                            }
18125                                            else {
18126                                                    query.append(WHERE_LESSER_THAN);
18127                                            }
18128                                    }
18129                            }
18130    
18131                            query.append(ORDER_BY_CLAUSE);
18132    
18133                            String[] orderByFields = orderByComparator.getOrderByFields();
18134    
18135                            for (int i = 0; i < orderByFields.length; i++) {
18136                                    query.append(_ORDER_BY_ENTITY_ALIAS);
18137                                    query.append(orderByFields[i]);
18138    
18139                                    if ((i + 1) < orderByFields.length) {
18140                                            if (orderByComparator.isAscending() ^ previous) {
18141                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
18142                                            }
18143                                            else {
18144                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
18145                                            }
18146                                    }
18147                                    else {
18148                                            if (orderByComparator.isAscending() ^ previous) {
18149                                                    query.append(ORDER_BY_ASC);
18150                                            }
18151                                            else {
18152                                                    query.append(ORDER_BY_DESC);
18153                                            }
18154                                    }
18155                            }
18156                    }
18157                    else {
18158                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
18159                    }
18160    
18161                    String sql = query.toString();
18162    
18163                    Query q = session.createQuery(sql);
18164    
18165                    q.setFirstResult(0);
18166                    q.setMaxResults(2);
18167    
18168                    QueryPos qPos = QueryPos.getInstance(q);
18169    
18170                    qPos.add(groupId);
18171    
18172                    qPos.add(userId);
18173    
18174                    if (bindDisplayDate) {
18175                            qPos.add(new Timestamp(displayDate.getTime()));
18176                    }
18177    
18178                    qPos.add(status);
18179    
18180                    if (orderByComparator != null) {
18181                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
18182    
18183                            for (Object value : values) {
18184                                    qPos.add(value);
18185                            }
18186                    }
18187    
18188                    List<BlogsEntry> list = q.list();
18189    
18190                    if (list.size() == 2) {
18191                            return list.get(1);
18192                    }
18193                    else {
18194                            return null;
18195                    }
18196            }
18197    
18198            /**
18199             * 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;.
18200             *
18201             * @param groupId the group ID
18202             * @param userId the user ID
18203             * @param displayDate the display date
18204             * @param status the status
18205             * @return the matching blogs entries that the user has permission to view
18206             */
18207            @Override
18208            public List<BlogsEntry> filterFindByG_U_LtD_NotS(long groupId, long userId,
18209                    Date displayDate, int status) {
18210                    return filterFindByG_U_LtD_NotS(groupId, userId, displayDate, status,
18211                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
18212            }
18213    
18214            /**
18215             * 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;.
18216             *
18217             * <p>
18218             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
18219             * </p>
18220             *
18221             * @param groupId the group ID
18222             * @param userId the user ID
18223             * @param displayDate the display date
18224             * @param status the status
18225             * @param start the lower bound of the range of blogs entries
18226             * @param end the upper bound of the range of blogs entries (not inclusive)
18227             * @return the range of matching blogs entries that the user has permission to view
18228             */
18229            @Override
18230            public List<BlogsEntry> filterFindByG_U_LtD_NotS(long groupId, long userId,
18231                    Date displayDate, int status, int start, int end) {
18232                    return filterFindByG_U_LtD_NotS(groupId, userId, displayDate, status,
18233                            start, end, null);
18234            }
18235    
18236            /**
18237             * 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;.
18238             *
18239             * <p>
18240             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
18241             * </p>
18242             *
18243             * @param groupId the group ID
18244             * @param userId the user ID
18245             * @param displayDate the display date
18246             * @param status the status
18247             * @param start the lower bound of the range of blogs entries
18248             * @param end the upper bound of the range of blogs entries (not inclusive)
18249             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
18250             * @return the ordered range of matching blogs entries that the user has permission to view
18251             */
18252            @Override
18253            public List<BlogsEntry> filterFindByG_U_LtD_NotS(long groupId, long userId,
18254                    Date displayDate, int status, int start, int end,
18255                    OrderByComparator<BlogsEntry> orderByComparator) {
18256                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
18257                            return findByG_U_LtD_NotS(groupId, userId, displayDate, status,
18258                                    start, end, orderByComparator);
18259                    }
18260    
18261                    StringBundler query = null;
18262    
18263                    if (orderByComparator != null) {
18264                            query = new StringBundler(6 +
18265                                            (orderByComparator.getOrderByFields().length * 2));
18266                    }
18267                    else {
18268                            query = new StringBundler(7);
18269                    }
18270    
18271                    if (getDB().isSupportsInlineDistinct()) {
18272                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
18273                    }
18274                    else {
18275                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
18276                    }
18277    
18278                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
18279    
18280                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
18281    
18282                    boolean bindDisplayDate = false;
18283    
18284                    if (displayDate == null) {
18285                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
18286                    }
18287                    else {
18288                            bindDisplayDate = true;
18289    
18290                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
18291                    }
18292    
18293                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
18294    
18295                    if (!getDB().isSupportsInlineDistinct()) {
18296                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
18297                    }
18298    
18299                    if (orderByComparator != null) {
18300                            if (getDB().isSupportsInlineDistinct()) {
18301                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
18302                                            orderByComparator, true);
18303                            }
18304                            else {
18305                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
18306                                            orderByComparator, true);
18307                            }
18308                    }
18309                    else {
18310                            if (getDB().isSupportsInlineDistinct()) {
18311                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
18312                            }
18313                            else {
18314                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
18315                            }
18316                    }
18317    
18318                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
18319                                    BlogsEntry.class.getName(),
18320                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
18321    
18322                    Session session = null;
18323    
18324                    try {
18325                            session = openSession();
18326    
18327                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
18328    
18329                            if (getDB().isSupportsInlineDistinct()) {
18330                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
18331                            }
18332                            else {
18333                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
18334                            }
18335    
18336                            QueryPos qPos = QueryPos.getInstance(q);
18337    
18338                            qPos.add(groupId);
18339    
18340                            qPos.add(userId);
18341    
18342                            if (bindDisplayDate) {
18343                                    qPos.add(new Timestamp(displayDate.getTime()));
18344                            }
18345    
18346                            qPos.add(status);
18347    
18348                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
18349                    }
18350                    catch (Exception e) {
18351                            throw processException(e);
18352                    }
18353                    finally {
18354                            closeSession(session);
18355                    }
18356            }
18357    
18358            /**
18359             * 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;.
18360             *
18361             * @param entryId the primary key of the current blogs entry
18362             * @param groupId the group ID
18363             * @param userId the user ID
18364             * @param displayDate the display date
18365             * @param status the status
18366             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18367             * @return the previous, current, and next blogs entry
18368             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
18369             */
18370            @Override
18371            public BlogsEntry[] filterFindByG_U_LtD_NotS_PrevAndNext(long entryId,
18372                    long groupId, long userId, Date displayDate, int status,
18373                    OrderByComparator<BlogsEntry> orderByComparator)
18374                    throws NoSuchEntryException {
18375                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
18376                            return findByG_U_LtD_NotS_PrevAndNext(entryId, groupId, userId,
18377                                    displayDate, status, orderByComparator);
18378                    }
18379    
18380                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
18381    
18382                    Session session = null;
18383    
18384                    try {
18385                            session = openSession();
18386    
18387                            BlogsEntry[] array = new BlogsEntryImpl[3];
18388    
18389                            array[0] = filterGetByG_U_LtD_NotS_PrevAndNext(session, blogsEntry,
18390                                            groupId, userId, displayDate, status, orderByComparator,
18391                                            true);
18392    
18393                            array[1] = blogsEntry;
18394    
18395                            array[2] = filterGetByG_U_LtD_NotS_PrevAndNext(session, blogsEntry,
18396                                            groupId, userId, displayDate, status, orderByComparator,
18397                                            false);
18398    
18399                            return array;
18400                    }
18401                    catch (Exception e) {
18402                            throw processException(e);
18403                    }
18404                    finally {
18405                            closeSession(session);
18406                    }
18407            }
18408    
18409            protected BlogsEntry filterGetByG_U_LtD_NotS_PrevAndNext(Session session,
18410                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
18411                    int status, OrderByComparator<BlogsEntry> orderByComparator,
18412                    boolean previous) {
18413                    StringBundler query = null;
18414    
18415                    if (orderByComparator != null) {
18416                            query = new StringBundler(8 +
18417                                            (orderByComparator.getOrderByConditionFields().length * 3) +
18418                                            (orderByComparator.getOrderByFields().length * 3));
18419                    }
18420                    else {
18421                            query = new StringBundler(7);
18422                    }
18423    
18424                    if (getDB().isSupportsInlineDistinct()) {
18425                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
18426                    }
18427                    else {
18428                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
18429                    }
18430    
18431                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
18432    
18433                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
18434    
18435                    boolean bindDisplayDate = false;
18436    
18437                    if (displayDate == null) {
18438                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
18439                    }
18440                    else {
18441                            bindDisplayDate = true;
18442    
18443                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
18444                    }
18445    
18446                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
18447    
18448                    if (!getDB().isSupportsInlineDistinct()) {
18449                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
18450                    }
18451    
18452                    if (orderByComparator != null) {
18453                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
18454    
18455                            if (orderByConditionFields.length > 0) {
18456                                    query.append(WHERE_AND);
18457                            }
18458    
18459                            for (int i = 0; i < orderByConditionFields.length; i++) {
18460                                    if (getDB().isSupportsInlineDistinct()) {
18461                                            query.append(_ORDER_BY_ENTITY_ALIAS);
18462                                    }
18463                                    else {
18464                                            query.append(_ORDER_BY_ENTITY_TABLE);
18465                                    }
18466    
18467                                    query.append(orderByConditionFields[i]);
18468    
18469                                    if ((i + 1) < orderByConditionFields.length) {
18470                                            if (orderByComparator.isAscending() ^ previous) {
18471                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
18472                                            }
18473                                            else {
18474                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
18475                                            }
18476                                    }
18477                                    else {
18478                                            if (orderByComparator.isAscending() ^ previous) {
18479                                                    query.append(WHERE_GREATER_THAN);
18480                                            }
18481                                            else {
18482                                                    query.append(WHERE_LESSER_THAN);
18483                                            }
18484                                    }
18485                            }
18486    
18487                            query.append(ORDER_BY_CLAUSE);
18488    
18489                            String[] orderByFields = orderByComparator.getOrderByFields();
18490    
18491                            for (int i = 0; i < orderByFields.length; i++) {
18492                                    if (getDB().isSupportsInlineDistinct()) {
18493                                            query.append(_ORDER_BY_ENTITY_ALIAS);
18494                                    }
18495                                    else {
18496                                            query.append(_ORDER_BY_ENTITY_TABLE);
18497                                    }
18498    
18499                                    query.append(orderByFields[i]);
18500    
18501                                    if ((i + 1) < orderByFields.length) {
18502                                            if (orderByComparator.isAscending() ^ previous) {
18503                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
18504                                            }
18505                                            else {
18506                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
18507                                            }
18508                                    }
18509                                    else {
18510                                            if (orderByComparator.isAscending() ^ previous) {
18511                                                    query.append(ORDER_BY_ASC);
18512                                            }
18513                                            else {
18514                                                    query.append(ORDER_BY_DESC);
18515                                            }
18516                                    }
18517                            }
18518                    }
18519                    else {
18520                            if (getDB().isSupportsInlineDistinct()) {
18521                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
18522                            }
18523                            else {
18524                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
18525                            }
18526                    }
18527    
18528                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
18529                                    BlogsEntry.class.getName(),
18530                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
18531    
18532                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
18533    
18534                    q.setFirstResult(0);
18535                    q.setMaxResults(2);
18536    
18537                    if (getDB().isSupportsInlineDistinct()) {
18538                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
18539                    }
18540                    else {
18541                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
18542                    }
18543    
18544                    QueryPos qPos = QueryPos.getInstance(q);
18545    
18546                    qPos.add(groupId);
18547    
18548                    qPos.add(userId);
18549    
18550                    if (bindDisplayDate) {
18551                            qPos.add(new Timestamp(displayDate.getTime()));
18552                    }
18553    
18554                    qPos.add(status);
18555    
18556                    if (orderByComparator != null) {
18557                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
18558    
18559                            for (Object value : values) {
18560                                    qPos.add(value);
18561                            }
18562                    }
18563    
18564                    List<BlogsEntry> list = q.list();
18565    
18566                    if (list.size() == 2) {
18567                            return list.get(1);
18568                    }
18569                    else {
18570                            return null;
18571                    }
18572            }
18573    
18574            /**
18575             * Removes all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63; from the database.
18576             *
18577             * @param groupId the group ID
18578             * @param userId the user ID
18579             * @param displayDate the display date
18580             * @param status the status
18581             */
18582            @Override
18583            public void removeByG_U_LtD_NotS(long groupId, long userId,
18584                    Date displayDate, int status) {
18585                    for (BlogsEntry blogsEntry : findByG_U_LtD_NotS(groupId, userId,
18586                                    displayDate, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
18587                            remove(blogsEntry);
18588                    }
18589            }
18590    
18591            /**
18592             * Returns the number of blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
18593             *
18594             * @param groupId the group ID
18595             * @param userId the user ID
18596             * @param displayDate the display date
18597             * @param status the status
18598             * @return the number of matching blogs entries
18599             */
18600            @Override
18601            public int countByG_U_LtD_NotS(long groupId, long userId, Date displayDate,
18602                    int status) {
18603                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD_NOTS;
18604    
18605                    Object[] finderArgs = new Object[] { groupId, userId, displayDate, status };
18606    
18607                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
18608    
18609                    if (count == null) {
18610                            StringBundler query = new StringBundler(5);
18611    
18612                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
18613    
18614                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
18615    
18616                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
18617    
18618                            boolean bindDisplayDate = false;
18619    
18620                            if (displayDate == null) {
18621                                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
18622                            }
18623                            else {
18624                                    bindDisplayDate = true;
18625    
18626                                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
18627                            }
18628    
18629                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
18630    
18631                            String sql = query.toString();
18632    
18633                            Session session = null;
18634    
18635                            try {
18636                                    session = openSession();
18637    
18638                                    Query q = session.createQuery(sql);
18639    
18640                                    QueryPos qPos = QueryPos.getInstance(q);
18641    
18642                                    qPos.add(groupId);
18643    
18644                                    qPos.add(userId);
18645    
18646                                    if (bindDisplayDate) {
18647                                            qPos.add(new Timestamp(displayDate.getTime()));
18648                                    }
18649    
18650                                    qPos.add(status);
18651    
18652                                    count = (Long)q.uniqueResult();
18653    
18654                                    finderCache.putResult(finderPath, finderArgs, count);
18655                            }
18656                            catch (Exception e) {
18657                                    finderCache.removeResult(finderPath, finderArgs);
18658    
18659                                    throw processException(e);
18660                            }
18661                            finally {
18662                                    closeSession(session);
18663                            }
18664                    }
18665    
18666                    return count.intValue();
18667            }
18668    
18669            /**
18670             * 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;.
18671             *
18672             * @param groupId the group ID
18673             * @param userId the user ID
18674             * @param displayDate the display date
18675             * @param status the status
18676             * @return the number of matching blogs entries that the user has permission to view
18677             */
18678            @Override
18679            public int filterCountByG_U_LtD_NotS(long groupId, long userId,
18680                    Date displayDate, int status) {
18681                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
18682                            return countByG_U_LtD_NotS(groupId, userId, displayDate, status);
18683                    }
18684    
18685                    StringBundler query = new StringBundler(5);
18686    
18687                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
18688    
18689                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
18690    
18691                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
18692    
18693                    boolean bindDisplayDate = false;
18694    
18695                    if (displayDate == null) {
18696                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
18697                    }
18698                    else {
18699                            bindDisplayDate = true;
18700    
18701                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
18702                    }
18703    
18704                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
18705    
18706                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
18707                                    BlogsEntry.class.getName(),
18708                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
18709    
18710                    Session session = null;
18711    
18712                    try {
18713                            session = openSession();
18714    
18715                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
18716    
18717                            q.addScalar(COUNT_COLUMN_NAME,
18718                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
18719    
18720                            QueryPos qPos = QueryPos.getInstance(q);
18721    
18722                            qPos.add(groupId);
18723    
18724                            qPos.add(userId);
18725    
18726                            if (bindDisplayDate) {
18727                                    qPos.add(new Timestamp(displayDate.getTime()));
18728                            }
18729    
18730                            qPos.add(status);
18731    
18732                            Long count = (Long)q.uniqueResult();
18733    
18734                            return count.intValue();
18735                    }
18736                    catch (Exception e) {
18737                            throw processException(e);
18738                    }
18739                    finally {
18740                            closeSession(session);
18741                    }
18742            }
18743    
18744            private static final String _FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2 = "blogsEntry.groupId = ? AND ";
18745            private static final String _FINDER_COLUMN_G_U_LTD_NOTS_USERID_2 = "blogsEntry.userId = ? AND ";
18746            private static final String _FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1 = "blogsEntry.displayDate IS NULL AND ";
18747            private static final String _FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
18748            private static final String _FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2 = "blogsEntry.status != ?";
18749    
18750            public BlogsEntryPersistenceImpl() {
18751                    setModelClass(BlogsEntry.class);
18752            }
18753    
18754            /**
18755             * Caches the blogs entry in the entity cache if it is enabled.
18756             *
18757             * @param blogsEntry the blogs entry
18758             */
18759            @Override
18760            public void cacheResult(BlogsEntry blogsEntry) {
18761                    entityCache.putResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18762                            BlogsEntryImpl.class, blogsEntry.getPrimaryKey(), blogsEntry);
18763    
18764                    finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G,
18765                            new Object[] { blogsEntry.getUuid(), blogsEntry.getGroupId() },
18766                            blogsEntry);
18767    
18768                    finderCache.putResult(FINDER_PATH_FETCH_BY_G_UT,
18769                            new Object[] { blogsEntry.getGroupId(), blogsEntry.getUrlTitle() },
18770                            blogsEntry);
18771    
18772                    blogsEntry.resetOriginalValues();
18773            }
18774    
18775            /**
18776             * Caches the blogs entries in the entity cache if it is enabled.
18777             *
18778             * @param blogsEntries the blogs entries
18779             */
18780            @Override
18781            public void cacheResult(List<BlogsEntry> blogsEntries) {
18782                    for (BlogsEntry blogsEntry : blogsEntries) {
18783                            if (entityCache.getResult(
18784                                                    BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18785                                                    BlogsEntryImpl.class, blogsEntry.getPrimaryKey()) == null) {
18786                                    cacheResult(blogsEntry);
18787                            }
18788                            else {
18789                                    blogsEntry.resetOriginalValues();
18790                            }
18791                    }
18792            }
18793    
18794            /**
18795             * Clears the cache for all blogs entries.
18796             *
18797             * <p>
18798             * The {@link EntityCache} and {@link FinderCache} are both cleared by this method.
18799             * </p>
18800             */
18801            @Override
18802            public void clearCache() {
18803                    entityCache.clearCache(BlogsEntryImpl.class);
18804    
18805                    finderCache.clearCache(FINDER_CLASS_NAME_ENTITY);
18806                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
18807                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
18808            }
18809    
18810            /**
18811             * Clears the cache for the blogs entry.
18812             *
18813             * <p>
18814             * The {@link EntityCache} and {@link FinderCache} are both cleared by this method.
18815             * </p>
18816             */
18817            @Override
18818            public void clearCache(BlogsEntry blogsEntry) {
18819                    entityCache.removeResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18820                            BlogsEntryImpl.class, blogsEntry.getPrimaryKey());
18821    
18822                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
18823                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
18824    
18825                    clearUniqueFindersCache((BlogsEntryModelImpl)blogsEntry);
18826            }
18827    
18828            @Override
18829            public void clearCache(List<BlogsEntry> blogsEntries) {
18830                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
18831                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
18832    
18833                    for (BlogsEntry blogsEntry : blogsEntries) {
18834                            entityCache.removeResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18835                                    BlogsEntryImpl.class, blogsEntry.getPrimaryKey());
18836    
18837                            clearUniqueFindersCache((BlogsEntryModelImpl)blogsEntry);
18838                    }
18839            }
18840    
18841            protected void cacheUniqueFindersCache(
18842                    BlogsEntryModelImpl blogsEntryModelImpl, boolean isNew) {
18843                    if (isNew) {
18844                            Object[] args = new Object[] {
18845                                            blogsEntryModelImpl.getUuid(),
18846                                            blogsEntryModelImpl.getGroupId()
18847                                    };
18848    
18849                            finderCache.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
18850                                    Long.valueOf(1));
18851                            finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
18852                                    blogsEntryModelImpl);
18853    
18854                            args = new Object[] {
18855                                            blogsEntryModelImpl.getGroupId(),
18856                                            blogsEntryModelImpl.getUrlTitle()
18857                                    };
18858    
18859                            finderCache.putResult(FINDER_PATH_COUNT_BY_G_UT, args,
18860                                    Long.valueOf(1));
18861                            finderCache.putResult(FINDER_PATH_FETCH_BY_G_UT, args,
18862                                    blogsEntryModelImpl);
18863                    }
18864                    else {
18865                            if ((blogsEntryModelImpl.getColumnBitmask() &
18866                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
18867                                    Object[] args = new Object[] {
18868                                                    blogsEntryModelImpl.getUuid(),
18869                                                    blogsEntryModelImpl.getGroupId()
18870                                            };
18871    
18872                                    finderCache.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
18873                                            Long.valueOf(1));
18874                                    finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
18875                                            blogsEntryModelImpl);
18876                            }
18877    
18878                            if ((blogsEntryModelImpl.getColumnBitmask() &
18879                                            FINDER_PATH_FETCH_BY_G_UT.getColumnBitmask()) != 0) {
18880                                    Object[] args = new Object[] {
18881                                                    blogsEntryModelImpl.getGroupId(),
18882                                                    blogsEntryModelImpl.getUrlTitle()
18883                                            };
18884    
18885                                    finderCache.putResult(FINDER_PATH_COUNT_BY_G_UT, args,
18886                                            Long.valueOf(1));
18887                                    finderCache.putResult(FINDER_PATH_FETCH_BY_G_UT, args,
18888                                            blogsEntryModelImpl);
18889                            }
18890                    }
18891            }
18892    
18893            protected void clearUniqueFindersCache(
18894                    BlogsEntryModelImpl blogsEntryModelImpl) {
18895                    Object[] args = new Object[] {
18896                                    blogsEntryModelImpl.getUuid(), blogsEntryModelImpl.getGroupId()
18897                            };
18898    
18899                    finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
18900                    finderCache.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
18901    
18902                    if ((blogsEntryModelImpl.getColumnBitmask() &
18903                                    FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
18904                            args = new Object[] {
18905                                            blogsEntryModelImpl.getOriginalUuid(),
18906                                            blogsEntryModelImpl.getOriginalGroupId()
18907                                    };
18908    
18909                            finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
18910                            finderCache.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
18911                    }
18912    
18913                    args = new Object[] {
18914                                    blogsEntryModelImpl.getGroupId(),
18915                                    blogsEntryModelImpl.getUrlTitle()
18916                            };
18917    
18918                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_UT, args);
18919                    finderCache.removeResult(FINDER_PATH_FETCH_BY_G_UT, args);
18920    
18921                    if ((blogsEntryModelImpl.getColumnBitmask() &
18922                                    FINDER_PATH_FETCH_BY_G_UT.getColumnBitmask()) != 0) {
18923                            args = new Object[] {
18924                                            blogsEntryModelImpl.getOriginalGroupId(),
18925                                            blogsEntryModelImpl.getOriginalUrlTitle()
18926                                    };
18927    
18928                            finderCache.removeResult(FINDER_PATH_COUNT_BY_G_UT, args);
18929                            finderCache.removeResult(FINDER_PATH_FETCH_BY_G_UT, args);
18930                    }
18931            }
18932    
18933            /**
18934             * Creates a new blogs entry with the primary key. Does not add the blogs entry to the database.
18935             *
18936             * @param entryId the primary key for the new blogs entry
18937             * @return the new blogs entry
18938             */
18939            @Override
18940            public BlogsEntry create(long entryId) {
18941                    BlogsEntry blogsEntry = new BlogsEntryImpl();
18942    
18943                    blogsEntry.setNew(true);
18944                    blogsEntry.setPrimaryKey(entryId);
18945    
18946                    String uuid = PortalUUIDUtil.generate();
18947    
18948                    blogsEntry.setUuid(uuid);
18949    
18950                    blogsEntry.setCompanyId(companyProvider.getCompanyId());
18951    
18952                    return blogsEntry;
18953            }
18954    
18955            /**
18956             * Removes the blogs entry with the primary key from the database. Also notifies the appropriate model listeners.
18957             *
18958             * @param entryId the primary key of the blogs entry
18959             * @return the blogs entry that was removed
18960             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
18961             */
18962            @Override
18963            public BlogsEntry remove(long entryId) throws NoSuchEntryException {
18964                    return remove((Serializable)entryId);
18965            }
18966    
18967            /**
18968             * Removes the blogs entry with the primary key from the database. Also notifies the appropriate model listeners.
18969             *
18970             * @param primaryKey the primary key of the blogs entry
18971             * @return the blogs entry that was removed
18972             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
18973             */
18974            @Override
18975            public BlogsEntry remove(Serializable primaryKey)
18976                    throws NoSuchEntryException {
18977                    Session session = null;
18978    
18979                    try {
18980                            session = openSession();
18981    
18982                            BlogsEntry blogsEntry = (BlogsEntry)session.get(BlogsEntryImpl.class,
18983                                            primaryKey);
18984    
18985                            if (blogsEntry == null) {
18986                                    if (_log.isWarnEnabled()) {
18987                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
18988                                    }
18989    
18990                                    throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
18991                                            primaryKey);
18992                            }
18993    
18994                            return remove(blogsEntry);
18995                    }
18996                    catch (NoSuchEntryException nsee) {
18997                            throw nsee;
18998                    }
18999                    catch (Exception e) {
19000                            throw processException(e);
19001                    }
19002                    finally {
19003                            closeSession(session);
19004                    }
19005            }
19006    
19007            @Override
19008            protected BlogsEntry removeImpl(BlogsEntry blogsEntry) {
19009                    blogsEntry = toUnwrappedModel(blogsEntry);
19010    
19011                    Session session = null;
19012    
19013                    try {
19014                            session = openSession();
19015    
19016                            if (!session.contains(blogsEntry)) {
19017                                    blogsEntry = (BlogsEntry)session.get(BlogsEntryImpl.class,
19018                                                    blogsEntry.getPrimaryKeyObj());
19019                            }
19020    
19021                            if (blogsEntry != null) {
19022                                    session.delete(blogsEntry);
19023                            }
19024                    }
19025                    catch (Exception e) {
19026                            throw processException(e);
19027                    }
19028                    finally {
19029                            closeSession(session);
19030                    }
19031    
19032                    if (blogsEntry != null) {
19033                            clearCache(blogsEntry);
19034                    }
19035    
19036                    return blogsEntry;
19037            }
19038    
19039            @Override
19040            public BlogsEntry updateImpl(BlogsEntry blogsEntry) {
19041                    blogsEntry = toUnwrappedModel(blogsEntry);
19042    
19043                    boolean isNew = blogsEntry.isNew();
19044    
19045                    BlogsEntryModelImpl blogsEntryModelImpl = (BlogsEntryModelImpl)blogsEntry;
19046    
19047                    if (Validator.isNull(blogsEntry.getUuid())) {
19048                            String uuid = PortalUUIDUtil.generate();
19049    
19050                            blogsEntry.setUuid(uuid);
19051                    }
19052    
19053                    ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();
19054    
19055                    Date now = new Date();
19056    
19057                    if (isNew && (blogsEntry.getCreateDate() == null)) {
19058                            if (serviceContext == null) {
19059                                    blogsEntry.setCreateDate(now);
19060                            }
19061                            else {
19062                                    blogsEntry.setCreateDate(serviceContext.getCreateDate(now));
19063                            }
19064                    }
19065    
19066                    if (!blogsEntryModelImpl.hasSetModifiedDate()) {
19067                            if (serviceContext == null) {
19068                                    blogsEntry.setModifiedDate(now);
19069                            }
19070                            else {
19071                                    blogsEntry.setModifiedDate(serviceContext.getModifiedDate(now));
19072                            }
19073                    }
19074    
19075                    long userId = GetterUtil.getLong(PrincipalThreadLocal.getName());
19076    
19077                    if (userId > 0) {
19078                            long companyId = blogsEntry.getCompanyId();
19079    
19080                            long groupId = blogsEntry.getGroupId();
19081    
19082                            long entryId = 0;
19083    
19084                            if (!isNew) {
19085                                    entryId = blogsEntry.getPrimaryKey();
19086                            }
19087    
19088                            try {
19089                                    blogsEntry.setTitle(SanitizerUtil.sanitize(companyId, groupId,
19090                                                    userId,
19091                                                    com.liferay.portlet.blogs.model.BlogsEntry.class.getName(),
19092                                                    entryId, ContentTypes.TEXT_PLAIN, Sanitizer.MODE_ALL,
19093                                                    blogsEntry.getTitle(), null));
19094    
19095                                    blogsEntry.setContent(SanitizerUtil.sanitize(companyId,
19096                                                    groupId, userId,
19097                                                    com.liferay.portlet.blogs.model.BlogsEntry.class.getName(),
19098                                                    entryId, 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.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.isWarnEnabled()) {
19384                                    _log.warn(_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    }