001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.blogs.service.persistence.impl;
016    
017    import aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.blogs.kernel.exception.NoSuchEntryException;
020    import com.liferay.blogs.kernel.model.BlogsEntry;
021    import com.liferay.blogs.kernel.service.persistence.BlogsEntryPersistence;
022    
023    import com.liferay.portal.kernel.bean.BeanReference;
024    import com.liferay.portal.kernel.dao.orm.EntityCache;
025    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
026    import com.liferay.portal.kernel.dao.orm.FinderCache;
027    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
028    import com.liferay.portal.kernel.dao.orm.FinderPath;
029    import com.liferay.portal.kernel.dao.orm.Query;
030    import com.liferay.portal.kernel.dao.orm.QueryPos;
031    import com.liferay.portal.kernel.dao.orm.QueryUtil;
032    import com.liferay.portal.kernel.dao.orm.SQLQuery;
033    import com.liferay.portal.kernel.dao.orm.Session;
034    import com.liferay.portal.kernel.exception.SystemException;
035    import com.liferay.portal.kernel.log.Log;
036    import com.liferay.portal.kernel.log.LogFactoryUtil;
037    import com.liferay.portal.kernel.model.CacheModel;
038    import com.liferay.portal.kernel.sanitizer.Sanitizer;
039    import com.liferay.portal.kernel.sanitizer.SanitizerException;
040    import com.liferay.portal.kernel.sanitizer.SanitizerUtil;
041    import com.liferay.portal.kernel.security.auth.PrincipalThreadLocal;
042    import com.liferay.portal.kernel.security.permission.InlineSQLHelperUtil;
043    import com.liferay.portal.kernel.service.ServiceContext;
044    import com.liferay.portal.kernel.service.ServiceContextThreadLocal;
045    import com.liferay.portal.kernel.service.persistence.CompanyProvider;
046    import com.liferay.portal.kernel.service.persistence.CompanyProviderWrapper;
047    import com.liferay.portal.kernel.service.persistence.impl.BasePersistenceImpl;
048    import com.liferay.portal.kernel.util.ArrayUtil;
049    import com.liferay.portal.kernel.util.ContentTypes;
050    import com.liferay.portal.kernel.util.GetterUtil;
051    import com.liferay.portal.kernel.util.OrderByComparator;
052    import com.liferay.portal.kernel.util.SetUtil;
053    import com.liferay.portal.kernel.util.StringBundler;
054    import com.liferay.portal.kernel.util.StringPool;
055    import com.liferay.portal.kernel.util.StringUtil;
056    import com.liferay.portal.kernel.util.Validator;
057    import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
058    
059    import com.liferay.portlet.blogs.model.impl.BlogsEntryImpl;
060    import com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl;
061    
062    import java.io.Serializable;
063    
064    import java.sql.Timestamp;
065    
066    import java.util.Arrays;
067    import java.util.Collections;
068    import java.util.Date;
069    import java.util.HashMap;
070    import java.util.HashSet;
071    import java.util.Iterator;
072    import java.util.List;
073    import java.util.Map;
074    import java.util.Set;
075    
076    /**
077     * The persistence implementation for the blogs entry service.
078     *
079     * <p>
080     * Caching information and settings can be found in <code>portal.properties</code>
081     * </p>
082     *
083     * @author Brian Wing Shun Chan
084     * @see BlogsEntryPersistence
085     * @see com.liferay.blogs.kernel.service.persistence.BlogsEntryUtil
086     * @generated
087     */
088    @ProviderType
089    public class BlogsEntryPersistenceImpl extends BasePersistenceImpl<BlogsEntry>
090            implements BlogsEntryPersistence {
091            /*
092             * NOTE FOR DEVELOPERS:
093             *
094             * 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.
095             */
096            public static final String FINDER_CLASS_NAME_ENTITY = BlogsEntryImpl.class.getName();
097            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
098                    ".List1";
099            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
100                    ".List2";
101            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
102                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
103                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
104            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
105                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
106                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
107            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
108                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
109                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
110            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
111                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
112                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
113                            new String[] {
114                                    String.class.getName(),
115                                    
116                            Integer.class.getName(), Integer.class.getName(),
117                                    OrderByComparator.class.getName()
118                            });
119            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
120                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
121                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
122                            new String[] { String.class.getName() },
123                            BlogsEntryModelImpl.UUID_COLUMN_BITMASK |
124                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
125                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
126            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
127                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
128                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
129                            new String[] { String.class.getName() });
130    
131            /**
132             * Returns all the blogs entries where uuid = &#63;.
133             *
134             * @param uuid the uuid
135             * @return the matching blogs entries
136             */
137            @Override
138            public List<BlogsEntry> findByUuid(String uuid) {
139                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
140            }
141    
142            /**
143             * Returns a range of all the blogs entries where uuid = &#63;.
144             *
145             * <p>
146             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
147             * </p>
148             *
149             * @param uuid the uuid
150             * @param start the lower bound of the range of blogs entries
151             * @param end the upper bound of the range of blogs entries (not inclusive)
152             * @return the range of matching blogs entries
153             */
154            @Override
155            public List<BlogsEntry> findByUuid(String uuid, int start, int end) {
156                    return findByUuid(uuid, start, end, null);
157            }
158    
159            /**
160             * Returns an ordered range of all the blogs entries where uuid = &#63;.
161             *
162             * <p>
163             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
164             * </p>
165             *
166             * @param uuid the uuid
167             * @param start the lower bound of the range of blogs entries
168             * @param end the upper bound of the range of blogs entries (not inclusive)
169             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
170             * @return the ordered range of matching blogs entries
171             */
172            @Override
173            public List<BlogsEntry> findByUuid(String uuid, int start, int end,
174                    OrderByComparator<BlogsEntry> orderByComparator) {
175                    return findByUuid(uuid, start, end, orderByComparator, true);
176            }
177    
178            /**
179             * Returns an ordered range of all the blogs entries where uuid = &#63;.
180             *
181             * <p>
182             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
183             * </p>
184             *
185             * @param uuid the uuid
186             * @param start the lower bound of the range of blogs entries
187             * @param end the upper bound of the range of blogs entries (not inclusive)
188             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
189             * @param retrieveFromCache whether to retrieve from the finder cache
190             * @return the ordered range of matching blogs entries
191             */
192            @Override
193            public List<BlogsEntry> findByUuid(String uuid, int start, int end,
194                    OrderByComparator<BlogsEntry> orderByComparator,
195                    boolean retrieveFromCache) {
196                    boolean pagination = true;
197                    FinderPath finderPath = null;
198                    Object[] finderArgs = null;
199    
200                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
201                                    (orderByComparator == null)) {
202                            pagination = false;
203                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
204                            finderArgs = new Object[] { uuid };
205                    }
206                    else {
207                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
208                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
209                    }
210    
211                    List<BlogsEntry> list = null;
212    
213                    if (retrieveFromCache) {
214                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
215                                            finderArgs, this);
216    
217                            if ((list != null) && !list.isEmpty()) {
218                                    for (BlogsEntry blogsEntry : list) {
219                                            if (!Validator.equals(uuid, blogsEntry.getUuid())) {
220                                                    list = null;
221    
222                                                    break;
223                                            }
224                                    }
225                            }
226                    }
227    
228                    if (list == null) {
229                            StringBundler query = null;
230    
231                            if (orderByComparator != null) {
232                                    query = new StringBundler(3 +
233                                                    (orderByComparator.getOrderByFields().length * 2));
234                            }
235                            else {
236                                    query = new StringBundler(3);
237                            }
238    
239                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
240    
241                            boolean bindUuid = false;
242    
243                            if (uuid == null) {
244                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
245                            }
246                            else if (uuid.equals(StringPool.BLANK)) {
247                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
248                            }
249                            else {
250                                    bindUuid = true;
251    
252                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
253                            }
254    
255                            if (orderByComparator != null) {
256                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
257                                            orderByComparator);
258                            }
259                            else
260                             if (pagination) {
261                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
262                            }
263    
264                            String sql = query.toString();
265    
266                            Session session = null;
267    
268                            try {
269                                    session = openSession();
270    
271                                    Query q = session.createQuery(sql);
272    
273                                    QueryPos qPos = QueryPos.getInstance(q);
274    
275                                    if (bindUuid) {
276                                            qPos.add(uuid);
277                                    }
278    
279                                    if (!pagination) {
280                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
281                                                            start, end, false);
282    
283                                            Collections.sort(list);
284    
285                                            list = Collections.unmodifiableList(list);
286                                    }
287                                    else {
288                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
289                                                            start, end);
290                                    }
291    
292                                    cacheResult(list);
293    
294                                    finderCache.putResult(finderPath, finderArgs, list);
295                            }
296                            catch (Exception e) {
297                                    finderCache.removeResult(finderPath, finderArgs);
298    
299                                    throw processException(e);
300                            }
301                            finally {
302                                    closeSession(session);
303                            }
304                    }
305    
306                    return list;
307            }
308    
309            /**
310             * Returns the first blogs entry in the ordered set where uuid = &#63;.
311             *
312             * @param uuid the uuid
313             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
314             * @return the first matching blogs entry
315             * @throws NoSuchEntryException if a matching blogs entry could not be found
316             */
317            @Override
318            public BlogsEntry findByUuid_First(String uuid,
319                    OrderByComparator<BlogsEntry> orderByComparator)
320                    throws NoSuchEntryException {
321                    BlogsEntry blogsEntry = fetchByUuid_First(uuid, orderByComparator);
322    
323                    if (blogsEntry != null) {
324                            return blogsEntry;
325                    }
326    
327                    StringBundler msg = new StringBundler(4);
328    
329                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
330    
331                    msg.append("uuid=");
332                    msg.append(uuid);
333    
334                    msg.append(StringPool.CLOSE_CURLY_BRACE);
335    
336                    throw new NoSuchEntryException(msg.toString());
337            }
338    
339            /**
340             * Returns the first blogs entry in the ordered set where uuid = &#63;.
341             *
342             * @param uuid the uuid
343             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
344             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
345             */
346            @Override
347            public BlogsEntry fetchByUuid_First(String uuid,
348                    OrderByComparator<BlogsEntry> orderByComparator) {
349                    List<BlogsEntry> list = findByUuid(uuid, 0, 1, orderByComparator);
350    
351                    if (!list.isEmpty()) {
352                            return list.get(0);
353                    }
354    
355                    return null;
356            }
357    
358            /**
359             * Returns the last blogs entry in the ordered set where uuid = &#63;.
360             *
361             * @param uuid the uuid
362             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
363             * @return the last matching blogs entry
364             * @throws NoSuchEntryException if a matching blogs entry could not be found
365             */
366            @Override
367            public BlogsEntry findByUuid_Last(String uuid,
368                    OrderByComparator<BlogsEntry> orderByComparator)
369                    throws NoSuchEntryException {
370                    BlogsEntry blogsEntry = fetchByUuid_Last(uuid, orderByComparator);
371    
372                    if (blogsEntry != null) {
373                            return blogsEntry;
374                    }
375    
376                    StringBundler msg = new StringBundler(4);
377    
378                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
379    
380                    msg.append("uuid=");
381                    msg.append(uuid);
382    
383                    msg.append(StringPool.CLOSE_CURLY_BRACE);
384    
385                    throw new NoSuchEntryException(msg.toString());
386            }
387    
388            /**
389             * Returns the last blogs entry in the ordered set where uuid = &#63;.
390             *
391             * @param uuid the uuid
392             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
393             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
394             */
395            @Override
396            public BlogsEntry fetchByUuid_Last(String uuid,
397                    OrderByComparator<BlogsEntry> orderByComparator) {
398                    int count = countByUuid(uuid);
399    
400                    if (count == 0) {
401                            return null;
402                    }
403    
404                    List<BlogsEntry> list = findByUuid(uuid, count - 1, count,
405                                    orderByComparator);
406    
407                    if (!list.isEmpty()) {
408                            return list.get(0);
409                    }
410    
411                    return null;
412            }
413    
414            /**
415             * Returns the blogs entries before and after the current blogs entry in the ordered set where uuid = &#63;.
416             *
417             * @param entryId the primary key of the current blogs entry
418             * @param uuid the uuid
419             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
420             * @return the previous, current, and next blogs entry
421             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
422             */
423            @Override
424            public BlogsEntry[] findByUuid_PrevAndNext(long entryId, String uuid,
425                    OrderByComparator<BlogsEntry> orderByComparator)
426                    throws NoSuchEntryException {
427                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
428    
429                    Session session = null;
430    
431                    try {
432                            session = openSession();
433    
434                            BlogsEntry[] array = new BlogsEntryImpl[3];
435    
436                            array[0] = getByUuid_PrevAndNext(session, blogsEntry, uuid,
437                                            orderByComparator, true);
438    
439                            array[1] = blogsEntry;
440    
441                            array[2] = getByUuid_PrevAndNext(session, blogsEntry, uuid,
442                                            orderByComparator, false);
443    
444                            return array;
445                    }
446                    catch (Exception e) {
447                            throw processException(e);
448                    }
449                    finally {
450                            closeSession(session);
451                    }
452            }
453    
454            protected BlogsEntry getByUuid_PrevAndNext(Session session,
455                    BlogsEntry blogsEntry, String uuid,
456                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
457                    StringBundler query = null;
458    
459                    if (orderByComparator != null) {
460                            query = new StringBundler(4 +
461                                            (orderByComparator.getOrderByConditionFields().length * 3) +
462                                            (orderByComparator.getOrderByFields().length * 3));
463                    }
464                    else {
465                            query = new StringBundler(3);
466                    }
467    
468                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
469    
470                    boolean bindUuid = false;
471    
472                    if (uuid == null) {
473                            query.append(_FINDER_COLUMN_UUID_UUID_1);
474                    }
475                    else if (uuid.equals(StringPool.BLANK)) {
476                            query.append(_FINDER_COLUMN_UUID_UUID_3);
477                    }
478                    else {
479                            bindUuid = true;
480    
481                            query.append(_FINDER_COLUMN_UUID_UUID_2);
482                    }
483    
484                    if (orderByComparator != null) {
485                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
486    
487                            if (orderByConditionFields.length > 0) {
488                                    query.append(WHERE_AND);
489                            }
490    
491                            for (int i = 0; i < orderByConditionFields.length; i++) {
492                                    query.append(_ORDER_BY_ENTITY_ALIAS);
493                                    query.append(orderByConditionFields[i]);
494    
495                                    if ((i + 1) < orderByConditionFields.length) {
496                                            if (orderByComparator.isAscending() ^ previous) {
497                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
498                                            }
499                                            else {
500                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
501                                            }
502                                    }
503                                    else {
504                                            if (orderByComparator.isAscending() ^ previous) {
505                                                    query.append(WHERE_GREATER_THAN);
506                                            }
507                                            else {
508                                                    query.append(WHERE_LESSER_THAN);
509                                            }
510                                    }
511                            }
512    
513                            query.append(ORDER_BY_CLAUSE);
514    
515                            String[] orderByFields = orderByComparator.getOrderByFields();
516    
517                            for (int i = 0; i < orderByFields.length; i++) {
518                                    query.append(_ORDER_BY_ENTITY_ALIAS);
519                                    query.append(orderByFields[i]);
520    
521                                    if ((i + 1) < orderByFields.length) {
522                                            if (orderByComparator.isAscending() ^ previous) {
523                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
524                                            }
525                                            else {
526                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
527                                            }
528                                    }
529                                    else {
530                                            if (orderByComparator.isAscending() ^ previous) {
531                                                    query.append(ORDER_BY_ASC);
532                                            }
533                                            else {
534                                                    query.append(ORDER_BY_DESC);
535                                            }
536                                    }
537                            }
538                    }
539                    else {
540                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
541                    }
542    
543                    String sql = query.toString();
544    
545                    Query q = session.createQuery(sql);
546    
547                    q.setFirstResult(0);
548                    q.setMaxResults(2);
549    
550                    QueryPos qPos = QueryPos.getInstance(q);
551    
552                    if (bindUuid) {
553                            qPos.add(uuid);
554                    }
555    
556                    if (orderByComparator != null) {
557                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
558    
559                            for (Object value : values) {
560                                    qPos.add(value);
561                            }
562                    }
563    
564                    List<BlogsEntry> list = q.list();
565    
566                    if (list.size() == 2) {
567                            return list.get(1);
568                    }
569                    else {
570                            return null;
571                    }
572            }
573    
574            /**
575             * Removes all the blogs entries where uuid = &#63; from the database.
576             *
577             * @param uuid the uuid
578             */
579            @Override
580            public void removeByUuid(String uuid) {
581                    for (BlogsEntry blogsEntry : findByUuid(uuid, QueryUtil.ALL_POS,
582                                    QueryUtil.ALL_POS, null)) {
583                            remove(blogsEntry);
584                    }
585            }
586    
587            /**
588             * Returns the number of blogs entries where uuid = &#63;.
589             *
590             * @param uuid the uuid
591             * @return the number of matching blogs entries
592             */
593            @Override
594            public int countByUuid(String uuid) {
595                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
596    
597                    Object[] finderArgs = new Object[] { uuid };
598    
599                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
600    
601                    if (count == null) {
602                            StringBundler query = new StringBundler(2);
603    
604                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
605    
606                            boolean bindUuid = false;
607    
608                            if (uuid == null) {
609                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
610                            }
611                            else if (uuid.equals(StringPool.BLANK)) {
612                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
613                            }
614                            else {
615                                    bindUuid = true;
616    
617                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
618                            }
619    
620                            String sql = query.toString();
621    
622                            Session session = null;
623    
624                            try {
625                                    session = openSession();
626    
627                                    Query q = session.createQuery(sql);
628    
629                                    QueryPos qPos = QueryPos.getInstance(q);
630    
631                                    if (bindUuid) {
632                                            qPos.add(uuid);
633                                    }
634    
635                                    count = (Long)q.uniqueResult();
636    
637                                    finderCache.putResult(finderPath, finderArgs, count);
638                            }
639                            catch (Exception e) {
640                                    finderCache.removeResult(finderPath, finderArgs);
641    
642                                    throw processException(e);
643                            }
644                            finally {
645                                    closeSession(session);
646                            }
647                    }
648    
649                    return count.intValue();
650            }
651    
652            private static final String _FINDER_COLUMN_UUID_UUID_1 = "blogsEntry.uuid IS NULL";
653            private static final String _FINDER_COLUMN_UUID_UUID_2 = "blogsEntry.uuid = ?";
654            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(blogsEntry.uuid IS NULL OR blogsEntry.uuid = '')";
655            public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
656                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
657                            FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
658                            new String[] { String.class.getName(), Long.class.getName() },
659                            BlogsEntryModelImpl.UUID_COLUMN_BITMASK |
660                            BlogsEntryModelImpl.GROUPID_COLUMN_BITMASK);
661            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
662                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
663                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
664                            new String[] { String.class.getName(), Long.class.getName() });
665    
666            /**
667             * Returns the blogs entry where uuid = &#63; and groupId = &#63; or throws a {@link NoSuchEntryException} if it could not be found.
668             *
669             * @param uuid the uuid
670             * @param groupId the group ID
671             * @return the matching blogs entry
672             * @throws NoSuchEntryException if a matching blogs entry could not be found
673             */
674            @Override
675            public BlogsEntry findByUUID_G(String uuid, long groupId)
676                    throws NoSuchEntryException {
677                    BlogsEntry blogsEntry = fetchByUUID_G(uuid, groupId);
678    
679                    if (blogsEntry == null) {
680                            StringBundler msg = new StringBundler(6);
681    
682                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
683    
684                            msg.append("uuid=");
685                            msg.append(uuid);
686    
687                            msg.append(", groupId=");
688                            msg.append(groupId);
689    
690                            msg.append(StringPool.CLOSE_CURLY_BRACE);
691    
692                            if (_log.isWarnEnabled()) {
693                                    _log.warn(msg.toString());
694                            }
695    
696                            throw new NoSuchEntryException(msg.toString());
697                    }
698    
699                    return blogsEntry;
700            }
701    
702            /**
703             * 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.
704             *
705             * @param uuid the uuid
706             * @param groupId the group ID
707             * @return the matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
708             */
709            @Override
710            public BlogsEntry fetchByUUID_G(String uuid, long groupId) {
711                    return fetchByUUID_G(uuid, groupId, true);
712            }
713    
714            /**
715             * 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.
716             *
717             * @param uuid the uuid
718             * @param groupId the group ID
719             * @param retrieveFromCache whether to retrieve from the finder cache
720             * @return the matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
721             */
722            @Override
723            public BlogsEntry fetchByUUID_G(String uuid, long groupId,
724                    boolean retrieveFromCache) {
725                    Object[] finderArgs = new Object[] { uuid, groupId };
726    
727                    Object result = null;
728    
729                    if (retrieveFromCache) {
730                            result = finderCache.getResult(FINDER_PATH_FETCH_BY_UUID_G,
731                                            finderArgs, this);
732                    }
733    
734                    if (result instanceof BlogsEntry) {
735                            BlogsEntry blogsEntry = (BlogsEntry)result;
736    
737                            if (!Validator.equals(uuid, blogsEntry.getUuid()) ||
738                                            (groupId != blogsEntry.getGroupId())) {
739                                    result = null;
740                            }
741                    }
742    
743                    if (result == null) {
744                            StringBundler query = new StringBundler(4);
745    
746                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
747    
748                            boolean bindUuid = false;
749    
750                            if (uuid == null) {
751                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
752                            }
753                            else if (uuid.equals(StringPool.BLANK)) {
754                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
755                            }
756                            else {
757                                    bindUuid = true;
758    
759                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
760                            }
761    
762                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
763    
764                            String sql = query.toString();
765    
766                            Session session = null;
767    
768                            try {
769                                    session = openSession();
770    
771                                    Query q = session.createQuery(sql);
772    
773                                    QueryPos qPos = QueryPos.getInstance(q);
774    
775                                    if (bindUuid) {
776                                            qPos.add(uuid);
777                                    }
778    
779                                    qPos.add(groupId);
780    
781                                    List<BlogsEntry> list = q.list();
782    
783                                    if (list.isEmpty()) {
784                                            finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G,
785                                                    finderArgs, list);
786                                    }
787                                    else {
788                                            BlogsEntry blogsEntry = list.get(0);
789    
790                                            result = blogsEntry;
791    
792                                            cacheResult(blogsEntry);
793    
794                                            if ((blogsEntry.getUuid() == null) ||
795                                                            !blogsEntry.getUuid().equals(uuid) ||
796                                                            (blogsEntry.getGroupId() != groupId)) {
797                                                    finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G,
798                                                            finderArgs, blogsEntry);
799                                            }
800                                    }
801                            }
802                            catch (Exception e) {
803                                    finderCache.removeResult(FINDER_PATH_FETCH_BY_UUID_G, finderArgs);
804    
805                                    throw processException(e);
806                            }
807                            finally {
808                                    closeSession(session);
809                            }
810                    }
811    
812                    if (result instanceof List<?>) {
813                            return null;
814                    }
815                    else {
816                            return (BlogsEntry)result;
817                    }
818            }
819    
820            /**
821             * Removes the blogs entry where uuid = &#63; and groupId = &#63; from the database.
822             *
823             * @param uuid the uuid
824             * @param groupId the group ID
825             * @return the blogs entry that was removed
826             */
827            @Override
828            public BlogsEntry removeByUUID_G(String uuid, long groupId)
829                    throws NoSuchEntryException {
830                    BlogsEntry blogsEntry = findByUUID_G(uuid, groupId);
831    
832                    return remove(blogsEntry);
833            }
834    
835            /**
836             * Returns the number of blogs entries where uuid = &#63; and groupId = &#63;.
837             *
838             * @param uuid the uuid
839             * @param groupId the group ID
840             * @return the number of matching blogs entries
841             */
842            @Override
843            public int countByUUID_G(String uuid, long groupId) {
844                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_G;
845    
846                    Object[] finderArgs = new Object[] { uuid, groupId };
847    
848                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
849    
850                    if (count == null) {
851                            StringBundler query = new StringBundler(3);
852    
853                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
854    
855                            boolean bindUuid = false;
856    
857                            if (uuid == null) {
858                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
859                            }
860                            else if (uuid.equals(StringPool.BLANK)) {
861                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
862                            }
863                            else {
864                                    bindUuid = true;
865    
866                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
867                            }
868    
869                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
870    
871                            String sql = query.toString();
872    
873                            Session session = null;
874    
875                            try {
876                                    session = openSession();
877    
878                                    Query q = session.createQuery(sql);
879    
880                                    QueryPos qPos = QueryPos.getInstance(q);
881    
882                                    if (bindUuid) {
883                                            qPos.add(uuid);
884                                    }
885    
886                                    qPos.add(groupId);
887    
888                                    count = (Long)q.uniqueResult();
889    
890                                    finderCache.putResult(finderPath, finderArgs, count);
891                            }
892                            catch (Exception e) {
893                                    finderCache.removeResult(finderPath, finderArgs);
894    
895                                    throw processException(e);
896                            }
897                            finally {
898                                    closeSession(session);
899                            }
900                    }
901    
902                    return count.intValue();
903            }
904    
905            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "blogsEntry.uuid IS NULL AND ";
906            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "blogsEntry.uuid = ? AND ";
907            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(blogsEntry.uuid IS NULL OR blogsEntry.uuid = '') AND ";
908            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "blogsEntry.groupId = ?";
909            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
910                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
911                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C",
912                            new String[] {
913                                    String.class.getName(), Long.class.getName(),
914                                    
915                            Integer.class.getName(), Integer.class.getName(),
916                                    OrderByComparator.class.getName()
917                            });
918            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
919                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
920                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
921                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
922                            new String[] { String.class.getName(), Long.class.getName() },
923                            BlogsEntryModelImpl.UUID_COLUMN_BITMASK |
924                            BlogsEntryModelImpl.COMPANYID_COLUMN_BITMASK |
925                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
926                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
927            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
928                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
929                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
930                            new String[] { String.class.getName(), Long.class.getName() });
931    
932            /**
933             * Returns all the blogs entries where uuid = &#63; and companyId = &#63;.
934             *
935             * @param uuid the uuid
936             * @param companyId the company ID
937             * @return the matching blogs entries
938             */
939            @Override
940            public List<BlogsEntry> findByUuid_C(String uuid, long companyId) {
941                    return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
942                            QueryUtil.ALL_POS, null);
943            }
944    
945            /**
946             * Returns a range of all the blogs entries where uuid = &#63; and companyId = &#63;.
947             *
948             * <p>
949             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
950             * </p>
951             *
952             * @param uuid the uuid
953             * @param companyId the company ID
954             * @param start the lower bound of the range of blogs entries
955             * @param end the upper bound of the range of blogs entries (not inclusive)
956             * @return the range of matching blogs entries
957             */
958            @Override
959            public List<BlogsEntry> findByUuid_C(String uuid, long companyId,
960                    int start, int end) {
961                    return findByUuid_C(uuid, companyId, start, end, null);
962            }
963    
964            /**
965             * Returns an ordered range of all the blogs entries where uuid = &#63; and companyId = &#63;.
966             *
967             * <p>
968             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
969             * </p>
970             *
971             * @param uuid the uuid
972             * @param companyId the company ID
973             * @param start the lower bound of the range of blogs entries
974             * @param end the upper bound of the range of blogs entries (not inclusive)
975             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
976             * @return the ordered range of matching blogs entries
977             */
978            @Override
979            public List<BlogsEntry> findByUuid_C(String uuid, long companyId,
980                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator) {
981                    return findByUuid_C(uuid, companyId, start, end, orderByComparator, true);
982            }
983    
984            /**
985             * Returns an ordered range of all the blogs entries where uuid = &#63; and companyId = &#63;.
986             *
987             * <p>
988             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
989             * </p>
990             *
991             * @param uuid the uuid
992             * @param companyId the company ID
993             * @param start the lower bound of the range of blogs entries
994             * @param end the upper bound of the range of blogs entries (not inclusive)
995             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
996             * @param retrieveFromCache whether to retrieve from the finder cache
997             * @return the ordered range of matching blogs entries
998             */
999            @Override
1000            public List<BlogsEntry> findByUuid_C(String uuid, long companyId,
1001                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator,
1002                    boolean retrieveFromCache) {
1003                    boolean pagination = true;
1004                    FinderPath finderPath = null;
1005                    Object[] finderArgs = null;
1006    
1007                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1008                                    (orderByComparator == null)) {
1009                            pagination = false;
1010                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
1011                            finderArgs = new Object[] { uuid, companyId };
1012                    }
1013                    else {
1014                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
1015                            finderArgs = new Object[] {
1016                                            uuid, companyId,
1017                                            
1018                                            start, end, orderByComparator
1019                                    };
1020                    }
1021    
1022                    List<BlogsEntry> list = null;
1023    
1024                    if (retrieveFromCache) {
1025                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
1026                                            finderArgs, this);
1027    
1028                            if ((list != null) && !list.isEmpty()) {
1029                                    for (BlogsEntry blogsEntry : list) {
1030                                            if (!Validator.equals(uuid, blogsEntry.getUuid()) ||
1031                                                            (companyId != blogsEntry.getCompanyId())) {
1032                                                    list = null;
1033    
1034                                                    break;
1035                                            }
1036                                    }
1037                            }
1038                    }
1039    
1040                    if (list == null) {
1041                            StringBundler query = null;
1042    
1043                            if (orderByComparator != null) {
1044                                    query = new StringBundler(4 +
1045                                                    (orderByComparator.getOrderByFields().length * 2));
1046                            }
1047                            else {
1048                                    query = new StringBundler(4);
1049                            }
1050    
1051                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
1052    
1053                            boolean bindUuid = false;
1054    
1055                            if (uuid == null) {
1056                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1057                            }
1058                            else if (uuid.equals(StringPool.BLANK)) {
1059                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1060                            }
1061                            else {
1062                                    bindUuid = true;
1063    
1064                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1065                            }
1066    
1067                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1068    
1069                            if (orderByComparator != null) {
1070                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1071                                            orderByComparator);
1072                            }
1073                            else
1074                             if (pagination) {
1075                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
1076                            }
1077    
1078                            String sql = query.toString();
1079    
1080                            Session session = null;
1081    
1082                            try {
1083                                    session = openSession();
1084    
1085                                    Query q = session.createQuery(sql);
1086    
1087                                    QueryPos qPos = QueryPos.getInstance(q);
1088    
1089                                    if (bindUuid) {
1090                                            qPos.add(uuid);
1091                                    }
1092    
1093                                    qPos.add(companyId);
1094    
1095                                    if (!pagination) {
1096                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
1097                                                            start, end, false);
1098    
1099                                            Collections.sort(list);
1100    
1101                                            list = Collections.unmodifiableList(list);
1102                                    }
1103                                    else {
1104                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
1105                                                            start, end);
1106                                    }
1107    
1108                                    cacheResult(list);
1109    
1110                                    finderCache.putResult(finderPath, finderArgs, list);
1111                            }
1112                            catch (Exception e) {
1113                                    finderCache.removeResult(finderPath, finderArgs);
1114    
1115                                    throw processException(e);
1116                            }
1117                            finally {
1118                                    closeSession(session);
1119                            }
1120                    }
1121    
1122                    return list;
1123            }
1124    
1125            /**
1126             * Returns the first blogs entry in the ordered set where uuid = &#63; and companyId = &#63;.
1127             *
1128             * @param uuid the uuid
1129             * @param companyId the company ID
1130             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1131             * @return the first matching blogs entry
1132             * @throws NoSuchEntryException if a matching blogs entry could not be found
1133             */
1134            @Override
1135            public BlogsEntry findByUuid_C_First(String uuid, long companyId,
1136                    OrderByComparator<BlogsEntry> orderByComparator)
1137                    throws NoSuchEntryException {
1138                    BlogsEntry blogsEntry = fetchByUuid_C_First(uuid, companyId,
1139                                    orderByComparator);
1140    
1141                    if (blogsEntry != null) {
1142                            return blogsEntry;
1143                    }
1144    
1145                    StringBundler msg = new StringBundler(6);
1146    
1147                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1148    
1149                    msg.append("uuid=");
1150                    msg.append(uuid);
1151    
1152                    msg.append(", companyId=");
1153                    msg.append(companyId);
1154    
1155                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1156    
1157                    throw new NoSuchEntryException(msg.toString());
1158            }
1159    
1160            /**
1161             * Returns the first blogs entry in the ordered set where uuid = &#63; and companyId = &#63;.
1162             *
1163             * @param uuid the uuid
1164             * @param companyId the company ID
1165             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1166             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
1167             */
1168            @Override
1169            public BlogsEntry fetchByUuid_C_First(String uuid, long companyId,
1170                    OrderByComparator<BlogsEntry> orderByComparator) {
1171                    List<BlogsEntry> list = findByUuid_C(uuid, companyId, 0, 1,
1172                                    orderByComparator);
1173    
1174                    if (!list.isEmpty()) {
1175                            return list.get(0);
1176                    }
1177    
1178                    return null;
1179            }
1180    
1181            /**
1182             * Returns the last blogs entry in the ordered set where uuid = &#63; and companyId = &#63;.
1183             *
1184             * @param uuid the uuid
1185             * @param companyId the company ID
1186             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1187             * @return the last matching blogs entry
1188             * @throws NoSuchEntryException if a matching blogs entry could not be found
1189             */
1190            @Override
1191            public BlogsEntry findByUuid_C_Last(String uuid, long companyId,
1192                    OrderByComparator<BlogsEntry> orderByComparator)
1193                    throws NoSuchEntryException {
1194                    BlogsEntry blogsEntry = fetchByUuid_C_Last(uuid, companyId,
1195                                    orderByComparator);
1196    
1197                    if (blogsEntry != null) {
1198                            return blogsEntry;
1199                    }
1200    
1201                    StringBundler msg = new StringBundler(6);
1202    
1203                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1204    
1205                    msg.append("uuid=");
1206                    msg.append(uuid);
1207    
1208                    msg.append(", companyId=");
1209                    msg.append(companyId);
1210    
1211                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1212    
1213                    throw new NoSuchEntryException(msg.toString());
1214            }
1215    
1216            /**
1217             * Returns the last blogs entry in the ordered set where uuid = &#63; and companyId = &#63;.
1218             *
1219             * @param uuid the uuid
1220             * @param companyId the company ID
1221             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1222             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
1223             */
1224            @Override
1225            public BlogsEntry fetchByUuid_C_Last(String uuid, long companyId,
1226                    OrderByComparator<BlogsEntry> orderByComparator) {
1227                    int count = countByUuid_C(uuid, companyId);
1228    
1229                    if (count == 0) {
1230                            return null;
1231                    }
1232    
1233                    List<BlogsEntry> list = findByUuid_C(uuid, companyId, count - 1, count,
1234                                    orderByComparator);
1235    
1236                    if (!list.isEmpty()) {
1237                            return list.get(0);
1238                    }
1239    
1240                    return null;
1241            }
1242    
1243            /**
1244             * Returns the blogs entries before and after the current blogs entry in the ordered set where uuid = &#63; and companyId = &#63;.
1245             *
1246             * @param entryId the primary key of the current blogs entry
1247             * @param uuid the uuid
1248             * @param companyId the company ID
1249             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1250             * @return the previous, current, and next blogs entry
1251             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
1252             */
1253            @Override
1254            public BlogsEntry[] findByUuid_C_PrevAndNext(long entryId, String uuid,
1255                    long companyId, OrderByComparator<BlogsEntry> orderByComparator)
1256                    throws NoSuchEntryException {
1257                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
1258    
1259                    Session session = null;
1260    
1261                    try {
1262                            session = openSession();
1263    
1264                            BlogsEntry[] array = new BlogsEntryImpl[3];
1265    
1266                            array[0] = getByUuid_C_PrevAndNext(session, blogsEntry, uuid,
1267                                            companyId, orderByComparator, true);
1268    
1269                            array[1] = blogsEntry;
1270    
1271                            array[2] = getByUuid_C_PrevAndNext(session, blogsEntry, uuid,
1272                                            companyId, orderByComparator, false);
1273    
1274                            return array;
1275                    }
1276                    catch (Exception e) {
1277                            throw processException(e);
1278                    }
1279                    finally {
1280                            closeSession(session);
1281                    }
1282            }
1283    
1284            protected BlogsEntry getByUuid_C_PrevAndNext(Session session,
1285                    BlogsEntry blogsEntry, String uuid, long companyId,
1286                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
1287                    StringBundler query = null;
1288    
1289                    if (orderByComparator != null) {
1290                            query = new StringBundler(5 +
1291                                            (orderByComparator.getOrderByConditionFields().length * 3) +
1292                                            (orderByComparator.getOrderByFields().length * 3));
1293                    }
1294                    else {
1295                            query = new StringBundler(4);
1296                    }
1297    
1298                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
1299    
1300                    boolean bindUuid = false;
1301    
1302                    if (uuid == null) {
1303                            query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1304                    }
1305                    else if (uuid.equals(StringPool.BLANK)) {
1306                            query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1307                    }
1308                    else {
1309                            bindUuid = true;
1310    
1311                            query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1312                    }
1313    
1314                    query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1315    
1316                    if (orderByComparator != null) {
1317                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1318    
1319                            if (orderByConditionFields.length > 0) {
1320                                    query.append(WHERE_AND);
1321                            }
1322    
1323                            for (int i = 0; i < orderByConditionFields.length; i++) {
1324                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1325                                    query.append(orderByConditionFields[i]);
1326    
1327                                    if ((i + 1) < orderByConditionFields.length) {
1328                                            if (orderByComparator.isAscending() ^ previous) {
1329                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1330                                            }
1331                                            else {
1332                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1333                                            }
1334                                    }
1335                                    else {
1336                                            if (orderByComparator.isAscending() ^ previous) {
1337                                                    query.append(WHERE_GREATER_THAN);
1338                                            }
1339                                            else {
1340                                                    query.append(WHERE_LESSER_THAN);
1341                                            }
1342                                    }
1343                            }
1344    
1345                            query.append(ORDER_BY_CLAUSE);
1346    
1347                            String[] orderByFields = orderByComparator.getOrderByFields();
1348    
1349                            for (int i = 0; i < orderByFields.length; i++) {
1350                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1351                                    query.append(orderByFields[i]);
1352    
1353                                    if ((i + 1) < orderByFields.length) {
1354                                            if (orderByComparator.isAscending() ^ previous) {
1355                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1356                                            }
1357                                            else {
1358                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1359                                            }
1360                                    }
1361                                    else {
1362                                            if (orderByComparator.isAscending() ^ previous) {
1363                                                    query.append(ORDER_BY_ASC);
1364                                            }
1365                                            else {
1366                                                    query.append(ORDER_BY_DESC);
1367                                            }
1368                                    }
1369                            }
1370                    }
1371                    else {
1372                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
1373                    }
1374    
1375                    String sql = query.toString();
1376    
1377                    Query q = session.createQuery(sql);
1378    
1379                    q.setFirstResult(0);
1380                    q.setMaxResults(2);
1381    
1382                    QueryPos qPos = QueryPos.getInstance(q);
1383    
1384                    if (bindUuid) {
1385                            qPos.add(uuid);
1386                    }
1387    
1388                    qPos.add(companyId);
1389    
1390                    if (orderByComparator != null) {
1391                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
1392    
1393                            for (Object value : values) {
1394                                    qPos.add(value);
1395                            }
1396                    }
1397    
1398                    List<BlogsEntry> list = q.list();
1399    
1400                    if (list.size() == 2) {
1401                            return list.get(1);
1402                    }
1403                    else {
1404                            return null;
1405                    }
1406            }
1407    
1408            /**
1409             * Removes all the blogs entries where uuid = &#63; and companyId = &#63; from the database.
1410             *
1411             * @param uuid the uuid
1412             * @param companyId the company ID
1413             */
1414            @Override
1415            public void removeByUuid_C(String uuid, long companyId) {
1416                    for (BlogsEntry blogsEntry : findByUuid_C(uuid, companyId,
1417                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1418                            remove(blogsEntry);
1419                    }
1420            }
1421    
1422            /**
1423             * Returns the number of blogs entries where uuid = &#63; and companyId = &#63;.
1424             *
1425             * @param uuid the uuid
1426             * @param companyId the company ID
1427             * @return the number of matching blogs entries
1428             */
1429            @Override
1430            public int countByUuid_C(String uuid, long companyId) {
1431                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1432    
1433                    Object[] finderArgs = new Object[] { uuid, companyId };
1434    
1435                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
1436    
1437                    if (count == null) {
1438                            StringBundler query = new StringBundler(3);
1439    
1440                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
1441    
1442                            boolean bindUuid = false;
1443    
1444                            if (uuid == null) {
1445                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1446                            }
1447                            else if (uuid.equals(StringPool.BLANK)) {
1448                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1449                            }
1450                            else {
1451                                    bindUuid = true;
1452    
1453                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1454                            }
1455    
1456                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1457    
1458                            String sql = query.toString();
1459    
1460                            Session session = null;
1461    
1462                            try {
1463                                    session = openSession();
1464    
1465                                    Query q = session.createQuery(sql);
1466    
1467                                    QueryPos qPos = QueryPos.getInstance(q);
1468    
1469                                    if (bindUuid) {
1470                                            qPos.add(uuid);
1471                                    }
1472    
1473                                    qPos.add(companyId);
1474    
1475                                    count = (Long)q.uniqueResult();
1476    
1477                                    finderCache.putResult(finderPath, finderArgs, count);
1478                            }
1479                            catch (Exception e) {
1480                                    finderCache.removeResult(finderPath, finderArgs);
1481    
1482                                    throw processException(e);
1483                            }
1484                            finally {
1485                                    closeSession(session);
1486                            }
1487                    }
1488    
1489                    return count.intValue();
1490            }
1491    
1492            private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "blogsEntry.uuid IS NULL AND ";
1493            private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "blogsEntry.uuid = ? AND ";
1494            private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(blogsEntry.uuid IS NULL OR blogsEntry.uuid = '') AND ";
1495            private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "blogsEntry.companyId = ?";
1496            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
1497                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
1498                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId",
1499                            new String[] {
1500                                    Long.class.getName(),
1501                                    
1502                            Integer.class.getName(), Integer.class.getName(),
1503                                    OrderByComparator.class.getName()
1504                            });
1505            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
1506                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
1507                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
1508                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
1509                            new String[] { Long.class.getName() },
1510                            BlogsEntryModelImpl.GROUPID_COLUMN_BITMASK |
1511                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
1512                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
1513            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
1514                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
1515                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
1516                            new String[] { Long.class.getName() });
1517    
1518            /**
1519             * Returns all the blogs entries where groupId = &#63;.
1520             *
1521             * @param groupId the group ID
1522             * @return the matching blogs entries
1523             */
1524            @Override
1525            public List<BlogsEntry> findByGroupId(long groupId) {
1526                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1527            }
1528    
1529            /**
1530             * Returns a range of all the blogs entries where groupId = &#63;.
1531             *
1532             * <p>
1533             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1534             * </p>
1535             *
1536             * @param groupId the group ID
1537             * @param start the lower bound of the range of blogs entries
1538             * @param end the upper bound of the range of blogs entries (not inclusive)
1539             * @return the range of matching blogs entries
1540             */
1541            @Override
1542            public List<BlogsEntry> findByGroupId(long groupId, int start, int end) {
1543                    return findByGroupId(groupId, start, end, null);
1544            }
1545    
1546            /**
1547             * Returns an ordered range of all the blogs entries where groupId = &#63;.
1548             *
1549             * <p>
1550             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1551             * </p>
1552             *
1553             * @param groupId the group ID
1554             * @param start the lower bound of the range of blogs entries
1555             * @param end the upper bound of the range of blogs entries (not inclusive)
1556             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1557             * @return the ordered range of matching blogs entries
1558             */
1559            @Override
1560            public List<BlogsEntry> findByGroupId(long groupId, int start, int end,
1561                    OrderByComparator<BlogsEntry> orderByComparator) {
1562                    return findByGroupId(groupId, start, end, orderByComparator, true);
1563            }
1564    
1565            /**
1566             * Returns an ordered range of all the blogs entries where groupId = &#63;.
1567             *
1568             * <p>
1569             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1570             * </p>
1571             *
1572             * @param groupId the group ID
1573             * @param start the lower bound of the range of blogs entries
1574             * @param end the upper bound of the range of blogs entries (not inclusive)
1575             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1576             * @param retrieveFromCache whether to retrieve from the finder cache
1577             * @return the ordered range of matching blogs entries
1578             */
1579            @Override
1580            public List<BlogsEntry> findByGroupId(long groupId, int start, int end,
1581                    OrderByComparator<BlogsEntry> orderByComparator,
1582                    boolean retrieveFromCache) {
1583                    boolean pagination = true;
1584                    FinderPath finderPath = null;
1585                    Object[] finderArgs = null;
1586    
1587                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1588                                    (orderByComparator == null)) {
1589                            pagination = false;
1590                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1591                            finderArgs = new Object[] { groupId };
1592                    }
1593                    else {
1594                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1595                            finderArgs = new Object[] { groupId, start, end, orderByComparator };
1596                    }
1597    
1598                    List<BlogsEntry> list = null;
1599    
1600                    if (retrieveFromCache) {
1601                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
1602                                            finderArgs, this);
1603    
1604                            if ((list != null) && !list.isEmpty()) {
1605                                    for (BlogsEntry blogsEntry : list) {
1606                                            if ((groupId != blogsEntry.getGroupId())) {
1607                                                    list = null;
1608    
1609                                                    break;
1610                                            }
1611                                    }
1612                            }
1613                    }
1614    
1615                    if (list == null) {
1616                            StringBundler query = null;
1617    
1618                            if (orderByComparator != null) {
1619                                    query = new StringBundler(3 +
1620                                                    (orderByComparator.getOrderByFields().length * 2));
1621                            }
1622                            else {
1623                                    query = new StringBundler(3);
1624                            }
1625    
1626                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
1627    
1628                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1629    
1630                            if (orderByComparator != null) {
1631                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1632                                            orderByComparator);
1633                            }
1634                            else
1635                             if (pagination) {
1636                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
1637                            }
1638    
1639                            String sql = query.toString();
1640    
1641                            Session session = null;
1642    
1643                            try {
1644                                    session = openSession();
1645    
1646                                    Query q = session.createQuery(sql);
1647    
1648                                    QueryPos qPos = QueryPos.getInstance(q);
1649    
1650                                    qPos.add(groupId);
1651    
1652                                    if (!pagination) {
1653                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
1654                                                            start, end, false);
1655    
1656                                            Collections.sort(list);
1657    
1658                                            list = Collections.unmodifiableList(list);
1659                                    }
1660                                    else {
1661                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
1662                                                            start, end);
1663                                    }
1664    
1665                                    cacheResult(list);
1666    
1667                                    finderCache.putResult(finderPath, finderArgs, list);
1668                            }
1669                            catch (Exception e) {
1670                                    finderCache.removeResult(finderPath, finderArgs);
1671    
1672                                    throw processException(e);
1673                            }
1674                            finally {
1675                                    closeSession(session);
1676                            }
1677                    }
1678    
1679                    return list;
1680            }
1681    
1682            /**
1683             * Returns the first blogs entry in the ordered set where groupId = &#63;.
1684             *
1685             * @param groupId the group ID
1686             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1687             * @return the first matching blogs entry
1688             * @throws NoSuchEntryException if a matching blogs entry could not be found
1689             */
1690            @Override
1691            public BlogsEntry findByGroupId_First(long groupId,
1692                    OrderByComparator<BlogsEntry> orderByComparator)
1693                    throws NoSuchEntryException {
1694                    BlogsEntry blogsEntry = fetchByGroupId_First(groupId, orderByComparator);
1695    
1696                    if (blogsEntry != null) {
1697                            return blogsEntry;
1698                    }
1699    
1700                    StringBundler msg = new StringBundler(4);
1701    
1702                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1703    
1704                    msg.append("groupId=");
1705                    msg.append(groupId);
1706    
1707                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1708    
1709                    throw new NoSuchEntryException(msg.toString());
1710            }
1711    
1712            /**
1713             * Returns the first blogs entry in the ordered set where groupId = &#63;.
1714             *
1715             * @param groupId the group ID
1716             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1717             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
1718             */
1719            @Override
1720            public BlogsEntry fetchByGroupId_First(long groupId,
1721                    OrderByComparator<BlogsEntry> orderByComparator) {
1722                    List<BlogsEntry> list = findByGroupId(groupId, 0, 1, orderByComparator);
1723    
1724                    if (!list.isEmpty()) {
1725                            return list.get(0);
1726                    }
1727    
1728                    return null;
1729            }
1730    
1731            /**
1732             * Returns the last blogs entry in the ordered set where groupId = &#63;.
1733             *
1734             * @param groupId the group ID
1735             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1736             * @return the last matching blogs entry
1737             * @throws NoSuchEntryException if a matching blogs entry could not be found
1738             */
1739            @Override
1740            public BlogsEntry findByGroupId_Last(long groupId,
1741                    OrderByComparator<BlogsEntry> orderByComparator)
1742                    throws NoSuchEntryException {
1743                    BlogsEntry blogsEntry = fetchByGroupId_Last(groupId, orderByComparator);
1744    
1745                    if (blogsEntry != null) {
1746                            return blogsEntry;
1747                    }
1748    
1749                    StringBundler msg = new StringBundler(4);
1750    
1751                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1752    
1753                    msg.append("groupId=");
1754                    msg.append(groupId);
1755    
1756                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1757    
1758                    throw new NoSuchEntryException(msg.toString());
1759            }
1760    
1761            /**
1762             * Returns the last blogs entry in the ordered set where groupId = &#63;.
1763             *
1764             * @param groupId the group ID
1765             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1766             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
1767             */
1768            @Override
1769            public BlogsEntry fetchByGroupId_Last(long groupId,
1770                    OrderByComparator<BlogsEntry> orderByComparator) {
1771                    int count = countByGroupId(groupId);
1772    
1773                    if (count == 0) {
1774                            return null;
1775                    }
1776    
1777                    List<BlogsEntry> list = findByGroupId(groupId, count - 1, count,
1778                                    orderByComparator);
1779    
1780                    if (!list.isEmpty()) {
1781                            return list.get(0);
1782                    }
1783    
1784                    return null;
1785            }
1786    
1787            /**
1788             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63;.
1789             *
1790             * @param entryId the primary key of the current blogs entry
1791             * @param groupId the group ID
1792             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1793             * @return the previous, current, and next blogs entry
1794             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
1795             */
1796            @Override
1797            public BlogsEntry[] findByGroupId_PrevAndNext(long entryId, long groupId,
1798                    OrderByComparator<BlogsEntry> orderByComparator)
1799                    throws NoSuchEntryException {
1800                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
1801    
1802                    Session session = null;
1803    
1804                    try {
1805                            session = openSession();
1806    
1807                            BlogsEntry[] array = new BlogsEntryImpl[3];
1808    
1809                            array[0] = getByGroupId_PrevAndNext(session, blogsEntry, groupId,
1810                                            orderByComparator, true);
1811    
1812                            array[1] = blogsEntry;
1813    
1814                            array[2] = getByGroupId_PrevAndNext(session, blogsEntry, groupId,
1815                                            orderByComparator, false);
1816    
1817                            return array;
1818                    }
1819                    catch (Exception e) {
1820                            throw processException(e);
1821                    }
1822                    finally {
1823                            closeSession(session);
1824                    }
1825            }
1826    
1827            protected BlogsEntry getByGroupId_PrevAndNext(Session session,
1828                    BlogsEntry blogsEntry, long groupId,
1829                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
1830                    StringBundler query = null;
1831    
1832                    if (orderByComparator != null) {
1833                            query = new StringBundler(4 +
1834                                            (orderByComparator.getOrderByConditionFields().length * 3) +
1835                                            (orderByComparator.getOrderByFields().length * 3));
1836                    }
1837                    else {
1838                            query = new StringBundler(3);
1839                    }
1840    
1841                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
1842    
1843                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1844    
1845                    if (orderByComparator != null) {
1846                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1847    
1848                            if (orderByConditionFields.length > 0) {
1849                                    query.append(WHERE_AND);
1850                            }
1851    
1852                            for (int i = 0; i < orderByConditionFields.length; i++) {
1853                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1854                                    query.append(orderByConditionFields[i]);
1855    
1856                                    if ((i + 1) < orderByConditionFields.length) {
1857                                            if (orderByComparator.isAscending() ^ previous) {
1858                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1859                                            }
1860                                            else {
1861                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1862                                            }
1863                                    }
1864                                    else {
1865                                            if (orderByComparator.isAscending() ^ previous) {
1866                                                    query.append(WHERE_GREATER_THAN);
1867                                            }
1868                                            else {
1869                                                    query.append(WHERE_LESSER_THAN);
1870                                            }
1871                                    }
1872                            }
1873    
1874                            query.append(ORDER_BY_CLAUSE);
1875    
1876                            String[] orderByFields = orderByComparator.getOrderByFields();
1877    
1878                            for (int i = 0; i < orderByFields.length; i++) {
1879                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1880                                    query.append(orderByFields[i]);
1881    
1882                                    if ((i + 1) < orderByFields.length) {
1883                                            if (orderByComparator.isAscending() ^ previous) {
1884                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1885                                            }
1886                                            else {
1887                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1888                                            }
1889                                    }
1890                                    else {
1891                                            if (orderByComparator.isAscending() ^ previous) {
1892                                                    query.append(ORDER_BY_ASC);
1893                                            }
1894                                            else {
1895                                                    query.append(ORDER_BY_DESC);
1896                                            }
1897                                    }
1898                            }
1899                    }
1900                    else {
1901                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
1902                    }
1903    
1904                    String sql = query.toString();
1905    
1906                    Query q = session.createQuery(sql);
1907    
1908                    q.setFirstResult(0);
1909                    q.setMaxResults(2);
1910    
1911                    QueryPos qPos = QueryPos.getInstance(q);
1912    
1913                    qPos.add(groupId);
1914    
1915                    if (orderByComparator != null) {
1916                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
1917    
1918                            for (Object value : values) {
1919                                    qPos.add(value);
1920                            }
1921                    }
1922    
1923                    List<BlogsEntry> list = q.list();
1924    
1925                    if (list.size() == 2) {
1926                            return list.get(1);
1927                    }
1928                    else {
1929                            return null;
1930                    }
1931            }
1932    
1933            /**
1934             * Returns all the blogs entries that the user has permission to view where groupId = &#63;.
1935             *
1936             * @param groupId the group ID
1937             * @return the matching blogs entries that the user has permission to view
1938             */
1939            @Override
1940            public List<BlogsEntry> filterFindByGroupId(long groupId) {
1941                    return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1942                            QueryUtil.ALL_POS, null);
1943            }
1944    
1945            /**
1946             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63;.
1947             *
1948             * <p>
1949             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1950             * </p>
1951             *
1952             * @param groupId the group ID
1953             * @param start the lower bound of the range of blogs entries
1954             * @param end the upper bound of the range of blogs entries (not inclusive)
1955             * @return the range of matching blogs entries that the user has permission to view
1956             */
1957            @Override
1958            public List<BlogsEntry> filterFindByGroupId(long groupId, int start, int end) {
1959                    return filterFindByGroupId(groupId, start, end, null);
1960            }
1961    
1962            /**
1963             * Returns an ordered range of all the blogs entries that the user has permissions to view where groupId = &#63;.
1964             *
1965             * <p>
1966             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1967             * </p>
1968             *
1969             * @param groupId the group ID
1970             * @param start the lower bound of the range of blogs entries
1971             * @param end the upper bound of the range of blogs entries (not inclusive)
1972             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1973             * @return the ordered range of matching blogs entries that the user has permission to view
1974             */
1975            @Override
1976            public List<BlogsEntry> filterFindByGroupId(long groupId, int start,
1977                    int end, OrderByComparator<BlogsEntry> orderByComparator) {
1978                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1979                            return findByGroupId(groupId, start, end, orderByComparator);
1980                    }
1981    
1982                    StringBundler query = null;
1983    
1984                    if (orderByComparator != null) {
1985                            query = new StringBundler(3 +
1986                                            (orderByComparator.getOrderByFields().length * 2));
1987                    }
1988                    else {
1989                            query = new StringBundler(4);
1990                    }
1991    
1992                    if (getDB().isSupportsInlineDistinct()) {
1993                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
1994                    }
1995                    else {
1996                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
1997                    }
1998    
1999                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2000    
2001                    if (!getDB().isSupportsInlineDistinct()) {
2002                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
2003                    }
2004    
2005                    if (orderByComparator != null) {
2006                            if (getDB().isSupportsInlineDistinct()) {
2007                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2008                                            orderByComparator, true);
2009                            }
2010                            else {
2011                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2012                                            orderByComparator, true);
2013                            }
2014                    }
2015                    else {
2016                            if (getDB().isSupportsInlineDistinct()) {
2017                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
2018                            }
2019                            else {
2020                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
2021                            }
2022                    }
2023    
2024                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2025                                    BlogsEntry.class.getName(),
2026                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2027    
2028                    Session session = null;
2029    
2030                    try {
2031                            session = openSession();
2032    
2033                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
2034    
2035                            if (getDB().isSupportsInlineDistinct()) {
2036                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
2037                            }
2038                            else {
2039                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
2040                            }
2041    
2042                            QueryPos qPos = QueryPos.getInstance(q);
2043    
2044                            qPos.add(groupId);
2045    
2046                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
2047                    }
2048                    catch (Exception e) {
2049                            throw processException(e);
2050                    }
2051                    finally {
2052                            closeSession(session);
2053                    }
2054            }
2055    
2056            /**
2057             * 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;.
2058             *
2059             * @param entryId the primary key of the current blogs entry
2060             * @param groupId the group ID
2061             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2062             * @return the previous, current, and next blogs entry
2063             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
2064             */
2065            @Override
2066            public BlogsEntry[] filterFindByGroupId_PrevAndNext(long entryId,
2067                    long groupId, OrderByComparator<BlogsEntry> orderByComparator)
2068                    throws NoSuchEntryException {
2069                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2070                            return findByGroupId_PrevAndNext(entryId, groupId, orderByComparator);
2071                    }
2072    
2073                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
2074    
2075                    Session session = null;
2076    
2077                    try {
2078                            session = openSession();
2079    
2080                            BlogsEntry[] array = new BlogsEntryImpl[3];
2081    
2082                            array[0] = filterGetByGroupId_PrevAndNext(session, blogsEntry,
2083                                            groupId, orderByComparator, true);
2084    
2085                            array[1] = blogsEntry;
2086    
2087                            array[2] = filterGetByGroupId_PrevAndNext(session, blogsEntry,
2088                                            groupId, orderByComparator, false);
2089    
2090                            return array;
2091                    }
2092                    catch (Exception e) {
2093                            throw processException(e);
2094                    }
2095                    finally {
2096                            closeSession(session);
2097                    }
2098            }
2099    
2100            protected BlogsEntry filterGetByGroupId_PrevAndNext(Session session,
2101                    BlogsEntry blogsEntry, long groupId,
2102                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
2103                    StringBundler query = null;
2104    
2105                    if (orderByComparator != null) {
2106                            query = new StringBundler(5 +
2107                                            (orderByComparator.getOrderByConditionFields().length * 3) +
2108                                            (orderByComparator.getOrderByFields().length * 3));
2109                    }
2110                    else {
2111                            query = new StringBundler(4);
2112                    }
2113    
2114                    if (getDB().isSupportsInlineDistinct()) {
2115                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
2116                    }
2117                    else {
2118                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
2119                    }
2120    
2121                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2122    
2123                    if (!getDB().isSupportsInlineDistinct()) {
2124                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
2125                    }
2126    
2127                    if (orderByComparator != null) {
2128                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2129    
2130                            if (orderByConditionFields.length > 0) {
2131                                    query.append(WHERE_AND);
2132                            }
2133    
2134                            for (int i = 0; i < orderByConditionFields.length; i++) {
2135                                    if (getDB().isSupportsInlineDistinct()) {
2136                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2137                                    }
2138                                    else {
2139                                            query.append(_ORDER_BY_ENTITY_TABLE);
2140                                    }
2141    
2142                                    query.append(orderByConditionFields[i]);
2143    
2144                                    if ((i + 1) < orderByConditionFields.length) {
2145                                            if (orderByComparator.isAscending() ^ previous) {
2146                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2147                                            }
2148                                            else {
2149                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2150                                            }
2151                                    }
2152                                    else {
2153                                            if (orderByComparator.isAscending() ^ previous) {
2154                                                    query.append(WHERE_GREATER_THAN);
2155                                            }
2156                                            else {
2157                                                    query.append(WHERE_LESSER_THAN);
2158                                            }
2159                                    }
2160                            }
2161    
2162                            query.append(ORDER_BY_CLAUSE);
2163    
2164                            String[] orderByFields = orderByComparator.getOrderByFields();
2165    
2166                            for (int i = 0; i < orderByFields.length; i++) {
2167                                    if (getDB().isSupportsInlineDistinct()) {
2168                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2169                                    }
2170                                    else {
2171                                            query.append(_ORDER_BY_ENTITY_TABLE);
2172                                    }
2173    
2174                                    query.append(orderByFields[i]);
2175    
2176                                    if ((i + 1) < orderByFields.length) {
2177                                            if (orderByComparator.isAscending() ^ previous) {
2178                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2179                                            }
2180                                            else {
2181                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2182                                            }
2183                                    }
2184                                    else {
2185                                            if (orderByComparator.isAscending() ^ previous) {
2186                                                    query.append(ORDER_BY_ASC);
2187                                            }
2188                                            else {
2189                                                    query.append(ORDER_BY_DESC);
2190                                            }
2191                                    }
2192                            }
2193                    }
2194                    else {
2195                            if (getDB().isSupportsInlineDistinct()) {
2196                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
2197                            }
2198                            else {
2199                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
2200                            }
2201                    }
2202    
2203                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2204                                    BlogsEntry.class.getName(),
2205                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2206    
2207                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
2208    
2209                    q.setFirstResult(0);
2210                    q.setMaxResults(2);
2211    
2212                    if (getDB().isSupportsInlineDistinct()) {
2213                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
2214                    }
2215                    else {
2216                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
2217                    }
2218    
2219                    QueryPos qPos = QueryPos.getInstance(q);
2220    
2221                    qPos.add(groupId);
2222    
2223                    if (orderByComparator != null) {
2224                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
2225    
2226                            for (Object value : values) {
2227                                    qPos.add(value);
2228                            }
2229                    }
2230    
2231                    List<BlogsEntry> list = q.list();
2232    
2233                    if (list.size() == 2) {
2234                            return list.get(1);
2235                    }
2236                    else {
2237                            return null;
2238                    }
2239            }
2240    
2241            /**
2242             * Removes all the blogs entries where groupId = &#63; from the database.
2243             *
2244             * @param groupId the group ID
2245             */
2246            @Override
2247            public void removeByGroupId(long groupId) {
2248                    for (BlogsEntry blogsEntry : findByGroupId(groupId, QueryUtil.ALL_POS,
2249                                    QueryUtil.ALL_POS, null)) {
2250                            remove(blogsEntry);
2251                    }
2252            }
2253    
2254            /**
2255             * Returns the number of blogs entries where groupId = &#63;.
2256             *
2257             * @param groupId the group ID
2258             * @return the number of matching blogs entries
2259             */
2260            @Override
2261            public int countByGroupId(long groupId) {
2262                    FinderPath finderPath = FINDER_PATH_COUNT_BY_GROUPID;
2263    
2264                    Object[] finderArgs = new Object[] { groupId };
2265    
2266                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
2267    
2268                    if (count == null) {
2269                            StringBundler query = new StringBundler(2);
2270    
2271                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
2272    
2273                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2274    
2275                            String sql = query.toString();
2276    
2277                            Session session = null;
2278    
2279                            try {
2280                                    session = openSession();
2281    
2282                                    Query q = session.createQuery(sql);
2283    
2284                                    QueryPos qPos = QueryPos.getInstance(q);
2285    
2286                                    qPos.add(groupId);
2287    
2288                                    count = (Long)q.uniqueResult();
2289    
2290                                    finderCache.putResult(finderPath, finderArgs, count);
2291                            }
2292                            catch (Exception e) {
2293                                    finderCache.removeResult(finderPath, finderArgs);
2294    
2295                                    throw processException(e);
2296                            }
2297                            finally {
2298                                    closeSession(session);
2299                            }
2300                    }
2301    
2302                    return count.intValue();
2303            }
2304    
2305            /**
2306             * Returns the number of blogs entries that the user has permission to view where groupId = &#63;.
2307             *
2308             * @param groupId the group ID
2309             * @return the number of matching blogs entries that the user has permission to view
2310             */
2311            @Override
2312            public int filterCountByGroupId(long groupId) {
2313                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2314                            return countByGroupId(groupId);
2315                    }
2316    
2317                    StringBundler query = new StringBundler(2);
2318    
2319                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
2320    
2321                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2322    
2323                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2324                                    BlogsEntry.class.getName(),
2325                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2326    
2327                    Session session = null;
2328    
2329                    try {
2330                            session = openSession();
2331    
2332                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
2333    
2334                            q.addScalar(COUNT_COLUMN_NAME,
2335                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
2336    
2337                            QueryPos qPos = QueryPos.getInstance(q);
2338    
2339                            qPos.add(groupId);
2340    
2341                            Long count = (Long)q.uniqueResult();
2342    
2343                            return count.intValue();
2344                    }
2345                    catch (Exception e) {
2346                            throw processException(e);
2347                    }
2348                    finally {
2349                            closeSession(session);
2350                    }
2351            }
2352    
2353            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "blogsEntry.groupId = ?";
2354            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
2355                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
2356                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
2357                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId",
2358                            new String[] {
2359                                    Long.class.getName(),
2360                                    
2361                            Integer.class.getName(), Integer.class.getName(),
2362                                    OrderByComparator.class.getName()
2363                            });
2364            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
2365                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
2366                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
2367                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
2368                            new String[] { Long.class.getName() },
2369                            BlogsEntryModelImpl.COMPANYID_COLUMN_BITMASK |
2370                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
2371                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
2372            public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
2373                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
2374                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
2375                            new String[] { Long.class.getName() });
2376    
2377            /**
2378             * Returns all the blogs entries where companyId = &#63;.
2379             *
2380             * @param companyId the company ID
2381             * @return the matching blogs entries
2382             */
2383            @Override
2384            public List<BlogsEntry> findByCompanyId(long companyId) {
2385                    return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2386                            null);
2387            }
2388    
2389            /**
2390             * Returns a range of all the blogs entries where companyId = &#63;.
2391             *
2392             * <p>
2393             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2394             * </p>
2395             *
2396             * @param companyId the company ID
2397             * @param start the lower bound of the range of blogs entries
2398             * @param end the upper bound of the range of blogs entries (not inclusive)
2399             * @return the range of matching blogs entries
2400             */
2401            @Override
2402            public List<BlogsEntry> findByCompanyId(long companyId, int start, int end) {
2403                    return findByCompanyId(companyId, start, end, null);
2404            }
2405    
2406            /**
2407             * Returns an ordered range of all the blogs entries where companyId = &#63;.
2408             *
2409             * <p>
2410             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2411             * </p>
2412             *
2413             * @param companyId the company ID
2414             * @param start the lower bound of the range of blogs entries
2415             * @param end the upper bound of the range of blogs entries (not inclusive)
2416             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2417             * @return the ordered range of matching blogs entries
2418             */
2419            @Override
2420            public List<BlogsEntry> findByCompanyId(long companyId, int start, int end,
2421                    OrderByComparator<BlogsEntry> orderByComparator) {
2422                    return findByCompanyId(companyId, start, end, orderByComparator, true);
2423            }
2424    
2425            /**
2426             * Returns an ordered range of all the blogs entries where companyId = &#63;.
2427             *
2428             * <p>
2429             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2430             * </p>
2431             *
2432             * @param companyId the company ID
2433             * @param start the lower bound of the range of blogs entries
2434             * @param end the upper bound of the range of blogs entries (not inclusive)
2435             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2436             * @param retrieveFromCache whether to retrieve from the finder cache
2437             * @return the ordered range of matching blogs entries
2438             */
2439            @Override
2440            public List<BlogsEntry> findByCompanyId(long companyId, int start, int end,
2441                    OrderByComparator<BlogsEntry> orderByComparator,
2442                    boolean retrieveFromCache) {
2443                    boolean pagination = true;
2444                    FinderPath finderPath = null;
2445                    Object[] finderArgs = null;
2446    
2447                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2448                                    (orderByComparator == null)) {
2449                            pagination = false;
2450                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
2451                            finderArgs = new Object[] { companyId };
2452                    }
2453                    else {
2454                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
2455                            finderArgs = new Object[] { companyId, start, end, orderByComparator };
2456                    }
2457    
2458                    List<BlogsEntry> list = null;
2459    
2460                    if (retrieveFromCache) {
2461                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
2462                                            finderArgs, this);
2463    
2464                            if ((list != null) && !list.isEmpty()) {
2465                                    for (BlogsEntry blogsEntry : list) {
2466                                            if ((companyId != blogsEntry.getCompanyId())) {
2467                                                    list = null;
2468    
2469                                                    break;
2470                                            }
2471                                    }
2472                            }
2473                    }
2474    
2475                    if (list == null) {
2476                            StringBundler query = null;
2477    
2478                            if (orderByComparator != null) {
2479                                    query = new StringBundler(3 +
2480                                                    (orderByComparator.getOrderByFields().length * 2));
2481                            }
2482                            else {
2483                                    query = new StringBundler(3);
2484                            }
2485    
2486                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
2487    
2488                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2489    
2490                            if (orderByComparator != null) {
2491                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2492                                            orderByComparator);
2493                            }
2494                            else
2495                             if (pagination) {
2496                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
2497                            }
2498    
2499                            String sql = query.toString();
2500    
2501                            Session session = null;
2502    
2503                            try {
2504                                    session = openSession();
2505    
2506                                    Query q = session.createQuery(sql);
2507    
2508                                    QueryPos qPos = QueryPos.getInstance(q);
2509    
2510                                    qPos.add(companyId);
2511    
2512                                    if (!pagination) {
2513                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
2514                                                            start, end, false);
2515    
2516                                            Collections.sort(list);
2517    
2518                                            list = Collections.unmodifiableList(list);
2519                                    }
2520                                    else {
2521                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
2522                                                            start, end);
2523                                    }
2524    
2525                                    cacheResult(list);
2526    
2527                                    finderCache.putResult(finderPath, finderArgs, list);
2528                            }
2529                            catch (Exception e) {
2530                                    finderCache.removeResult(finderPath, finderArgs);
2531    
2532                                    throw processException(e);
2533                            }
2534                            finally {
2535                                    closeSession(session);
2536                            }
2537                    }
2538    
2539                    return list;
2540            }
2541    
2542            /**
2543             * Returns the first blogs entry in the ordered set where companyId = &#63;.
2544             *
2545             * @param companyId the company ID
2546             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2547             * @return the first matching blogs entry
2548             * @throws NoSuchEntryException if a matching blogs entry could not be found
2549             */
2550            @Override
2551            public BlogsEntry findByCompanyId_First(long companyId,
2552                    OrderByComparator<BlogsEntry> orderByComparator)
2553                    throws NoSuchEntryException {
2554                    BlogsEntry blogsEntry = fetchByCompanyId_First(companyId,
2555                                    orderByComparator);
2556    
2557                    if (blogsEntry != null) {
2558                            return blogsEntry;
2559                    }
2560    
2561                    StringBundler msg = new StringBundler(4);
2562    
2563                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2564    
2565                    msg.append("companyId=");
2566                    msg.append(companyId);
2567    
2568                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2569    
2570                    throw new NoSuchEntryException(msg.toString());
2571            }
2572    
2573            /**
2574             * Returns the first blogs entry in the ordered set where companyId = &#63;.
2575             *
2576             * @param companyId the company ID
2577             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2578             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
2579             */
2580            @Override
2581            public BlogsEntry fetchByCompanyId_First(long companyId,
2582                    OrderByComparator<BlogsEntry> orderByComparator) {
2583                    List<BlogsEntry> list = findByCompanyId(companyId, 0, 1,
2584                                    orderByComparator);
2585    
2586                    if (!list.isEmpty()) {
2587                            return list.get(0);
2588                    }
2589    
2590                    return null;
2591            }
2592    
2593            /**
2594             * Returns the last blogs entry in the ordered set where companyId = &#63;.
2595             *
2596             * @param companyId the company ID
2597             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2598             * @return the last matching blogs entry
2599             * @throws NoSuchEntryException if a matching blogs entry could not be found
2600             */
2601            @Override
2602            public BlogsEntry findByCompanyId_Last(long companyId,
2603                    OrderByComparator<BlogsEntry> orderByComparator)
2604                    throws NoSuchEntryException {
2605                    BlogsEntry blogsEntry = fetchByCompanyId_Last(companyId,
2606                                    orderByComparator);
2607    
2608                    if (blogsEntry != null) {
2609                            return blogsEntry;
2610                    }
2611    
2612                    StringBundler msg = new StringBundler(4);
2613    
2614                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2615    
2616                    msg.append("companyId=");
2617                    msg.append(companyId);
2618    
2619                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2620    
2621                    throw new NoSuchEntryException(msg.toString());
2622            }
2623    
2624            /**
2625             * Returns the last blogs entry in the ordered set where companyId = &#63;.
2626             *
2627             * @param companyId the company ID
2628             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2629             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
2630             */
2631            @Override
2632            public BlogsEntry fetchByCompanyId_Last(long companyId,
2633                    OrderByComparator<BlogsEntry> orderByComparator) {
2634                    int count = countByCompanyId(companyId);
2635    
2636                    if (count == 0) {
2637                            return null;
2638                    }
2639    
2640                    List<BlogsEntry> list = findByCompanyId(companyId, count - 1, count,
2641                                    orderByComparator);
2642    
2643                    if (!list.isEmpty()) {
2644                            return list.get(0);
2645                    }
2646    
2647                    return null;
2648            }
2649    
2650            /**
2651             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63;.
2652             *
2653             * @param entryId the primary key of the current blogs entry
2654             * @param companyId the company ID
2655             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2656             * @return the previous, current, and next blogs entry
2657             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
2658             */
2659            @Override
2660            public BlogsEntry[] findByCompanyId_PrevAndNext(long entryId,
2661                    long companyId, OrderByComparator<BlogsEntry> orderByComparator)
2662                    throws NoSuchEntryException {
2663                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
2664    
2665                    Session session = null;
2666    
2667                    try {
2668                            session = openSession();
2669    
2670                            BlogsEntry[] array = new BlogsEntryImpl[3];
2671    
2672                            array[0] = getByCompanyId_PrevAndNext(session, blogsEntry,
2673                                            companyId, orderByComparator, true);
2674    
2675                            array[1] = blogsEntry;
2676    
2677                            array[2] = getByCompanyId_PrevAndNext(session, blogsEntry,
2678                                            companyId, orderByComparator, false);
2679    
2680                            return array;
2681                    }
2682                    catch (Exception e) {
2683                            throw processException(e);
2684                    }
2685                    finally {
2686                            closeSession(session);
2687                    }
2688            }
2689    
2690            protected BlogsEntry getByCompanyId_PrevAndNext(Session session,
2691                    BlogsEntry blogsEntry, long companyId,
2692                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
2693                    StringBundler query = null;
2694    
2695                    if (orderByComparator != null) {
2696                            query = new StringBundler(4 +
2697                                            (orderByComparator.getOrderByConditionFields().length * 3) +
2698                                            (orderByComparator.getOrderByFields().length * 3));
2699                    }
2700                    else {
2701                            query = new StringBundler(3);
2702                    }
2703    
2704                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
2705    
2706                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2707    
2708                    if (orderByComparator != null) {
2709                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2710    
2711                            if (orderByConditionFields.length > 0) {
2712                                    query.append(WHERE_AND);
2713                            }
2714    
2715                            for (int i = 0; i < orderByConditionFields.length; i++) {
2716                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2717                                    query.append(orderByConditionFields[i]);
2718    
2719                                    if ((i + 1) < orderByConditionFields.length) {
2720                                            if (orderByComparator.isAscending() ^ previous) {
2721                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2722                                            }
2723                                            else {
2724                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2725                                            }
2726                                    }
2727                                    else {
2728                                            if (orderByComparator.isAscending() ^ previous) {
2729                                                    query.append(WHERE_GREATER_THAN);
2730                                            }
2731                                            else {
2732                                                    query.append(WHERE_LESSER_THAN);
2733                                            }
2734                                    }
2735                            }
2736    
2737                            query.append(ORDER_BY_CLAUSE);
2738    
2739                            String[] orderByFields = orderByComparator.getOrderByFields();
2740    
2741                            for (int i = 0; i < orderByFields.length; i++) {
2742                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2743                                    query.append(orderByFields[i]);
2744    
2745                                    if ((i + 1) < orderByFields.length) {
2746                                            if (orderByComparator.isAscending() ^ previous) {
2747                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2748                                            }
2749                                            else {
2750                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2751                                            }
2752                                    }
2753                                    else {
2754                                            if (orderByComparator.isAscending() ^ previous) {
2755                                                    query.append(ORDER_BY_ASC);
2756                                            }
2757                                            else {
2758                                                    query.append(ORDER_BY_DESC);
2759                                            }
2760                                    }
2761                            }
2762                    }
2763                    else {
2764                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
2765                    }
2766    
2767                    String sql = query.toString();
2768    
2769                    Query q = session.createQuery(sql);
2770    
2771                    q.setFirstResult(0);
2772                    q.setMaxResults(2);
2773    
2774                    QueryPos qPos = QueryPos.getInstance(q);
2775    
2776                    qPos.add(companyId);
2777    
2778                    if (orderByComparator != null) {
2779                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
2780    
2781                            for (Object value : values) {
2782                                    qPos.add(value);
2783                            }
2784                    }
2785    
2786                    List<BlogsEntry> list = q.list();
2787    
2788                    if (list.size() == 2) {
2789                            return list.get(1);
2790                    }
2791                    else {
2792                            return null;
2793                    }
2794            }
2795    
2796            /**
2797             * Removes all the blogs entries where companyId = &#63; from the database.
2798             *
2799             * @param companyId the company ID
2800             */
2801            @Override
2802            public void removeByCompanyId(long companyId) {
2803                    for (BlogsEntry blogsEntry : findByCompanyId(companyId,
2804                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2805                            remove(blogsEntry);
2806                    }
2807            }
2808    
2809            /**
2810             * Returns the number of blogs entries where companyId = &#63;.
2811             *
2812             * @param companyId the company ID
2813             * @return the number of matching blogs entries
2814             */
2815            @Override
2816            public int countByCompanyId(long companyId) {
2817                    FinderPath finderPath = FINDER_PATH_COUNT_BY_COMPANYID;
2818    
2819                    Object[] finderArgs = new Object[] { companyId };
2820    
2821                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
2822    
2823                    if (count == null) {
2824                            StringBundler query = new StringBundler(2);
2825    
2826                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
2827    
2828                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2829    
2830                            String sql = query.toString();
2831    
2832                            Session session = null;
2833    
2834                            try {
2835                                    session = openSession();
2836    
2837                                    Query q = session.createQuery(sql);
2838    
2839                                    QueryPos qPos = QueryPos.getInstance(q);
2840    
2841                                    qPos.add(companyId);
2842    
2843                                    count = (Long)q.uniqueResult();
2844    
2845                                    finderCache.putResult(finderPath, finderArgs, count);
2846                            }
2847                            catch (Exception e) {
2848                                    finderCache.removeResult(finderPath, finderArgs);
2849    
2850                                    throw processException(e);
2851                            }
2852                            finally {
2853                                    closeSession(session);
2854                            }
2855                    }
2856    
2857                    return count.intValue();
2858            }
2859    
2860            private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "blogsEntry.companyId = ?";
2861            public static final FinderPath FINDER_PATH_FETCH_BY_G_UT = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
2862                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
2863                            FINDER_CLASS_NAME_ENTITY, "fetchByG_UT",
2864                            new String[] { Long.class.getName(), String.class.getName() },
2865                            BlogsEntryModelImpl.GROUPID_COLUMN_BITMASK |
2866                            BlogsEntryModelImpl.URLTITLE_COLUMN_BITMASK);
2867            public static final FinderPath FINDER_PATH_COUNT_BY_G_UT = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
2868                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
2869                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_UT",
2870                            new String[] { Long.class.getName(), String.class.getName() });
2871    
2872            /**
2873             * Returns the blogs entry where groupId = &#63; and urlTitle = &#63; or throws a {@link NoSuchEntryException} if it could not be found.
2874             *
2875             * @param groupId the group ID
2876             * @param urlTitle the url title
2877             * @return the matching blogs entry
2878             * @throws NoSuchEntryException if a matching blogs entry could not be found
2879             */
2880            @Override
2881            public BlogsEntry findByG_UT(long groupId, String urlTitle)
2882                    throws NoSuchEntryException {
2883                    BlogsEntry blogsEntry = fetchByG_UT(groupId, urlTitle);
2884    
2885                    if (blogsEntry == null) {
2886                            StringBundler msg = new StringBundler(6);
2887    
2888                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2889    
2890                            msg.append("groupId=");
2891                            msg.append(groupId);
2892    
2893                            msg.append(", urlTitle=");
2894                            msg.append(urlTitle);
2895    
2896                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2897    
2898                            if (_log.isWarnEnabled()) {
2899                                    _log.warn(msg.toString());
2900                            }
2901    
2902                            throw new NoSuchEntryException(msg.toString());
2903                    }
2904    
2905                    return blogsEntry;
2906            }
2907    
2908            /**
2909             * Returns the blogs entry where groupId = &#63; and urlTitle = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
2910             *
2911             * @param groupId the group ID
2912             * @param urlTitle the url title
2913             * @return the matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
2914             */
2915            @Override
2916            public BlogsEntry fetchByG_UT(long groupId, String urlTitle) {
2917                    return fetchByG_UT(groupId, urlTitle, true);
2918            }
2919    
2920            /**
2921             * 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.
2922             *
2923             * @param groupId the group ID
2924             * @param urlTitle the url title
2925             * @param retrieveFromCache whether to retrieve from the finder cache
2926             * @return the matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
2927             */
2928            @Override
2929            public BlogsEntry fetchByG_UT(long groupId, String urlTitle,
2930                    boolean retrieveFromCache) {
2931                    Object[] finderArgs = new Object[] { groupId, urlTitle };
2932    
2933                    Object result = null;
2934    
2935                    if (retrieveFromCache) {
2936                            result = finderCache.getResult(FINDER_PATH_FETCH_BY_G_UT,
2937                                            finderArgs, this);
2938                    }
2939    
2940                    if (result instanceof BlogsEntry) {
2941                            BlogsEntry blogsEntry = (BlogsEntry)result;
2942    
2943                            if ((groupId != blogsEntry.getGroupId()) ||
2944                                            !Validator.equals(urlTitle, blogsEntry.getUrlTitle())) {
2945                                    result = null;
2946                            }
2947                    }
2948    
2949                    if (result == null) {
2950                            StringBundler query = new StringBundler(4);
2951    
2952                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
2953    
2954                            query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
2955    
2956                            boolean bindUrlTitle = false;
2957    
2958                            if (urlTitle == null) {
2959                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
2960                            }
2961                            else if (urlTitle.equals(StringPool.BLANK)) {
2962                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
2963                            }
2964                            else {
2965                                    bindUrlTitle = true;
2966    
2967                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
2968                            }
2969    
2970                            String sql = query.toString();
2971    
2972                            Session session = null;
2973    
2974                            try {
2975                                    session = openSession();
2976    
2977                                    Query q = session.createQuery(sql);
2978    
2979                                    QueryPos qPos = QueryPos.getInstance(q);
2980    
2981                                    qPos.add(groupId);
2982    
2983                                    if (bindUrlTitle) {
2984                                            qPos.add(urlTitle);
2985                                    }
2986    
2987                                    List<BlogsEntry> list = q.list();
2988    
2989                                    if (list.isEmpty()) {
2990                                            finderCache.putResult(FINDER_PATH_FETCH_BY_G_UT,
2991                                                    finderArgs, list);
2992                                    }
2993                                    else {
2994                                            BlogsEntry blogsEntry = list.get(0);
2995    
2996                                            result = blogsEntry;
2997    
2998                                            cacheResult(blogsEntry);
2999    
3000                                            if ((blogsEntry.getGroupId() != groupId) ||
3001                                                            (blogsEntry.getUrlTitle() == null) ||
3002                                                            !blogsEntry.getUrlTitle().equals(urlTitle)) {
3003                                                    finderCache.putResult(FINDER_PATH_FETCH_BY_G_UT,
3004                                                            finderArgs, blogsEntry);
3005                                            }
3006                                    }
3007                            }
3008                            catch (Exception e) {
3009                                    finderCache.removeResult(FINDER_PATH_FETCH_BY_G_UT, finderArgs);
3010    
3011                                    throw processException(e);
3012                            }
3013                            finally {
3014                                    closeSession(session);
3015                            }
3016                    }
3017    
3018                    if (result instanceof List<?>) {
3019                            return null;
3020                    }
3021                    else {
3022                            return (BlogsEntry)result;
3023                    }
3024            }
3025    
3026            /**
3027             * Removes the blogs entry where groupId = &#63; and urlTitle = &#63; from the database.
3028             *
3029             * @param groupId the group ID
3030             * @param urlTitle the url title
3031             * @return the blogs entry that was removed
3032             */
3033            @Override
3034            public BlogsEntry removeByG_UT(long groupId, String urlTitle)
3035                    throws NoSuchEntryException {
3036                    BlogsEntry blogsEntry = findByG_UT(groupId, urlTitle);
3037    
3038                    return remove(blogsEntry);
3039            }
3040    
3041            /**
3042             * Returns the number of blogs entries where groupId = &#63; and urlTitle = &#63;.
3043             *
3044             * @param groupId the group ID
3045             * @param urlTitle the url title
3046             * @return the number of matching blogs entries
3047             */
3048            @Override
3049            public int countByG_UT(long groupId, String urlTitle) {
3050                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_UT;
3051    
3052                    Object[] finderArgs = new Object[] { groupId, urlTitle };
3053    
3054                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
3055    
3056                    if (count == null) {
3057                            StringBundler query = new StringBundler(3);
3058    
3059                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
3060    
3061                            query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
3062    
3063                            boolean bindUrlTitle = false;
3064    
3065                            if (urlTitle == null) {
3066                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
3067                            }
3068                            else if (urlTitle.equals(StringPool.BLANK)) {
3069                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
3070                            }
3071                            else {
3072                                    bindUrlTitle = true;
3073    
3074                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
3075                            }
3076    
3077                            String sql = query.toString();
3078    
3079                            Session session = null;
3080    
3081                            try {
3082                                    session = openSession();
3083    
3084                                    Query q = session.createQuery(sql);
3085    
3086                                    QueryPos qPos = QueryPos.getInstance(q);
3087    
3088                                    qPos.add(groupId);
3089    
3090                                    if (bindUrlTitle) {
3091                                            qPos.add(urlTitle);
3092                                    }
3093    
3094                                    count = (Long)q.uniqueResult();
3095    
3096                                    finderCache.putResult(finderPath, finderArgs, count);
3097                            }
3098                            catch (Exception e) {
3099                                    finderCache.removeResult(finderPath, finderArgs);
3100    
3101                                    throw processException(e);
3102                            }
3103                            finally {
3104                                    closeSession(session);
3105                            }
3106                    }
3107    
3108                    return count.intValue();
3109            }
3110    
3111            private static final String _FINDER_COLUMN_G_UT_GROUPID_2 = "blogsEntry.groupId = ? AND ";
3112            private static final String _FINDER_COLUMN_G_UT_URLTITLE_1 = "blogsEntry.urlTitle IS NULL";
3113            private static final String _FINDER_COLUMN_G_UT_URLTITLE_2 = "blogsEntry.urlTitle = ?";
3114            private static final String _FINDER_COLUMN_G_UT_URLTITLE_3 = "(blogsEntry.urlTitle IS NULL OR blogsEntry.urlTitle = '')";
3115            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
3116                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
3117                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_LtD",
3118                            new String[] {
3119                                    Long.class.getName(), Date.class.getName(),
3120                                    
3121                            Integer.class.getName(), Integer.class.getName(),
3122                                    OrderByComparator.class.getName()
3123                            });
3124            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
3125                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
3126                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_LtD",
3127                            new String[] { Long.class.getName(), Date.class.getName() });
3128    
3129            /**
3130             * Returns all the blogs entries where groupId = &#63; and displayDate &lt; &#63;.
3131             *
3132             * @param groupId the group ID
3133             * @param displayDate the display date
3134             * @return the matching blogs entries
3135             */
3136            @Override
3137            public List<BlogsEntry> findByG_LtD(long groupId, Date displayDate) {
3138                    return findByG_LtD(groupId, displayDate, QueryUtil.ALL_POS,
3139                            QueryUtil.ALL_POS, null);
3140            }
3141    
3142            /**
3143             * Returns a range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63;.
3144             *
3145             * <p>
3146             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3147             * </p>
3148             *
3149             * @param groupId the group ID
3150             * @param displayDate the display date
3151             * @param start the lower bound of the range of blogs entries
3152             * @param end the upper bound of the range of blogs entries (not inclusive)
3153             * @return the range of matching blogs entries
3154             */
3155            @Override
3156            public List<BlogsEntry> findByG_LtD(long groupId, Date displayDate,
3157                    int start, int end) {
3158                    return findByG_LtD(groupId, displayDate, start, end, null);
3159            }
3160    
3161            /**
3162             * Returns an ordered range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63;.
3163             *
3164             * <p>
3165             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3166             * </p>
3167             *
3168             * @param groupId the group ID
3169             * @param displayDate the display date
3170             * @param start the lower bound of the range of blogs entries
3171             * @param end the upper bound of the range of blogs entries (not inclusive)
3172             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3173             * @return the ordered range of matching blogs entries
3174             */
3175            @Override
3176            public List<BlogsEntry> findByG_LtD(long groupId, Date displayDate,
3177                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator) {
3178                    return findByG_LtD(groupId, displayDate, start, end, orderByComparator,
3179                            true);
3180            }
3181    
3182            /**
3183             * Returns an ordered range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63;.
3184             *
3185             * <p>
3186             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3187             * </p>
3188             *
3189             * @param groupId the group ID
3190             * @param displayDate the display date
3191             * @param start the lower bound of the range of blogs entries
3192             * @param end the upper bound of the range of blogs entries (not inclusive)
3193             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3194             * @param retrieveFromCache whether to retrieve from the finder cache
3195             * @return the ordered range of matching blogs entries
3196             */
3197            @Override
3198            public List<BlogsEntry> findByG_LtD(long groupId, Date displayDate,
3199                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator,
3200                    boolean retrieveFromCache) {
3201                    boolean pagination = true;
3202                    FinderPath finderPath = null;
3203                    Object[] finderArgs = null;
3204    
3205                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD;
3206                    finderArgs = new Object[] {
3207                                    groupId, displayDate,
3208                                    
3209                                    start, end, orderByComparator
3210                            };
3211    
3212                    List<BlogsEntry> list = null;
3213    
3214                    if (retrieveFromCache) {
3215                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
3216                                            finderArgs, this);
3217    
3218                            if ((list != null) && !list.isEmpty()) {
3219                                    for (BlogsEntry blogsEntry : list) {
3220                                            if ((groupId != blogsEntry.getGroupId()) ||
3221                                                            (displayDate.getTime() <= blogsEntry.getDisplayDate()
3222                                                                                                                                            .getTime())) {
3223                                                    list = null;
3224    
3225                                                    break;
3226                                            }
3227                                    }
3228                            }
3229                    }
3230    
3231                    if (list == null) {
3232                            StringBundler query = null;
3233    
3234                            if (orderByComparator != null) {
3235                                    query = new StringBundler(4 +
3236                                                    (orderByComparator.getOrderByFields().length * 2));
3237                            }
3238                            else {
3239                                    query = new StringBundler(4);
3240                            }
3241    
3242                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
3243    
3244                            query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
3245    
3246                            boolean bindDisplayDate = false;
3247    
3248                            if (displayDate == null) {
3249                                    query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
3250                            }
3251                            else {
3252                                    bindDisplayDate = true;
3253    
3254                                    query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
3255                            }
3256    
3257                            if (orderByComparator != null) {
3258                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3259                                            orderByComparator);
3260                            }
3261                            else
3262                             if (pagination) {
3263                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
3264                            }
3265    
3266                            String sql = query.toString();
3267    
3268                            Session session = null;
3269    
3270                            try {
3271                                    session = openSession();
3272    
3273                                    Query q = session.createQuery(sql);
3274    
3275                                    QueryPos qPos = QueryPos.getInstance(q);
3276    
3277                                    qPos.add(groupId);
3278    
3279                                    if (bindDisplayDate) {
3280                                            qPos.add(new Timestamp(displayDate.getTime()));
3281                                    }
3282    
3283                                    if (!pagination) {
3284                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
3285                                                            start, end, false);
3286    
3287                                            Collections.sort(list);
3288    
3289                                            list = Collections.unmodifiableList(list);
3290                                    }
3291                                    else {
3292                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
3293                                                            start, end);
3294                                    }
3295    
3296                                    cacheResult(list);
3297    
3298                                    finderCache.putResult(finderPath, finderArgs, list);
3299                            }
3300                            catch (Exception e) {
3301                                    finderCache.removeResult(finderPath, finderArgs);
3302    
3303                                    throw processException(e);
3304                            }
3305                            finally {
3306                                    closeSession(session);
3307                            }
3308                    }
3309    
3310                    return list;
3311            }
3312    
3313            /**
3314             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63;.
3315             *
3316             * @param groupId the group ID
3317             * @param displayDate the display date
3318             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3319             * @return the first matching blogs entry
3320             * @throws NoSuchEntryException if a matching blogs entry could not be found
3321             */
3322            @Override
3323            public BlogsEntry findByG_LtD_First(long groupId, Date displayDate,
3324                    OrderByComparator<BlogsEntry> orderByComparator)
3325                    throws NoSuchEntryException {
3326                    BlogsEntry blogsEntry = fetchByG_LtD_First(groupId, displayDate,
3327                                    orderByComparator);
3328    
3329                    if (blogsEntry != null) {
3330                            return blogsEntry;
3331                    }
3332    
3333                    StringBundler msg = new StringBundler(6);
3334    
3335                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3336    
3337                    msg.append("groupId=");
3338                    msg.append(groupId);
3339    
3340                    msg.append(", displayDate=");
3341                    msg.append(displayDate);
3342    
3343                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3344    
3345                    throw new NoSuchEntryException(msg.toString());
3346            }
3347    
3348            /**
3349             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63;.
3350             *
3351             * @param groupId the group ID
3352             * @param displayDate the display date
3353             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3354             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
3355             */
3356            @Override
3357            public BlogsEntry fetchByG_LtD_First(long groupId, Date displayDate,
3358                    OrderByComparator<BlogsEntry> orderByComparator) {
3359                    List<BlogsEntry> list = findByG_LtD(groupId, displayDate, 0, 1,
3360                                    orderByComparator);
3361    
3362                    if (!list.isEmpty()) {
3363                            return list.get(0);
3364                    }
3365    
3366                    return null;
3367            }
3368    
3369            /**
3370             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63;.
3371             *
3372             * @param groupId the group ID
3373             * @param displayDate the display date
3374             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3375             * @return the last matching blogs entry
3376             * @throws NoSuchEntryException if a matching blogs entry could not be found
3377             */
3378            @Override
3379            public BlogsEntry findByG_LtD_Last(long groupId, Date displayDate,
3380                    OrderByComparator<BlogsEntry> orderByComparator)
3381                    throws NoSuchEntryException {
3382                    BlogsEntry blogsEntry = fetchByG_LtD_Last(groupId, displayDate,
3383                                    orderByComparator);
3384    
3385                    if (blogsEntry != null) {
3386                            return blogsEntry;
3387                    }
3388    
3389                    StringBundler msg = new StringBundler(6);
3390    
3391                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3392    
3393                    msg.append("groupId=");
3394                    msg.append(groupId);
3395    
3396                    msg.append(", displayDate=");
3397                    msg.append(displayDate);
3398    
3399                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3400    
3401                    throw new NoSuchEntryException(msg.toString());
3402            }
3403    
3404            /**
3405             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63;.
3406             *
3407             * @param groupId the group ID
3408             * @param displayDate the display date
3409             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3410             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
3411             */
3412            @Override
3413            public BlogsEntry fetchByG_LtD_Last(long groupId, Date displayDate,
3414                    OrderByComparator<BlogsEntry> orderByComparator) {
3415                    int count = countByG_LtD(groupId, displayDate);
3416    
3417                    if (count == 0) {
3418                            return null;
3419                    }
3420    
3421                    List<BlogsEntry> list = findByG_LtD(groupId, displayDate, count - 1,
3422                                    count, orderByComparator);
3423    
3424                    if (!list.isEmpty()) {
3425                            return list.get(0);
3426                    }
3427    
3428                    return null;
3429            }
3430    
3431            /**
3432             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63;.
3433             *
3434             * @param entryId the primary key of the current blogs entry
3435             * @param groupId the group ID
3436             * @param displayDate the display date
3437             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3438             * @return the previous, current, and next blogs entry
3439             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
3440             */
3441            @Override
3442            public BlogsEntry[] findByG_LtD_PrevAndNext(long entryId, long groupId,
3443                    Date displayDate, OrderByComparator<BlogsEntry> orderByComparator)
3444                    throws NoSuchEntryException {
3445                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
3446    
3447                    Session session = null;
3448    
3449                    try {
3450                            session = openSession();
3451    
3452                            BlogsEntry[] array = new BlogsEntryImpl[3];
3453    
3454                            array[0] = getByG_LtD_PrevAndNext(session, blogsEntry, groupId,
3455                                            displayDate, orderByComparator, true);
3456    
3457                            array[1] = blogsEntry;
3458    
3459                            array[2] = getByG_LtD_PrevAndNext(session, blogsEntry, groupId,
3460                                            displayDate, orderByComparator, false);
3461    
3462                            return array;
3463                    }
3464                    catch (Exception e) {
3465                            throw processException(e);
3466                    }
3467                    finally {
3468                            closeSession(session);
3469                    }
3470            }
3471    
3472            protected BlogsEntry getByG_LtD_PrevAndNext(Session session,
3473                    BlogsEntry blogsEntry, long groupId, Date displayDate,
3474                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
3475                    StringBundler query = null;
3476    
3477                    if (orderByComparator != null) {
3478                            query = new StringBundler(5 +
3479                                            (orderByComparator.getOrderByConditionFields().length * 3) +
3480                                            (orderByComparator.getOrderByFields().length * 3));
3481                    }
3482                    else {
3483                            query = new StringBundler(4);
3484                    }
3485    
3486                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
3487    
3488                    query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
3489    
3490                    boolean bindDisplayDate = false;
3491    
3492                    if (displayDate == null) {
3493                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
3494                    }
3495                    else {
3496                            bindDisplayDate = true;
3497    
3498                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
3499                    }
3500    
3501                    if (orderByComparator != null) {
3502                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3503    
3504                            if (orderByConditionFields.length > 0) {
3505                                    query.append(WHERE_AND);
3506                            }
3507    
3508                            for (int i = 0; i < orderByConditionFields.length; i++) {
3509                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3510                                    query.append(orderByConditionFields[i]);
3511    
3512                                    if ((i + 1) < orderByConditionFields.length) {
3513                                            if (orderByComparator.isAscending() ^ previous) {
3514                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3515                                            }
3516                                            else {
3517                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3518                                            }
3519                                    }
3520                                    else {
3521                                            if (orderByComparator.isAscending() ^ previous) {
3522                                                    query.append(WHERE_GREATER_THAN);
3523                                            }
3524                                            else {
3525                                                    query.append(WHERE_LESSER_THAN);
3526                                            }
3527                                    }
3528                            }
3529    
3530                            query.append(ORDER_BY_CLAUSE);
3531    
3532                            String[] orderByFields = orderByComparator.getOrderByFields();
3533    
3534                            for (int i = 0; i < orderByFields.length; i++) {
3535                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3536                                    query.append(orderByFields[i]);
3537    
3538                                    if ((i + 1) < orderByFields.length) {
3539                                            if (orderByComparator.isAscending() ^ previous) {
3540                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3541                                            }
3542                                            else {
3543                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3544                                            }
3545                                    }
3546                                    else {
3547                                            if (orderByComparator.isAscending() ^ previous) {
3548                                                    query.append(ORDER_BY_ASC);
3549                                            }
3550                                            else {
3551                                                    query.append(ORDER_BY_DESC);
3552                                            }
3553                                    }
3554                            }
3555                    }
3556                    else {
3557                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
3558                    }
3559    
3560                    String sql = query.toString();
3561    
3562                    Query q = session.createQuery(sql);
3563    
3564                    q.setFirstResult(0);
3565                    q.setMaxResults(2);
3566    
3567                    QueryPos qPos = QueryPos.getInstance(q);
3568    
3569                    qPos.add(groupId);
3570    
3571                    if (bindDisplayDate) {
3572                            qPos.add(new Timestamp(displayDate.getTime()));
3573                    }
3574    
3575                    if (orderByComparator != null) {
3576                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
3577    
3578                            for (Object value : values) {
3579                                    qPos.add(value);
3580                            }
3581                    }
3582    
3583                    List<BlogsEntry> list = q.list();
3584    
3585                    if (list.size() == 2) {
3586                            return list.get(1);
3587                    }
3588                    else {
3589                            return null;
3590                    }
3591            }
3592    
3593            /**
3594             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63;.
3595             *
3596             * @param groupId the group ID
3597             * @param displayDate the display date
3598             * @return the matching blogs entries that the user has permission to view
3599             */
3600            @Override
3601            public List<BlogsEntry> filterFindByG_LtD(long groupId, Date displayDate) {
3602                    return filterFindByG_LtD(groupId, displayDate, QueryUtil.ALL_POS,
3603                            QueryUtil.ALL_POS, null);
3604            }
3605    
3606            /**
3607             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63;.
3608             *
3609             * <p>
3610             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3611             * </p>
3612             *
3613             * @param groupId the group ID
3614             * @param displayDate the display date
3615             * @param start the lower bound of the range of blogs entries
3616             * @param end the upper bound of the range of blogs entries (not inclusive)
3617             * @return the range of matching blogs entries that the user has permission to view
3618             */
3619            @Override
3620            public List<BlogsEntry> filterFindByG_LtD(long groupId, Date displayDate,
3621                    int start, int end) {
3622                    return filterFindByG_LtD(groupId, displayDate, start, end, null);
3623            }
3624    
3625            /**
3626             * Returns an ordered range of all the blogs entries that the user has permissions to view where groupId = &#63; and displayDate &lt; &#63;.
3627             *
3628             * <p>
3629             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3630             * </p>
3631             *
3632             * @param groupId the group ID
3633             * @param displayDate the display date
3634             * @param start the lower bound of the range of blogs entries
3635             * @param end the upper bound of the range of blogs entries (not inclusive)
3636             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3637             * @return the ordered range of matching blogs entries that the user has permission to view
3638             */
3639            @Override
3640            public List<BlogsEntry> filterFindByG_LtD(long groupId, Date displayDate,
3641                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator) {
3642                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3643                            return findByG_LtD(groupId, displayDate, start, end,
3644                                    orderByComparator);
3645                    }
3646    
3647                    StringBundler query = null;
3648    
3649                    if (orderByComparator != null) {
3650                            query = new StringBundler(4 +
3651                                            (orderByComparator.getOrderByFields().length * 2));
3652                    }
3653                    else {
3654                            query = new StringBundler(5);
3655                    }
3656    
3657                    if (getDB().isSupportsInlineDistinct()) {
3658                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
3659                    }
3660                    else {
3661                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
3662                    }
3663    
3664                    query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
3665    
3666                    boolean bindDisplayDate = false;
3667    
3668                    if (displayDate == null) {
3669                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
3670                    }
3671                    else {
3672                            bindDisplayDate = true;
3673    
3674                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
3675                    }
3676    
3677                    if (!getDB().isSupportsInlineDistinct()) {
3678                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
3679                    }
3680    
3681                    if (orderByComparator != null) {
3682                            if (getDB().isSupportsInlineDistinct()) {
3683                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3684                                            orderByComparator, true);
3685                            }
3686                            else {
3687                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
3688                                            orderByComparator, true);
3689                            }
3690                    }
3691                    else {
3692                            if (getDB().isSupportsInlineDistinct()) {
3693                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
3694                            }
3695                            else {
3696                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
3697                            }
3698                    }
3699    
3700                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3701                                    BlogsEntry.class.getName(),
3702                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3703    
3704                    Session session = null;
3705    
3706                    try {
3707                            session = openSession();
3708    
3709                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
3710    
3711                            if (getDB().isSupportsInlineDistinct()) {
3712                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
3713                            }
3714                            else {
3715                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
3716                            }
3717    
3718                            QueryPos qPos = QueryPos.getInstance(q);
3719    
3720                            qPos.add(groupId);
3721    
3722                            if (bindDisplayDate) {
3723                                    qPos.add(new Timestamp(displayDate.getTime()));
3724                            }
3725    
3726                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
3727                    }
3728                    catch (Exception e) {
3729                            throw processException(e);
3730                    }
3731                    finally {
3732                            closeSession(session);
3733                    }
3734            }
3735    
3736            /**
3737             * 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;.
3738             *
3739             * @param entryId the primary key of the current blogs entry
3740             * @param groupId the group ID
3741             * @param displayDate the display date
3742             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3743             * @return the previous, current, and next blogs entry
3744             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
3745             */
3746            @Override
3747            public BlogsEntry[] filterFindByG_LtD_PrevAndNext(long entryId,
3748                    long groupId, Date displayDate,
3749                    OrderByComparator<BlogsEntry> orderByComparator)
3750                    throws NoSuchEntryException {
3751                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3752                            return findByG_LtD_PrevAndNext(entryId, groupId, displayDate,
3753                                    orderByComparator);
3754                    }
3755    
3756                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
3757    
3758                    Session session = null;
3759    
3760                    try {
3761                            session = openSession();
3762    
3763                            BlogsEntry[] array = new BlogsEntryImpl[3];
3764    
3765                            array[0] = filterGetByG_LtD_PrevAndNext(session, blogsEntry,
3766                                            groupId, displayDate, orderByComparator, true);
3767    
3768                            array[1] = blogsEntry;
3769    
3770                            array[2] = filterGetByG_LtD_PrevAndNext(session, blogsEntry,
3771                                            groupId, displayDate, orderByComparator, false);
3772    
3773                            return array;
3774                    }
3775                    catch (Exception e) {
3776                            throw processException(e);
3777                    }
3778                    finally {
3779                            closeSession(session);
3780                    }
3781            }
3782    
3783            protected BlogsEntry filterGetByG_LtD_PrevAndNext(Session session,
3784                    BlogsEntry blogsEntry, long groupId, Date displayDate,
3785                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
3786                    StringBundler query = null;
3787    
3788                    if (orderByComparator != null) {
3789                            query = new StringBundler(6 +
3790                                            (orderByComparator.getOrderByConditionFields().length * 3) +
3791                                            (orderByComparator.getOrderByFields().length * 3));
3792                    }
3793                    else {
3794                            query = new StringBundler(5);
3795                    }
3796    
3797                    if (getDB().isSupportsInlineDistinct()) {
3798                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
3799                    }
3800                    else {
3801                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
3802                    }
3803    
3804                    query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
3805    
3806                    boolean bindDisplayDate = false;
3807    
3808                    if (displayDate == null) {
3809                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
3810                    }
3811                    else {
3812                            bindDisplayDate = true;
3813    
3814                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
3815                    }
3816    
3817                    if (!getDB().isSupportsInlineDistinct()) {
3818                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
3819                    }
3820    
3821                    if (orderByComparator != null) {
3822                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3823    
3824                            if (orderByConditionFields.length > 0) {
3825                                    query.append(WHERE_AND);
3826                            }
3827    
3828                            for (int i = 0; i < orderByConditionFields.length; i++) {
3829                                    if (getDB().isSupportsInlineDistinct()) {
3830                                            query.append(_ORDER_BY_ENTITY_ALIAS);
3831                                    }
3832                                    else {
3833                                            query.append(_ORDER_BY_ENTITY_TABLE);
3834                                    }
3835    
3836                                    query.append(orderByConditionFields[i]);
3837    
3838                                    if ((i + 1) < orderByConditionFields.length) {
3839                                            if (orderByComparator.isAscending() ^ previous) {
3840                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3841                                            }
3842                                            else {
3843                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3844                                            }
3845                                    }
3846                                    else {
3847                                            if (orderByComparator.isAscending() ^ previous) {
3848                                                    query.append(WHERE_GREATER_THAN);
3849                                            }
3850                                            else {
3851                                                    query.append(WHERE_LESSER_THAN);
3852                                            }
3853                                    }
3854                            }
3855    
3856                            query.append(ORDER_BY_CLAUSE);
3857    
3858                            String[] orderByFields = orderByComparator.getOrderByFields();
3859    
3860                            for (int i = 0; i < orderByFields.length; i++) {
3861                                    if (getDB().isSupportsInlineDistinct()) {
3862                                            query.append(_ORDER_BY_ENTITY_ALIAS);
3863                                    }
3864                                    else {
3865                                            query.append(_ORDER_BY_ENTITY_TABLE);
3866                                    }
3867    
3868                                    query.append(orderByFields[i]);
3869    
3870                                    if ((i + 1) < orderByFields.length) {
3871                                            if (orderByComparator.isAscending() ^ previous) {
3872                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3873                                            }
3874                                            else {
3875                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3876                                            }
3877                                    }
3878                                    else {
3879                                            if (orderByComparator.isAscending() ^ previous) {
3880                                                    query.append(ORDER_BY_ASC);
3881                                            }
3882                                            else {
3883                                                    query.append(ORDER_BY_DESC);
3884                                            }
3885                                    }
3886                            }
3887                    }
3888                    else {
3889                            if (getDB().isSupportsInlineDistinct()) {
3890                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
3891                            }
3892                            else {
3893                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
3894                            }
3895                    }
3896    
3897                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3898                                    BlogsEntry.class.getName(),
3899                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3900    
3901                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
3902    
3903                    q.setFirstResult(0);
3904                    q.setMaxResults(2);
3905    
3906                    if (getDB().isSupportsInlineDistinct()) {
3907                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
3908                    }
3909                    else {
3910                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
3911                    }
3912    
3913                    QueryPos qPos = QueryPos.getInstance(q);
3914    
3915                    qPos.add(groupId);
3916    
3917                    if (bindDisplayDate) {
3918                            qPos.add(new Timestamp(displayDate.getTime()));
3919                    }
3920    
3921                    if (orderByComparator != null) {
3922                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
3923    
3924                            for (Object value : values) {
3925                                    qPos.add(value);
3926                            }
3927                    }
3928    
3929                    List<BlogsEntry> list = q.list();
3930    
3931                    if (list.size() == 2) {
3932                            return list.get(1);
3933                    }
3934                    else {
3935                            return null;
3936                    }
3937            }
3938    
3939            /**
3940             * Removes all the blogs entries where groupId = &#63; and displayDate &lt; &#63; from the database.
3941             *
3942             * @param groupId the group ID
3943             * @param displayDate the display date
3944             */
3945            @Override
3946            public void removeByG_LtD(long groupId, Date displayDate) {
3947                    for (BlogsEntry blogsEntry : findByG_LtD(groupId, displayDate,
3948                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3949                            remove(blogsEntry);
3950                    }
3951            }
3952    
3953            /**
3954             * Returns the number of blogs entries where groupId = &#63; and displayDate &lt; &#63;.
3955             *
3956             * @param groupId the group ID
3957             * @param displayDate the display date
3958             * @return the number of matching blogs entries
3959             */
3960            @Override
3961            public int countByG_LtD(long groupId, Date displayDate) {
3962                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD;
3963    
3964                    Object[] finderArgs = new Object[] { groupId, displayDate };
3965    
3966                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
3967    
3968                    if (count == null) {
3969                            StringBundler query = new StringBundler(3);
3970    
3971                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
3972    
3973                            query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
3974    
3975                            boolean bindDisplayDate = false;
3976    
3977                            if (displayDate == null) {
3978                                    query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
3979                            }
3980                            else {
3981                                    bindDisplayDate = true;
3982    
3983                                    query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
3984                            }
3985    
3986                            String sql = query.toString();
3987    
3988                            Session session = null;
3989    
3990                            try {
3991                                    session = openSession();
3992    
3993                                    Query q = session.createQuery(sql);
3994    
3995                                    QueryPos qPos = QueryPos.getInstance(q);
3996    
3997                                    qPos.add(groupId);
3998    
3999                                    if (bindDisplayDate) {
4000                                            qPos.add(new Timestamp(displayDate.getTime()));
4001                                    }
4002    
4003                                    count = (Long)q.uniqueResult();
4004    
4005                                    finderCache.putResult(finderPath, finderArgs, count);
4006                            }
4007                            catch (Exception e) {
4008                                    finderCache.removeResult(finderPath, finderArgs);
4009    
4010                                    throw processException(e);
4011                            }
4012                            finally {
4013                                    closeSession(session);
4014                            }
4015                    }
4016    
4017                    return count.intValue();
4018            }
4019    
4020            /**
4021             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63;.
4022             *
4023             * @param groupId the group ID
4024             * @param displayDate the display date
4025             * @return the number of matching blogs entries that the user has permission to view
4026             */
4027            @Override
4028            public int filterCountByG_LtD(long groupId, Date displayDate) {
4029                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4030                            return countByG_LtD(groupId, displayDate);
4031                    }
4032    
4033                    StringBundler query = new StringBundler(3);
4034    
4035                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
4036    
4037                    query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
4038    
4039                    boolean bindDisplayDate = false;
4040    
4041                    if (displayDate == null) {
4042                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
4043                    }
4044                    else {
4045                            bindDisplayDate = true;
4046    
4047                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
4048                    }
4049    
4050                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4051                                    BlogsEntry.class.getName(),
4052                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4053    
4054                    Session session = null;
4055    
4056                    try {
4057                            session = openSession();
4058    
4059                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
4060    
4061                            q.addScalar(COUNT_COLUMN_NAME,
4062                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
4063    
4064                            QueryPos qPos = QueryPos.getInstance(q);
4065    
4066                            qPos.add(groupId);
4067    
4068                            if (bindDisplayDate) {
4069                                    qPos.add(new Timestamp(displayDate.getTime()));
4070                            }
4071    
4072                            Long count = (Long)q.uniqueResult();
4073    
4074                            return count.intValue();
4075                    }
4076                    catch (Exception e) {
4077                            throw processException(e);
4078                    }
4079                    finally {
4080                            closeSession(session);
4081                    }
4082            }
4083    
4084            private static final String _FINDER_COLUMN_G_LTD_GROUPID_2 = "blogsEntry.groupId = ? AND ";
4085            private static final String _FINDER_COLUMN_G_LTD_DISPLAYDATE_1 = "blogsEntry.displayDate IS NULL";
4086            private static final String _FINDER_COLUMN_G_LTD_DISPLAYDATE_2 = "blogsEntry.displayDate < ?";
4087            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
4088                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
4089                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_S",
4090                            new String[] {
4091                                    Long.class.getName(), Integer.class.getName(),
4092                                    
4093                            Integer.class.getName(), Integer.class.getName(),
4094                                    OrderByComparator.class.getName()
4095                            });
4096            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
4097                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
4098                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_S",
4099                            new String[] { Long.class.getName(), Integer.class.getName() },
4100                            BlogsEntryModelImpl.GROUPID_COLUMN_BITMASK |
4101                            BlogsEntryModelImpl.STATUS_COLUMN_BITMASK |
4102                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
4103                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
4104            public static final FinderPath FINDER_PATH_COUNT_BY_G_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
4105                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
4106                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_S",
4107                            new String[] { Long.class.getName(), Integer.class.getName() });
4108    
4109            /**
4110             * Returns all the blogs entries where groupId = &#63; and status = &#63;.
4111             *
4112             * @param groupId the group ID
4113             * @param status the status
4114             * @return the matching blogs entries
4115             */
4116            @Override
4117            public List<BlogsEntry> findByG_S(long groupId, int status) {
4118                    return findByG_S(groupId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
4119                            null);
4120            }
4121    
4122            /**
4123             * Returns a range of all the blogs entries where groupId = &#63; and status = &#63;.
4124             *
4125             * <p>
4126             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4127             * </p>
4128             *
4129             * @param groupId the group ID
4130             * @param status the status
4131             * @param start the lower bound of the range of blogs entries
4132             * @param end the upper bound of the range of blogs entries (not inclusive)
4133             * @return the range of matching blogs entries
4134             */
4135            @Override
4136            public List<BlogsEntry> findByG_S(long groupId, int status, int start,
4137                    int end) {
4138                    return findByG_S(groupId, status, start, end, null);
4139            }
4140    
4141            /**
4142             * Returns an ordered range of all the blogs entries where groupId = &#63; and status = &#63;.
4143             *
4144             * <p>
4145             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4146             * </p>
4147             *
4148             * @param groupId the group ID
4149             * @param status the status
4150             * @param start the lower bound of the range of blogs entries
4151             * @param end the upper bound of the range of blogs entries (not inclusive)
4152             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4153             * @return the ordered range of matching blogs entries
4154             */
4155            @Override
4156            public List<BlogsEntry> findByG_S(long groupId, int status, int start,
4157                    int end, OrderByComparator<BlogsEntry> orderByComparator) {
4158                    return findByG_S(groupId, status, start, end, orderByComparator, true);
4159            }
4160    
4161            /**
4162             * Returns an ordered range of all the blogs entries where groupId = &#63; and status = &#63;.
4163             *
4164             * <p>
4165             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4166             * </p>
4167             *
4168             * @param groupId the group ID
4169             * @param status the status
4170             * @param start the lower bound of the range of blogs entries
4171             * @param end the upper bound of the range of blogs entries (not inclusive)
4172             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4173             * @param retrieveFromCache whether to retrieve from the finder cache
4174             * @return the ordered range of matching blogs entries
4175             */
4176            @Override
4177            public List<BlogsEntry> findByG_S(long groupId, int status, int start,
4178                    int end, OrderByComparator<BlogsEntry> orderByComparator,
4179                    boolean retrieveFromCache) {
4180                    boolean pagination = true;
4181                    FinderPath finderPath = null;
4182                    Object[] finderArgs = null;
4183    
4184                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4185                                    (orderByComparator == null)) {
4186                            pagination = false;
4187                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S;
4188                            finderArgs = new Object[] { groupId, status };
4189                    }
4190                    else {
4191                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S;
4192                            finderArgs = new Object[] {
4193                                            groupId, status,
4194                                            
4195                                            start, end, orderByComparator
4196                                    };
4197                    }
4198    
4199                    List<BlogsEntry> list = null;
4200    
4201                    if (retrieveFromCache) {
4202                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
4203                                            finderArgs, this);
4204    
4205                            if ((list != null) && !list.isEmpty()) {
4206                                    for (BlogsEntry blogsEntry : list) {
4207                                            if ((groupId != blogsEntry.getGroupId()) ||
4208                                                            (status != blogsEntry.getStatus())) {
4209                                                    list = null;
4210    
4211                                                    break;
4212                                            }
4213                                    }
4214                            }
4215                    }
4216    
4217                    if (list == null) {
4218                            StringBundler query = null;
4219    
4220                            if (orderByComparator != null) {
4221                                    query = new StringBundler(4 +
4222                                                    (orderByComparator.getOrderByFields().length * 2));
4223                            }
4224                            else {
4225                                    query = new StringBundler(4);
4226                            }
4227    
4228                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
4229    
4230                            query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4231    
4232                            query.append(_FINDER_COLUMN_G_S_STATUS_2);
4233    
4234                            if (orderByComparator != null) {
4235                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4236                                            orderByComparator);
4237                            }
4238                            else
4239                             if (pagination) {
4240                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
4241                            }
4242    
4243                            String sql = query.toString();
4244    
4245                            Session session = null;
4246    
4247                            try {
4248                                    session = openSession();
4249    
4250                                    Query q = session.createQuery(sql);
4251    
4252                                    QueryPos qPos = QueryPos.getInstance(q);
4253    
4254                                    qPos.add(groupId);
4255    
4256                                    qPos.add(status);
4257    
4258                                    if (!pagination) {
4259                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
4260                                                            start, end, false);
4261    
4262                                            Collections.sort(list);
4263    
4264                                            list = Collections.unmodifiableList(list);
4265                                    }
4266                                    else {
4267                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
4268                                                            start, end);
4269                                    }
4270    
4271                                    cacheResult(list);
4272    
4273                                    finderCache.putResult(finderPath, finderArgs, list);
4274                            }
4275                            catch (Exception e) {
4276                                    finderCache.removeResult(finderPath, finderArgs);
4277    
4278                                    throw processException(e);
4279                            }
4280                            finally {
4281                                    closeSession(session);
4282                            }
4283                    }
4284    
4285                    return list;
4286            }
4287    
4288            /**
4289             * Returns the first blogs entry in the ordered set where groupId = &#63; and status = &#63;.
4290             *
4291             * @param groupId the group ID
4292             * @param status the status
4293             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4294             * @return the first matching blogs entry
4295             * @throws NoSuchEntryException if a matching blogs entry could not be found
4296             */
4297            @Override
4298            public BlogsEntry findByG_S_First(long groupId, int status,
4299                    OrderByComparator<BlogsEntry> orderByComparator)
4300                    throws NoSuchEntryException {
4301                    BlogsEntry blogsEntry = fetchByG_S_First(groupId, status,
4302                                    orderByComparator);
4303    
4304                    if (blogsEntry != null) {
4305                            return blogsEntry;
4306                    }
4307    
4308                    StringBundler msg = new StringBundler(6);
4309    
4310                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4311    
4312                    msg.append("groupId=");
4313                    msg.append(groupId);
4314    
4315                    msg.append(", status=");
4316                    msg.append(status);
4317    
4318                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4319    
4320                    throw new NoSuchEntryException(msg.toString());
4321            }
4322    
4323            /**
4324             * Returns the first blogs entry in the ordered set where groupId = &#63; and status = &#63;.
4325             *
4326             * @param groupId the group ID
4327             * @param status the status
4328             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4329             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
4330             */
4331            @Override
4332            public BlogsEntry fetchByG_S_First(long groupId, int status,
4333                    OrderByComparator<BlogsEntry> orderByComparator) {
4334                    List<BlogsEntry> list = findByG_S(groupId, status, 0, 1,
4335                                    orderByComparator);
4336    
4337                    if (!list.isEmpty()) {
4338                            return list.get(0);
4339                    }
4340    
4341                    return null;
4342            }
4343    
4344            /**
4345             * Returns the last blogs entry in the ordered set where groupId = &#63; and status = &#63;.
4346             *
4347             * @param groupId the group ID
4348             * @param status the status
4349             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4350             * @return the last matching blogs entry
4351             * @throws NoSuchEntryException if a matching blogs entry could not be found
4352             */
4353            @Override
4354            public BlogsEntry findByG_S_Last(long groupId, int status,
4355                    OrderByComparator<BlogsEntry> orderByComparator)
4356                    throws NoSuchEntryException {
4357                    BlogsEntry blogsEntry = fetchByG_S_Last(groupId, status,
4358                                    orderByComparator);
4359    
4360                    if (blogsEntry != null) {
4361                            return blogsEntry;
4362                    }
4363    
4364                    StringBundler msg = new StringBundler(6);
4365    
4366                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4367    
4368                    msg.append("groupId=");
4369                    msg.append(groupId);
4370    
4371                    msg.append(", status=");
4372                    msg.append(status);
4373    
4374                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4375    
4376                    throw new NoSuchEntryException(msg.toString());
4377            }
4378    
4379            /**
4380             * Returns the last blogs entry in the ordered set where groupId = &#63; and status = &#63;.
4381             *
4382             * @param groupId the group ID
4383             * @param status the status
4384             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4385             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
4386             */
4387            @Override
4388            public BlogsEntry fetchByG_S_Last(long groupId, int status,
4389                    OrderByComparator<BlogsEntry> orderByComparator) {
4390                    int count = countByG_S(groupId, status);
4391    
4392                    if (count == 0) {
4393                            return null;
4394                    }
4395    
4396                    List<BlogsEntry> list = findByG_S(groupId, status, count - 1, count,
4397                                    orderByComparator);
4398    
4399                    if (!list.isEmpty()) {
4400                            return list.get(0);
4401                    }
4402    
4403                    return null;
4404            }
4405    
4406            /**
4407             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63; and status = &#63;.
4408             *
4409             * @param entryId the primary key of the current blogs entry
4410             * @param groupId the group ID
4411             * @param status the status
4412             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4413             * @return the previous, current, and next blogs entry
4414             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
4415             */
4416            @Override
4417            public BlogsEntry[] findByG_S_PrevAndNext(long entryId, long groupId,
4418                    int status, OrderByComparator<BlogsEntry> orderByComparator)
4419                    throws NoSuchEntryException {
4420                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
4421    
4422                    Session session = null;
4423    
4424                    try {
4425                            session = openSession();
4426    
4427                            BlogsEntry[] array = new BlogsEntryImpl[3];
4428    
4429                            array[0] = getByG_S_PrevAndNext(session, blogsEntry, groupId,
4430                                            status, orderByComparator, true);
4431    
4432                            array[1] = blogsEntry;
4433    
4434                            array[2] = getByG_S_PrevAndNext(session, blogsEntry, groupId,
4435                                            status, orderByComparator, false);
4436    
4437                            return array;
4438                    }
4439                    catch (Exception e) {
4440                            throw processException(e);
4441                    }
4442                    finally {
4443                            closeSession(session);
4444                    }
4445            }
4446    
4447            protected BlogsEntry getByG_S_PrevAndNext(Session session,
4448                    BlogsEntry blogsEntry, long groupId, int status,
4449                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
4450                    StringBundler query = null;
4451    
4452                    if (orderByComparator != null) {
4453                            query = new StringBundler(5 +
4454                                            (orderByComparator.getOrderByConditionFields().length * 3) +
4455                                            (orderByComparator.getOrderByFields().length * 3));
4456                    }
4457                    else {
4458                            query = new StringBundler(4);
4459                    }
4460    
4461                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
4462    
4463                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4464    
4465                    query.append(_FINDER_COLUMN_G_S_STATUS_2);
4466    
4467                    if (orderByComparator != null) {
4468                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4469    
4470                            if (orderByConditionFields.length > 0) {
4471                                    query.append(WHERE_AND);
4472                            }
4473    
4474                            for (int i = 0; i < orderByConditionFields.length; i++) {
4475                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4476                                    query.append(orderByConditionFields[i]);
4477    
4478                                    if ((i + 1) < orderByConditionFields.length) {
4479                                            if (orderByComparator.isAscending() ^ previous) {
4480                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4481                                            }
4482                                            else {
4483                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4484                                            }
4485                                    }
4486                                    else {
4487                                            if (orderByComparator.isAscending() ^ previous) {
4488                                                    query.append(WHERE_GREATER_THAN);
4489                                            }
4490                                            else {
4491                                                    query.append(WHERE_LESSER_THAN);
4492                                            }
4493                                    }
4494                            }
4495    
4496                            query.append(ORDER_BY_CLAUSE);
4497    
4498                            String[] orderByFields = orderByComparator.getOrderByFields();
4499    
4500                            for (int i = 0; i < orderByFields.length; i++) {
4501                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4502                                    query.append(orderByFields[i]);
4503    
4504                                    if ((i + 1) < orderByFields.length) {
4505                                            if (orderByComparator.isAscending() ^ previous) {
4506                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4507                                            }
4508                                            else {
4509                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4510                                            }
4511                                    }
4512                                    else {
4513                                            if (orderByComparator.isAscending() ^ previous) {
4514                                                    query.append(ORDER_BY_ASC);
4515                                            }
4516                                            else {
4517                                                    query.append(ORDER_BY_DESC);
4518                                            }
4519                                    }
4520                            }
4521                    }
4522                    else {
4523                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
4524                    }
4525    
4526                    String sql = query.toString();
4527    
4528                    Query q = session.createQuery(sql);
4529    
4530                    q.setFirstResult(0);
4531                    q.setMaxResults(2);
4532    
4533                    QueryPos qPos = QueryPos.getInstance(q);
4534    
4535                    qPos.add(groupId);
4536    
4537                    qPos.add(status);
4538    
4539                    if (orderByComparator != null) {
4540                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
4541    
4542                            for (Object value : values) {
4543                                    qPos.add(value);
4544                            }
4545                    }
4546    
4547                    List<BlogsEntry> list = q.list();
4548    
4549                    if (list.size() == 2) {
4550                            return list.get(1);
4551                    }
4552                    else {
4553                            return null;
4554                    }
4555            }
4556    
4557            /**
4558             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and status = &#63;.
4559             *
4560             * @param groupId the group ID
4561             * @param status the status
4562             * @return the matching blogs entries that the user has permission to view
4563             */
4564            @Override
4565            public List<BlogsEntry> filterFindByG_S(long groupId, int status) {
4566                    return filterFindByG_S(groupId, status, QueryUtil.ALL_POS,
4567                            QueryUtil.ALL_POS, null);
4568            }
4569    
4570            /**
4571             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63; and status = &#63;.
4572             *
4573             * <p>
4574             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4575             * </p>
4576             *
4577             * @param groupId the group ID
4578             * @param status the status
4579             * @param start the lower bound of the range of blogs entries
4580             * @param end the upper bound of the range of blogs entries (not inclusive)
4581             * @return the range of matching blogs entries that the user has permission to view
4582             */
4583            @Override
4584            public List<BlogsEntry> filterFindByG_S(long groupId, int status,
4585                    int start, int end) {
4586                    return filterFindByG_S(groupId, status, start, end, null);
4587            }
4588    
4589            /**
4590             * Returns an ordered range of all the blogs entries that the user has permissions to view where groupId = &#63; and status = &#63;.
4591             *
4592             * <p>
4593             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4594             * </p>
4595             *
4596             * @param groupId the group ID
4597             * @param status the status
4598             * @param start the lower bound of the range of blogs entries
4599             * @param end the upper bound of the range of blogs entries (not inclusive)
4600             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4601             * @return the ordered range of matching blogs entries that the user has permission to view
4602             */
4603            @Override
4604            public List<BlogsEntry> filterFindByG_S(long groupId, int status,
4605                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator) {
4606                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4607                            return findByG_S(groupId, status, start, end, orderByComparator);
4608                    }
4609    
4610                    StringBundler query = null;
4611    
4612                    if (orderByComparator != null) {
4613                            query = new StringBundler(4 +
4614                                            (orderByComparator.getOrderByFields().length * 2));
4615                    }
4616                    else {
4617                            query = new StringBundler(5);
4618                    }
4619    
4620                    if (getDB().isSupportsInlineDistinct()) {
4621                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
4622                    }
4623                    else {
4624                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
4625                    }
4626    
4627                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4628    
4629                    query.append(_FINDER_COLUMN_G_S_STATUS_2);
4630    
4631                    if (!getDB().isSupportsInlineDistinct()) {
4632                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
4633                    }
4634    
4635                    if (orderByComparator != null) {
4636                            if (getDB().isSupportsInlineDistinct()) {
4637                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4638                                            orderByComparator, true);
4639                            }
4640                            else {
4641                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
4642                                            orderByComparator, true);
4643                            }
4644                    }
4645                    else {
4646                            if (getDB().isSupportsInlineDistinct()) {
4647                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
4648                            }
4649                            else {
4650                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
4651                            }
4652                    }
4653    
4654                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4655                                    BlogsEntry.class.getName(),
4656                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4657    
4658                    Session session = null;
4659    
4660                    try {
4661                            session = openSession();
4662    
4663                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
4664    
4665                            if (getDB().isSupportsInlineDistinct()) {
4666                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
4667                            }
4668                            else {
4669                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
4670                            }
4671    
4672                            QueryPos qPos = QueryPos.getInstance(q);
4673    
4674                            qPos.add(groupId);
4675    
4676                            qPos.add(status);
4677    
4678                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
4679                    }
4680                    catch (Exception e) {
4681                            throw processException(e);
4682                    }
4683                    finally {
4684                            closeSession(session);
4685                    }
4686            }
4687    
4688            /**
4689             * 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;.
4690             *
4691             * @param entryId the primary key of the current blogs entry
4692             * @param groupId the group ID
4693             * @param status the status
4694             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4695             * @return the previous, current, and next blogs entry
4696             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
4697             */
4698            @Override
4699            public BlogsEntry[] filterFindByG_S_PrevAndNext(long entryId, long groupId,
4700                    int status, OrderByComparator<BlogsEntry> orderByComparator)
4701                    throws NoSuchEntryException {
4702                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4703                            return findByG_S_PrevAndNext(entryId, groupId, status,
4704                                    orderByComparator);
4705                    }
4706    
4707                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
4708    
4709                    Session session = null;
4710    
4711                    try {
4712                            session = openSession();
4713    
4714                            BlogsEntry[] array = new BlogsEntryImpl[3];
4715    
4716                            array[0] = filterGetByG_S_PrevAndNext(session, blogsEntry, groupId,
4717                                            status, orderByComparator, true);
4718    
4719                            array[1] = blogsEntry;
4720    
4721                            array[2] = filterGetByG_S_PrevAndNext(session, blogsEntry, groupId,
4722                                            status, orderByComparator, false);
4723    
4724                            return array;
4725                    }
4726                    catch (Exception e) {
4727                            throw processException(e);
4728                    }
4729                    finally {
4730                            closeSession(session);
4731                    }
4732            }
4733    
4734            protected BlogsEntry filterGetByG_S_PrevAndNext(Session session,
4735                    BlogsEntry blogsEntry, long groupId, int status,
4736                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
4737                    StringBundler query = null;
4738    
4739                    if (orderByComparator != null) {
4740                            query = new StringBundler(6 +
4741                                            (orderByComparator.getOrderByConditionFields().length * 3) +
4742                                            (orderByComparator.getOrderByFields().length * 3));
4743                    }
4744                    else {
4745                            query = new StringBundler(5);
4746                    }
4747    
4748                    if (getDB().isSupportsInlineDistinct()) {
4749                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
4750                    }
4751                    else {
4752                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
4753                    }
4754    
4755                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4756    
4757                    query.append(_FINDER_COLUMN_G_S_STATUS_2);
4758    
4759                    if (!getDB().isSupportsInlineDistinct()) {
4760                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
4761                    }
4762    
4763                    if (orderByComparator != null) {
4764                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4765    
4766                            if (orderByConditionFields.length > 0) {
4767                                    query.append(WHERE_AND);
4768                            }
4769    
4770                            for (int i = 0; i < orderByConditionFields.length; i++) {
4771                                    if (getDB().isSupportsInlineDistinct()) {
4772                                            query.append(_ORDER_BY_ENTITY_ALIAS);
4773                                    }
4774                                    else {
4775                                            query.append(_ORDER_BY_ENTITY_TABLE);
4776                                    }
4777    
4778                                    query.append(orderByConditionFields[i]);
4779    
4780                                    if ((i + 1) < orderByConditionFields.length) {
4781                                            if (orderByComparator.isAscending() ^ previous) {
4782                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4783                                            }
4784                                            else {
4785                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4786                                            }
4787                                    }
4788                                    else {
4789                                            if (orderByComparator.isAscending() ^ previous) {
4790                                                    query.append(WHERE_GREATER_THAN);
4791                                            }
4792                                            else {
4793                                                    query.append(WHERE_LESSER_THAN);
4794                                            }
4795                                    }
4796                            }
4797    
4798                            query.append(ORDER_BY_CLAUSE);
4799    
4800                            String[] orderByFields = orderByComparator.getOrderByFields();
4801    
4802                            for (int i = 0; i < orderByFields.length; i++) {
4803                                    if (getDB().isSupportsInlineDistinct()) {
4804                                            query.append(_ORDER_BY_ENTITY_ALIAS);
4805                                    }
4806                                    else {
4807                                            query.append(_ORDER_BY_ENTITY_TABLE);
4808                                    }
4809    
4810                                    query.append(orderByFields[i]);
4811    
4812                                    if ((i + 1) < orderByFields.length) {
4813                                            if (orderByComparator.isAscending() ^ previous) {
4814                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4815                                            }
4816                                            else {
4817                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4818                                            }
4819                                    }
4820                                    else {
4821                                            if (orderByComparator.isAscending() ^ previous) {
4822                                                    query.append(ORDER_BY_ASC);
4823                                            }
4824                                            else {
4825                                                    query.append(ORDER_BY_DESC);
4826                                            }
4827                                    }
4828                            }
4829                    }
4830                    else {
4831                            if (getDB().isSupportsInlineDistinct()) {
4832                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
4833                            }
4834                            else {
4835                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
4836                            }
4837                    }
4838    
4839                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4840                                    BlogsEntry.class.getName(),
4841                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4842    
4843                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
4844    
4845                    q.setFirstResult(0);
4846                    q.setMaxResults(2);
4847    
4848                    if (getDB().isSupportsInlineDistinct()) {
4849                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
4850                    }
4851                    else {
4852                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
4853                    }
4854    
4855                    QueryPos qPos = QueryPos.getInstance(q);
4856    
4857                    qPos.add(groupId);
4858    
4859                    qPos.add(status);
4860    
4861                    if (orderByComparator != null) {
4862                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
4863    
4864                            for (Object value : values) {
4865                                    qPos.add(value);
4866                            }
4867                    }
4868    
4869                    List<BlogsEntry> list = q.list();
4870    
4871                    if (list.size() == 2) {
4872                            return list.get(1);
4873                    }
4874                    else {
4875                            return null;
4876                    }
4877            }
4878    
4879            /**
4880             * Removes all the blogs entries where groupId = &#63; and status = &#63; from the database.
4881             *
4882             * @param groupId the group ID
4883             * @param status the status
4884             */
4885            @Override
4886            public void removeByG_S(long groupId, int status) {
4887                    for (BlogsEntry blogsEntry : findByG_S(groupId, status,
4888                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
4889                            remove(blogsEntry);
4890                    }
4891            }
4892    
4893            /**
4894             * Returns the number of blogs entries where groupId = &#63; and status = &#63;.
4895             *
4896             * @param groupId the group ID
4897             * @param status the status
4898             * @return the number of matching blogs entries
4899             */
4900            @Override
4901            public int countByG_S(long groupId, int status) {
4902                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_S;
4903    
4904                    Object[] finderArgs = new Object[] { groupId, status };
4905    
4906                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
4907    
4908                    if (count == null) {
4909                            StringBundler query = new StringBundler(3);
4910    
4911                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
4912    
4913                            query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4914    
4915                            query.append(_FINDER_COLUMN_G_S_STATUS_2);
4916    
4917                            String sql = query.toString();
4918    
4919                            Session session = null;
4920    
4921                            try {
4922                                    session = openSession();
4923    
4924                                    Query q = session.createQuery(sql);
4925    
4926                                    QueryPos qPos = QueryPos.getInstance(q);
4927    
4928                                    qPos.add(groupId);
4929    
4930                                    qPos.add(status);
4931    
4932                                    count = (Long)q.uniqueResult();
4933    
4934                                    finderCache.putResult(finderPath, finderArgs, count);
4935                            }
4936                            catch (Exception e) {
4937                                    finderCache.removeResult(finderPath, finderArgs);
4938    
4939                                    throw processException(e);
4940                            }
4941                            finally {
4942                                    closeSession(session);
4943                            }
4944                    }
4945    
4946                    return count.intValue();
4947            }
4948    
4949            /**
4950             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and status = &#63;.
4951             *
4952             * @param groupId the group ID
4953             * @param status the status
4954             * @return the number of matching blogs entries that the user has permission to view
4955             */
4956            @Override
4957            public int filterCountByG_S(long groupId, int status) {
4958                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4959                            return countByG_S(groupId, status);
4960                    }
4961    
4962                    StringBundler query = new StringBundler(3);
4963    
4964                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
4965    
4966                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4967    
4968                    query.append(_FINDER_COLUMN_G_S_STATUS_2);
4969    
4970                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4971                                    BlogsEntry.class.getName(),
4972                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4973    
4974                    Session session = null;
4975    
4976                    try {
4977                            session = openSession();
4978    
4979                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
4980    
4981                            q.addScalar(COUNT_COLUMN_NAME,
4982                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
4983    
4984                            QueryPos qPos = QueryPos.getInstance(q);
4985    
4986                            qPos.add(groupId);
4987    
4988                            qPos.add(status);
4989    
4990                            Long count = (Long)q.uniqueResult();
4991    
4992                            return count.intValue();
4993                    }
4994                    catch (Exception e) {
4995                            throw processException(e);
4996                    }
4997                    finally {
4998                            closeSession(session);
4999                    }
5000            }
5001    
5002            private static final String _FINDER_COLUMN_G_S_GROUPID_2 = "blogsEntry.groupId = ? AND ";
5003            private static final String _FINDER_COLUMN_G_S_STATUS_2 = "blogsEntry.status = ?";
5004            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_NOTS = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
5005                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
5006                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_NotS",
5007                            new String[] {
5008                                    Long.class.getName(), Integer.class.getName(),
5009                                    
5010                            Integer.class.getName(), Integer.class.getName(),
5011                                    OrderByComparator.class.getName()
5012                            });
5013            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_NOTS = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
5014                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
5015                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_NotS",
5016                            new String[] { Long.class.getName(), Integer.class.getName() });
5017    
5018            /**
5019             * Returns all the blogs entries where groupId = &#63; and status &ne; &#63;.
5020             *
5021             * @param groupId the group ID
5022             * @param status the status
5023             * @return the matching blogs entries
5024             */
5025            @Override
5026            public List<BlogsEntry> findByG_NotS(long groupId, int status) {
5027                    return findByG_NotS(groupId, status, QueryUtil.ALL_POS,
5028                            QueryUtil.ALL_POS, null);
5029            }
5030    
5031            /**
5032             * Returns a range of all the blogs entries where groupId = &#63; and status &ne; &#63;.
5033             *
5034             * <p>
5035             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5036             * </p>
5037             *
5038             * @param groupId the group ID
5039             * @param status the status
5040             * @param start the lower bound of the range of blogs entries
5041             * @param end the upper bound of the range of blogs entries (not inclusive)
5042             * @return the range of matching blogs entries
5043             */
5044            @Override
5045            public List<BlogsEntry> findByG_NotS(long groupId, int status, int start,
5046                    int end) {
5047                    return findByG_NotS(groupId, status, start, end, null);
5048            }
5049    
5050            /**
5051             * Returns an ordered range of all the blogs entries where groupId = &#63; and status &ne; &#63;.
5052             *
5053             * <p>
5054             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5055             * </p>
5056             *
5057             * @param groupId the group ID
5058             * @param status the status
5059             * @param start the lower bound of the range of blogs entries
5060             * @param end the upper bound of the range of blogs entries (not inclusive)
5061             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5062             * @return the ordered range of matching blogs entries
5063             */
5064            @Override
5065            public List<BlogsEntry> findByG_NotS(long groupId, int status, int start,
5066                    int end, OrderByComparator<BlogsEntry> orderByComparator) {
5067                    return findByG_NotS(groupId, status, start, end, orderByComparator, true);
5068            }
5069    
5070            /**
5071             * Returns an ordered range of all the blogs entries where groupId = &#63; and status &ne; &#63;.
5072             *
5073             * <p>
5074             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5075             * </p>
5076             *
5077             * @param groupId the group ID
5078             * @param status the status
5079             * @param start the lower bound of the range of blogs entries
5080             * @param end the upper bound of the range of blogs entries (not inclusive)
5081             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5082             * @param retrieveFromCache whether to retrieve from the finder cache
5083             * @return the ordered range of matching blogs entries
5084             */
5085            @Override
5086            public List<BlogsEntry> findByG_NotS(long groupId, int status, int start,
5087                    int end, OrderByComparator<BlogsEntry> orderByComparator,
5088                    boolean retrieveFromCache) {
5089                    boolean pagination = true;
5090                    FinderPath finderPath = null;
5091                    Object[] finderArgs = null;
5092    
5093                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_NOTS;
5094                    finderArgs = new Object[] { groupId, status, start, end, orderByComparator };
5095    
5096                    List<BlogsEntry> list = null;
5097    
5098                    if (retrieveFromCache) {
5099                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
5100                                            finderArgs, this);
5101    
5102                            if ((list != null) && !list.isEmpty()) {
5103                                    for (BlogsEntry blogsEntry : list) {
5104                                            if ((groupId != blogsEntry.getGroupId()) ||
5105                                                            (status == blogsEntry.getStatus())) {
5106                                                    list = null;
5107    
5108                                                    break;
5109                                            }
5110                                    }
5111                            }
5112                    }
5113    
5114                    if (list == null) {
5115                            StringBundler query = null;
5116    
5117                            if (orderByComparator != null) {
5118                                    query = new StringBundler(4 +
5119                                                    (orderByComparator.getOrderByFields().length * 2));
5120                            }
5121                            else {
5122                                    query = new StringBundler(4);
5123                            }
5124    
5125                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
5126    
5127                            query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
5128    
5129                            query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
5130    
5131                            if (orderByComparator != null) {
5132                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5133                                            orderByComparator);
5134                            }
5135                            else
5136                             if (pagination) {
5137                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
5138                            }
5139    
5140                            String sql = query.toString();
5141    
5142                            Session session = null;
5143    
5144                            try {
5145                                    session = openSession();
5146    
5147                                    Query q = session.createQuery(sql);
5148    
5149                                    QueryPos qPos = QueryPos.getInstance(q);
5150    
5151                                    qPos.add(groupId);
5152    
5153                                    qPos.add(status);
5154    
5155                                    if (!pagination) {
5156                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
5157                                                            start, end, false);
5158    
5159                                            Collections.sort(list);
5160    
5161                                            list = Collections.unmodifiableList(list);
5162                                    }
5163                                    else {
5164                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
5165                                                            start, end);
5166                                    }
5167    
5168                                    cacheResult(list);
5169    
5170                                    finderCache.putResult(finderPath, finderArgs, list);
5171                            }
5172                            catch (Exception e) {
5173                                    finderCache.removeResult(finderPath, finderArgs);
5174    
5175                                    throw processException(e);
5176                            }
5177                            finally {
5178                                    closeSession(session);
5179                            }
5180                    }
5181    
5182                    return list;
5183            }
5184    
5185            /**
5186             * Returns the first blogs entry in the ordered set where groupId = &#63; and status &ne; &#63;.
5187             *
5188             * @param groupId the group ID
5189             * @param status the status
5190             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5191             * @return the first matching blogs entry
5192             * @throws NoSuchEntryException if a matching blogs entry could not be found
5193             */
5194            @Override
5195            public BlogsEntry findByG_NotS_First(long groupId, int status,
5196                    OrderByComparator<BlogsEntry> orderByComparator)
5197                    throws NoSuchEntryException {
5198                    BlogsEntry blogsEntry = fetchByG_NotS_First(groupId, status,
5199                                    orderByComparator);
5200    
5201                    if (blogsEntry != null) {
5202                            return blogsEntry;
5203                    }
5204    
5205                    StringBundler msg = new StringBundler(6);
5206    
5207                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5208    
5209                    msg.append("groupId=");
5210                    msg.append(groupId);
5211    
5212                    msg.append(", status=");
5213                    msg.append(status);
5214    
5215                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5216    
5217                    throw new NoSuchEntryException(msg.toString());
5218            }
5219    
5220            /**
5221             * Returns the first blogs entry in the ordered set where groupId = &#63; and status &ne; &#63;.
5222             *
5223             * @param groupId the group ID
5224             * @param status the status
5225             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5226             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
5227             */
5228            @Override
5229            public BlogsEntry fetchByG_NotS_First(long groupId, int status,
5230                    OrderByComparator<BlogsEntry> orderByComparator) {
5231                    List<BlogsEntry> list = findByG_NotS(groupId, status, 0, 1,
5232                                    orderByComparator);
5233    
5234                    if (!list.isEmpty()) {
5235                            return list.get(0);
5236                    }
5237    
5238                    return null;
5239            }
5240    
5241            /**
5242             * Returns the last blogs entry in the ordered set where groupId = &#63; and status &ne; &#63;.
5243             *
5244             * @param groupId the group ID
5245             * @param status the status
5246             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5247             * @return the last matching blogs entry
5248             * @throws NoSuchEntryException if a matching blogs entry could not be found
5249             */
5250            @Override
5251            public BlogsEntry findByG_NotS_Last(long groupId, int status,
5252                    OrderByComparator<BlogsEntry> orderByComparator)
5253                    throws NoSuchEntryException {
5254                    BlogsEntry blogsEntry = fetchByG_NotS_Last(groupId, status,
5255                                    orderByComparator);
5256    
5257                    if (blogsEntry != null) {
5258                            return blogsEntry;
5259                    }
5260    
5261                    StringBundler msg = new StringBundler(6);
5262    
5263                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5264    
5265                    msg.append("groupId=");
5266                    msg.append(groupId);
5267    
5268                    msg.append(", status=");
5269                    msg.append(status);
5270    
5271                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5272    
5273                    throw new NoSuchEntryException(msg.toString());
5274            }
5275    
5276            /**
5277             * Returns the last blogs entry in the ordered set where groupId = &#63; and status &ne; &#63;.
5278             *
5279             * @param groupId the group ID
5280             * @param status the status
5281             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5282             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
5283             */
5284            @Override
5285            public BlogsEntry fetchByG_NotS_Last(long groupId, int status,
5286                    OrderByComparator<BlogsEntry> orderByComparator) {
5287                    int count = countByG_NotS(groupId, status);
5288    
5289                    if (count == 0) {
5290                            return null;
5291                    }
5292    
5293                    List<BlogsEntry> list = findByG_NotS(groupId, status, count - 1, count,
5294                                    orderByComparator);
5295    
5296                    if (!list.isEmpty()) {
5297                            return list.get(0);
5298                    }
5299    
5300                    return null;
5301            }
5302    
5303            /**
5304             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63; and status &ne; &#63;.
5305             *
5306             * @param entryId the primary key of the current blogs entry
5307             * @param groupId the group ID
5308             * @param status the status
5309             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5310             * @return the previous, current, and next blogs entry
5311             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
5312             */
5313            @Override
5314            public BlogsEntry[] findByG_NotS_PrevAndNext(long entryId, long groupId,
5315                    int status, OrderByComparator<BlogsEntry> orderByComparator)
5316                    throws NoSuchEntryException {
5317                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
5318    
5319                    Session session = null;
5320    
5321                    try {
5322                            session = openSession();
5323    
5324                            BlogsEntry[] array = new BlogsEntryImpl[3];
5325    
5326                            array[0] = getByG_NotS_PrevAndNext(session, blogsEntry, groupId,
5327                                            status, orderByComparator, true);
5328    
5329                            array[1] = blogsEntry;
5330    
5331                            array[2] = getByG_NotS_PrevAndNext(session, blogsEntry, groupId,
5332                                            status, orderByComparator, false);
5333    
5334                            return array;
5335                    }
5336                    catch (Exception e) {
5337                            throw processException(e);
5338                    }
5339                    finally {
5340                            closeSession(session);
5341                    }
5342            }
5343    
5344            protected BlogsEntry getByG_NotS_PrevAndNext(Session session,
5345                    BlogsEntry blogsEntry, long groupId, int status,
5346                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
5347                    StringBundler query = null;
5348    
5349                    if (orderByComparator != null) {
5350                            query = new StringBundler(5 +
5351                                            (orderByComparator.getOrderByConditionFields().length * 3) +
5352                                            (orderByComparator.getOrderByFields().length * 3));
5353                    }
5354                    else {
5355                            query = new StringBundler(4);
5356                    }
5357    
5358                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
5359    
5360                    query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
5361    
5362                    query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
5363    
5364                    if (orderByComparator != null) {
5365                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5366    
5367                            if (orderByConditionFields.length > 0) {
5368                                    query.append(WHERE_AND);
5369                            }
5370    
5371                            for (int i = 0; i < orderByConditionFields.length; i++) {
5372                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5373                                    query.append(orderByConditionFields[i]);
5374    
5375                                    if ((i + 1) < orderByConditionFields.length) {
5376                                            if (orderByComparator.isAscending() ^ previous) {
5377                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5378                                            }
5379                                            else {
5380                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5381                                            }
5382                                    }
5383                                    else {
5384                                            if (orderByComparator.isAscending() ^ previous) {
5385                                                    query.append(WHERE_GREATER_THAN);
5386                                            }
5387                                            else {
5388                                                    query.append(WHERE_LESSER_THAN);
5389                                            }
5390                                    }
5391                            }
5392    
5393                            query.append(ORDER_BY_CLAUSE);
5394    
5395                            String[] orderByFields = orderByComparator.getOrderByFields();
5396    
5397                            for (int i = 0; i < orderByFields.length; i++) {
5398                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5399                                    query.append(orderByFields[i]);
5400    
5401                                    if ((i + 1) < orderByFields.length) {
5402                                            if (orderByComparator.isAscending() ^ previous) {
5403                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5404                                            }
5405                                            else {
5406                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5407                                            }
5408                                    }
5409                                    else {
5410                                            if (orderByComparator.isAscending() ^ previous) {
5411                                                    query.append(ORDER_BY_ASC);
5412                                            }
5413                                            else {
5414                                                    query.append(ORDER_BY_DESC);
5415                                            }
5416                                    }
5417                            }
5418                    }
5419                    else {
5420                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
5421                    }
5422    
5423                    String sql = query.toString();
5424    
5425                    Query q = session.createQuery(sql);
5426    
5427                    q.setFirstResult(0);
5428                    q.setMaxResults(2);
5429    
5430                    QueryPos qPos = QueryPos.getInstance(q);
5431    
5432                    qPos.add(groupId);
5433    
5434                    qPos.add(status);
5435    
5436                    if (orderByComparator != null) {
5437                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
5438    
5439                            for (Object value : values) {
5440                                    qPos.add(value);
5441                            }
5442                    }
5443    
5444                    List<BlogsEntry> list = q.list();
5445    
5446                    if (list.size() == 2) {
5447                            return list.get(1);
5448                    }
5449                    else {
5450                            return null;
5451                    }
5452            }
5453    
5454            /**
5455             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and status &ne; &#63;.
5456             *
5457             * @param groupId the group ID
5458             * @param status the status
5459             * @return the matching blogs entries that the user has permission to view
5460             */
5461            @Override
5462            public List<BlogsEntry> filterFindByG_NotS(long groupId, int status) {
5463                    return filterFindByG_NotS(groupId, status, QueryUtil.ALL_POS,
5464                            QueryUtil.ALL_POS, null);
5465            }
5466    
5467            /**
5468             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63; and status &ne; &#63;.
5469             *
5470             * <p>
5471             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5472             * </p>
5473             *
5474             * @param groupId the group ID
5475             * @param status the status
5476             * @param start the lower bound of the range of blogs entries
5477             * @param end the upper bound of the range of blogs entries (not inclusive)
5478             * @return the range of matching blogs entries that the user has permission to view
5479             */
5480            @Override
5481            public List<BlogsEntry> filterFindByG_NotS(long groupId, int status,
5482                    int start, int end) {
5483                    return filterFindByG_NotS(groupId, status, start, end, null);
5484            }
5485    
5486            /**
5487             * Returns an ordered range of all the blogs entries that the user has permissions to view where groupId = &#63; and status &ne; &#63;.
5488             *
5489             * <p>
5490             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5491             * </p>
5492             *
5493             * @param groupId the group ID
5494             * @param status the status
5495             * @param start the lower bound of the range of blogs entries
5496             * @param end the upper bound of the range of blogs entries (not inclusive)
5497             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5498             * @return the ordered range of matching blogs entries that the user has permission to view
5499             */
5500            @Override
5501            public List<BlogsEntry> filterFindByG_NotS(long groupId, int status,
5502                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator) {
5503                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5504                            return findByG_NotS(groupId, status, start, end, orderByComparator);
5505                    }
5506    
5507                    StringBundler query = null;
5508    
5509                    if (orderByComparator != null) {
5510                            query = new StringBundler(4 +
5511                                            (orderByComparator.getOrderByFields().length * 2));
5512                    }
5513                    else {
5514                            query = new StringBundler(5);
5515                    }
5516    
5517                    if (getDB().isSupportsInlineDistinct()) {
5518                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
5519                    }
5520                    else {
5521                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
5522                    }
5523    
5524                    query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
5525    
5526                    query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
5527    
5528                    if (!getDB().isSupportsInlineDistinct()) {
5529                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
5530                    }
5531    
5532                    if (orderByComparator != null) {
5533                            if (getDB().isSupportsInlineDistinct()) {
5534                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5535                                            orderByComparator, true);
5536                            }
5537                            else {
5538                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
5539                                            orderByComparator, true);
5540                            }
5541                    }
5542                    else {
5543                            if (getDB().isSupportsInlineDistinct()) {
5544                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
5545                            }
5546                            else {
5547                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
5548                            }
5549                    }
5550    
5551                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5552                                    BlogsEntry.class.getName(),
5553                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5554    
5555                    Session session = null;
5556    
5557                    try {
5558                            session = openSession();
5559    
5560                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
5561    
5562                            if (getDB().isSupportsInlineDistinct()) {
5563                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
5564                            }
5565                            else {
5566                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
5567                            }
5568    
5569                            QueryPos qPos = QueryPos.getInstance(q);
5570    
5571                            qPos.add(groupId);
5572    
5573                            qPos.add(status);
5574    
5575                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
5576                    }
5577                    catch (Exception e) {
5578                            throw processException(e);
5579                    }
5580                    finally {
5581                            closeSession(session);
5582                    }
5583            }
5584    
5585            /**
5586             * 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;.
5587             *
5588             * @param entryId the primary key of the current blogs entry
5589             * @param groupId the group ID
5590             * @param status the status
5591             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5592             * @return the previous, current, and next blogs entry
5593             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
5594             */
5595            @Override
5596            public BlogsEntry[] filterFindByG_NotS_PrevAndNext(long entryId,
5597                    long groupId, int status,
5598                    OrderByComparator<BlogsEntry> orderByComparator)
5599                    throws NoSuchEntryException {
5600                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5601                            return findByG_NotS_PrevAndNext(entryId, groupId, status,
5602                                    orderByComparator);
5603                    }
5604    
5605                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
5606    
5607                    Session session = null;
5608    
5609                    try {
5610                            session = openSession();
5611    
5612                            BlogsEntry[] array = new BlogsEntryImpl[3];
5613    
5614                            array[0] = filterGetByG_NotS_PrevAndNext(session, blogsEntry,
5615                                            groupId, status, orderByComparator, true);
5616    
5617                            array[1] = blogsEntry;
5618    
5619                            array[2] = filterGetByG_NotS_PrevAndNext(session, blogsEntry,
5620                                            groupId, status, orderByComparator, false);
5621    
5622                            return array;
5623                    }
5624                    catch (Exception e) {
5625                            throw processException(e);
5626                    }
5627                    finally {
5628                            closeSession(session);
5629                    }
5630            }
5631    
5632            protected BlogsEntry filterGetByG_NotS_PrevAndNext(Session session,
5633                    BlogsEntry blogsEntry, long groupId, int status,
5634                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
5635                    StringBundler query = null;
5636    
5637                    if (orderByComparator != null) {
5638                            query = new StringBundler(6 +
5639                                            (orderByComparator.getOrderByConditionFields().length * 3) +
5640                                            (orderByComparator.getOrderByFields().length * 3));
5641                    }
5642                    else {
5643                            query = new StringBundler(5);
5644                    }
5645    
5646                    if (getDB().isSupportsInlineDistinct()) {
5647                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
5648                    }
5649                    else {
5650                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
5651                    }
5652    
5653                    query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
5654    
5655                    query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
5656    
5657                    if (!getDB().isSupportsInlineDistinct()) {
5658                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
5659                    }
5660    
5661                    if (orderByComparator != null) {
5662                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5663    
5664                            if (orderByConditionFields.length > 0) {
5665                                    query.append(WHERE_AND);
5666                            }
5667    
5668                            for (int i = 0; i < orderByConditionFields.length; i++) {
5669                                    if (getDB().isSupportsInlineDistinct()) {
5670                                            query.append(_ORDER_BY_ENTITY_ALIAS);
5671                                    }
5672                                    else {
5673                                            query.append(_ORDER_BY_ENTITY_TABLE);
5674                                    }
5675    
5676                                    query.append(orderByConditionFields[i]);
5677    
5678                                    if ((i + 1) < orderByConditionFields.length) {
5679                                            if (orderByComparator.isAscending() ^ previous) {
5680                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5681                                            }
5682                                            else {
5683                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5684                                            }
5685                                    }
5686                                    else {
5687                                            if (orderByComparator.isAscending() ^ previous) {
5688                                                    query.append(WHERE_GREATER_THAN);
5689                                            }
5690                                            else {
5691                                                    query.append(WHERE_LESSER_THAN);
5692                                            }
5693                                    }
5694                            }
5695    
5696                            query.append(ORDER_BY_CLAUSE);
5697    
5698                            String[] orderByFields = orderByComparator.getOrderByFields();
5699    
5700                            for (int i = 0; i < orderByFields.length; i++) {
5701                                    if (getDB().isSupportsInlineDistinct()) {
5702                                            query.append(_ORDER_BY_ENTITY_ALIAS);
5703                                    }
5704                                    else {
5705                                            query.append(_ORDER_BY_ENTITY_TABLE);
5706                                    }
5707    
5708                                    query.append(orderByFields[i]);
5709    
5710                                    if ((i + 1) < orderByFields.length) {
5711                                            if (orderByComparator.isAscending() ^ previous) {
5712                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5713                                            }
5714                                            else {
5715                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5716                                            }
5717                                    }
5718                                    else {
5719                                            if (orderByComparator.isAscending() ^ previous) {
5720                                                    query.append(ORDER_BY_ASC);
5721                                            }
5722                                            else {
5723                                                    query.append(ORDER_BY_DESC);
5724                                            }
5725                                    }
5726                            }
5727                    }
5728                    else {
5729                            if (getDB().isSupportsInlineDistinct()) {
5730                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
5731                            }
5732                            else {
5733                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
5734                            }
5735                    }
5736    
5737                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5738                                    BlogsEntry.class.getName(),
5739                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5740    
5741                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
5742    
5743                    q.setFirstResult(0);
5744                    q.setMaxResults(2);
5745    
5746                    if (getDB().isSupportsInlineDistinct()) {
5747                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
5748                    }
5749                    else {
5750                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
5751                    }
5752    
5753                    QueryPos qPos = QueryPos.getInstance(q);
5754    
5755                    qPos.add(groupId);
5756    
5757                    qPos.add(status);
5758    
5759                    if (orderByComparator != null) {
5760                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
5761    
5762                            for (Object value : values) {
5763                                    qPos.add(value);
5764                            }
5765                    }
5766    
5767                    List<BlogsEntry> list = q.list();
5768    
5769                    if (list.size() == 2) {
5770                            return list.get(1);
5771                    }
5772                    else {
5773                            return null;
5774                    }
5775            }
5776    
5777            /**
5778             * Removes all the blogs entries where groupId = &#63; and status &ne; &#63; from the database.
5779             *
5780             * @param groupId the group ID
5781             * @param status the status
5782             */
5783            @Override
5784            public void removeByG_NotS(long groupId, int status) {
5785                    for (BlogsEntry blogsEntry : findByG_NotS(groupId, status,
5786                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
5787                            remove(blogsEntry);
5788                    }
5789            }
5790    
5791            /**
5792             * Returns the number of blogs entries where groupId = &#63; and status &ne; &#63;.
5793             *
5794             * @param groupId the group ID
5795             * @param status the status
5796             * @return the number of matching blogs entries
5797             */
5798            @Override
5799            public int countByG_NotS(long groupId, int status) {
5800                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_NOTS;
5801    
5802                    Object[] finderArgs = new Object[] { groupId, status };
5803    
5804                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
5805    
5806                    if (count == null) {
5807                            StringBundler query = new StringBundler(3);
5808    
5809                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
5810    
5811                            query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
5812    
5813                            query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
5814    
5815                            String sql = query.toString();
5816    
5817                            Session session = null;
5818    
5819                            try {
5820                                    session = openSession();
5821    
5822                                    Query q = session.createQuery(sql);
5823    
5824                                    QueryPos qPos = QueryPos.getInstance(q);
5825    
5826                                    qPos.add(groupId);
5827    
5828                                    qPos.add(status);
5829    
5830                                    count = (Long)q.uniqueResult();
5831    
5832                                    finderCache.putResult(finderPath, finderArgs, count);
5833                            }
5834                            catch (Exception e) {
5835                                    finderCache.removeResult(finderPath, finderArgs);
5836    
5837                                    throw processException(e);
5838                            }
5839                            finally {
5840                                    closeSession(session);
5841                            }
5842                    }
5843    
5844                    return count.intValue();
5845            }
5846    
5847            /**
5848             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and status &ne; &#63;.
5849             *
5850             * @param groupId the group ID
5851             * @param status the status
5852             * @return the number of matching blogs entries that the user has permission to view
5853             */
5854            @Override
5855            public int filterCountByG_NotS(long groupId, int status) {
5856                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5857                            return countByG_NotS(groupId, status);
5858                    }
5859    
5860                    StringBundler query = new StringBundler(3);
5861    
5862                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
5863    
5864                    query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
5865    
5866                    query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
5867    
5868                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5869                                    BlogsEntry.class.getName(),
5870                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5871    
5872                    Session session = null;
5873    
5874                    try {
5875                            session = openSession();
5876    
5877                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
5878    
5879                            q.addScalar(COUNT_COLUMN_NAME,
5880                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
5881    
5882                            QueryPos qPos = QueryPos.getInstance(q);
5883    
5884                            qPos.add(groupId);
5885    
5886                            qPos.add(status);
5887    
5888                            Long count = (Long)q.uniqueResult();
5889    
5890                            return count.intValue();
5891                    }
5892                    catch (Exception e) {
5893                            throw processException(e);
5894                    }
5895                    finally {
5896                            closeSession(session);
5897                    }
5898            }
5899    
5900            private static final String _FINDER_COLUMN_G_NOTS_GROUPID_2 = "blogsEntry.groupId = ? AND ";
5901            private static final String _FINDER_COLUMN_G_NOTS_STATUS_2 = "blogsEntry.status != ?";
5902            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
5903                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
5904                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_U",
5905                            new String[] {
5906                                    Long.class.getName(), Long.class.getName(),
5907                                    
5908                            Integer.class.getName(), Integer.class.getName(),
5909                                    OrderByComparator.class.getName()
5910                            });
5911            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
5912                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
5913                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_U",
5914                            new String[] { Long.class.getName(), Long.class.getName() },
5915                            BlogsEntryModelImpl.COMPANYID_COLUMN_BITMASK |
5916                            BlogsEntryModelImpl.USERID_COLUMN_BITMASK |
5917                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
5918                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
5919            public static final FinderPath FINDER_PATH_COUNT_BY_C_U = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
5920                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
5921                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_U",
5922                            new String[] { Long.class.getName(), Long.class.getName() });
5923    
5924            /**
5925             * Returns all the blogs entries where companyId = &#63; and userId = &#63;.
5926             *
5927             * @param companyId the company ID
5928             * @param userId the user ID
5929             * @return the matching blogs entries
5930             */
5931            @Override
5932            public List<BlogsEntry> findByC_U(long companyId, long userId) {
5933                    return findByC_U(companyId, userId, QueryUtil.ALL_POS,
5934                            QueryUtil.ALL_POS, null);
5935            }
5936    
5937            /**
5938             * Returns a range of all the blogs entries where companyId = &#63; and userId = &#63;.
5939             *
5940             * <p>
5941             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5942             * </p>
5943             *
5944             * @param companyId the company ID
5945             * @param userId the user ID
5946             * @param start the lower bound of the range of blogs entries
5947             * @param end the upper bound of the range of blogs entries (not inclusive)
5948             * @return the range of matching blogs entries
5949             */
5950            @Override
5951            public List<BlogsEntry> findByC_U(long companyId, long userId, int start,
5952                    int end) {
5953                    return findByC_U(companyId, userId, start, end, null);
5954            }
5955    
5956            /**
5957             * Returns an ordered range of all the blogs entries where companyId = &#63; and userId = &#63;.
5958             *
5959             * <p>
5960             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5961             * </p>
5962             *
5963             * @param companyId the company ID
5964             * @param userId the user ID
5965             * @param start the lower bound of the range of blogs entries
5966             * @param end the upper bound of the range of blogs entries (not inclusive)
5967             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5968             * @return the ordered range of matching blogs entries
5969             */
5970            @Override
5971            public List<BlogsEntry> findByC_U(long companyId, long userId, int start,
5972                    int end, OrderByComparator<BlogsEntry> orderByComparator) {
5973                    return findByC_U(companyId, userId, start, end, orderByComparator, true);
5974            }
5975    
5976            /**
5977             * Returns an ordered range of all the blogs entries where companyId = &#63; and userId = &#63;.
5978             *
5979             * <p>
5980             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5981             * </p>
5982             *
5983             * @param companyId the company ID
5984             * @param userId the user ID
5985             * @param start the lower bound of the range of blogs entries
5986             * @param end the upper bound of the range of blogs entries (not inclusive)
5987             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5988             * @param retrieveFromCache whether to retrieve from the finder cache
5989             * @return the ordered range of matching blogs entries
5990             */
5991            @Override
5992            public List<BlogsEntry> findByC_U(long companyId, long userId, int start,
5993                    int end, OrderByComparator<BlogsEntry> orderByComparator,
5994                    boolean retrieveFromCache) {
5995                    boolean pagination = true;
5996                    FinderPath finderPath = null;
5997                    Object[] finderArgs = null;
5998    
5999                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6000                                    (orderByComparator == null)) {
6001                            pagination = false;
6002                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U;
6003                            finderArgs = new Object[] { companyId, userId };
6004                    }
6005                    else {
6006                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U;
6007                            finderArgs = new Object[] {
6008                                            companyId, userId,
6009                                            
6010                                            start, end, orderByComparator
6011                                    };
6012                    }
6013    
6014                    List<BlogsEntry> list = null;
6015    
6016                    if (retrieveFromCache) {
6017                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
6018                                            finderArgs, this);
6019    
6020                            if ((list != null) && !list.isEmpty()) {
6021                                    for (BlogsEntry blogsEntry : list) {
6022                                            if ((companyId != blogsEntry.getCompanyId()) ||
6023                                                            (userId != blogsEntry.getUserId())) {
6024                                                    list = null;
6025    
6026                                                    break;
6027                                            }
6028                                    }
6029                            }
6030                    }
6031    
6032                    if (list == null) {
6033                            StringBundler query = null;
6034    
6035                            if (orderByComparator != null) {
6036                                    query = new StringBundler(4 +
6037                                                    (orderByComparator.getOrderByFields().length * 2));
6038                            }
6039                            else {
6040                                    query = new StringBundler(4);
6041                            }
6042    
6043                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
6044    
6045                            query.append(_FINDER_COLUMN_C_U_COMPANYID_2);
6046    
6047                            query.append(_FINDER_COLUMN_C_U_USERID_2);
6048    
6049                            if (orderByComparator != null) {
6050                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6051                                            orderByComparator);
6052                            }
6053                            else
6054                             if (pagination) {
6055                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
6056                            }
6057    
6058                            String sql = query.toString();
6059    
6060                            Session session = null;
6061    
6062                            try {
6063                                    session = openSession();
6064    
6065                                    Query q = session.createQuery(sql);
6066    
6067                                    QueryPos qPos = QueryPos.getInstance(q);
6068    
6069                                    qPos.add(companyId);
6070    
6071                                    qPos.add(userId);
6072    
6073                                    if (!pagination) {
6074                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
6075                                                            start, end, false);
6076    
6077                                            Collections.sort(list);
6078    
6079                                            list = Collections.unmodifiableList(list);
6080                                    }
6081                                    else {
6082                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
6083                                                            start, end);
6084                                    }
6085    
6086                                    cacheResult(list);
6087    
6088                                    finderCache.putResult(finderPath, finderArgs, list);
6089                            }
6090                            catch (Exception e) {
6091                                    finderCache.removeResult(finderPath, finderArgs);
6092    
6093                                    throw processException(e);
6094                            }
6095                            finally {
6096                                    closeSession(session);
6097                            }
6098                    }
6099    
6100                    return list;
6101            }
6102    
6103            /**
6104             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63;.
6105             *
6106             * @param companyId the company ID
6107             * @param userId the user ID
6108             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6109             * @return the first matching blogs entry
6110             * @throws NoSuchEntryException if a matching blogs entry could not be found
6111             */
6112            @Override
6113            public BlogsEntry findByC_U_First(long companyId, long userId,
6114                    OrderByComparator<BlogsEntry> orderByComparator)
6115                    throws NoSuchEntryException {
6116                    BlogsEntry blogsEntry = fetchByC_U_First(companyId, userId,
6117                                    orderByComparator);
6118    
6119                    if (blogsEntry != null) {
6120                            return blogsEntry;
6121                    }
6122    
6123                    StringBundler msg = new StringBundler(6);
6124    
6125                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6126    
6127                    msg.append("companyId=");
6128                    msg.append(companyId);
6129    
6130                    msg.append(", userId=");
6131                    msg.append(userId);
6132    
6133                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6134    
6135                    throw new NoSuchEntryException(msg.toString());
6136            }
6137    
6138            /**
6139             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63;.
6140             *
6141             * @param companyId the company ID
6142             * @param userId the user ID
6143             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6144             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
6145             */
6146            @Override
6147            public BlogsEntry fetchByC_U_First(long companyId, long userId,
6148                    OrderByComparator<BlogsEntry> orderByComparator) {
6149                    List<BlogsEntry> list = findByC_U(companyId, userId, 0, 1,
6150                                    orderByComparator);
6151    
6152                    if (!list.isEmpty()) {
6153                            return list.get(0);
6154                    }
6155    
6156                    return null;
6157            }
6158    
6159            /**
6160             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63;.
6161             *
6162             * @param companyId the company ID
6163             * @param userId the user ID
6164             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6165             * @return the last matching blogs entry
6166             * @throws NoSuchEntryException if a matching blogs entry could not be found
6167             */
6168            @Override
6169            public BlogsEntry findByC_U_Last(long companyId, long userId,
6170                    OrderByComparator<BlogsEntry> orderByComparator)
6171                    throws NoSuchEntryException {
6172                    BlogsEntry blogsEntry = fetchByC_U_Last(companyId, userId,
6173                                    orderByComparator);
6174    
6175                    if (blogsEntry != null) {
6176                            return blogsEntry;
6177                    }
6178    
6179                    StringBundler msg = new StringBundler(6);
6180    
6181                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6182    
6183                    msg.append("companyId=");
6184                    msg.append(companyId);
6185    
6186                    msg.append(", userId=");
6187                    msg.append(userId);
6188    
6189                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6190    
6191                    throw new NoSuchEntryException(msg.toString());
6192            }
6193    
6194            /**
6195             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63;.
6196             *
6197             * @param companyId the company ID
6198             * @param userId the user ID
6199             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6200             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
6201             */
6202            @Override
6203            public BlogsEntry fetchByC_U_Last(long companyId, long userId,
6204                    OrderByComparator<BlogsEntry> orderByComparator) {
6205                    int count = countByC_U(companyId, userId);
6206    
6207                    if (count == 0) {
6208                            return null;
6209                    }
6210    
6211                    List<BlogsEntry> list = findByC_U(companyId, userId, count - 1, count,
6212                                    orderByComparator);
6213    
6214                    if (!list.isEmpty()) {
6215                            return list.get(0);
6216                    }
6217    
6218                    return null;
6219            }
6220    
6221            /**
6222             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63; and userId = &#63;.
6223             *
6224             * @param entryId the primary key of the current blogs entry
6225             * @param companyId the company ID
6226             * @param userId the user ID
6227             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6228             * @return the previous, current, and next blogs entry
6229             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
6230             */
6231            @Override
6232            public BlogsEntry[] findByC_U_PrevAndNext(long entryId, long companyId,
6233                    long userId, OrderByComparator<BlogsEntry> orderByComparator)
6234                    throws NoSuchEntryException {
6235                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
6236    
6237                    Session session = null;
6238    
6239                    try {
6240                            session = openSession();
6241    
6242                            BlogsEntry[] array = new BlogsEntryImpl[3];
6243    
6244                            array[0] = getByC_U_PrevAndNext(session, blogsEntry, companyId,
6245                                            userId, orderByComparator, true);
6246    
6247                            array[1] = blogsEntry;
6248    
6249                            array[2] = getByC_U_PrevAndNext(session, blogsEntry, companyId,
6250                                            userId, orderByComparator, false);
6251    
6252                            return array;
6253                    }
6254                    catch (Exception e) {
6255                            throw processException(e);
6256                    }
6257                    finally {
6258                            closeSession(session);
6259                    }
6260            }
6261    
6262            protected BlogsEntry getByC_U_PrevAndNext(Session session,
6263                    BlogsEntry blogsEntry, long companyId, long userId,
6264                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
6265                    StringBundler query = null;
6266    
6267                    if (orderByComparator != null) {
6268                            query = new StringBundler(5 +
6269                                            (orderByComparator.getOrderByConditionFields().length * 3) +
6270                                            (orderByComparator.getOrderByFields().length * 3));
6271                    }
6272                    else {
6273                            query = new StringBundler(4);
6274                    }
6275    
6276                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
6277    
6278                    query.append(_FINDER_COLUMN_C_U_COMPANYID_2);
6279    
6280                    query.append(_FINDER_COLUMN_C_U_USERID_2);
6281    
6282                    if (orderByComparator != null) {
6283                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6284    
6285                            if (orderByConditionFields.length > 0) {
6286                                    query.append(WHERE_AND);
6287                            }
6288    
6289                            for (int i = 0; i < orderByConditionFields.length; i++) {
6290                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6291                                    query.append(orderByConditionFields[i]);
6292    
6293                                    if ((i + 1) < orderByConditionFields.length) {
6294                                            if (orderByComparator.isAscending() ^ previous) {
6295                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6296                                            }
6297                                            else {
6298                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6299                                            }
6300                                    }
6301                                    else {
6302                                            if (orderByComparator.isAscending() ^ previous) {
6303                                                    query.append(WHERE_GREATER_THAN);
6304                                            }
6305                                            else {
6306                                                    query.append(WHERE_LESSER_THAN);
6307                                            }
6308                                    }
6309                            }
6310    
6311                            query.append(ORDER_BY_CLAUSE);
6312    
6313                            String[] orderByFields = orderByComparator.getOrderByFields();
6314    
6315                            for (int i = 0; i < orderByFields.length; i++) {
6316                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6317                                    query.append(orderByFields[i]);
6318    
6319                                    if ((i + 1) < orderByFields.length) {
6320                                            if (orderByComparator.isAscending() ^ previous) {
6321                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6322                                            }
6323                                            else {
6324                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6325                                            }
6326                                    }
6327                                    else {
6328                                            if (orderByComparator.isAscending() ^ previous) {
6329                                                    query.append(ORDER_BY_ASC);
6330                                            }
6331                                            else {
6332                                                    query.append(ORDER_BY_DESC);
6333                                            }
6334                                    }
6335                            }
6336                    }
6337                    else {
6338                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
6339                    }
6340    
6341                    String sql = query.toString();
6342    
6343                    Query q = session.createQuery(sql);
6344    
6345                    q.setFirstResult(0);
6346                    q.setMaxResults(2);
6347    
6348                    QueryPos qPos = QueryPos.getInstance(q);
6349    
6350                    qPos.add(companyId);
6351    
6352                    qPos.add(userId);
6353    
6354                    if (orderByComparator != null) {
6355                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
6356    
6357                            for (Object value : values) {
6358                                    qPos.add(value);
6359                            }
6360                    }
6361    
6362                    List<BlogsEntry> list = q.list();
6363    
6364                    if (list.size() == 2) {
6365                            return list.get(1);
6366                    }
6367                    else {
6368                            return null;
6369                    }
6370            }
6371    
6372            /**
6373             * Removes all the blogs entries where companyId = &#63; and userId = &#63; from the database.
6374             *
6375             * @param companyId the company ID
6376             * @param userId the user ID
6377             */
6378            @Override
6379            public void removeByC_U(long companyId, long userId) {
6380                    for (BlogsEntry blogsEntry : findByC_U(companyId, userId,
6381                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
6382                            remove(blogsEntry);
6383                    }
6384            }
6385    
6386            /**
6387             * Returns the number of blogs entries where companyId = &#63; and userId = &#63;.
6388             *
6389             * @param companyId the company ID
6390             * @param userId the user ID
6391             * @return the number of matching blogs entries
6392             */
6393            @Override
6394            public int countByC_U(long companyId, long userId) {
6395                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_U;
6396    
6397                    Object[] finderArgs = new Object[] { companyId, userId };
6398    
6399                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
6400    
6401                    if (count == null) {
6402                            StringBundler query = new StringBundler(3);
6403    
6404                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
6405    
6406                            query.append(_FINDER_COLUMN_C_U_COMPANYID_2);
6407    
6408                            query.append(_FINDER_COLUMN_C_U_USERID_2);
6409    
6410                            String sql = query.toString();
6411    
6412                            Session session = null;
6413    
6414                            try {
6415                                    session = openSession();
6416    
6417                                    Query q = session.createQuery(sql);
6418    
6419                                    QueryPos qPos = QueryPos.getInstance(q);
6420    
6421                                    qPos.add(companyId);
6422    
6423                                    qPos.add(userId);
6424    
6425                                    count = (Long)q.uniqueResult();
6426    
6427                                    finderCache.putResult(finderPath, finderArgs, count);
6428                            }
6429                            catch (Exception e) {
6430                                    finderCache.removeResult(finderPath, finderArgs);
6431    
6432                                    throw processException(e);
6433                            }
6434                            finally {
6435                                    closeSession(session);
6436                            }
6437                    }
6438    
6439                    return count.intValue();
6440            }
6441    
6442            private static final String _FINDER_COLUMN_C_U_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
6443            private static final String _FINDER_COLUMN_C_U_USERID_2 = "blogsEntry.userId = ?";
6444            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
6445                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
6446                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_LtD",
6447                            new String[] {
6448                                    Long.class.getName(), Date.class.getName(),
6449                                    
6450                            Integer.class.getName(), Integer.class.getName(),
6451                                    OrderByComparator.class.getName()
6452                            });
6453            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
6454                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
6455                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_LtD",
6456                            new String[] { Long.class.getName(), Date.class.getName() });
6457    
6458            /**
6459             * Returns all the blogs entries where companyId = &#63; and displayDate &lt; &#63;.
6460             *
6461             * @param companyId the company ID
6462             * @param displayDate the display date
6463             * @return the matching blogs entries
6464             */
6465            @Override
6466            public List<BlogsEntry> findByC_LtD(long companyId, Date displayDate) {
6467                    return findByC_LtD(companyId, displayDate, QueryUtil.ALL_POS,
6468                            QueryUtil.ALL_POS, null);
6469            }
6470    
6471            /**
6472             * Returns a range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63;.
6473             *
6474             * <p>
6475             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6476             * </p>
6477             *
6478             * @param companyId the company ID
6479             * @param displayDate the display date
6480             * @param start the lower bound of the range of blogs entries
6481             * @param end the upper bound of the range of blogs entries (not inclusive)
6482             * @return the range of matching blogs entries
6483             */
6484            @Override
6485            public List<BlogsEntry> findByC_LtD(long companyId, Date displayDate,
6486                    int start, int end) {
6487                    return findByC_LtD(companyId, displayDate, start, end, null);
6488            }
6489    
6490            /**
6491             * Returns an ordered range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63;.
6492             *
6493             * <p>
6494             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6495             * </p>
6496             *
6497             * @param companyId the company ID
6498             * @param displayDate the display date
6499             * @param start the lower bound of the range of blogs entries
6500             * @param end the upper bound of the range of blogs entries (not inclusive)
6501             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6502             * @return the ordered range of matching blogs entries
6503             */
6504            @Override
6505            public List<BlogsEntry> findByC_LtD(long companyId, Date displayDate,
6506                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator) {
6507                    return findByC_LtD(companyId, displayDate, start, end,
6508                            orderByComparator, true);
6509            }
6510    
6511            /**
6512             * Returns an ordered range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63;.
6513             *
6514             * <p>
6515             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6516             * </p>
6517             *
6518             * @param companyId the company ID
6519             * @param displayDate the display date
6520             * @param start the lower bound of the range of blogs entries
6521             * @param end the upper bound of the range of blogs entries (not inclusive)
6522             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6523             * @param retrieveFromCache whether to retrieve from the finder cache
6524             * @return the ordered range of matching blogs entries
6525             */
6526            @Override
6527            public List<BlogsEntry> findByC_LtD(long companyId, Date displayDate,
6528                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator,
6529                    boolean retrieveFromCache) {
6530                    boolean pagination = true;
6531                    FinderPath finderPath = null;
6532                    Object[] finderArgs = null;
6533    
6534                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD;
6535                    finderArgs = new Object[] {
6536                                    companyId, displayDate,
6537                                    
6538                                    start, end, orderByComparator
6539                            };
6540    
6541                    List<BlogsEntry> list = null;
6542    
6543                    if (retrieveFromCache) {
6544                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
6545                                            finderArgs, this);
6546    
6547                            if ((list != null) && !list.isEmpty()) {
6548                                    for (BlogsEntry blogsEntry : list) {
6549                                            if ((companyId != blogsEntry.getCompanyId()) ||
6550                                                            (displayDate.getTime() <= blogsEntry.getDisplayDate()
6551                                                                                                                                            .getTime())) {
6552                                                    list = null;
6553    
6554                                                    break;
6555                                            }
6556                                    }
6557                            }
6558                    }
6559    
6560                    if (list == null) {
6561                            StringBundler query = null;
6562    
6563                            if (orderByComparator != null) {
6564                                    query = new StringBundler(4 +
6565                                                    (orderByComparator.getOrderByFields().length * 2));
6566                            }
6567                            else {
6568                                    query = new StringBundler(4);
6569                            }
6570    
6571                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
6572    
6573                            query.append(_FINDER_COLUMN_C_LTD_COMPANYID_2);
6574    
6575                            boolean bindDisplayDate = false;
6576    
6577                            if (displayDate == null) {
6578                                    query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_1);
6579                            }
6580                            else {
6581                                    bindDisplayDate = true;
6582    
6583                                    query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_2);
6584                            }
6585    
6586                            if (orderByComparator != null) {
6587                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6588                                            orderByComparator);
6589                            }
6590                            else
6591                             if (pagination) {
6592                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
6593                            }
6594    
6595                            String sql = query.toString();
6596    
6597                            Session session = null;
6598    
6599                            try {
6600                                    session = openSession();
6601    
6602                                    Query q = session.createQuery(sql);
6603    
6604                                    QueryPos qPos = QueryPos.getInstance(q);
6605    
6606                                    qPos.add(companyId);
6607    
6608                                    if (bindDisplayDate) {
6609                                            qPos.add(new Timestamp(displayDate.getTime()));
6610                                    }
6611    
6612                                    if (!pagination) {
6613                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
6614                                                            start, end, false);
6615    
6616                                            Collections.sort(list);
6617    
6618                                            list = Collections.unmodifiableList(list);
6619                                    }
6620                                    else {
6621                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
6622                                                            start, end);
6623                                    }
6624    
6625                                    cacheResult(list);
6626    
6627                                    finderCache.putResult(finderPath, finderArgs, list);
6628                            }
6629                            catch (Exception e) {
6630                                    finderCache.removeResult(finderPath, finderArgs);
6631    
6632                                    throw processException(e);
6633                            }
6634                            finally {
6635                                    closeSession(session);
6636                            }
6637                    }
6638    
6639                    return list;
6640            }
6641    
6642            /**
6643             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63;.
6644             *
6645             * @param companyId the company ID
6646             * @param displayDate the display date
6647             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6648             * @return the first matching blogs entry
6649             * @throws NoSuchEntryException if a matching blogs entry could not be found
6650             */
6651            @Override
6652            public BlogsEntry findByC_LtD_First(long companyId, Date displayDate,
6653                    OrderByComparator<BlogsEntry> orderByComparator)
6654                    throws NoSuchEntryException {
6655                    BlogsEntry blogsEntry = fetchByC_LtD_First(companyId, displayDate,
6656                                    orderByComparator);
6657    
6658                    if (blogsEntry != null) {
6659                            return blogsEntry;
6660                    }
6661    
6662                    StringBundler msg = new StringBundler(6);
6663    
6664                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6665    
6666                    msg.append("companyId=");
6667                    msg.append(companyId);
6668    
6669                    msg.append(", displayDate=");
6670                    msg.append(displayDate);
6671    
6672                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6673    
6674                    throw new NoSuchEntryException(msg.toString());
6675            }
6676    
6677            /**
6678             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63;.
6679             *
6680             * @param companyId the company ID
6681             * @param displayDate the display date
6682             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6683             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
6684             */
6685            @Override
6686            public BlogsEntry fetchByC_LtD_First(long companyId, Date displayDate,
6687                    OrderByComparator<BlogsEntry> orderByComparator) {
6688                    List<BlogsEntry> list = findByC_LtD(companyId, displayDate, 0, 1,
6689                                    orderByComparator);
6690    
6691                    if (!list.isEmpty()) {
6692                            return list.get(0);
6693                    }
6694    
6695                    return null;
6696            }
6697    
6698            /**
6699             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63;.
6700             *
6701             * @param companyId the company ID
6702             * @param displayDate the display date
6703             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6704             * @return the last matching blogs entry
6705             * @throws NoSuchEntryException if a matching blogs entry could not be found
6706             */
6707            @Override
6708            public BlogsEntry findByC_LtD_Last(long companyId, Date displayDate,
6709                    OrderByComparator<BlogsEntry> orderByComparator)
6710                    throws NoSuchEntryException {
6711                    BlogsEntry blogsEntry = fetchByC_LtD_Last(companyId, displayDate,
6712                                    orderByComparator);
6713    
6714                    if (blogsEntry != null) {
6715                            return blogsEntry;
6716                    }
6717    
6718                    StringBundler msg = new StringBundler(6);
6719    
6720                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6721    
6722                    msg.append("companyId=");
6723                    msg.append(companyId);
6724    
6725                    msg.append(", displayDate=");
6726                    msg.append(displayDate);
6727    
6728                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6729    
6730                    throw new NoSuchEntryException(msg.toString());
6731            }
6732    
6733            /**
6734             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63;.
6735             *
6736             * @param companyId the company ID
6737             * @param displayDate the display date
6738             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6739             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
6740             */
6741            @Override
6742            public BlogsEntry fetchByC_LtD_Last(long companyId, Date displayDate,
6743                    OrderByComparator<BlogsEntry> orderByComparator) {
6744                    int count = countByC_LtD(companyId, displayDate);
6745    
6746                    if (count == 0) {
6747                            return null;
6748                    }
6749    
6750                    List<BlogsEntry> list = findByC_LtD(companyId, displayDate, count - 1,
6751                                    count, orderByComparator);
6752    
6753                    if (!list.isEmpty()) {
6754                            return list.get(0);
6755                    }
6756    
6757                    return null;
6758            }
6759    
6760            /**
6761             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63;.
6762             *
6763             * @param entryId the primary key of the current blogs entry
6764             * @param companyId the company ID
6765             * @param displayDate the display date
6766             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6767             * @return the previous, current, and next blogs entry
6768             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
6769             */
6770            @Override
6771            public BlogsEntry[] findByC_LtD_PrevAndNext(long entryId, long companyId,
6772                    Date displayDate, OrderByComparator<BlogsEntry> orderByComparator)
6773                    throws NoSuchEntryException {
6774                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
6775    
6776                    Session session = null;
6777    
6778                    try {
6779                            session = openSession();
6780    
6781                            BlogsEntry[] array = new BlogsEntryImpl[3];
6782    
6783                            array[0] = getByC_LtD_PrevAndNext(session, blogsEntry, companyId,
6784                                            displayDate, orderByComparator, true);
6785    
6786                            array[1] = blogsEntry;
6787    
6788                            array[2] = getByC_LtD_PrevAndNext(session, blogsEntry, companyId,
6789                                            displayDate, orderByComparator, false);
6790    
6791                            return array;
6792                    }
6793                    catch (Exception e) {
6794                            throw processException(e);
6795                    }
6796                    finally {
6797                            closeSession(session);
6798                    }
6799            }
6800    
6801            protected BlogsEntry getByC_LtD_PrevAndNext(Session session,
6802                    BlogsEntry blogsEntry, long companyId, Date displayDate,
6803                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
6804                    StringBundler query = null;
6805    
6806                    if (orderByComparator != null) {
6807                            query = new StringBundler(5 +
6808                                            (orderByComparator.getOrderByConditionFields().length * 3) +
6809                                            (orderByComparator.getOrderByFields().length * 3));
6810                    }
6811                    else {
6812                            query = new StringBundler(4);
6813                    }
6814    
6815                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
6816    
6817                    query.append(_FINDER_COLUMN_C_LTD_COMPANYID_2);
6818    
6819                    boolean bindDisplayDate = false;
6820    
6821                    if (displayDate == null) {
6822                            query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_1);
6823                    }
6824                    else {
6825                            bindDisplayDate = true;
6826    
6827                            query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_2);
6828                    }
6829    
6830                    if (orderByComparator != null) {
6831                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6832    
6833                            if (orderByConditionFields.length > 0) {
6834                                    query.append(WHERE_AND);
6835                            }
6836    
6837                            for (int i = 0; i < orderByConditionFields.length; i++) {
6838                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6839                                    query.append(orderByConditionFields[i]);
6840    
6841                                    if ((i + 1) < orderByConditionFields.length) {
6842                                            if (orderByComparator.isAscending() ^ previous) {
6843                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6844                                            }
6845                                            else {
6846                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6847                                            }
6848                                    }
6849                                    else {
6850                                            if (orderByComparator.isAscending() ^ previous) {
6851                                                    query.append(WHERE_GREATER_THAN);
6852                                            }
6853                                            else {
6854                                                    query.append(WHERE_LESSER_THAN);
6855                                            }
6856                                    }
6857                            }
6858    
6859                            query.append(ORDER_BY_CLAUSE);
6860    
6861                            String[] orderByFields = orderByComparator.getOrderByFields();
6862    
6863                            for (int i = 0; i < orderByFields.length; i++) {
6864                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6865                                    query.append(orderByFields[i]);
6866    
6867                                    if ((i + 1) < orderByFields.length) {
6868                                            if (orderByComparator.isAscending() ^ previous) {
6869                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6870                                            }
6871                                            else {
6872                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6873                                            }
6874                                    }
6875                                    else {
6876                                            if (orderByComparator.isAscending() ^ previous) {
6877                                                    query.append(ORDER_BY_ASC);
6878                                            }
6879                                            else {
6880                                                    query.append(ORDER_BY_DESC);
6881                                            }
6882                                    }
6883                            }
6884                    }
6885                    else {
6886                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
6887                    }
6888    
6889                    String sql = query.toString();
6890    
6891                    Query q = session.createQuery(sql);
6892    
6893                    q.setFirstResult(0);
6894                    q.setMaxResults(2);
6895    
6896                    QueryPos qPos = QueryPos.getInstance(q);
6897    
6898                    qPos.add(companyId);
6899    
6900                    if (bindDisplayDate) {
6901                            qPos.add(new Timestamp(displayDate.getTime()));
6902                    }
6903    
6904                    if (orderByComparator != null) {
6905                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
6906    
6907                            for (Object value : values) {
6908                                    qPos.add(value);
6909                            }
6910                    }
6911    
6912                    List<BlogsEntry> list = q.list();
6913    
6914                    if (list.size() == 2) {
6915                            return list.get(1);
6916                    }
6917                    else {
6918                            return null;
6919                    }
6920            }
6921    
6922            /**
6923             * Removes all the blogs entries where companyId = &#63; and displayDate &lt; &#63; from the database.
6924             *
6925             * @param companyId the company ID
6926             * @param displayDate the display date
6927             */
6928            @Override
6929            public void removeByC_LtD(long companyId, Date displayDate) {
6930                    for (BlogsEntry blogsEntry : findByC_LtD(companyId, displayDate,
6931                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
6932                            remove(blogsEntry);
6933                    }
6934            }
6935    
6936            /**
6937             * Returns the number of blogs entries where companyId = &#63; and displayDate &lt; &#63;.
6938             *
6939             * @param companyId the company ID
6940             * @param displayDate the display date
6941             * @return the number of matching blogs entries
6942             */
6943            @Override
6944            public int countByC_LtD(long companyId, Date displayDate) {
6945                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD;
6946    
6947                    Object[] finderArgs = new Object[] { companyId, displayDate };
6948    
6949                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
6950    
6951                    if (count == null) {
6952                            StringBundler query = new StringBundler(3);
6953    
6954                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
6955    
6956                            query.append(_FINDER_COLUMN_C_LTD_COMPANYID_2);
6957    
6958                            boolean bindDisplayDate = false;
6959    
6960                            if (displayDate == null) {
6961                                    query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_1);
6962                            }
6963                            else {
6964                                    bindDisplayDate = true;
6965    
6966                                    query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_2);
6967                            }
6968    
6969                            String sql = query.toString();
6970    
6971                            Session session = null;
6972    
6973                            try {
6974                                    session = openSession();
6975    
6976                                    Query q = session.createQuery(sql);
6977    
6978                                    QueryPos qPos = QueryPos.getInstance(q);
6979    
6980                                    qPos.add(companyId);
6981    
6982                                    if (bindDisplayDate) {
6983                                            qPos.add(new Timestamp(displayDate.getTime()));
6984                                    }
6985    
6986                                    count = (Long)q.uniqueResult();
6987    
6988                                    finderCache.putResult(finderPath, finderArgs, count);
6989                            }
6990                            catch (Exception e) {
6991                                    finderCache.removeResult(finderPath, finderArgs);
6992    
6993                                    throw processException(e);
6994                            }
6995                            finally {
6996                                    closeSession(session);
6997                            }
6998                    }
6999    
7000                    return count.intValue();
7001            }
7002    
7003            private static final String _FINDER_COLUMN_C_LTD_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
7004            private static final String _FINDER_COLUMN_C_LTD_DISPLAYDATE_1 = "blogsEntry.displayDate IS NULL";
7005            private static final String _FINDER_COLUMN_C_LTD_DISPLAYDATE_2 = "blogsEntry.displayDate < ?";
7006            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
7007                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
7008                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_S",
7009                            new String[] {
7010                                    Long.class.getName(), Integer.class.getName(),
7011                                    
7012                            Integer.class.getName(), Integer.class.getName(),
7013                                    OrderByComparator.class.getName()
7014                            });
7015            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
7016                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
7017                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_S",
7018                            new String[] { Long.class.getName(), Integer.class.getName() },
7019                            BlogsEntryModelImpl.COMPANYID_COLUMN_BITMASK |
7020                            BlogsEntryModelImpl.STATUS_COLUMN_BITMASK |
7021                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
7022                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
7023            public static final FinderPath FINDER_PATH_COUNT_BY_C_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
7024                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
7025                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_S",
7026                            new String[] { Long.class.getName(), Integer.class.getName() });
7027    
7028            /**
7029             * Returns all the blogs entries where companyId = &#63; and status = &#63;.
7030             *
7031             * @param companyId the company ID
7032             * @param status the status
7033             * @return the matching blogs entries
7034             */
7035            @Override
7036            public List<BlogsEntry> findByC_S(long companyId, int status) {
7037                    return findByC_S(companyId, status, QueryUtil.ALL_POS,
7038                            QueryUtil.ALL_POS, null);
7039            }
7040    
7041            /**
7042             * Returns a range of all the blogs entries where companyId = &#63; and status = &#63;.
7043             *
7044             * <p>
7045             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7046             * </p>
7047             *
7048             * @param companyId the company ID
7049             * @param status the status
7050             * @param start the lower bound of the range of blogs entries
7051             * @param end the upper bound of the range of blogs entries (not inclusive)
7052             * @return the range of matching blogs entries
7053             */
7054            @Override
7055            public List<BlogsEntry> findByC_S(long companyId, int status, int start,
7056                    int end) {
7057                    return findByC_S(companyId, status, start, end, null);
7058            }
7059    
7060            /**
7061             * Returns an ordered range of all the blogs entries where companyId = &#63; and status = &#63;.
7062             *
7063             * <p>
7064             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7065             * </p>
7066             *
7067             * @param companyId the company ID
7068             * @param status the status
7069             * @param start the lower bound of the range of blogs entries
7070             * @param end the upper bound of the range of blogs entries (not inclusive)
7071             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7072             * @return the ordered range of matching blogs entries
7073             */
7074            @Override
7075            public List<BlogsEntry> findByC_S(long companyId, int status, int start,
7076                    int end, OrderByComparator<BlogsEntry> orderByComparator) {
7077                    return findByC_S(companyId, status, start, end, orderByComparator, true);
7078            }
7079    
7080            /**
7081             * Returns an ordered range of all the blogs entries where companyId = &#63; and status = &#63;.
7082             *
7083             * <p>
7084             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7085             * </p>
7086             *
7087             * @param companyId the company ID
7088             * @param status the status
7089             * @param start the lower bound of the range of blogs entries
7090             * @param end the upper bound of the range of blogs entries (not inclusive)
7091             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7092             * @param retrieveFromCache whether to retrieve from the finder cache
7093             * @return the ordered range of matching blogs entries
7094             */
7095            @Override
7096            public List<BlogsEntry> findByC_S(long companyId, int status, int start,
7097                    int end, OrderByComparator<BlogsEntry> orderByComparator,
7098                    boolean retrieveFromCache) {
7099                    boolean pagination = true;
7100                    FinderPath finderPath = null;
7101                    Object[] finderArgs = null;
7102    
7103                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
7104                                    (orderByComparator == null)) {
7105                            pagination = false;
7106                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S;
7107                            finderArgs = new Object[] { companyId, status };
7108                    }
7109                    else {
7110                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_S;
7111                            finderArgs = new Object[] {
7112                                            companyId, status,
7113                                            
7114                                            start, end, orderByComparator
7115                                    };
7116                    }
7117    
7118                    List<BlogsEntry> list = null;
7119    
7120                    if (retrieveFromCache) {
7121                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
7122                                            finderArgs, this);
7123    
7124                            if ((list != null) && !list.isEmpty()) {
7125                                    for (BlogsEntry blogsEntry : list) {
7126                                            if ((companyId != blogsEntry.getCompanyId()) ||
7127                                                            (status != blogsEntry.getStatus())) {
7128                                                    list = null;
7129    
7130                                                    break;
7131                                            }
7132                                    }
7133                            }
7134                    }
7135    
7136                    if (list == null) {
7137                            StringBundler query = null;
7138    
7139                            if (orderByComparator != null) {
7140                                    query = new StringBundler(4 +
7141                                                    (orderByComparator.getOrderByFields().length * 2));
7142                            }
7143                            else {
7144                                    query = new StringBundler(4);
7145                            }
7146    
7147                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
7148    
7149                            query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
7150    
7151                            query.append(_FINDER_COLUMN_C_S_STATUS_2);
7152    
7153                            if (orderByComparator != null) {
7154                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7155                                            orderByComparator);
7156                            }
7157                            else
7158                             if (pagination) {
7159                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
7160                            }
7161    
7162                            String sql = query.toString();
7163    
7164                            Session session = null;
7165    
7166                            try {
7167                                    session = openSession();
7168    
7169                                    Query q = session.createQuery(sql);
7170    
7171                                    QueryPos qPos = QueryPos.getInstance(q);
7172    
7173                                    qPos.add(companyId);
7174    
7175                                    qPos.add(status);
7176    
7177                                    if (!pagination) {
7178                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
7179                                                            start, end, false);
7180    
7181                                            Collections.sort(list);
7182    
7183                                            list = Collections.unmodifiableList(list);
7184                                    }
7185                                    else {
7186                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
7187                                                            start, end);
7188                                    }
7189    
7190                                    cacheResult(list);
7191    
7192                                    finderCache.putResult(finderPath, finderArgs, list);
7193                            }
7194                            catch (Exception e) {
7195                                    finderCache.removeResult(finderPath, finderArgs);
7196    
7197                                    throw processException(e);
7198                            }
7199                            finally {
7200                                    closeSession(session);
7201                            }
7202                    }
7203    
7204                    return list;
7205            }
7206    
7207            /**
7208             * Returns the first blogs entry in the ordered set where companyId = &#63; and status = &#63;.
7209             *
7210             * @param companyId the company ID
7211             * @param status the status
7212             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7213             * @return the first matching blogs entry
7214             * @throws NoSuchEntryException if a matching blogs entry could not be found
7215             */
7216            @Override
7217            public BlogsEntry findByC_S_First(long companyId, int status,
7218                    OrderByComparator<BlogsEntry> orderByComparator)
7219                    throws NoSuchEntryException {
7220                    BlogsEntry blogsEntry = fetchByC_S_First(companyId, status,
7221                                    orderByComparator);
7222    
7223                    if (blogsEntry != null) {
7224                            return blogsEntry;
7225                    }
7226    
7227                    StringBundler msg = new StringBundler(6);
7228    
7229                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7230    
7231                    msg.append("companyId=");
7232                    msg.append(companyId);
7233    
7234                    msg.append(", status=");
7235                    msg.append(status);
7236    
7237                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7238    
7239                    throw new NoSuchEntryException(msg.toString());
7240            }
7241    
7242            /**
7243             * Returns the first blogs entry in the ordered set where companyId = &#63; and status = &#63;.
7244             *
7245             * @param companyId the company ID
7246             * @param status the status
7247             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7248             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
7249             */
7250            @Override
7251            public BlogsEntry fetchByC_S_First(long companyId, int status,
7252                    OrderByComparator<BlogsEntry> orderByComparator) {
7253                    List<BlogsEntry> list = findByC_S(companyId, status, 0, 1,
7254                                    orderByComparator);
7255    
7256                    if (!list.isEmpty()) {
7257                            return list.get(0);
7258                    }
7259    
7260                    return null;
7261            }
7262    
7263            /**
7264             * Returns the last blogs entry in the ordered set where companyId = &#63; and status = &#63;.
7265             *
7266             * @param companyId the company ID
7267             * @param status the status
7268             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7269             * @return the last matching blogs entry
7270             * @throws NoSuchEntryException if a matching blogs entry could not be found
7271             */
7272            @Override
7273            public BlogsEntry findByC_S_Last(long companyId, int status,
7274                    OrderByComparator<BlogsEntry> orderByComparator)
7275                    throws NoSuchEntryException {
7276                    BlogsEntry blogsEntry = fetchByC_S_Last(companyId, status,
7277                                    orderByComparator);
7278    
7279                    if (blogsEntry != null) {
7280                            return blogsEntry;
7281                    }
7282    
7283                    StringBundler msg = new StringBundler(6);
7284    
7285                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7286    
7287                    msg.append("companyId=");
7288                    msg.append(companyId);
7289    
7290                    msg.append(", status=");
7291                    msg.append(status);
7292    
7293                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7294    
7295                    throw new NoSuchEntryException(msg.toString());
7296            }
7297    
7298            /**
7299             * Returns the last blogs entry in the ordered set where companyId = &#63; and status = &#63;.
7300             *
7301             * @param companyId the company ID
7302             * @param status the status
7303             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7304             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
7305             */
7306            @Override
7307            public BlogsEntry fetchByC_S_Last(long companyId, int status,
7308                    OrderByComparator<BlogsEntry> orderByComparator) {
7309                    int count = countByC_S(companyId, status);
7310    
7311                    if (count == 0) {
7312                            return null;
7313                    }
7314    
7315                    List<BlogsEntry> list = findByC_S(companyId, status, count - 1, count,
7316                                    orderByComparator);
7317    
7318                    if (!list.isEmpty()) {
7319                            return list.get(0);
7320                    }
7321    
7322                    return null;
7323            }
7324    
7325            /**
7326             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63; and status = &#63;.
7327             *
7328             * @param entryId the primary key of the current blogs entry
7329             * @param companyId the company ID
7330             * @param status the status
7331             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7332             * @return the previous, current, and next blogs entry
7333             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
7334             */
7335            @Override
7336            public BlogsEntry[] findByC_S_PrevAndNext(long entryId, long companyId,
7337                    int status, OrderByComparator<BlogsEntry> orderByComparator)
7338                    throws NoSuchEntryException {
7339                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
7340    
7341                    Session session = null;
7342    
7343                    try {
7344                            session = openSession();
7345    
7346                            BlogsEntry[] array = new BlogsEntryImpl[3];
7347    
7348                            array[0] = getByC_S_PrevAndNext(session, blogsEntry, companyId,
7349                                            status, orderByComparator, true);
7350    
7351                            array[1] = blogsEntry;
7352    
7353                            array[2] = getByC_S_PrevAndNext(session, blogsEntry, companyId,
7354                                            status, orderByComparator, false);
7355    
7356                            return array;
7357                    }
7358                    catch (Exception e) {
7359                            throw processException(e);
7360                    }
7361                    finally {
7362                            closeSession(session);
7363                    }
7364            }
7365    
7366            protected BlogsEntry getByC_S_PrevAndNext(Session session,
7367                    BlogsEntry blogsEntry, long companyId, int status,
7368                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
7369                    StringBundler query = null;
7370    
7371                    if (orderByComparator != null) {
7372                            query = new StringBundler(5 +
7373                                            (orderByComparator.getOrderByConditionFields().length * 3) +
7374                                            (orderByComparator.getOrderByFields().length * 3));
7375                    }
7376                    else {
7377                            query = new StringBundler(4);
7378                    }
7379    
7380                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
7381    
7382                    query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
7383    
7384                    query.append(_FINDER_COLUMN_C_S_STATUS_2);
7385    
7386                    if (orderByComparator != null) {
7387                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7388    
7389                            if (orderByConditionFields.length > 0) {
7390                                    query.append(WHERE_AND);
7391                            }
7392    
7393                            for (int i = 0; i < orderByConditionFields.length; i++) {
7394                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7395                                    query.append(orderByConditionFields[i]);
7396    
7397                                    if ((i + 1) < orderByConditionFields.length) {
7398                                            if (orderByComparator.isAscending() ^ previous) {
7399                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7400                                            }
7401                                            else {
7402                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7403                                            }
7404                                    }
7405                                    else {
7406                                            if (orderByComparator.isAscending() ^ previous) {
7407                                                    query.append(WHERE_GREATER_THAN);
7408                                            }
7409                                            else {
7410                                                    query.append(WHERE_LESSER_THAN);
7411                                            }
7412                                    }
7413                            }
7414    
7415                            query.append(ORDER_BY_CLAUSE);
7416    
7417                            String[] orderByFields = orderByComparator.getOrderByFields();
7418    
7419                            for (int i = 0; i < orderByFields.length; i++) {
7420                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7421                                    query.append(orderByFields[i]);
7422    
7423                                    if ((i + 1) < orderByFields.length) {
7424                                            if (orderByComparator.isAscending() ^ previous) {
7425                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7426                                            }
7427                                            else {
7428                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7429                                            }
7430                                    }
7431                                    else {
7432                                            if (orderByComparator.isAscending() ^ previous) {
7433                                                    query.append(ORDER_BY_ASC);
7434                                            }
7435                                            else {
7436                                                    query.append(ORDER_BY_DESC);
7437                                            }
7438                                    }
7439                            }
7440                    }
7441                    else {
7442                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
7443                    }
7444    
7445                    String sql = query.toString();
7446    
7447                    Query q = session.createQuery(sql);
7448    
7449                    q.setFirstResult(0);
7450                    q.setMaxResults(2);
7451    
7452                    QueryPos qPos = QueryPos.getInstance(q);
7453    
7454                    qPos.add(companyId);
7455    
7456                    qPos.add(status);
7457    
7458                    if (orderByComparator != null) {
7459                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
7460    
7461                            for (Object value : values) {
7462                                    qPos.add(value);
7463                            }
7464                    }
7465    
7466                    List<BlogsEntry> list = q.list();
7467    
7468                    if (list.size() == 2) {
7469                            return list.get(1);
7470                    }
7471                    else {
7472                            return null;
7473                    }
7474            }
7475    
7476            /**
7477             * Removes all the blogs entries where companyId = &#63; and status = &#63; from the database.
7478             *
7479             * @param companyId the company ID
7480             * @param status the status
7481             */
7482            @Override
7483            public void removeByC_S(long companyId, int status) {
7484                    for (BlogsEntry blogsEntry : findByC_S(companyId, status,
7485                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
7486                            remove(blogsEntry);
7487                    }
7488            }
7489    
7490            /**
7491             * Returns the number of blogs entries where companyId = &#63; and status = &#63;.
7492             *
7493             * @param companyId the company ID
7494             * @param status the status
7495             * @return the number of matching blogs entries
7496             */
7497            @Override
7498            public int countByC_S(long companyId, int status) {
7499                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_S;
7500    
7501                    Object[] finderArgs = new Object[] { companyId, status };
7502    
7503                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
7504    
7505                    if (count == null) {
7506                            StringBundler query = new StringBundler(3);
7507    
7508                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
7509    
7510                            query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
7511    
7512                            query.append(_FINDER_COLUMN_C_S_STATUS_2);
7513    
7514                            String sql = query.toString();
7515    
7516                            Session session = null;
7517    
7518                            try {
7519                                    session = openSession();
7520    
7521                                    Query q = session.createQuery(sql);
7522    
7523                                    QueryPos qPos = QueryPos.getInstance(q);
7524    
7525                                    qPos.add(companyId);
7526    
7527                                    qPos.add(status);
7528    
7529                                    count = (Long)q.uniqueResult();
7530    
7531                                    finderCache.putResult(finderPath, finderArgs, count);
7532                            }
7533                            catch (Exception e) {
7534                                    finderCache.removeResult(finderPath, finderArgs);
7535    
7536                                    throw processException(e);
7537                            }
7538                            finally {
7539                                    closeSession(session);
7540                            }
7541                    }
7542    
7543                    return count.intValue();
7544            }
7545    
7546            private static final String _FINDER_COLUMN_C_S_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
7547            private static final String _FINDER_COLUMN_C_S_STATUS_2 = "blogsEntry.status = ?";
7548            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_NOTS = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
7549                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
7550                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_NotS",
7551                            new String[] {
7552                                    Long.class.getName(), Integer.class.getName(),
7553                                    
7554                            Integer.class.getName(), Integer.class.getName(),
7555                                    OrderByComparator.class.getName()
7556                            });
7557            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_NOTS = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
7558                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
7559                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_NotS",
7560                            new String[] { Long.class.getName(), Integer.class.getName() });
7561    
7562            /**
7563             * Returns all the blogs entries where companyId = &#63; and status &ne; &#63;.
7564             *
7565             * @param companyId the company ID
7566             * @param status the status
7567             * @return the matching blogs entries
7568             */
7569            @Override
7570            public List<BlogsEntry> findByC_NotS(long companyId, int status) {
7571                    return findByC_NotS(companyId, status, QueryUtil.ALL_POS,
7572                            QueryUtil.ALL_POS, null);
7573            }
7574    
7575            /**
7576             * Returns a range of all the blogs entries where companyId = &#63; and status &ne; &#63;.
7577             *
7578             * <p>
7579             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7580             * </p>
7581             *
7582             * @param companyId the company ID
7583             * @param status the status
7584             * @param start the lower bound of the range of blogs entries
7585             * @param end the upper bound of the range of blogs entries (not inclusive)
7586             * @return the range of matching blogs entries
7587             */
7588            @Override
7589            public List<BlogsEntry> findByC_NotS(long companyId, int status, int start,
7590                    int end) {
7591                    return findByC_NotS(companyId, status, start, end, null);
7592            }
7593    
7594            /**
7595             * Returns an ordered range of all the blogs entries where companyId = &#63; and status &ne; &#63;.
7596             *
7597             * <p>
7598             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7599             * </p>
7600             *
7601             * @param companyId the company ID
7602             * @param status the status
7603             * @param start the lower bound of the range of blogs entries
7604             * @param end the upper bound of the range of blogs entries (not inclusive)
7605             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7606             * @return the ordered range of matching blogs entries
7607             */
7608            @Override
7609            public List<BlogsEntry> findByC_NotS(long companyId, int status, int start,
7610                    int end, OrderByComparator<BlogsEntry> orderByComparator) {
7611                    return findByC_NotS(companyId, status, start, end, orderByComparator,
7612                            true);
7613            }
7614    
7615            /**
7616             * Returns an ordered range of all the blogs entries where companyId = &#63; and status &ne; &#63;.
7617             *
7618             * <p>
7619             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7620             * </p>
7621             *
7622             * @param companyId the company ID
7623             * @param status the status
7624             * @param start the lower bound of the range of blogs entries
7625             * @param end the upper bound of the range of blogs entries (not inclusive)
7626             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7627             * @param retrieveFromCache whether to retrieve from the finder cache
7628             * @return the ordered range of matching blogs entries
7629             */
7630            @Override
7631            public List<BlogsEntry> findByC_NotS(long companyId, int status, int start,
7632                    int end, OrderByComparator<BlogsEntry> orderByComparator,
7633                    boolean retrieveFromCache) {
7634                    boolean pagination = true;
7635                    FinderPath finderPath = null;
7636                    Object[] finderArgs = null;
7637    
7638                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_NOTS;
7639                    finderArgs = new Object[] {
7640                                    companyId, status,
7641                                    
7642                                    start, end, orderByComparator
7643                            };
7644    
7645                    List<BlogsEntry> list = null;
7646    
7647                    if (retrieveFromCache) {
7648                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
7649                                            finderArgs, this);
7650    
7651                            if ((list != null) && !list.isEmpty()) {
7652                                    for (BlogsEntry blogsEntry : list) {
7653                                            if ((companyId != blogsEntry.getCompanyId()) ||
7654                                                            (status == blogsEntry.getStatus())) {
7655                                                    list = null;
7656    
7657                                                    break;
7658                                            }
7659                                    }
7660                            }
7661                    }
7662    
7663                    if (list == null) {
7664                            StringBundler query = null;
7665    
7666                            if (orderByComparator != null) {
7667                                    query = new StringBundler(4 +
7668                                                    (orderByComparator.getOrderByFields().length * 2));
7669                            }
7670                            else {
7671                                    query = new StringBundler(4);
7672                            }
7673    
7674                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
7675    
7676                            query.append(_FINDER_COLUMN_C_NOTS_COMPANYID_2);
7677    
7678                            query.append(_FINDER_COLUMN_C_NOTS_STATUS_2);
7679    
7680                            if (orderByComparator != null) {
7681                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7682                                            orderByComparator);
7683                            }
7684                            else
7685                             if (pagination) {
7686                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
7687                            }
7688    
7689                            String sql = query.toString();
7690    
7691                            Session session = null;
7692    
7693                            try {
7694                                    session = openSession();
7695    
7696                                    Query q = session.createQuery(sql);
7697    
7698                                    QueryPos qPos = QueryPos.getInstance(q);
7699    
7700                                    qPos.add(companyId);
7701    
7702                                    qPos.add(status);
7703    
7704                                    if (!pagination) {
7705                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
7706                                                            start, end, false);
7707    
7708                                            Collections.sort(list);
7709    
7710                                            list = Collections.unmodifiableList(list);
7711                                    }
7712                                    else {
7713                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
7714                                                            start, end);
7715                                    }
7716    
7717                                    cacheResult(list);
7718    
7719                                    finderCache.putResult(finderPath, finderArgs, list);
7720                            }
7721                            catch (Exception e) {
7722                                    finderCache.removeResult(finderPath, finderArgs);
7723    
7724                                    throw processException(e);
7725                            }
7726                            finally {
7727                                    closeSession(session);
7728                            }
7729                    }
7730    
7731                    return list;
7732            }
7733    
7734            /**
7735             * Returns the first blogs entry in the ordered set where companyId = &#63; and status &ne; &#63;.
7736             *
7737             * @param companyId the company ID
7738             * @param status the status
7739             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7740             * @return the first matching blogs entry
7741             * @throws NoSuchEntryException if a matching blogs entry could not be found
7742             */
7743            @Override
7744            public BlogsEntry findByC_NotS_First(long companyId, int status,
7745                    OrderByComparator<BlogsEntry> orderByComparator)
7746                    throws NoSuchEntryException {
7747                    BlogsEntry blogsEntry = fetchByC_NotS_First(companyId, status,
7748                                    orderByComparator);
7749    
7750                    if (blogsEntry != null) {
7751                            return blogsEntry;
7752                    }
7753    
7754                    StringBundler msg = new StringBundler(6);
7755    
7756                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7757    
7758                    msg.append("companyId=");
7759                    msg.append(companyId);
7760    
7761                    msg.append(", status=");
7762                    msg.append(status);
7763    
7764                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7765    
7766                    throw new NoSuchEntryException(msg.toString());
7767            }
7768    
7769            /**
7770             * Returns the first blogs entry in the ordered set where companyId = &#63; and status &ne; &#63;.
7771             *
7772             * @param companyId the company ID
7773             * @param status the status
7774             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7775             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
7776             */
7777            @Override
7778            public BlogsEntry fetchByC_NotS_First(long companyId, int status,
7779                    OrderByComparator<BlogsEntry> orderByComparator) {
7780                    List<BlogsEntry> list = findByC_NotS(companyId, status, 0, 1,
7781                                    orderByComparator);
7782    
7783                    if (!list.isEmpty()) {
7784                            return list.get(0);
7785                    }
7786    
7787                    return null;
7788            }
7789    
7790            /**
7791             * Returns the last blogs entry in the ordered set where companyId = &#63; and status &ne; &#63;.
7792             *
7793             * @param companyId the company ID
7794             * @param status the status
7795             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7796             * @return the last matching blogs entry
7797             * @throws NoSuchEntryException if a matching blogs entry could not be found
7798             */
7799            @Override
7800            public BlogsEntry findByC_NotS_Last(long companyId, int status,
7801                    OrderByComparator<BlogsEntry> orderByComparator)
7802                    throws NoSuchEntryException {
7803                    BlogsEntry blogsEntry = fetchByC_NotS_Last(companyId, status,
7804                                    orderByComparator);
7805    
7806                    if (blogsEntry != null) {
7807                            return blogsEntry;
7808                    }
7809    
7810                    StringBundler msg = new StringBundler(6);
7811    
7812                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7813    
7814                    msg.append("companyId=");
7815                    msg.append(companyId);
7816    
7817                    msg.append(", status=");
7818                    msg.append(status);
7819    
7820                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7821    
7822                    throw new NoSuchEntryException(msg.toString());
7823            }
7824    
7825            /**
7826             * Returns the last blogs entry in the ordered set where companyId = &#63; and status &ne; &#63;.
7827             *
7828             * @param companyId the company ID
7829             * @param status the status
7830             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7831             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
7832             */
7833            @Override
7834            public BlogsEntry fetchByC_NotS_Last(long companyId, int status,
7835                    OrderByComparator<BlogsEntry> orderByComparator) {
7836                    int count = countByC_NotS(companyId, status);
7837    
7838                    if (count == 0) {
7839                            return null;
7840                    }
7841    
7842                    List<BlogsEntry> list = findByC_NotS(companyId, status, count - 1,
7843                                    count, orderByComparator);
7844    
7845                    if (!list.isEmpty()) {
7846                            return list.get(0);
7847                    }
7848    
7849                    return null;
7850            }
7851    
7852            /**
7853             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63; and status &ne; &#63;.
7854             *
7855             * @param entryId the primary key of the current blogs entry
7856             * @param companyId the company ID
7857             * @param status the status
7858             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7859             * @return the previous, current, and next blogs entry
7860             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
7861             */
7862            @Override
7863            public BlogsEntry[] findByC_NotS_PrevAndNext(long entryId, long companyId,
7864                    int status, OrderByComparator<BlogsEntry> orderByComparator)
7865                    throws NoSuchEntryException {
7866                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
7867    
7868                    Session session = null;
7869    
7870                    try {
7871                            session = openSession();
7872    
7873                            BlogsEntry[] array = new BlogsEntryImpl[3];
7874    
7875                            array[0] = getByC_NotS_PrevAndNext(session, blogsEntry, companyId,
7876                                            status, orderByComparator, true);
7877    
7878                            array[1] = blogsEntry;
7879    
7880                            array[2] = getByC_NotS_PrevAndNext(session, blogsEntry, companyId,
7881                                            status, orderByComparator, false);
7882    
7883                            return array;
7884                    }
7885                    catch (Exception e) {
7886                            throw processException(e);
7887                    }
7888                    finally {
7889                            closeSession(session);
7890                    }
7891            }
7892    
7893            protected BlogsEntry getByC_NotS_PrevAndNext(Session session,
7894                    BlogsEntry blogsEntry, long companyId, int status,
7895                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
7896                    StringBundler query = null;
7897    
7898                    if (orderByComparator != null) {
7899                            query = new StringBundler(5 +
7900                                            (orderByComparator.getOrderByConditionFields().length * 3) +
7901                                            (orderByComparator.getOrderByFields().length * 3));
7902                    }
7903                    else {
7904                            query = new StringBundler(4);
7905                    }
7906    
7907                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
7908    
7909                    query.append(_FINDER_COLUMN_C_NOTS_COMPANYID_2);
7910    
7911                    query.append(_FINDER_COLUMN_C_NOTS_STATUS_2);
7912    
7913                    if (orderByComparator != null) {
7914                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7915    
7916                            if (orderByConditionFields.length > 0) {
7917                                    query.append(WHERE_AND);
7918                            }
7919    
7920                            for (int i = 0; i < orderByConditionFields.length; i++) {
7921                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7922                                    query.append(orderByConditionFields[i]);
7923    
7924                                    if ((i + 1) < orderByConditionFields.length) {
7925                                            if (orderByComparator.isAscending() ^ previous) {
7926                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7927                                            }
7928                                            else {
7929                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7930                                            }
7931                                    }
7932                                    else {
7933                                            if (orderByComparator.isAscending() ^ previous) {
7934                                                    query.append(WHERE_GREATER_THAN);
7935                                            }
7936                                            else {
7937                                                    query.append(WHERE_LESSER_THAN);
7938                                            }
7939                                    }
7940                            }
7941    
7942                            query.append(ORDER_BY_CLAUSE);
7943    
7944                            String[] orderByFields = orderByComparator.getOrderByFields();
7945    
7946                            for (int i = 0; i < orderByFields.length; i++) {
7947                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7948                                    query.append(orderByFields[i]);
7949    
7950                                    if ((i + 1) < orderByFields.length) {
7951                                            if (orderByComparator.isAscending() ^ previous) {
7952                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7953                                            }
7954                                            else {
7955                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7956                                            }
7957                                    }
7958                                    else {
7959                                            if (orderByComparator.isAscending() ^ previous) {
7960                                                    query.append(ORDER_BY_ASC);
7961                                            }
7962                                            else {
7963                                                    query.append(ORDER_BY_DESC);
7964                                            }
7965                                    }
7966                            }
7967                    }
7968                    else {
7969                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
7970                    }
7971    
7972                    String sql = query.toString();
7973    
7974                    Query q = session.createQuery(sql);
7975    
7976                    q.setFirstResult(0);
7977                    q.setMaxResults(2);
7978    
7979                    QueryPos qPos = QueryPos.getInstance(q);
7980    
7981                    qPos.add(companyId);
7982    
7983                    qPos.add(status);
7984    
7985                    if (orderByComparator != null) {
7986                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
7987    
7988                            for (Object value : values) {
7989                                    qPos.add(value);
7990                            }
7991                    }
7992    
7993                    List<BlogsEntry> list = q.list();
7994    
7995                    if (list.size() == 2) {
7996                            return list.get(1);
7997                    }
7998                    else {
7999                            return null;
8000                    }
8001            }
8002    
8003            /**
8004             * Removes all the blogs entries where companyId = &#63; and status &ne; &#63; from the database.
8005             *
8006             * @param companyId the company ID
8007             * @param status the status
8008             */
8009            @Override
8010            public void removeByC_NotS(long companyId, int status) {
8011                    for (BlogsEntry blogsEntry : findByC_NotS(companyId, status,
8012                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
8013                            remove(blogsEntry);
8014                    }
8015            }
8016    
8017            /**
8018             * Returns the number of blogs entries where companyId = &#63; and status &ne; &#63;.
8019             *
8020             * @param companyId the company ID
8021             * @param status the status
8022             * @return the number of matching blogs entries
8023             */
8024            @Override
8025            public int countByC_NotS(long companyId, int status) {
8026                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_NOTS;
8027    
8028                    Object[] finderArgs = new Object[] { companyId, status };
8029    
8030                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
8031    
8032                    if (count == null) {
8033                            StringBundler query = new StringBundler(3);
8034    
8035                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
8036    
8037                            query.append(_FINDER_COLUMN_C_NOTS_COMPANYID_2);
8038    
8039                            query.append(_FINDER_COLUMN_C_NOTS_STATUS_2);
8040    
8041                            String sql = query.toString();
8042    
8043                            Session session = null;
8044    
8045                            try {
8046                                    session = openSession();
8047    
8048                                    Query q = session.createQuery(sql);
8049    
8050                                    QueryPos qPos = QueryPos.getInstance(q);
8051    
8052                                    qPos.add(companyId);
8053    
8054                                    qPos.add(status);
8055    
8056                                    count = (Long)q.uniqueResult();
8057    
8058                                    finderCache.putResult(finderPath, finderArgs, count);
8059                            }
8060                            catch (Exception e) {
8061                                    finderCache.removeResult(finderPath, finderArgs);
8062    
8063                                    throw processException(e);
8064                            }
8065                            finally {
8066                                    closeSession(session);
8067                            }
8068                    }
8069    
8070                    return count.intValue();
8071            }
8072    
8073            private static final String _FINDER_COLUMN_C_NOTS_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
8074            private static final String _FINDER_COLUMN_C_NOTS_STATUS_2 = "blogsEntry.status != ?";
8075            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
8076                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
8077                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByLtD_S",
8078                            new String[] {
8079                                    Date.class.getName(), Integer.class.getName(),
8080                                    
8081                            Integer.class.getName(), Integer.class.getName(),
8082                                    OrderByComparator.class.getName()
8083                            });
8084            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
8085                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
8086                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByLtD_S",
8087                            new String[] { Date.class.getName(), Integer.class.getName() });
8088    
8089            /**
8090             * Returns all the blogs entries where displayDate &lt; &#63; and status = &#63;.
8091             *
8092             * @param displayDate the display date
8093             * @param status the status
8094             * @return the matching blogs entries
8095             */
8096            @Override
8097            public List<BlogsEntry> findByLtD_S(Date displayDate, int status) {
8098                    return findByLtD_S(displayDate, status, QueryUtil.ALL_POS,
8099                            QueryUtil.ALL_POS, null);
8100            }
8101    
8102            /**
8103             * Returns a range of all the blogs entries where displayDate &lt; &#63; and status = &#63;.
8104             *
8105             * <p>
8106             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8107             * </p>
8108             *
8109             * @param displayDate the display date
8110             * @param status the status
8111             * @param start the lower bound of the range of blogs entries
8112             * @param end the upper bound of the range of blogs entries (not inclusive)
8113             * @return the range of matching blogs entries
8114             */
8115            @Override
8116            public List<BlogsEntry> findByLtD_S(Date displayDate, int status,
8117                    int start, int end) {
8118                    return findByLtD_S(displayDate, status, start, end, null);
8119            }
8120    
8121            /**
8122             * Returns an ordered range of all the blogs entries where displayDate &lt; &#63; and status = &#63;.
8123             *
8124             * <p>
8125             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8126             * </p>
8127             *
8128             * @param displayDate the display date
8129             * @param status the status
8130             * @param start the lower bound of the range of blogs entries
8131             * @param end the upper bound of the range of blogs entries (not inclusive)
8132             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8133             * @return the ordered range of matching blogs entries
8134             */
8135            @Override
8136            public List<BlogsEntry> findByLtD_S(Date displayDate, int status,
8137                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator) {
8138                    return findByLtD_S(displayDate, status, start, end, orderByComparator,
8139                            true);
8140            }
8141    
8142            /**
8143             * Returns an ordered range of all the blogs entries where displayDate &lt; &#63; and status = &#63;.
8144             *
8145             * <p>
8146             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8147             * </p>
8148             *
8149             * @param displayDate the display date
8150             * @param status the status
8151             * @param start the lower bound of the range of blogs entries
8152             * @param end the upper bound of the range of blogs entries (not inclusive)
8153             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8154             * @param retrieveFromCache whether to retrieve from the finder cache
8155             * @return the ordered range of matching blogs entries
8156             */
8157            @Override
8158            public List<BlogsEntry> findByLtD_S(Date displayDate, int status,
8159                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator,
8160                    boolean retrieveFromCache) {
8161                    boolean pagination = true;
8162                    FinderPath finderPath = null;
8163                    Object[] finderArgs = null;
8164    
8165                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_LTD_S;
8166                    finderArgs = new Object[] {
8167                                    displayDate, status,
8168                                    
8169                                    start, end, orderByComparator
8170                            };
8171    
8172                    List<BlogsEntry> list = null;
8173    
8174                    if (retrieveFromCache) {
8175                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
8176                                            finderArgs, this);
8177    
8178                            if ((list != null) && !list.isEmpty()) {
8179                                    for (BlogsEntry blogsEntry : list) {
8180                                            if ((displayDate.getTime() <= blogsEntry.getDisplayDate()
8181                                                                                                                                    .getTime()) ||
8182                                                            (status != blogsEntry.getStatus())) {
8183                                                    list = null;
8184    
8185                                                    break;
8186                                            }
8187                                    }
8188                            }
8189                    }
8190    
8191                    if (list == null) {
8192                            StringBundler query = null;
8193    
8194                            if (orderByComparator != null) {
8195                                    query = new StringBundler(4 +
8196                                                    (orderByComparator.getOrderByFields().length * 2));
8197                            }
8198                            else {
8199                                    query = new StringBundler(4);
8200                            }
8201    
8202                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
8203    
8204                            boolean bindDisplayDate = false;
8205    
8206                            if (displayDate == null) {
8207                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_1);
8208                            }
8209                            else {
8210                                    bindDisplayDate = true;
8211    
8212                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_2);
8213                            }
8214    
8215                            query.append(_FINDER_COLUMN_LTD_S_STATUS_2);
8216    
8217                            if (orderByComparator != null) {
8218                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8219                                            orderByComparator);
8220                            }
8221                            else
8222                             if (pagination) {
8223                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
8224                            }
8225    
8226                            String sql = query.toString();
8227    
8228                            Session session = null;
8229    
8230                            try {
8231                                    session = openSession();
8232    
8233                                    Query q = session.createQuery(sql);
8234    
8235                                    QueryPos qPos = QueryPos.getInstance(q);
8236    
8237                                    if (bindDisplayDate) {
8238                                            qPos.add(new Timestamp(displayDate.getTime()));
8239                                    }
8240    
8241                                    qPos.add(status);
8242    
8243                                    if (!pagination) {
8244                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
8245                                                            start, end, false);
8246    
8247                                            Collections.sort(list);
8248    
8249                                            list = Collections.unmodifiableList(list);
8250                                    }
8251                                    else {
8252                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
8253                                                            start, end);
8254                                    }
8255    
8256                                    cacheResult(list);
8257    
8258                                    finderCache.putResult(finderPath, finderArgs, list);
8259                            }
8260                            catch (Exception e) {
8261                                    finderCache.removeResult(finderPath, finderArgs);
8262    
8263                                    throw processException(e);
8264                            }
8265                            finally {
8266                                    closeSession(session);
8267                            }
8268                    }
8269    
8270                    return list;
8271            }
8272    
8273            /**
8274             * Returns the first blogs entry in the ordered set where displayDate &lt; &#63; and status = &#63;.
8275             *
8276             * @param displayDate the display date
8277             * @param status the status
8278             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8279             * @return the first matching blogs entry
8280             * @throws NoSuchEntryException if a matching blogs entry could not be found
8281             */
8282            @Override
8283            public BlogsEntry findByLtD_S_First(Date displayDate, int status,
8284                    OrderByComparator<BlogsEntry> orderByComparator)
8285                    throws NoSuchEntryException {
8286                    BlogsEntry blogsEntry = fetchByLtD_S_First(displayDate, status,
8287                                    orderByComparator);
8288    
8289                    if (blogsEntry != null) {
8290                            return blogsEntry;
8291                    }
8292    
8293                    StringBundler msg = new StringBundler(6);
8294    
8295                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8296    
8297                    msg.append("displayDate=");
8298                    msg.append(displayDate);
8299    
8300                    msg.append(", status=");
8301                    msg.append(status);
8302    
8303                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8304    
8305                    throw new NoSuchEntryException(msg.toString());
8306            }
8307    
8308            /**
8309             * Returns the first blogs entry in the ordered set where displayDate &lt; &#63; and status = &#63;.
8310             *
8311             * @param displayDate the display date
8312             * @param status the status
8313             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8314             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
8315             */
8316            @Override
8317            public BlogsEntry fetchByLtD_S_First(Date displayDate, int status,
8318                    OrderByComparator<BlogsEntry> orderByComparator) {
8319                    List<BlogsEntry> list = findByLtD_S(displayDate, status, 0, 1,
8320                                    orderByComparator);
8321    
8322                    if (!list.isEmpty()) {
8323                            return list.get(0);
8324                    }
8325    
8326                    return null;
8327            }
8328    
8329            /**
8330             * Returns the last blogs entry in the ordered set where displayDate &lt; &#63; and status = &#63;.
8331             *
8332             * @param displayDate the display date
8333             * @param status the status
8334             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8335             * @return the last matching blogs entry
8336             * @throws NoSuchEntryException if a matching blogs entry could not be found
8337             */
8338            @Override
8339            public BlogsEntry findByLtD_S_Last(Date displayDate, int status,
8340                    OrderByComparator<BlogsEntry> orderByComparator)
8341                    throws NoSuchEntryException {
8342                    BlogsEntry blogsEntry = fetchByLtD_S_Last(displayDate, status,
8343                                    orderByComparator);
8344    
8345                    if (blogsEntry != null) {
8346                            return blogsEntry;
8347                    }
8348    
8349                    StringBundler msg = new StringBundler(6);
8350    
8351                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8352    
8353                    msg.append("displayDate=");
8354                    msg.append(displayDate);
8355    
8356                    msg.append(", status=");
8357                    msg.append(status);
8358    
8359                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8360    
8361                    throw new NoSuchEntryException(msg.toString());
8362            }
8363    
8364            /**
8365             * Returns the last blogs entry in the ordered set where displayDate &lt; &#63; and status = &#63;.
8366             *
8367             * @param displayDate the display date
8368             * @param status the status
8369             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8370             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
8371             */
8372            @Override
8373            public BlogsEntry fetchByLtD_S_Last(Date displayDate, int status,
8374                    OrderByComparator<BlogsEntry> orderByComparator) {
8375                    int count = countByLtD_S(displayDate, status);
8376    
8377                    if (count == 0) {
8378                            return null;
8379                    }
8380    
8381                    List<BlogsEntry> list = findByLtD_S(displayDate, status, count - 1,
8382                                    count, orderByComparator);
8383    
8384                    if (!list.isEmpty()) {
8385                            return list.get(0);
8386                    }
8387    
8388                    return null;
8389            }
8390    
8391            /**
8392             * Returns the blogs entries before and after the current blogs entry in the ordered set where displayDate &lt; &#63; and status = &#63;.
8393             *
8394             * @param entryId the primary key of the current blogs entry
8395             * @param displayDate the display date
8396             * @param status the status
8397             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8398             * @return the previous, current, and next blogs entry
8399             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
8400             */
8401            @Override
8402            public BlogsEntry[] findByLtD_S_PrevAndNext(long entryId, Date displayDate,
8403                    int status, OrderByComparator<BlogsEntry> orderByComparator)
8404                    throws NoSuchEntryException {
8405                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
8406    
8407                    Session session = null;
8408    
8409                    try {
8410                            session = openSession();
8411    
8412                            BlogsEntry[] array = new BlogsEntryImpl[3];
8413    
8414                            array[0] = getByLtD_S_PrevAndNext(session, blogsEntry, displayDate,
8415                                            status, orderByComparator, true);
8416    
8417                            array[1] = blogsEntry;
8418    
8419                            array[2] = getByLtD_S_PrevAndNext(session, blogsEntry, displayDate,
8420                                            status, orderByComparator, false);
8421    
8422                            return array;
8423                    }
8424                    catch (Exception e) {
8425                            throw processException(e);
8426                    }
8427                    finally {
8428                            closeSession(session);
8429                    }
8430            }
8431    
8432            protected BlogsEntry getByLtD_S_PrevAndNext(Session session,
8433                    BlogsEntry blogsEntry, Date displayDate, int status,
8434                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
8435                    StringBundler query = null;
8436    
8437                    if (orderByComparator != null) {
8438                            query = new StringBundler(5 +
8439                                            (orderByComparator.getOrderByConditionFields().length * 3) +
8440                                            (orderByComparator.getOrderByFields().length * 3));
8441                    }
8442                    else {
8443                            query = new StringBundler(4);
8444                    }
8445    
8446                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
8447    
8448                    boolean bindDisplayDate = false;
8449    
8450                    if (displayDate == null) {
8451                            query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_1);
8452                    }
8453                    else {
8454                            bindDisplayDate = true;
8455    
8456                            query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_2);
8457                    }
8458    
8459                    query.append(_FINDER_COLUMN_LTD_S_STATUS_2);
8460    
8461                    if (orderByComparator != null) {
8462                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8463    
8464                            if (orderByConditionFields.length > 0) {
8465                                    query.append(WHERE_AND);
8466                            }
8467    
8468                            for (int i = 0; i < orderByConditionFields.length; i++) {
8469                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8470                                    query.append(orderByConditionFields[i]);
8471    
8472                                    if ((i + 1) < orderByConditionFields.length) {
8473                                            if (orderByComparator.isAscending() ^ previous) {
8474                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8475                                            }
8476                                            else {
8477                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8478                                            }
8479                                    }
8480                                    else {
8481                                            if (orderByComparator.isAscending() ^ previous) {
8482                                                    query.append(WHERE_GREATER_THAN);
8483                                            }
8484                                            else {
8485                                                    query.append(WHERE_LESSER_THAN);
8486                                            }
8487                                    }
8488                            }
8489    
8490                            query.append(ORDER_BY_CLAUSE);
8491    
8492                            String[] orderByFields = orderByComparator.getOrderByFields();
8493    
8494                            for (int i = 0; i < orderByFields.length; i++) {
8495                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8496                                    query.append(orderByFields[i]);
8497    
8498                                    if ((i + 1) < orderByFields.length) {
8499                                            if (orderByComparator.isAscending() ^ previous) {
8500                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8501                                            }
8502                                            else {
8503                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8504                                            }
8505                                    }
8506                                    else {
8507                                            if (orderByComparator.isAscending() ^ previous) {
8508                                                    query.append(ORDER_BY_ASC);
8509                                            }
8510                                            else {
8511                                                    query.append(ORDER_BY_DESC);
8512                                            }
8513                                    }
8514                            }
8515                    }
8516                    else {
8517                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
8518                    }
8519    
8520                    String sql = query.toString();
8521    
8522                    Query q = session.createQuery(sql);
8523    
8524                    q.setFirstResult(0);
8525                    q.setMaxResults(2);
8526    
8527                    QueryPos qPos = QueryPos.getInstance(q);
8528    
8529                    if (bindDisplayDate) {
8530                            qPos.add(new Timestamp(displayDate.getTime()));
8531                    }
8532    
8533                    qPos.add(status);
8534    
8535                    if (orderByComparator != null) {
8536                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
8537    
8538                            for (Object value : values) {
8539                                    qPos.add(value);
8540                            }
8541                    }
8542    
8543                    List<BlogsEntry> list = q.list();
8544    
8545                    if (list.size() == 2) {
8546                            return list.get(1);
8547                    }
8548                    else {
8549                            return null;
8550                    }
8551            }
8552    
8553            /**
8554             * Removes all the blogs entries where displayDate &lt; &#63; and status = &#63; from the database.
8555             *
8556             * @param displayDate the display date
8557             * @param status the status
8558             */
8559            @Override
8560            public void removeByLtD_S(Date displayDate, int status) {
8561                    for (BlogsEntry blogsEntry : findByLtD_S(displayDate, status,
8562                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
8563                            remove(blogsEntry);
8564                    }
8565            }
8566    
8567            /**
8568             * Returns the number of blogs entries where displayDate &lt; &#63; and status = &#63;.
8569             *
8570             * @param displayDate the display date
8571             * @param status the status
8572             * @return the number of matching blogs entries
8573             */
8574            @Override
8575            public int countByLtD_S(Date displayDate, int status) {
8576                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_LTD_S;
8577    
8578                    Object[] finderArgs = new Object[] { displayDate, status };
8579    
8580                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
8581    
8582                    if (count == null) {
8583                            StringBundler query = new StringBundler(3);
8584    
8585                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
8586    
8587                            boolean bindDisplayDate = false;
8588    
8589                            if (displayDate == null) {
8590                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_1);
8591                            }
8592                            else {
8593                                    bindDisplayDate = true;
8594    
8595                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_2);
8596                            }
8597    
8598                            query.append(_FINDER_COLUMN_LTD_S_STATUS_2);
8599    
8600                            String sql = query.toString();
8601    
8602                            Session session = null;
8603    
8604                            try {
8605                                    session = openSession();
8606    
8607                                    Query q = session.createQuery(sql);
8608    
8609                                    QueryPos qPos = QueryPos.getInstance(q);
8610    
8611                                    if (bindDisplayDate) {
8612                                            qPos.add(new Timestamp(displayDate.getTime()));
8613                                    }
8614    
8615                                    qPos.add(status);
8616    
8617                                    count = (Long)q.uniqueResult();
8618    
8619                                    finderCache.putResult(finderPath, finderArgs, count);
8620                            }
8621                            catch (Exception e) {
8622                                    finderCache.removeResult(finderPath, finderArgs);
8623    
8624                                    throw processException(e);
8625                            }
8626                            finally {
8627                                    closeSession(session);
8628                            }
8629                    }
8630    
8631                    return count.intValue();
8632            }
8633    
8634            private static final String _FINDER_COLUMN_LTD_S_DISPLAYDATE_1 = "blogsEntry.displayDate IS NULL AND ";
8635            private static final String _FINDER_COLUMN_LTD_S_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
8636            private static final String _FINDER_COLUMN_LTD_S_STATUS_2 = "blogsEntry.status = ?";
8637            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
8638                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
8639                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_LtD",
8640                            new String[] {
8641                                    Long.class.getName(), Long.class.getName(), Date.class.getName(),
8642                                    
8643                            Integer.class.getName(), Integer.class.getName(),
8644                                    OrderByComparator.class.getName()
8645                            });
8646            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
8647                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
8648                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_U_LtD",
8649                            new String[] {
8650                                    Long.class.getName(), Long.class.getName(), Date.class.getName()
8651                            });
8652    
8653            /**
8654             * Returns all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
8655             *
8656             * @param groupId the group ID
8657             * @param userId the user ID
8658             * @param displayDate the display date
8659             * @return the matching blogs entries
8660             */
8661            @Override
8662            public List<BlogsEntry> findByG_U_LtD(long groupId, long userId,
8663                    Date displayDate) {
8664                    return findByG_U_LtD(groupId, userId, displayDate, QueryUtil.ALL_POS,
8665                            QueryUtil.ALL_POS, null);
8666            }
8667    
8668            /**
8669             * Returns a range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
8670             *
8671             * <p>
8672             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8673             * </p>
8674             *
8675             * @param groupId the group ID
8676             * @param userId the user ID
8677             * @param displayDate the display date
8678             * @param start the lower bound of the range of blogs entries
8679             * @param end the upper bound of the range of blogs entries (not inclusive)
8680             * @return the range of matching blogs entries
8681             */
8682            @Override
8683            public List<BlogsEntry> findByG_U_LtD(long groupId, long userId,
8684                    Date displayDate, int start, int end) {
8685                    return findByG_U_LtD(groupId, userId, displayDate, start, end, null);
8686            }
8687    
8688            /**
8689             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
8690             *
8691             * <p>
8692             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8693             * </p>
8694             *
8695             * @param groupId the group ID
8696             * @param userId the user ID
8697             * @param displayDate the display date
8698             * @param start the lower bound of the range of blogs entries
8699             * @param end the upper bound of the range of blogs entries (not inclusive)
8700             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8701             * @return the ordered range of matching blogs entries
8702             */
8703            @Override
8704            public List<BlogsEntry> findByG_U_LtD(long groupId, long userId,
8705                    Date displayDate, int start, int end,
8706                    OrderByComparator<BlogsEntry> orderByComparator) {
8707                    return findByG_U_LtD(groupId, userId, displayDate, start, end,
8708                            orderByComparator, true);
8709            }
8710    
8711            /**
8712             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
8713             *
8714             * <p>
8715             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8716             * </p>
8717             *
8718             * @param groupId the group ID
8719             * @param userId the user ID
8720             * @param displayDate the display date
8721             * @param start the lower bound of the range of blogs entries
8722             * @param end the upper bound of the range of blogs entries (not inclusive)
8723             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8724             * @param retrieveFromCache whether to retrieve from the finder cache
8725             * @return the ordered range of matching blogs entries
8726             */
8727            @Override
8728            public List<BlogsEntry> findByG_U_LtD(long groupId, long userId,
8729                    Date displayDate, int start, int end,
8730                    OrderByComparator<BlogsEntry> orderByComparator,
8731                    boolean retrieveFromCache) {
8732                    boolean pagination = true;
8733                    FinderPath finderPath = null;
8734                    Object[] finderArgs = null;
8735    
8736                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD;
8737                    finderArgs = new Object[] {
8738                                    groupId, userId, displayDate,
8739                                    
8740                                    start, end, orderByComparator
8741                            };
8742    
8743                    List<BlogsEntry> list = null;
8744    
8745                    if (retrieveFromCache) {
8746                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
8747                                            finderArgs, this);
8748    
8749                            if ((list != null) && !list.isEmpty()) {
8750                                    for (BlogsEntry blogsEntry : list) {
8751                                            if ((groupId != blogsEntry.getGroupId()) ||
8752                                                            (userId != blogsEntry.getUserId()) ||
8753                                                            (displayDate.getTime() <= blogsEntry.getDisplayDate()
8754                                                                                                                                            .getTime())) {
8755                                                    list = null;
8756    
8757                                                    break;
8758                                            }
8759                                    }
8760                            }
8761                    }
8762    
8763                    if (list == null) {
8764                            StringBundler query = null;
8765    
8766                            if (orderByComparator != null) {
8767                                    query = new StringBundler(5 +
8768                                                    (orderByComparator.getOrderByFields().length * 2));
8769                            }
8770                            else {
8771                                    query = new StringBundler(5);
8772                            }
8773    
8774                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
8775    
8776                            query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
8777    
8778                            query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
8779    
8780                            boolean bindDisplayDate = false;
8781    
8782                            if (displayDate == null) {
8783                                    query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
8784                            }
8785                            else {
8786                                    bindDisplayDate = true;
8787    
8788                                    query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
8789                            }
8790    
8791                            if (orderByComparator != null) {
8792                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8793                                            orderByComparator);
8794                            }
8795                            else
8796                             if (pagination) {
8797                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
8798                            }
8799    
8800                            String sql = query.toString();
8801    
8802                            Session session = null;
8803    
8804                            try {
8805                                    session = openSession();
8806    
8807                                    Query q = session.createQuery(sql);
8808    
8809                                    QueryPos qPos = QueryPos.getInstance(q);
8810    
8811                                    qPos.add(groupId);
8812    
8813                                    qPos.add(userId);
8814    
8815                                    if (bindDisplayDate) {
8816                                            qPos.add(new Timestamp(displayDate.getTime()));
8817                                    }
8818    
8819                                    if (!pagination) {
8820                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
8821                                                            start, end, false);
8822    
8823                                            Collections.sort(list);
8824    
8825                                            list = Collections.unmodifiableList(list);
8826                                    }
8827                                    else {
8828                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
8829                                                            start, end);
8830                                    }
8831    
8832                                    cacheResult(list);
8833    
8834                                    finderCache.putResult(finderPath, finderArgs, list);
8835                            }
8836                            catch (Exception e) {
8837                                    finderCache.removeResult(finderPath, finderArgs);
8838    
8839                                    throw processException(e);
8840                            }
8841                            finally {
8842                                    closeSession(session);
8843                            }
8844                    }
8845    
8846                    return list;
8847            }
8848    
8849            /**
8850             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
8851             *
8852             * @param groupId the group ID
8853             * @param userId the user ID
8854             * @param displayDate the display date
8855             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8856             * @return the first matching blogs entry
8857             * @throws NoSuchEntryException if a matching blogs entry could not be found
8858             */
8859            @Override
8860            public BlogsEntry findByG_U_LtD_First(long groupId, long userId,
8861                    Date displayDate, OrderByComparator<BlogsEntry> orderByComparator)
8862                    throws NoSuchEntryException {
8863                    BlogsEntry blogsEntry = fetchByG_U_LtD_First(groupId, userId,
8864                                    displayDate, orderByComparator);
8865    
8866                    if (blogsEntry != null) {
8867                            return blogsEntry;
8868                    }
8869    
8870                    StringBundler msg = new StringBundler(8);
8871    
8872                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8873    
8874                    msg.append("groupId=");
8875                    msg.append(groupId);
8876    
8877                    msg.append(", userId=");
8878                    msg.append(userId);
8879    
8880                    msg.append(", displayDate=");
8881                    msg.append(displayDate);
8882    
8883                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8884    
8885                    throw new NoSuchEntryException(msg.toString());
8886            }
8887    
8888            /**
8889             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
8890             *
8891             * @param groupId the group ID
8892             * @param userId the user ID
8893             * @param displayDate the display date
8894             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8895             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
8896             */
8897            @Override
8898            public BlogsEntry fetchByG_U_LtD_First(long groupId, long userId,
8899                    Date displayDate, OrderByComparator<BlogsEntry> orderByComparator) {
8900                    List<BlogsEntry> list = findByG_U_LtD(groupId, userId, displayDate, 0,
8901                                    1, orderByComparator);
8902    
8903                    if (!list.isEmpty()) {
8904                            return list.get(0);
8905                    }
8906    
8907                    return null;
8908            }
8909    
8910            /**
8911             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
8912             *
8913             * @param groupId the group ID
8914             * @param userId the user ID
8915             * @param displayDate the display date
8916             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8917             * @return the last matching blogs entry
8918             * @throws NoSuchEntryException if a matching blogs entry could not be found
8919             */
8920            @Override
8921            public BlogsEntry findByG_U_LtD_Last(long groupId, long userId,
8922                    Date displayDate, OrderByComparator<BlogsEntry> orderByComparator)
8923                    throws NoSuchEntryException {
8924                    BlogsEntry blogsEntry = fetchByG_U_LtD_Last(groupId, userId,
8925                                    displayDate, orderByComparator);
8926    
8927                    if (blogsEntry != null) {
8928                            return blogsEntry;
8929                    }
8930    
8931                    StringBundler msg = new StringBundler(8);
8932    
8933                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8934    
8935                    msg.append("groupId=");
8936                    msg.append(groupId);
8937    
8938                    msg.append(", userId=");
8939                    msg.append(userId);
8940    
8941                    msg.append(", displayDate=");
8942                    msg.append(displayDate);
8943    
8944                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8945    
8946                    throw new NoSuchEntryException(msg.toString());
8947            }
8948    
8949            /**
8950             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
8951             *
8952             * @param groupId the group ID
8953             * @param userId the user ID
8954             * @param displayDate the display date
8955             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8956             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
8957             */
8958            @Override
8959            public BlogsEntry fetchByG_U_LtD_Last(long groupId, long userId,
8960                    Date displayDate, OrderByComparator<BlogsEntry> orderByComparator) {
8961                    int count = countByG_U_LtD(groupId, userId, displayDate);
8962    
8963                    if (count == 0) {
8964                            return null;
8965                    }
8966    
8967                    List<BlogsEntry> list = findByG_U_LtD(groupId, userId, displayDate,
8968                                    count - 1, count, orderByComparator);
8969    
8970                    if (!list.isEmpty()) {
8971                            return list.get(0);
8972                    }
8973    
8974                    return null;
8975            }
8976    
8977            /**
8978             * 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;.
8979             *
8980             * @param entryId the primary key of the current blogs entry
8981             * @param groupId the group ID
8982             * @param userId the user ID
8983             * @param displayDate the display date
8984             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8985             * @return the previous, current, and next blogs entry
8986             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
8987             */
8988            @Override
8989            public BlogsEntry[] findByG_U_LtD_PrevAndNext(long entryId, long groupId,
8990                    long userId, Date displayDate,
8991                    OrderByComparator<BlogsEntry> orderByComparator)
8992                    throws NoSuchEntryException {
8993                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
8994    
8995                    Session session = null;
8996    
8997                    try {
8998                            session = openSession();
8999    
9000                            BlogsEntry[] array = new BlogsEntryImpl[3];
9001    
9002                            array[0] = getByG_U_LtD_PrevAndNext(session, blogsEntry, groupId,
9003                                            userId, displayDate, orderByComparator, true);
9004    
9005                            array[1] = blogsEntry;
9006    
9007                            array[2] = getByG_U_LtD_PrevAndNext(session, blogsEntry, groupId,
9008                                            userId, displayDate, orderByComparator, false);
9009    
9010                            return array;
9011                    }
9012                    catch (Exception e) {
9013                            throw processException(e);
9014                    }
9015                    finally {
9016                            closeSession(session);
9017                    }
9018            }
9019    
9020            protected BlogsEntry getByG_U_LtD_PrevAndNext(Session session,
9021                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
9022                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
9023                    StringBundler query = null;
9024    
9025                    if (orderByComparator != null) {
9026                            query = new StringBundler(6 +
9027                                            (orderByComparator.getOrderByConditionFields().length * 3) +
9028                                            (orderByComparator.getOrderByFields().length * 3));
9029                    }
9030                    else {
9031                            query = new StringBundler(5);
9032                    }
9033    
9034                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
9035    
9036                    query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
9037    
9038                    query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
9039    
9040                    boolean bindDisplayDate = false;
9041    
9042                    if (displayDate == null) {
9043                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
9044                    }
9045                    else {
9046                            bindDisplayDate = true;
9047    
9048                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
9049                    }
9050    
9051                    if (orderByComparator != null) {
9052                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9053    
9054                            if (orderByConditionFields.length > 0) {
9055                                    query.append(WHERE_AND);
9056                            }
9057    
9058                            for (int i = 0; i < orderByConditionFields.length; i++) {
9059                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9060                                    query.append(orderByConditionFields[i]);
9061    
9062                                    if ((i + 1) < orderByConditionFields.length) {
9063                                            if (orderByComparator.isAscending() ^ previous) {
9064                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9065                                            }
9066                                            else {
9067                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
9068                                            }
9069                                    }
9070                                    else {
9071                                            if (orderByComparator.isAscending() ^ previous) {
9072                                                    query.append(WHERE_GREATER_THAN);
9073                                            }
9074                                            else {
9075                                                    query.append(WHERE_LESSER_THAN);
9076                                            }
9077                                    }
9078                            }
9079    
9080                            query.append(ORDER_BY_CLAUSE);
9081    
9082                            String[] orderByFields = orderByComparator.getOrderByFields();
9083    
9084                            for (int i = 0; i < orderByFields.length; i++) {
9085                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9086                                    query.append(orderByFields[i]);
9087    
9088                                    if ((i + 1) < orderByFields.length) {
9089                                            if (orderByComparator.isAscending() ^ previous) {
9090                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
9091                                            }
9092                                            else {
9093                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
9094                                            }
9095                                    }
9096                                    else {
9097                                            if (orderByComparator.isAscending() ^ previous) {
9098                                                    query.append(ORDER_BY_ASC);
9099                                            }
9100                                            else {
9101                                                    query.append(ORDER_BY_DESC);
9102                                            }
9103                                    }
9104                            }
9105                    }
9106                    else {
9107                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
9108                    }
9109    
9110                    String sql = query.toString();
9111    
9112                    Query q = session.createQuery(sql);
9113    
9114                    q.setFirstResult(0);
9115                    q.setMaxResults(2);
9116    
9117                    QueryPos qPos = QueryPos.getInstance(q);
9118    
9119                    qPos.add(groupId);
9120    
9121                    qPos.add(userId);
9122    
9123                    if (bindDisplayDate) {
9124                            qPos.add(new Timestamp(displayDate.getTime()));
9125                    }
9126    
9127                    if (orderByComparator != null) {
9128                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
9129    
9130                            for (Object value : values) {
9131                                    qPos.add(value);
9132                            }
9133                    }
9134    
9135                    List<BlogsEntry> list = q.list();
9136    
9137                    if (list.size() == 2) {
9138                            return list.get(1);
9139                    }
9140                    else {
9141                            return null;
9142                    }
9143            }
9144    
9145            /**
9146             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
9147             *
9148             * @param groupId the group ID
9149             * @param userId the user ID
9150             * @param displayDate the display date
9151             * @return the matching blogs entries that the user has permission to view
9152             */
9153            @Override
9154            public List<BlogsEntry> filterFindByG_U_LtD(long groupId, long userId,
9155                    Date displayDate) {
9156                    return filterFindByG_U_LtD(groupId, userId, displayDate,
9157                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
9158            }
9159    
9160            /**
9161             * 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;.
9162             *
9163             * <p>
9164             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9165             * </p>
9166             *
9167             * @param groupId the group ID
9168             * @param userId the user ID
9169             * @param displayDate the display date
9170             * @param start the lower bound of the range of blogs entries
9171             * @param end the upper bound of the range of blogs entries (not inclusive)
9172             * @return the range of matching blogs entries that the user has permission to view
9173             */
9174            @Override
9175            public List<BlogsEntry> filterFindByG_U_LtD(long groupId, long userId,
9176                    Date displayDate, int start, int end) {
9177                    return filterFindByG_U_LtD(groupId, userId, displayDate, start, end,
9178                            null);
9179            }
9180    
9181            /**
9182             * 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;.
9183             *
9184             * <p>
9185             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9186             * </p>
9187             *
9188             * @param groupId the group ID
9189             * @param userId the user ID
9190             * @param displayDate the display date
9191             * @param start the lower bound of the range of blogs entries
9192             * @param end the upper bound of the range of blogs entries (not inclusive)
9193             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9194             * @return the ordered range of matching blogs entries that the user has permission to view
9195             */
9196            @Override
9197            public List<BlogsEntry> filterFindByG_U_LtD(long groupId, long userId,
9198                    Date displayDate, int start, int end,
9199                    OrderByComparator<BlogsEntry> orderByComparator) {
9200                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9201                            return findByG_U_LtD(groupId, userId, displayDate, start, end,
9202                                    orderByComparator);
9203                    }
9204    
9205                    StringBundler query = null;
9206    
9207                    if (orderByComparator != null) {
9208                            query = new StringBundler(5 +
9209                                            (orderByComparator.getOrderByFields().length * 2));
9210                    }
9211                    else {
9212                            query = new StringBundler(6);
9213                    }
9214    
9215                    if (getDB().isSupportsInlineDistinct()) {
9216                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
9217                    }
9218                    else {
9219                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
9220                    }
9221    
9222                    query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
9223    
9224                    query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
9225    
9226                    boolean bindDisplayDate = false;
9227    
9228                    if (displayDate == null) {
9229                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
9230                    }
9231                    else {
9232                            bindDisplayDate = true;
9233    
9234                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
9235                    }
9236    
9237                    if (!getDB().isSupportsInlineDistinct()) {
9238                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
9239                    }
9240    
9241                    if (orderByComparator != null) {
9242                            if (getDB().isSupportsInlineDistinct()) {
9243                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9244                                            orderByComparator, true);
9245                            }
9246                            else {
9247                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
9248                                            orderByComparator, true);
9249                            }
9250                    }
9251                    else {
9252                            if (getDB().isSupportsInlineDistinct()) {
9253                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
9254                            }
9255                            else {
9256                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
9257                            }
9258                    }
9259    
9260                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9261                                    BlogsEntry.class.getName(),
9262                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9263    
9264                    Session session = null;
9265    
9266                    try {
9267                            session = openSession();
9268    
9269                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
9270    
9271                            if (getDB().isSupportsInlineDistinct()) {
9272                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
9273                            }
9274                            else {
9275                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
9276                            }
9277    
9278                            QueryPos qPos = QueryPos.getInstance(q);
9279    
9280                            qPos.add(groupId);
9281    
9282                            qPos.add(userId);
9283    
9284                            if (bindDisplayDate) {
9285                                    qPos.add(new Timestamp(displayDate.getTime()));
9286                            }
9287    
9288                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
9289                    }
9290                    catch (Exception e) {
9291                            throw processException(e);
9292                    }
9293                    finally {
9294                            closeSession(session);
9295                    }
9296            }
9297    
9298            /**
9299             * 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;.
9300             *
9301             * @param entryId the primary key of the current blogs entry
9302             * @param groupId the group ID
9303             * @param userId the user ID
9304             * @param displayDate the display date
9305             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9306             * @return the previous, current, and next blogs entry
9307             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
9308             */
9309            @Override
9310            public BlogsEntry[] filterFindByG_U_LtD_PrevAndNext(long entryId,
9311                    long groupId, long userId, Date displayDate,
9312                    OrderByComparator<BlogsEntry> orderByComparator)
9313                    throws NoSuchEntryException {
9314                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9315                            return findByG_U_LtD_PrevAndNext(entryId, groupId, userId,
9316                                    displayDate, orderByComparator);
9317                    }
9318    
9319                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
9320    
9321                    Session session = null;
9322    
9323                    try {
9324                            session = openSession();
9325    
9326                            BlogsEntry[] array = new BlogsEntryImpl[3];
9327    
9328                            array[0] = filterGetByG_U_LtD_PrevAndNext(session, blogsEntry,
9329                                            groupId, userId, displayDate, orderByComparator, true);
9330    
9331                            array[1] = blogsEntry;
9332    
9333                            array[2] = filterGetByG_U_LtD_PrevAndNext(session, blogsEntry,
9334                                            groupId, userId, displayDate, orderByComparator, false);
9335    
9336                            return array;
9337                    }
9338                    catch (Exception e) {
9339                            throw processException(e);
9340                    }
9341                    finally {
9342                            closeSession(session);
9343                    }
9344            }
9345    
9346            protected BlogsEntry filterGetByG_U_LtD_PrevAndNext(Session session,
9347                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
9348                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
9349                    StringBundler query = null;
9350    
9351                    if (orderByComparator != null) {
9352                            query = new StringBundler(7 +
9353                                            (orderByComparator.getOrderByConditionFields().length * 3) +
9354                                            (orderByComparator.getOrderByFields().length * 3));
9355                    }
9356                    else {
9357                            query = new StringBundler(6);
9358                    }
9359    
9360                    if (getDB().isSupportsInlineDistinct()) {
9361                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
9362                    }
9363                    else {
9364                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
9365                    }
9366    
9367                    query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
9368    
9369                    query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
9370    
9371                    boolean bindDisplayDate = false;
9372    
9373                    if (displayDate == null) {
9374                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
9375                    }
9376                    else {
9377                            bindDisplayDate = true;
9378    
9379                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
9380                    }
9381    
9382                    if (!getDB().isSupportsInlineDistinct()) {
9383                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
9384                    }
9385    
9386                    if (orderByComparator != null) {
9387                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9388    
9389                            if (orderByConditionFields.length > 0) {
9390                                    query.append(WHERE_AND);
9391                            }
9392    
9393                            for (int i = 0; i < orderByConditionFields.length; i++) {
9394                                    if (getDB().isSupportsInlineDistinct()) {
9395                                            query.append(_ORDER_BY_ENTITY_ALIAS);
9396                                    }
9397                                    else {
9398                                            query.append(_ORDER_BY_ENTITY_TABLE);
9399                                    }
9400    
9401                                    query.append(orderByConditionFields[i]);
9402    
9403                                    if ((i + 1) < orderByConditionFields.length) {
9404                                            if (orderByComparator.isAscending() ^ previous) {
9405                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9406                                            }
9407                                            else {
9408                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
9409                                            }
9410                                    }
9411                                    else {
9412                                            if (orderByComparator.isAscending() ^ previous) {
9413                                                    query.append(WHERE_GREATER_THAN);
9414                                            }
9415                                            else {
9416                                                    query.append(WHERE_LESSER_THAN);
9417                                            }
9418                                    }
9419                            }
9420    
9421                            query.append(ORDER_BY_CLAUSE);
9422    
9423                            String[] orderByFields = orderByComparator.getOrderByFields();
9424    
9425                            for (int i = 0; i < orderByFields.length; i++) {
9426                                    if (getDB().isSupportsInlineDistinct()) {
9427                                            query.append(_ORDER_BY_ENTITY_ALIAS);
9428                                    }
9429                                    else {
9430                                            query.append(_ORDER_BY_ENTITY_TABLE);
9431                                    }
9432    
9433                                    query.append(orderByFields[i]);
9434    
9435                                    if ((i + 1) < orderByFields.length) {
9436                                            if (orderByComparator.isAscending() ^ previous) {
9437                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
9438                                            }
9439                                            else {
9440                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
9441                                            }
9442                                    }
9443                                    else {
9444                                            if (orderByComparator.isAscending() ^ previous) {
9445                                                    query.append(ORDER_BY_ASC);
9446                                            }
9447                                            else {
9448                                                    query.append(ORDER_BY_DESC);
9449                                            }
9450                                    }
9451                            }
9452                    }
9453                    else {
9454                            if (getDB().isSupportsInlineDistinct()) {
9455                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
9456                            }
9457                            else {
9458                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
9459                            }
9460                    }
9461    
9462                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9463                                    BlogsEntry.class.getName(),
9464                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9465    
9466                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
9467    
9468                    q.setFirstResult(0);
9469                    q.setMaxResults(2);
9470    
9471                    if (getDB().isSupportsInlineDistinct()) {
9472                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
9473                    }
9474                    else {
9475                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
9476                    }
9477    
9478                    QueryPos qPos = QueryPos.getInstance(q);
9479    
9480                    qPos.add(groupId);
9481    
9482                    qPos.add(userId);
9483    
9484                    if (bindDisplayDate) {
9485                            qPos.add(new Timestamp(displayDate.getTime()));
9486                    }
9487    
9488                    if (orderByComparator != null) {
9489                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
9490    
9491                            for (Object value : values) {
9492                                    qPos.add(value);
9493                            }
9494                    }
9495    
9496                    List<BlogsEntry> list = q.list();
9497    
9498                    if (list.size() == 2) {
9499                            return list.get(1);
9500                    }
9501                    else {
9502                            return null;
9503                    }
9504            }
9505    
9506            /**
9507             * Removes all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; from the database.
9508             *
9509             * @param groupId the group ID
9510             * @param userId the user ID
9511             * @param displayDate the display date
9512             */
9513            @Override
9514            public void removeByG_U_LtD(long groupId, long userId, Date displayDate) {
9515                    for (BlogsEntry blogsEntry : findByG_U_LtD(groupId, userId,
9516                                    displayDate, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
9517                            remove(blogsEntry);
9518                    }
9519            }
9520    
9521            /**
9522             * Returns the number of blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
9523             *
9524             * @param groupId the group ID
9525             * @param userId the user ID
9526             * @param displayDate the display date
9527             * @return the number of matching blogs entries
9528             */
9529            @Override
9530            public int countByG_U_LtD(long groupId, long userId, Date displayDate) {
9531                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD;
9532    
9533                    Object[] finderArgs = new Object[] { groupId, userId, displayDate };
9534    
9535                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
9536    
9537                    if (count == null) {
9538                            StringBundler query = new StringBundler(4);
9539    
9540                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
9541    
9542                            query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
9543    
9544                            query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
9545    
9546                            boolean bindDisplayDate = false;
9547    
9548                            if (displayDate == null) {
9549                                    query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
9550                            }
9551                            else {
9552                                    bindDisplayDate = true;
9553    
9554                                    query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
9555                            }
9556    
9557                            String sql = query.toString();
9558    
9559                            Session session = null;
9560    
9561                            try {
9562                                    session = openSession();
9563    
9564                                    Query q = session.createQuery(sql);
9565    
9566                                    QueryPos qPos = QueryPos.getInstance(q);
9567    
9568                                    qPos.add(groupId);
9569    
9570                                    qPos.add(userId);
9571    
9572                                    if (bindDisplayDate) {
9573                                            qPos.add(new Timestamp(displayDate.getTime()));
9574                                    }
9575    
9576                                    count = (Long)q.uniqueResult();
9577    
9578                                    finderCache.putResult(finderPath, finderArgs, count);
9579                            }
9580                            catch (Exception e) {
9581                                    finderCache.removeResult(finderPath, finderArgs);
9582    
9583                                    throw processException(e);
9584                            }
9585                            finally {
9586                                    closeSession(session);
9587                            }
9588                    }
9589    
9590                    return count.intValue();
9591            }
9592    
9593            /**
9594             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
9595             *
9596             * @param groupId the group ID
9597             * @param userId the user ID
9598             * @param displayDate the display date
9599             * @return the number of matching blogs entries that the user has permission to view
9600             */
9601            @Override
9602            public int filterCountByG_U_LtD(long groupId, long userId, Date displayDate) {
9603                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9604                            return countByG_U_LtD(groupId, userId, displayDate);
9605                    }
9606    
9607                    StringBundler query = new StringBundler(4);
9608    
9609                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
9610    
9611                    query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
9612    
9613                    query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
9614    
9615                    boolean bindDisplayDate = false;
9616    
9617                    if (displayDate == null) {
9618                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
9619                    }
9620                    else {
9621                            bindDisplayDate = true;
9622    
9623                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
9624                    }
9625    
9626                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9627                                    BlogsEntry.class.getName(),
9628                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9629    
9630                    Session session = null;
9631    
9632                    try {
9633                            session = openSession();
9634    
9635                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
9636    
9637                            q.addScalar(COUNT_COLUMN_NAME,
9638                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
9639    
9640                            QueryPos qPos = QueryPos.getInstance(q);
9641    
9642                            qPos.add(groupId);
9643    
9644                            qPos.add(userId);
9645    
9646                            if (bindDisplayDate) {
9647                                    qPos.add(new Timestamp(displayDate.getTime()));
9648                            }
9649    
9650                            Long count = (Long)q.uniqueResult();
9651    
9652                            return count.intValue();
9653                    }
9654                    catch (Exception e) {
9655                            throw processException(e);
9656                    }
9657                    finally {
9658                            closeSession(session);
9659                    }
9660            }
9661    
9662            private static final String _FINDER_COLUMN_G_U_LTD_GROUPID_2 = "blogsEntry.groupId = ? AND ";
9663            private static final String _FINDER_COLUMN_G_U_LTD_USERID_2 = "blogsEntry.userId = ? AND ";
9664            private static final String _FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1 = "blogsEntry.displayDate IS NULL";
9665            private static final String _FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2 = "blogsEntry.displayDate < ?";
9666            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
9667                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
9668                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_S",
9669                            new String[] {
9670                                    Long.class.getName(), Long.class.getName(),
9671                                    Integer.class.getName(),
9672                                    
9673                            Integer.class.getName(), Integer.class.getName(),
9674                                    OrderByComparator.class.getName()
9675                            });
9676            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
9677                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
9678                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U_S",
9679                            new String[] {
9680                                    Long.class.getName(), Long.class.getName(),
9681                                    Integer.class.getName()
9682                            },
9683                            BlogsEntryModelImpl.GROUPID_COLUMN_BITMASK |
9684                            BlogsEntryModelImpl.USERID_COLUMN_BITMASK |
9685                            BlogsEntryModelImpl.STATUS_COLUMN_BITMASK |
9686                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
9687                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
9688            public static final FinderPath FINDER_PATH_COUNT_BY_G_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
9689                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
9690                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U_S",
9691                            new String[] {
9692                                    Long.class.getName(), Long.class.getName(),
9693                                    Integer.class.getName()
9694                            });
9695            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
9696                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
9697                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_U_S",
9698                            new String[] {
9699                                    Long.class.getName(), Long.class.getName(),
9700                                    Integer.class.getName()
9701                            });
9702    
9703            /**
9704             * Returns all the blogs entries where groupId = &#63; and userId = &#63; and status = &#63;.
9705             *
9706             * @param groupId the group ID
9707             * @param userId the user ID
9708             * @param status the status
9709             * @return the matching blogs entries
9710             */
9711            @Override
9712            public List<BlogsEntry> findByG_U_S(long groupId, long userId, int status) {
9713                    return findByG_U_S(groupId, userId, status, QueryUtil.ALL_POS,
9714                            QueryUtil.ALL_POS, null);
9715            }
9716    
9717            /**
9718             * Returns a range of all the blogs entries where groupId = &#63; and userId = &#63; and status = &#63;.
9719             *
9720             * <p>
9721             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9722             * </p>
9723             *
9724             * @param groupId the group ID
9725             * @param userId the user ID
9726             * @param status the status
9727             * @param start the lower bound of the range of blogs entries
9728             * @param end the upper bound of the range of blogs entries (not inclusive)
9729             * @return the range of matching blogs entries
9730             */
9731            @Override
9732            public List<BlogsEntry> findByG_U_S(long groupId, long userId, int status,
9733                    int start, int end) {
9734                    return findByG_U_S(groupId, userId, status, start, end, null);
9735            }
9736    
9737            /**
9738             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and status = &#63;.
9739             *
9740             * <p>
9741             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9742             * </p>
9743             *
9744             * @param groupId the group ID
9745             * @param userId the user ID
9746             * @param status the status
9747             * @param start the lower bound of the range of blogs entries
9748             * @param end the upper bound of the range of blogs entries (not inclusive)
9749             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9750             * @return the ordered range of matching blogs entries
9751             */
9752            @Override
9753            public List<BlogsEntry> findByG_U_S(long groupId, long userId, int status,
9754                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator) {
9755                    return findByG_U_S(groupId, userId, status, start, end,
9756                            orderByComparator, true);
9757            }
9758    
9759            /**
9760             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and status = &#63;.
9761             *
9762             * <p>
9763             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9764             * </p>
9765             *
9766             * @param groupId the group ID
9767             * @param userId the user ID
9768             * @param status the status
9769             * @param start the lower bound of the range of blogs entries
9770             * @param end the upper bound of the range of blogs entries (not inclusive)
9771             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9772             * @param retrieveFromCache whether to retrieve from the finder cache
9773             * @return the ordered range of matching blogs entries
9774             */
9775            @Override
9776            public List<BlogsEntry> findByG_U_S(long groupId, long userId, int status,
9777                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator,
9778                    boolean retrieveFromCache) {
9779                    boolean pagination = true;
9780                    FinderPath finderPath = null;
9781                    Object[] finderArgs = null;
9782    
9783                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
9784                                    (orderByComparator == null)) {
9785                            pagination = false;
9786                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S;
9787                            finderArgs = new Object[] { groupId, userId, status };
9788                    }
9789                    else {
9790                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_S;
9791                            finderArgs = new Object[] {
9792                                            groupId, userId, status,
9793                                            
9794                                            start, end, orderByComparator
9795                                    };
9796                    }
9797    
9798                    List<BlogsEntry> list = null;
9799    
9800                    if (retrieveFromCache) {
9801                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
9802                                            finderArgs, this);
9803    
9804                            if ((list != null) && !list.isEmpty()) {
9805                                    for (BlogsEntry blogsEntry : list) {
9806                                            if ((groupId != blogsEntry.getGroupId()) ||
9807                                                            (userId != blogsEntry.getUserId()) ||
9808                                                            (status != blogsEntry.getStatus())) {
9809                                                    list = null;
9810    
9811                                                    break;
9812                                            }
9813                                    }
9814                            }
9815                    }
9816    
9817                    if (list == null) {
9818                            StringBundler query = null;
9819    
9820                            if (orderByComparator != null) {
9821                                    query = new StringBundler(5 +
9822                                                    (orderByComparator.getOrderByFields().length * 2));
9823                            }
9824                            else {
9825                                    query = new StringBundler(5);
9826                            }
9827    
9828                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
9829    
9830                            query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
9831    
9832                            query.append(_FINDER_COLUMN_G_U_S_USERID_2);
9833    
9834                            query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
9835    
9836                            if (orderByComparator != null) {
9837                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9838                                            orderByComparator);
9839                            }
9840                            else
9841                             if (pagination) {
9842                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
9843                            }
9844    
9845                            String sql = query.toString();
9846    
9847                            Session session = null;
9848    
9849                            try {
9850                                    session = openSession();
9851    
9852                                    Query q = session.createQuery(sql);
9853    
9854                                    QueryPos qPos = QueryPos.getInstance(q);
9855    
9856                                    qPos.add(groupId);
9857    
9858                                    qPos.add(userId);
9859    
9860                                    qPos.add(status);
9861    
9862                                    if (!pagination) {
9863                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
9864                                                            start, end, false);
9865    
9866                                            Collections.sort(list);
9867    
9868                                            list = Collections.unmodifiableList(list);
9869                                    }
9870                                    else {
9871                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
9872                                                            start, end);
9873                                    }
9874    
9875                                    cacheResult(list);
9876    
9877                                    finderCache.putResult(finderPath, finderArgs, list);
9878                            }
9879                            catch (Exception e) {
9880                                    finderCache.removeResult(finderPath, finderArgs);
9881    
9882                                    throw processException(e);
9883                            }
9884                            finally {
9885                                    closeSession(session);
9886                            }
9887                    }
9888    
9889                    return list;
9890            }
9891    
9892            /**
9893             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
9894             *
9895             * @param groupId the group ID
9896             * @param userId the user ID
9897             * @param status the status
9898             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9899             * @return the first matching blogs entry
9900             * @throws NoSuchEntryException if a matching blogs entry could not be found
9901             */
9902            @Override
9903            public BlogsEntry findByG_U_S_First(long groupId, long userId, int status,
9904                    OrderByComparator<BlogsEntry> orderByComparator)
9905                    throws NoSuchEntryException {
9906                    BlogsEntry blogsEntry = fetchByG_U_S_First(groupId, userId, status,
9907                                    orderByComparator);
9908    
9909                    if (blogsEntry != null) {
9910                            return blogsEntry;
9911                    }
9912    
9913                    StringBundler msg = new StringBundler(8);
9914    
9915                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9916    
9917                    msg.append("groupId=");
9918                    msg.append(groupId);
9919    
9920                    msg.append(", userId=");
9921                    msg.append(userId);
9922    
9923                    msg.append(", status=");
9924                    msg.append(status);
9925    
9926                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9927    
9928                    throw new NoSuchEntryException(msg.toString());
9929            }
9930    
9931            /**
9932             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
9933             *
9934             * @param groupId the group ID
9935             * @param userId the user ID
9936             * @param status the status
9937             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9938             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
9939             */
9940            @Override
9941            public BlogsEntry fetchByG_U_S_First(long groupId, long userId, int status,
9942                    OrderByComparator<BlogsEntry> orderByComparator) {
9943                    List<BlogsEntry> list = findByG_U_S(groupId, userId, status, 0, 1,
9944                                    orderByComparator);
9945    
9946                    if (!list.isEmpty()) {
9947                            return list.get(0);
9948                    }
9949    
9950                    return null;
9951            }
9952    
9953            /**
9954             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
9955             *
9956             * @param groupId the group ID
9957             * @param userId the user ID
9958             * @param status the status
9959             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9960             * @return the last matching blogs entry
9961             * @throws NoSuchEntryException if a matching blogs entry could not be found
9962             */
9963            @Override
9964            public BlogsEntry findByG_U_S_Last(long groupId, long userId, int status,
9965                    OrderByComparator<BlogsEntry> orderByComparator)
9966                    throws NoSuchEntryException {
9967                    BlogsEntry blogsEntry = fetchByG_U_S_Last(groupId, userId, status,
9968                                    orderByComparator);
9969    
9970                    if (blogsEntry != null) {
9971                            return blogsEntry;
9972                    }
9973    
9974                    StringBundler msg = new StringBundler(8);
9975    
9976                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9977    
9978                    msg.append("groupId=");
9979                    msg.append(groupId);
9980    
9981                    msg.append(", userId=");
9982                    msg.append(userId);
9983    
9984                    msg.append(", status=");
9985                    msg.append(status);
9986    
9987                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9988    
9989                    throw new NoSuchEntryException(msg.toString());
9990            }
9991    
9992            /**
9993             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
9994             *
9995             * @param groupId the group ID
9996             * @param userId the user ID
9997             * @param status the status
9998             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9999             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
10000             */
10001            @Override
10002            public BlogsEntry fetchByG_U_S_Last(long groupId, long userId, int status,
10003                    OrderByComparator<BlogsEntry> orderByComparator) {
10004                    int count = countByG_U_S(groupId, userId, status);
10005    
10006                    if (count == 0) {
10007                            return null;
10008                    }
10009    
10010                    List<BlogsEntry> list = findByG_U_S(groupId, userId, status, count - 1,
10011                                    count, orderByComparator);
10012    
10013                    if (!list.isEmpty()) {
10014                            return list.get(0);
10015                    }
10016    
10017                    return null;
10018            }
10019    
10020            /**
10021             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
10022             *
10023             * @param entryId the primary key of the current blogs entry
10024             * @param groupId the group ID
10025             * @param userId the user ID
10026             * @param status the status
10027             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10028             * @return the previous, current, and next blogs entry
10029             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
10030             */
10031            @Override
10032            public BlogsEntry[] findByG_U_S_PrevAndNext(long entryId, long groupId,
10033                    long userId, int status, OrderByComparator<BlogsEntry> orderByComparator)
10034                    throws NoSuchEntryException {
10035                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
10036    
10037                    Session session = null;
10038    
10039                    try {
10040                            session = openSession();
10041    
10042                            BlogsEntry[] array = new BlogsEntryImpl[3];
10043    
10044                            array[0] = getByG_U_S_PrevAndNext(session, blogsEntry, groupId,
10045                                            userId, status, orderByComparator, true);
10046    
10047                            array[1] = blogsEntry;
10048    
10049                            array[2] = getByG_U_S_PrevAndNext(session, blogsEntry, groupId,
10050                                            userId, status, orderByComparator, false);
10051    
10052                            return array;
10053                    }
10054                    catch (Exception e) {
10055                            throw processException(e);
10056                    }
10057                    finally {
10058                            closeSession(session);
10059                    }
10060            }
10061    
10062            protected BlogsEntry getByG_U_S_PrevAndNext(Session session,
10063                    BlogsEntry blogsEntry, long groupId, long userId, int status,
10064                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
10065                    StringBundler query = null;
10066    
10067                    if (orderByComparator != null) {
10068                            query = new StringBundler(6 +
10069                                            (orderByComparator.getOrderByConditionFields().length * 3) +
10070                                            (orderByComparator.getOrderByFields().length * 3));
10071                    }
10072                    else {
10073                            query = new StringBundler(5);
10074                    }
10075    
10076                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
10077    
10078                    query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
10079    
10080                    query.append(_FINDER_COLUMN_G_U_S_USERID_2);
10081    
10082                    query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
10083    
10084                    if (orderByComparator != null) {
10085                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10086    
10087                            if (orderByConditionFields.length > 0) {
10088                                    query.append(WHERE_AND);
10089                            }
10090    
10091                            for (int i = 0; i < orderByConditionFields.length; i++) {
10092                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10093                                    query.append(orderByConditionFields[i]);
10094    
10095                                    if ((i + 1) < orderByConditionFields.length) {
10096                                            if (orderByComparator.isAscending() ^ previous) {
10097                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10098                                            }
10099                                            else {
10100                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10101                                            }
10102                                    }
10103                                    else {
10104                                            if (orderByComparator.isAscending() ^ previous) {
10105                                                    query.append(WHERE_GREATER_THAN);
10106                                            }
10107                                            else {
10108                                                    query.append(WHERE_LESSER_THAN);
10109                                            }
10110                                    }
10111                            }
10112    
10113                            query.append(ORDER_BY_CLAUSE);
10114    
10115                            String[] orderByFields = orderByComparator.getOrderByFields();
10116    
10117                            for (int i = 0; i < orderByFields.length; i++) {
10118                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10119                                    query.append(orderByFields[i]);
10120    
10121                                    if ((i + 1) < orderByFields.length) {
10122                                            if (orderByComparator.isAscending() ^ previous) {
10123                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10124                                            }
10125                                            else {
10126                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10127                                            }
10128                                    }
10129                                    else {
10130                                            if (orderByComparator.isAscending() ^ previous) {
10131                                                    query.append(ORDER_BY_ASC);
10132                                            }
10133                                            else {
10134                                                    query.append(ORDER_BY_DESC);
10135                                            }
10136                                    }
10137                            }
10138                    }
10139                    else {
10140                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
10141                    }
10142    
10143                    String sql = query.toString();
10144    
10145                    Query q = session.createQuery(sql);
10146    
10147                    q.setFirstResult(0);
10148                    q.setMaxResults(2);
10149    
10150                    QueryPos qPos = QueryPos.getInstance(q);
10151    
10152                    qPos.add(groupId);
10153    
10154                    qPos.add(userId);
10155    
10156                    qPos.add(status);
10157    
10158                    if (orderByComparator != null) {
10159                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
10160    
10161                            for (Object value : values) {
10162                                    qPos.add(value);
10163                            }
10164                    }
10165    
10166                    List<BlogsEntry> list = q.list();
10167    
10168                    if (list.size() == 2) {
10169                            return list.get(1);
10170                    }
10171                    else {
10172                            return null;
10173                    }
10174            }
10175    
10176            /**
10177             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status = &#63;.
10178             *
10179             * @param groupId the group ID
10180             * @param userId the user ID
10181             * @param status the status
10182             * @return the matching blogs entries that the user has permission to view
10183             */
10184            @Override
10185            public List<BlogsEntry> filterFindByG_U_S(long groupId, long userId,
10186                    int status) {
10187                    return filterFindByG_U_S(groupId, userId, status, QueryUtil.ALL_POS,
10188                            QueryUtil.ALL_POS, null);
10189            }
10190    
10191            /**
10192             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status = &#63;.
10193             *
10194             * <p>
10195             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10196             * </p>
10197             *
10198             * @param groupId the group ID
10199             * @param userId the user ID
10200             * @param status the status
10201             * @param start the lower bound of the range of blogs entries
10202             * @param end the upper bound of the range of blogs entries (not inclusive)
10203             * @return the range of matching blogs entries that the user has permission to view
10204             */
10205            @Override
10206            public List<BlogsEntry> filterFindByG_U_S(long groupId, long userId,
10207                    int status, int start, int end) {
10208                    return filterFindByG_U_S(groupId, userId, status, start, end, null);
10209            }
10210    
10211            /**
10212             * 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;.
10213             *
10214             * <p>
10215             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10216             * </p>
10217             *
10218             * @param groupId the group ID
10219             * @param userId the user ID
10220             * @param status the status
10221             * @param start the lower bound of the range of blogs entries
10222             * @param end the upper bound of the range of blogs entries (not inclusive)
10223             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10224             * @return the ordered range of matching blogs entries that the user has permission to view
10225             */
10226            @Override
10227            public List<BlogsEntry> filterFindByG_U_S(long groupId, long userId,
10228                    int status, int start, int end,
10229                    OrderByComparator<BlogsEntry> orderByComparator) {
10230                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10231                            return findByG_U_S(groupId, userId, status, start, end,
10232                                    orderByComparator);
10233                    }
10234    
10235                    StringBundler query = null;
10236    
10237                    if (orderByComparator != null) {
10238                            query = new StringBundler(5 +
10239                                            (orderByComparator.getOrderByFields().length * 2));
10240                    }
10241                    else {
10242                            query = new StringBundler(6);
10243                    }
10244    
10245                    if (getDB().isSupportsInlineDistinct()) {
10246                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
10247                    }
10248                    else {
10249                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
10250                    }
10251    
10252                    query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
10253    
10254                    query.append(_FINDER_COLUMN_G_U_S_USERID_2);
10255    
10256                    query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
10257    
10258                    if (!getDB().isSupportsInlineDistinct()) {
10259                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
10260                    }
10261    
10262                    if (orderByComparator != null) {
10263                            if (getDB().isSupportsInlineDistinct()) {
10264                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10265                                            orderByComparator, true);
10266                            }
10267                            else {
10268                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
10269                                            orderByComparator, true);
10270                            }
10271                    }
10272                    else {
10273                            if (getDB().isSupportsInlineDistinct()) {
10274                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
10275                            }
10276                            else {
10277                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
10278                            }
10279                    }
10280    
10281                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10282                                    BlogsEntry.class.getName(),
10283                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10284    
10285                    Session session = null;
10286    
10287                    try {
10288                            session = openSession();
10289    
10290                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
10291    
10292                            if (getDB().isSupportsInlineDistinct()) {
10293                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
10294                            }
10295                            else {
10296                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
10297                            }
10298    
10299                            QueryPos qPos = QueryPos.getInstance(q);
10300    
10301                            qPos.add(groupId);
10302    
10303                            qPos.add(userId);
10304    
10305                            qPos.add(status);
10306    
10307                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
10308                    }
10309                    catch (Exception e) {
10310                            throw processException(e);
10311                    }
10312                    finally {
10313                            closeSession(session);
10314                    }
10315            }
10316    
10317            /**
10318             * 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;.
10319             *
10320             * @param entryId the primary key of the current blogs entry
10321             * @param groupId the group ID
10322             * @param userId the user ID
10323             * @param status the status
10324             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10325             * @return the previous, current, and next blogs entry
10326             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
10327             */
10328            @Override
10329            public BlogsEntry[] filterFindByG_U_S_PrevAndNext(long entryId,
10330                    long groupId, long userId, int status,
10331                    OrderByComparator<BlogsEntry> orderByComparator)
10332                    throws NoSuchEntryException {
10333                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10334                            return findByG_U_S_PrevAndNext(entryId, groupId, userId, status,
10335                                    orderByComparator);
10336                    }
10337    
10338                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
10339    
10340                    Session session = null;
10341    
10342                    try {
10343                            session = openSession();
10344    
10345                            BlogsEntry[] array = new BlogsEntryImpl[3];
10346    
10347                            array[0] = filterGetByG_U_S_PrevAndNext(session, blogsEntry,
10348                                            groupId, userId, status, orderByComparator, true);
10349    
10350                            array[1] = blogsEntry;
10351    
10352                            array[2] = filterGetByG_U_S_PrevAndNext(session, blogsEntry,
10353                                            groupId, userId, status, orderByComparator, false);
10354    
10355                            return array;
10356                    }
10357                    catch (Exception e) {
10358                            throw processException(e);
10359                    }
10360                    finally {
10361                            closeSession(session);
10362                    }
10363            }
10364    
10365            protected BlogsEntry filterGetByG_U_S_PrevAndNext(Session session,
10366                    BlogsEntry blogsEntry, long groupId, long userId, int status,
10367                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
10368                    StringBundler query = null;
10369    
10370                    if (orderByComparator != null) {
10371                            query = new StringBundler(7 +
10372                                            (orderByComparator.getOrderByConditionFields().length * 3) +
10373                                            (orderByComparator.getOrderByFields().length * 3));
10374                    }
10375                    else {
10376                            query = new StringBundler(6);
10377                    }
10378    
10379                    if (getDB().isSupportsInlineDistinct()) {
10380                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
10381                    }
10382                    else {
10383                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
10384                    }
10385    
10386                    query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
10387    
10388                    query.append(_FINDER_COLUMN_G_U_S_USERID_2);
10389    
10390                    query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
10391    
10392                    if (!getDB().isSupportsInlineDistinct()) {
10393                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
10394                    }
10395    
10396                    if (orderByComparator != null) {
10397                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10398    
10399                            if (orderByConditionFields.length > 0) {
10400                                    query.append(WHERE_AND);
10401                            }
10402    
10403                            for (int i = 0; i < orderByConditionFields.length; i++) {
10404                                    if (getDB().isSupportsInlineDistinct()) {
10405                                            query.append(_ORDER_BY_ENTITY_ALIAS);
10406                                    }
10407                                    else {
10408                                            query.append(_ORDER_BY_ENTITY_TABLE);
10409                                    }
10410    
10411                                    query.append(orderByConditionFields[i]);
10412    
10413                                    if ((i + 1) < orderByConditionFields.length) {
10414                                            if (orderByComparator.isAscending() ^ previous) {
10415                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10416                                            }
10417                                            else {
10418                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10419                                            }
10420                                    }
10421                                    else {
10422                                            if (orderByComparator.isAscending() ^ previous) {
10423                                                    query.append(WHERE_GREATER_THAN);
10424                                            }
10425                                            else {
10426                                                    query.append(WHERE_LESSER_THAN);
10427                                            }
10428                                    }
10429                            }
10430    
10431                            query.append(ORDER_BY_CLAUSE);
10432    
10433                            String[] orderByFields = orderByComparator.getOrderByFields();
10434    
10435                            for (int i = 0; i < orderByFields.length; i++) {
10436                                    if (getDB().isSupportsInlineDistinct()) {
10437                                            query.append(_ORDER_BY_ENTITY_ALIAS);
10438                                    }
10439                                    else {
10440                                            query.append(_ORDER_BY_ENTITY_TABLE);
10441                                    }
10442    
10443                                    query.append(orderByFields[i]);
10444    
10445                                    if ((i + 1) < orderByFields.length) {
10446                                            if (orderByComparator.isAscending() ^ previous) {
10447                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10448                                            }
10449                                            else {
10450                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10451                                            }
10452                                    }
10453                                    else {
10454                                            if (orderByComparator.isAscending() ^ previous) {
10455                                                    query.append(ORDER_BY_ASC);
10456                                            }
10457                                            else {
10458                                                    query.append(ORDER_BY_DESC);
10459                                            }
10460                                    }
10461                            }
10462                    }
10463                    else {
10464                            if (getDB().isSupportsInlineDistinct()) {
10465                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
10466                            }
10467                            else {
10468                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
10469                            }
10470                    }
10471    
10472                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10473                                    BlogsEntry.class.getName(),
10474                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10475    
10476                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
10477    
10478                    q.setFirstResult(0);
10479                    q.setMaxResults(2);
10480    
10481                    if (getDB().isSupportsInlineDistinct()) {
10482                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
10483                    }
10484                    else {
10485                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
10486                    }
10487    
10488                    QueryPos qPos = QueryPos.getInstance(q);
10489    
10490                    qPos.add(groupId);
10491    
10492                    qPos.add(userId);
10493    
10494                    qPos.add(status);
10495    
10496                    if (orderByComparator != null) {
10497                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
10498    
10499                            for (Object value : values) {
10500                                    qPos.add(value);
10501                            }
10502                    }
10503    
10504                    List<BlogsEntry> list = q.list();
10505    
10506                    if (list.size() == 2) {
10507                            return list.get(1);
10508                    }
10509                    else {
10510                            return null;
10511                    }
10512            }
10513    
10514            /**
10515             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status = any &#63;.
10516             *
10517             * @param groupId the group ID
10518             * @param userId the user ID
10519             * @param statuses the statuses
10520             * @return the matching blogs entries that the user has permission to view
10521             */
10522            @Override
10523            public List<BlogsEntry> filterFindByG_U_S(long groupId, long userId,
10524                    int[] statuses) {
10525                    return filterFindByG_U_S(groupId, userId, statuses, QueryUtil.ALL_POS,
10526                            QueryUtil.ALL_POS, null);
10527            }
10528    
10529            /**
10530             * 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;.
10531             *
10532             * <p>
10533             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10534             * </p>
10535             *
10536             * @param groupId the group ID
10537             * @param userId the user ID
10538             * @param statuses the statuses
10539             * @param start the lower bound of the range of blogs entries
10540             * @param end the upper bound of the range of blogs entries (not inclusive)
10541             * @return the range of matching blogs entries that the user has permission to view
10542             */
10543            @Override
10544            public List<BlogsEntry> filterFindByG_U_S(long groupId, long userId,
10545                    int[] statuses, int start, int end) {
10546                    return filterFindByG_U_S(groupId, userId, statuses, start, end, null);
10547            }
10548    
10549            /**
10550             * 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;.
10551             *
10552             * <p>
10553             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10554             * </p>
10555             *
10556             * @param groupId the group ID
10557             * @param userId the user ID
10558             * @param statuses the statuses
10559             * @param start the lower bound of the range of blogs entries
10560             * @param end the upper bound of the range of blogs entries (not inclusive)
10561             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10562             * @return the ordered range of matching blogs entries that the user has permission to view
10563             */
10564            @Override
10565            public List<BlogsEntry> filterFindByG_U_S(long groupId, long userId,
10566                    int[] statuses, int start, int end,
10567                    OrderByComparator<BlogsEntry> orderByComparator) {
10568                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10569                            return findByG_U_S(groupId, userId, statuses, start, end,
10570                                    orderByComparator);
10571                    }
10572    
10573                    if (statuses == null) {
10574                            statuses = new int[0];
10575                    }
10576                    else if (statuses.length > 1) {
10577                            statuses = ArrayUtil.unique(statuses);
10578    
10579                            Arrays.sort(statuses);
10580                    }
10581    
10582                    StringBundler query = new StringBundler();
10583    
10584                    if (getDB().isSupportsInlineDistinct()) {
10585                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
10586                    }
10587                    else {
10588                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
10589                    }
10590    
10591                    query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
10592    
10593                    query.append(_FINDER_COLUMN_G_U_S_USERID_2);
10594    
10595                    if (statuses.length > 0) {
10596                            query.append(StringPool.OPEN_PARENTHESIS);
10597    
10598                            query.append(_FINDER_COLUMN_G_U_S_STATUS_7);
10599    
10600                            query.append(StringUtil.merge(statuses));
10601    
10602                            query.append(StringPool.CLOSE_PARENTHESIS);
10603    
10604                            query.append(StringPool.CLOSE_PARENTHESIS);
10605                    }
10606    
10607                    query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
10608                            query.index() - 1);
10609    
10610                    if (!getDB().isSupportsInlineDistinct()) {
10611                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
10612                    }
10613    
10614                    if (orderByComparator != null) {
10615                            if (getDB().isSupportsInlineDistinct()) {
10616                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10617                                            orderByComparator, true);
10618                            }
10619                            else {
10620                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
10621                                            orderByComparator, true);
10622                            }
10623                    }
10624                    else {
10625                            if (getDB().isSupportsInlineDistinct()) {
10626                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
10627                            }
10628                            else {
10629                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
10630                            }
10631                    }
10632    
10633                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10634                                    BlogsEntry.class.getName(),
10635                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10636    
10637                    Session session = null;
10638    
10639                    try {
10640                            session = openSession();
10641    
10642                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
10643    
10644                            if (getDB().isSupportsInlineDistinct()) {
10645                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
10646                            }
10647                            else {
10648                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
10649                            }
10650    
10651                            QueryPos qPos = QueryPos.getInstance(q);
10652    
10653                            qPos.add(groupId);
10654    
10655                            qPos.add(userId);
10656    
10657                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
10658                    }
10659                    catch (Exception e) {
10660                            throw processException(e);
10661                    }
10662                    finally {
10663                            closeSession(session);
10664                    }
10665            }
10666    
10667            /**
10668             * Returns all the blogs entries where groupId = &#63; and userId = &#63; and status = any &#63;.
10669             *
10670             * <p>
10671             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10672             * </p>
10673             *
10674             * @param groupId the group ID
10675             * @param userId the user ID
10676             * @param statuses the statuses
10677             * @return the matching blogs entries
10678             */
10679            @Override
10680            public List<BlogsEntry> findByG_U_S(long groupId, long userId,
10681                    int[] statuses) {
10682                    return findByG_U_S(groupId, userId, statuses, QueryUtil.ALL_POS,
10683                            QueryUtil.ALL_POS, null);
10684            }
10685    
10686            /**
10687             * Returns a range of all the blogs entries where groupId = &#63; and userId = &#63; and status = any &#63;.
10688             *
10689             * <p>
10690             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10691             * </p>
10692             *
10693             * @param groupId the group ID
10694             * @param userId the user ID
10695             * @param statuses the statuses
10696             * @param start the lower bound of the range of blogs entries
10697             * @param end the upper bound of the range of blogs entries (not inclusive)
10698             * @return the range of matching blogs entries
10699             */
10700            @Override
10701            public List<BlogsEntry> findByG_U_S(long groupId, long userId,
10702                    int[] statuses, int start, int end) {
10703                    return findByG_U_S(groupId, userId, statuses, start, end, null);
10704            }
10705    
10706            /**
10707             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and status = any &#63;.
10708             *
10709             * <p>
10710             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10711             * </p>
10712             *
10713             * @param groupId the group ID
10714             * @param userId the user ID
10715             * @param statuses the statuses
10716             * @param start the lower bound of the range of blogs entries
10717             * @param end the upper bound of the range of blogs entries (not inclusive)
10718             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10719             * @return the ordered range of matching blogs entries
10720             */
10721            @Override
10722            public List<BlogsEntry> findByG_U_S(long groupId, long userId,
10723                    int[] statuses, int start, int end,
10724                    OrderByComparator<BlogsEntry> orderByComparator) {
10725                    return findByG_U_S(groupId, userId, statuses, start, end,
10726                            orderByComparator, true);
10727            }
10728    
10729            /**
10730             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and status = &#63;, optionally using the finder cache.
10731             *
10732             * <p>
10733             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10734             * </p>
10735             *
10736             * @param groupId the group ID
10737             * @param userId the user ID
10738             * @param status the status
10739             * @param start the lower bound of the range of blogs entries
10740             * @param end the upper bound of the range of blogs entries (not inclusive)
10741             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10742             * @param retrieveFromCache whether to retrieve from the finder cache
10743             * @return the ordered range of matching blogs entries
10744             */
10745            @Override
10746            public List<BlogsEntry> findByG_U_S(long groupId, long userId,
10747                    int[] statuses, int start, int end,
10748                    OrderByComparator<BlogsEntry> orderByComparator,
10749                    boolean retrieveFromCache) {
10750                    if (statuses == null) {
10751                            statuses = new int[0];
10752                    }
10753                    else if (statuses.length > 1) {
10754                            statuses = ArrayUtil.unique(statuses);
10755    
10756                            Arrays.sort(statuses);
10757                    }
10758    
10759                    if (statuses.length == 1) {
10760                            return findByG_U_S(groupId, userId, statuses[0], start, end,
10761                                    orderByComparator);
10762                    }
10763    
10764                    boolean pagination = true;
10765                    Object[] finderArgs = null;
10766    
10767                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
10768                                    (orderByComparator == null)) {
10769                            pagination = false;
10770                            finderArgs = new Object[] {
10771                                            groupId, userId, StringUtil.merge(statuses)
10772                                    };
10773                    }
10774                    else {
10775                            finderArgs = new Object[] {
10776                                            groupId, userId, StringUtil.merge(statuses),
10777                                            
10778                                            start, end, orderByComparator
10779                                    };
10780                    }
10781    
10782                    List<BlogsEntry> list = null;
10783    
10784                    if (retrieveFromCache) {
10785                            list = (List<BlogsEntry>)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_S,
10786                                            finderArgs, this);
10787    
10788                            if ((list != null) && !list.isEmpty()) {
10789                                    for (BlogsEntry blogsEntry : list) {
10790                                            if ((groupId != blogsEntry.getGroupId()) ||
10791                                                            (userId != blogsEntry.getUserId()) ||
10792                                                            !ArrayUtil.contains(statuses, blogsEntry.getStatus())) {
10793                                                    list = null;
10794    
10795                                                    break;
10796                                            }
10797                                    }
10798                            }
10799                    }
10800    
10801                    if (list == null) {
10802                            StringBundler query = new StringBundler();
10803    
10804                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
10805    
10806                            query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
10807    
10808                            query.append(_FINDER_COLUMN_G_U_S_USERID_2);
10809    
10810                            if (statuses.length > 0) {
10811                                    query.append(StringPool.OPEN_PARENTHESIS);
10812    
10813                                    query.append(_FINDER_COLUMN_G_U_S_STATUS_7);
10814    
10815                                    query.append(StringUtil.merge(statuses));
10816    
10817                                    query.append(StringPool.CLOSE_PARENTHESIS);
10818    
10819                                    query.append(StringPool.CLOSE_PARENTHESIS);
10820                            }
10821    
10822                            query.setStringAt(removeConjunction(query.stringAt(query.index() -
10823                                                    1)), query.index() - 1);
10824    
10825                            if (orderByComparator != null) {
10826                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10827                                            orderByComparator);
10828                            }
10829                            else
10830                             if (pagination) {
10831                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
10832                            }
10833    
10834                            String sql = query.toString();
10835    
10836                            Session session = null;
10837    
10838                            try {
10839                                    session = openSession();
10840    
10841                                    Query q = session.createQuery(sql);
10842    
10843                                    QueryPos qPos = QueryPos.getInstance(q);
10844    
10845                                    qPos.add(groupId);
10846    
10847                                    qPos.add(userId);
10848    
10849                                    if (!pagination) {
10850                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
10851                                                            start, end, false);
10852    
10853                                            Collections.sort(list);
10854    
10855                                            list = Collections.unmodifiableList(list);
10856                                    }
10857                                    else {
10858                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
10859                                                            start, end);
10860                                    }
10861    
10862                                    cacheResult(list);
10863    
10864                                    finderCache.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_S,
10865                                            finderArgs, list);
10866                            }
10867                            catch (Exception e) {
10868                                    finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_S,
10869                                            finderArgs);
10870    
10871                                    throw processException(e);
10872                            }
10873                            finally {
10874                                    closeSession(session);
10875                            }
10876                    }
10877    
10878                    return list;
10879            }
10880    
10881            /**
10882             * Removes all the blogs entries where groupId = &#63; and userId = &#63; and status = &#63; from the database.
10883             *
10884             * @param groupId the group ID
10885             * @param userId the user ID
10886             * @param status the status
10887             */
10888            @Override
10889            public void removeByG_U_S(long groupId, long userId, int status) {
10890                    for (BlogsEntry blogsEntry : findByG_U_S(groupId, userId, status,
10891                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
10892                            remove(blogsEntry);
10893                    }
10894            }
10895    
10896            /**
10897             * Returns the number of blogs entries where groupId = &#63; and userId = &#63; and status = &#63;.
10898             *
10899             * @param groupId the group ID
10900             * @param userId the user ID
10901             * @param status the status
10902             * @return the number of matching blogs entries
10903             */
10904            @Override
10905            public int countByG_U_S(long groupId, long userId, int status) {
10906                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_U_S;
10907    
10908                    Object[] finderArgs = new Object[] { groupId, userId, status };
10909    
10910                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
10911    
10912                    if (count == null) {
10913                            StringBundler query = new StringBundler(4);
10914    
10915                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
10916    
10917                            query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
10918    
10919                            query.append(_FINDER_COLUMN_G_U_S_USERID_2);
10920    
10921                            query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
10922    
10923                            String sql = query.toString();
10924    
10925                            Session session = null;
10926    
10927                            try {
10928                                    session = openSession();
10929    
10930                                    Query q = session.createQuery(sql);
10931    
10932                                    QueryPos qPos = QueryPos.getInstance(q);
10933    
10934                                    qPos.add(groupId);
10935    
10936                                    qPos.add(userId);
10937    
10938                                    qPos.add(status);
10939    
10940                                    count = (Long)q.uniqueResult();
10941    
10942                                    finderCache.putResult(finderPath, finderArgs, count);
10943                            }
10944                            catch (Exception e) {
10945                                    finderCache.removeResult(finderPath, finderArgs);
10946    
10947                                    throw processException(e);
10948                            }
10949                            finally {
10950                                    closeSession(session);
10951                            }
10952                    }
10953    
10954                    return count.intValue();
10955            }
10956    
10957            /**
10958             * Returns the number of blogs entries where groupId = &#63; and userId = &#63; and status = any &#63;.
10959             *
10960             * @param groupId the group ID
10961             * @param userId the user ID
10962             * @param statuses the statuses
10963             * @return the number of matching blogs entries
10964             */
10965            @Override
10966            public int countByG_U_S(long groupId, long userId, int[] statuses) {
10967                    if (statuses == null) {
10968                            statuses = new int[0];
10969                    }
10970                    else if (statuses.length > 1) {
10971                            statuses = ArrayUtil.unique(statuses);
10972    
10973                            Arrays.sort(statuses);
10974                    }
10975    
10976                    Object[] finderArgs = new Object[] {
10977                                    groupId, userId, StringUtil.merge(statuses)
10978                            };
10979    
10980                    Long count = (Long)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_S,
10981                                    finderArgs, this);
10982    
10983                    if (count == null) {
10984                            StringBundler query = new StringBundler();
10985    
10986                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
10987    
10988                            query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
10989    
10990                            query.append(_FINDER_COLUMN_G_U_S_USERID_2);
10991    
10992                            if (statuses.length > 0) {
10993                                    query.append(StringPool.OPEN_PARENTHESIS);
10994    
10995                                    query.append(_FINDER_COLUMN_G_U_S_STATUS_7);
10996    
10997                                    query.append(StringUtil.merge(statuses));
10998    
10999                                    query.append(StringPool.CLOSE_PARENTHESIS);
11000    
11001                                    query.append(StringPool.CLOSE_PARENTHESIS);
11002                            }
11003    
11004                            query.setStringAt(removeConjunction(query.stringAt(query.index() -
11005                                                    1)), query.index() - 1);
11006    
11007                            String sql = query.toString();
11008    
11009                            Session session = null;
11010    
11011                            try {
11012                                    session = openSession();
11013    
11014                                    Query q = session.createQuery(sql);
11015    
11016                                    QueryPos qPos = QueryPos.getInstance(q);
11017    
11018                                    qPos.add(groupId);
11019    
11020                                    qPos.add(userId);
11021    
11022                                    count = (Long)q.uniqueResult();
11023    
11024                                    finderCache.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_S,
11025                                            finderArgs, count);
11026                            }
11027                            catch (Exception e) {
11028                                    finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_S,
11029                                            finderArgs);
11030    
11031                                    throw processException(e);
11032                            }
11033                            finally {
11034                                    closeSession(session);
11035                            }
11036                    }
11037    
11038                    return count.intValue();
11039            }
11040    
11041            /**
11042             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status = &#63;.
11043             *
11044             * @param groupId the group ID
11045             * @param userId the user ID
11046             * @param status the status
11047             * @return the number of matching blogs entries that the user has permission to view
11048             */
11049            @Override
11050            public int filterCountByG_U_S(long groupId, long userId, int status) {
11051                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11052                            return countByG_U_S(groupId, userId, status);
11053                    }
11054    
11055                    StringBundler query = new StringBundler(4);
11056    
11057                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
11058    
11059                    query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
11060    
11061                    query.append(_FINDER_COLUMN_G_U_S_USERID_2);
11062    
11063                    query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
11064    
11065                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11066                                    BlogsEntry.class.getName(),
11067                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11068    
11069                    Session session = null;
11070    
11071                    try {
11072                            session = openSession();
11073    
11074                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
11075    
11076                            q.addScalar(COUNT_COLUMN_NAME,
11077                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
11078    
11079                            QueryPos qPos = QueryPos.getInstance(q);
11080    
11081                            qPos.add(groupId);
11082    
11083                            qPos.add(userId);
11084    
11085                            qPos.add(status);
11086    
11087                            Long count = (Long)q.uniqueResult();
11088    
11089                            return count.intValue();
11090                    }
11091                    catch (Exception e) {
11092                            throw processException(e);
11093                    }
11094                    finally {
11095                            closeSession(session);
11096                    }
11097            }
11098    
11099            /**
11100             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status = any &#63;.
11101             *
11102             * @param groupId the group ID
11103             * @param userId the user ID
11104             * @param statuses the statuses
11105             * @return the number of matching blogs entries that the user has permission to view
11106             */
11107            @Override
11108            public int filterCountByG_U_S(long groupId, long userId, int[] statuses) {
11109                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11110                            return countByG_U_S(groupId, userId, statuses);
11111                    }
11112    
11113                    if (statuses == null) {
11114                            statuses = new int[0];
11115                    }
11116                    else if (statuses.length > 1) {
11117                            statuses = ArrayUtil.unique(statuses);
11118    
11119                            Arrays.sort(statuses);
11120                    }
11121    
11122                    StringBundler query = new StringBundler();
11123    
11124                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
11125    
11126                    query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
11127    
11128                    query.append(_FINDER_COLUMN_G_U_S_USERID_2);
11129    
11130                    if (statuses.length > 0) {
11131                            query.append(StringPool.OPEN_PARENTHESIS);
11132    
11133                            query.append(_FINDER_COLUMN_G_U_S_STATUS_7);
11134    
11135                            query.append(StringUtil.merge(statuses));
11136    
11137                            query.append(StringPool.CLOSE_PARENTHESIS);
11138    
11139                            query.append(StringPool.CLOSE_PARENTHESIS);
11140                    }
11141    
11142                    query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
11143                            query.index() - 1);
11144    
11145                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11146                                    BlogsEntry.class.getName(),
11147                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11148    
11149                    Session session = null;
11150    
11151                    try {
11152                            session = openSession();
11153    
11154                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
11155    
11156                            q.addScalar(COUNT_COLUMN_NAME,
11157                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
11158    
11159                            QueryPos qPos = QueryPos.getInstance(q);
11160    
11161                            qPos.add(groupId);
11162    
11163                            qPos.add(userId);
11164    
11165                            Long count = (Long)q.uniqueResult();
11166    
11167                            return count.intValue();
11168                    }
11169                    catch (Exception e) {
11170                            throw processException(e);
11171                    }
11172                    finally {
11173                            closeSession(session);
11174                    }
11175            }
11176    
11177            private static final String _FINDER_COLUMN_G_U_S_GROUPID_2 = "blogsEntry.groupId = ? AND ";
11178            private static final String _FINDER_COLUMN_G_U_S_USERID_2 = "blogsEntry.userId = ? AND ";
11179            private static final String _FINDER_COLUMN_G_U_S_STATUS_2 = "blogsEntry.status = ?";
11180            private static final String _FINDER_COLUMN_G_U_S_STATUS_7 = "blogsEntry.status IN (";
11181            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_NOTS = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
11182                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
11183                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_NotS",
11184                            new String[] {
11185                                    Long.class.getName(), Long.class.getName(),
11186                                    Integer.class.getName(),
11187                                    
11188                            Integer.class.getName(), Integer.class.getName(),
11189                                    OrderByComparator.class.getName()
11190                            });
11191            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_NOTS =
11192                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
11193                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
11194                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_U_NotS",
11195                            new String[] {
11196                                    Long.class.getName(), Long.class.getName(),
11197                                    Integer.class.getName()
11198                            });
11199    
11200            /**
11201             * Returns all the blogs entries where groupId = &#63; and userId = &#63; and status &ne; &#63;.
11202             *
11203             * @param groupId the group ID
11204             * @param userId the user ID
11205             * @param status the status
11206             * @return the matching blogs entries
11207             */
11208            @Override
11209            public List<BlogsEntry> findByG_U_NotS(long groupId, long userId, int status) {
11210                    return findByG_U_NotS(groupId, userId, status, QueryUtil.ALL_POS,
11211                            QueryUtil.ALL_POS, null);
11212            }
11213    
11214            /**
11215             * Returns a range of all the blogs entries where groupId = &#63; and userId = &#63; and status &ne; &#63;.
11216             *
11217             * <p>
11218             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11219             * </p>
11220             *
11221             * @param groupId the group ID
11222             * @param userId the user ID
11223             * @param status the status
11224             * @param start the lower bound of the range of blogs entries
11225             * @param end the upper bound of the range of blogs entries (not inclusive)
11226             * @return the range of matching blogs entries
11227             */
11228            @Override
11229            public List<BlogsEntry> findByG_U_NotS(long groupId, long userId,
11230                    int status, int start, int end) {
11231                    return findByG_U_NotS(groupId, userId, status, start, end, null);
11232            }
11233    
11234            /**
11235             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and status &ne; &#63;.
11236             *
11237             * <p>
11238             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11239             * </p>
11240             *
11241             * @param groupId the group ID
11242             * @param userId the user ID
11243             * @param status the status
11244             * @param start the lower bound of the range of blogs entries
11245             * @param end the upper bound of the range of blogs entries (not inclusive)
11246             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11247             * @return the ordered range of matching blogs entries
11248             */
11249            @Override
11250            public List<BlogsEntry> findByG_U_NotS(long groupId, long userId,
11251                    int status, int start, int end,
11252                    OrderByComparator<BlogsEntry> orderByComparator) {
11253                    return findByG_U_NotS(groupId, userId, status, start, end,
11254                            orderByComparator, true);
11255            }
11256    
11257            /**
11258             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and status &ne; &#63;.
11259             *
11260             * <p>
11261             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11262             * </p>
11263             *
11264             * @param groupId the group ID
11265             * @param userId the user ID
11266             * @param status the status
11267             * @param start the lower bound of the range of blogs entries
11268             * @param end the upper bound of the range of blogs entries (not inclusive)
11269             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11270             * @param retrieveFromCache whether to retrieve from the finder cache
11271             * @return the ordered range of matching blogs entries
11272             */
11273            @Override
11274            public List<BlogsEntry> findByG_U_NotS(long groupId, long userId,
11275                    int status, int start, int end,
11276                    OrderByComparator<BlogsEntry> orderByComparator,
11277                    boolean retrieveFromCache) {
11278                    boolean pagination = true;
11279                    FinderPath finderPath = null;
11280                    Object[] finderArgs = null;
11281    
11282                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_NOTS;
11283                    finderArgs = new Object[] {
11284                                    groupId, userId, status,
11285                                    
11286                                    start, end, orderByComparator
11287                            };
11288    
11289                    List<BlogsEntry> list = null;
11290    
11291                    if (retrieveFromCache) {
11292                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
11293                                            finderArgs, this);
11294    
11295                            if ((list != null) && !list.isEmpty()) {
11296                                    for (BlogsEntry blogsEntry : list) {
11297                                            if ((groupId != blogsEntry.getGroupId()) ||
11298                                                            (userId != blogsEntry.getUserId()) ||
11299                                                            (status == blogsEntry.getStatus())) {
11300                                                    list = null;
11301    
11302                                                    break;
11303                                            }
11304                                    }
11305                            }
11306                    }
11307    
11308                    if (list == null) {
11309                            StringBundler query = null;
11310    
11311                            if (orderByComparator != null) {
11312                                    query = new StringBundler(5 +
11313                                                    (orderByComparator.getOrderByFields().length * 2));
11314                            }
11315                            else {
11316                                    query = new StringBundler(5);
11317                            }
11318    
11319                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
11320    
11321                            query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
11322    
11323                            query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
11324    
11325                            query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
11326    
11327                            if (orderByComparator != null) {
11328                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11329                                            orderByComparator);
11330                            }
11331                            else
11332                             if (pagination) {
11333                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
11334                            }
11335    
11336                            String sql = query.toString();
11337    
11338                            Session session = null;
11339    
11340                            try {
11341                                    session = openSession();
11342    
11343                                    Query q = session.createQuery(sql);
11344    
11345                                    QueryPos qPos = QueryPos.getInstance(q);
11346    
11347                                    qPos.add(groupId);
11348    
11349                                    qPos.add(userId);
11350    
11351                                    qPos.add(status);
11352    
11353                                    if (!pagination) {
11354                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
11355                                                            start, end, false);
11356    
11357                                            Collections.sort(list);
11358    
11359                                            list = Collections.unmodifiableList(list);
11360                                    }
11361                                    else {
11362                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
11363                                                            start, end);
11364                                    }
11365    
11366                                    cacheResult(list);
11367    
11368                                    finderCache.putResult(finderPath, finderArgs, list);
11369                            }
11370                            catch (Exception e) {
11371                                    finderCache.removeResult(finderPath, finderArgs);
11372    
11373                                    throw processException(e);
11374                            }
11375                            finally {
11376                                    closeSession(session);
11377                            }
11378                    }
11379    
11380                    return list;
11381            }
11382    
11383            /**
11384             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status &ne; &#63;.
11385             *
11386             * @param groupId the group ID
11387             * @param userId the user ID
11388             * @param status the status
11389             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11390             * @return the first matching blogs entry
11391             * @throws NoSuchEntryException if a matching blogs entry could not be found
11392             */
11393            @Override
11394            public BlogsEntry findByG_U_NotS_First(long groupId, long userId,
11395                    int status, OrderByComparator<BlogsEntry> orderByComparator)
11396                    throws NoSuchEntryException {
11397                    BlogsEntry blogsEntry = fetchByG_U_NotS_First(groupId, userId, status,
11398                                    orderByComparator);
11399    
11400                    if (blogsEntry != null) {
11401                            return blogsEntry;
11402                    }
11403    
11404                    StringBundler msg = new StringBundler(8);
11405    
11406                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11407    
11408                    msg.append("groupId=");
11409                    msg.append(groupId);
11410    
11411                    msg.append(", userId=");
11412                    msg.append(userId);
11413    
11414                    msg.append(", status=");
11415                    msg.append(status);
11416    
11417                    msg.append(StringPool.CLOSE_CURLY_BRACE);
11418    
11419                    throw new NoSuchEntryException(msg.toString());
11420            }
11421    
11422            /**
11423             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status &ne; &#63;.
11424             *
11425             * @param groupId the group ID
11426             * @param userId the user ID
11427             * @param status the status
11428             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11429             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
11430             */
11431            @Override
11432            public BlogsEntry fetchByG_U_NotS_First(long groupId, long userId,
11433                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
11434                    List<BlogsEntry> list = findByG_U_NotS(groupId, userId, status, 0, 1,
11435                                    orderByComparator);
11436    
11437                    if (!list.isEmpty()) {
11438                            return list.get(0);
11439                    }
11440    
11441                    return null;
11442            }
11443    
11444            /**
11445             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status &ne; &#63;.
11446             *
11447             * @param groupId the group ID
11448             * @param userId the user ID
11449             * @param status the status
11450             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11451             * @return the last matching blogs entry
11452             * @throws NoSuchEntryException if a matching blogs entry could not be found
11453             */
11454            @Override
11455            public BlogsEntry findByG_U_NotS_Last(long groupId, long userId,
11456                    int status, OrderByComparator<BlogsEntry> orderByComparator)
11457                    throws NoSuchEntryException {
11458                    BlogsEntry blogsEntry = fetchByG_U_NotS_Last(groupId, userId, status,
11459                                    orderByComparator);
11460    
11461                    if (blogsEntry != null) {
11462                            return blogsEntry;
11463                    }
11464    
11465                    StringBundler msg = new StringBundler(8);
11466    
11467                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11468    
11469                    msg.append("groupId=");
11470                    msg.append(groupId);
11471    
11472                    msg.append(", userId=");
11473                    msg.append(userId);
11474    
11475                    msg.append(", status=");
11476                    msg.append(status);
11477    
11478                    msg.append(StringPool.CLOSE_CURLY_BRACE);
11479    
11480                    throw new NoSuchEntryException(msg.toString());
11481            }
11482    
11483            /**
11484             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status &ne; &#63;.
11485             *
11486             * @param groupId the group ID
11487             * @param userId the user ID
11488             * @param status the status
11489             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11490             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
11491             */
11492            @Override
11493            public BlogsEntry fetchByG_U_NotS_Last(long groupId, long userId,
11494                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
11495                    int count = countByG_U_NotS(groupId, userId, status);
11496    
11497                    if (count == 0) {
11498                            return null;
11499                    }
11500    
11501                    List<BlogsEntry> list = findByG_U_NotS(groupId, userId, status,
11502                                    count - 1, count, orderByComparator);
11503    
11504                    if (!list.isEmpty()) {
11505                            return list.get(0);
11506                    }
11507    
11508                    return null;
11509            }
11510    
11511            /**
11512             * 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;.
11513             *
11514             * @param entryId the primary key of the current blogs entry
11515             * @param groupId the group ID
11516             * @param userId the user ID
11517             * @param status the status
11518             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11519             * @return the previous, current, and next blogs entry
11520             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
11521             */
11522            @Override
11523            public BlogsEntry[] findByG_U_NotS_PrevAndNext(long entryId, long groupId,
11524                    long userId, int status, OrderByComparator<BlogsEntry> orderByComparator)
11525                    throws NoSuchEntryException {
11526                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
11527    
11528                    Session session = null;
11529    
11530                    try {
11531                            session = openSession();
11532    
11533                            BlogsEntry[] array = new BlogsEntryImpl[3];
11534    
11535                            array[0] = getByG_U_NotS_PrevAndNext(session, blogsEntry, groupId,
11536                                            userId, status, orderByComparator, true);
11537    
11538                            array[1] = blogsEntry;
11539    
11540                            array[2] = getByG_U_NotS_PrevAndNext(session, blogsEntry, groupId,
11541                                            userId, status, orderByComparator, false);
11542    
11543                            return array;
11544                    }
11545                    catch (Exception e) {
11546                            throw processException(e);
11547                    }
11548                    finally {
11549                            closeSession(session);
11550                    }
11551            }
11552    
11553            protected BlogsEntry getByG_U_NotS_PrevAndNext(Session session,
11554                    BlogsEntry blogsEntry, long groupId, long userId, int status,
11555                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
11556                    StringBundler query = null;
11557    
11558                    if (orderByComparator != null) {
11559                            query = new StringBundler(6 +
11560                                            (orderByComparator.getOrderByConditionFields().length * 3) +
11561                                            (orderByComparator.getOrderByFields().length * 3));
11562                    }
11563                    else {
11564                            query = new StringBundler(5);
11565                    }
11566    
11567                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
11568    
11569                    query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
11570    
11571                    query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
11572    
11573                    query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
11574    
11575                    if (orderByComparator != null) {
11576                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11577    
11578                            if (orderByConditionFields.length > 0) {
11579                                    query.append(WHERE_AND);
11580                            }
11581    
11582                            for (int i = 0; i < orderByConditionFields.length; i++) {
11583                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11584                                    query.append(orderByConditionFields[i]);
11585    
11586                                    if ((i + 1) < orderByConditionFields.length) {
11587                                            if (orderByComparator.isAscending() ^ previous) {
11588                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
11589                                            }
11590                                            else {
11591                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
11592                                            }
11593                                    }
11594                                    else {
11595                                            if (orderByComparator.isAscending() ^ previous) {
11596                                                    query.append(WHERE_GREATER_THAN);
11597                                            }
11598                                            else {
11599                                                    query.append(WHERE_LESSER_THAN);
11600                                            }
11601                                    }
11602                            }
11603    
11604                            query.append(ORDER_BY_CLAUSE);
11605    
11606                            String[] orderByFields = orderByComparator.getOrderByFields();
11607    
11608                            for (int i = 0; i < orderByFields.length; i++) {
11609                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11610                                    query.append(orderByFields[i]);
11611    
11612                                    if ((i + 1) < orderByFields.length) {
11613                                            if (orderByComparator.isAscending() ^ previous) {
11614                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
11615                                            }
11616                                            else {
11617                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
11618                                            }
11619                                    }
11620                                    else {
11621                                            if (orderByComparator.isAscending() ^ previous) {
11622                                                    query.append(ORDER_BY_ASC);
11623                                            }
11624                                            else {
11625                                                    query.append(ORDER_BY_DESC);
11626                                            }
11627                                    }
11628                            }
11629                    }
11630                    else {
11631                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
11632                    }
11633    
11634                    String sql = query.toString();
11635    
11636                    Query q = session.createQuery(sql);
11637    
11638                    q.setFirstResult(0);
11639                    q.setMaxResults(2);
11640    
11641                    QueryPos qPos = QueryPos.getInstance(q);
11642    
11643                    qPos.add(groupId);
11644    
11645                    qPos.add(userId);
11646    
11647                    qPos.add(status);
11648    
11649                    if (orderByComparator != null) {
11650                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
11651    
11652                            for (Object value : values) {
11653                                    qPos.add(value);
11654                            }
11655                    }
11656    
11657                    List<BlogsEntry> list = q.list();
11658    
11659                    if (list.size() == 2) {
11660                            return list.get(1);
11661                    }
11662                    else {
11663                            return null;
11664                    }
11665            }
11666    
11667            /**
11668             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status &ne; &#63;.
11669             *
11670             * @param groupId the group ID
11671             * @param userId the user ID
11672             * @param status the status
11673             * @return the matching blogs entries that the user has permission to view
11674             */
11675            @Override
11676            public List<BlogsEntry> filterFindByG_U_NotS(long groupId, long userId,
11677                    int status) {
11678                    return filterFindByG_U_NotS(groupId, userId, status, QueryUtil.ALL_POS,
11679                            QueryUtil.ALL_POS, null);
11680            }
11681    
11682            /**
11683             * 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;.
11684             *
11685             * <p>
11686             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11687             * </p>
11688             *
11689             * @param groupId the group ID
11690             * @param userId the user ID
11691             * @param status the status
11692             * @param start the lower bound of the range of blogs entries
11693             * @param end the upper bound of the range of blogs entries (not inclusive)
11694             * @return the range of matching blogs entries that the user has permission to view
11695             */
11696            @Override
11697            public List<BlogsEntry> filterFindByG_U_NotS(long groupId, long userId,
11698                    int status, int start, int end) {
11699                    return filterFindByG_U_NotS(groupId, userId, status, start, end, null);
11700            }
11701    
11702            /**
11703             * 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;.
11704             *
11705             * <p>
11706             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11707             * </p>
11708             *
11709             * @param groupId the group ID
11710             * @param userId the user ID
11711             * @param status the status
11712             * @param start the lower bound of the range of blogs entries
11713             * @param end the upper bound of the range of blogs entries (not inclusive)
11714             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11715             * @return the ordered range of matching blogs entries that the user has permission to view
11716             */
11717            @Override
11718            public List<BlogsEntry> filterFindByG_U_NotS(long groupId, long userId,
11719                    int status, int start, int end,
11720                    OrderByComparator<BlogsEntry> orderByComparator) {
11721                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11722                            return findByG_U_NotS(groupId, userId, status, start, end,
11723                                    orderByComparator);
11724                    }
11725    
11726                    StringBundler query = null;
11727    
11728                    if (orderByComparator != null) {
11729                            query = new StringBundler(5 +
11730                                            (orderByComparator.getOrderByFields().length * 2));
11731                    }
11732                    else {
11733                            query = new StringBundler(6);
11734                    }
11735    
11736                    if (getDB().isSupportsInlineDistinct()) {
11737                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
11738                    }
11739                    else {
11740                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
11741                    }
11742    
11743                    query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
11744    
11745                    query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
11746    
11747                    query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
11748    
11749                    if (!getDB().isSupportsInlineDistinct()) {
11750                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
11751                    }
11752    
11753                    if (orderByComparator != null) {
11754                            if (getDB().isSupportsInlineDistinct()) {
11755                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11756                                            orderByComparator, true);
11757                            }
11758                            else {
11759                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
11760                                            orderByComparator, true);
11761                            }
11762                    }
11763                    else {
11764                            if (getDB().isSupportsInlineDistinct()) {
11765                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
11766                            }
11767                            else {
11768                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
11769                            }
11770                    }
11771    
11772                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11773                                    BlogsEntry.class.getName(),
11774                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11775    
11776                    Session session = null;
11777    
11778                    try {
11779                            session = openSession();
11780    
11781                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
11782    
11783                            if (getDB().isSupportsInlineDistinct()) {
11784                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
11785                            }
11786                            else {
11787                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
11788                            }
11789    
11790                            QueryPos qPos = QueryPos.getInstance(q);
11791    
11792                            qPos.add(groupId);
11793    
11794                            qPos.add(userId);
11795    
11796                            qPos.add(status);
11797    
11798                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
11799                    }
11800                    catch (Exception e) {
11801                            throw processException(e);
11802                    }
11803                    finally {
11804                            closeSession(session);
11805                    }
11806            }
11807    
11808            /**
11809             * 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;.
11810             *
11811             * @param entryId the primary key of the current blogs entry
11812             * @param groupId the group ID
11813             * @param userId the user ID
11814             * @param status the status
11815             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11816             * @return the previous, current, and next blogs entry
11817             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
11818             */
11819            @Override
11820            public BlogsEntry[] filterFindByG_U_NotS_PrevAndNext(long entryId,
11821                    long groupId, long userId, int status,
11822                    OrderByComparator<BlogsEntry> orderByComparator)
11823                    throws NoSuchEntryException {
11824                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11825                            return findByG_U_NotS_PrevAndNext(entryId, groupId, userId, status,
11826                                    orderByComparator);
11827                    }
11828    
11829                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
11830    
11831                    Session session = null;
11832    
11833                    try {
11834                            session = openSession();
11835    
11836                            BlogsEntry[] array = new BlogsEntryImpl[3];
11837    
11838                            array[0] = filterGetByG_U_NotS_PrevAndNext(session, blogsEntry,
11839                                            groupId, userId, status, orderByComparator, true);
11840    
11841                            array[1] = blogsEntry;
11842    
11843                            array[2] = filterGetByG_U_NotS_PrevAndNext(session, blogsEntry,
11844                                            groupId, userId, status, orderByComparator, false);
11845    
11846                            return array;
11847                    }
11848                    catch (Exception e) {
11849                            throw processException(e);
11850                    }
11851                    finally {
11852                            closeSession(session);
11853                    }
11854            }
11855    
11856            protected BlogsEntry filterGetByG_U_NotS_PrevAndNext(Session session,
11857                    BlogsEntry blogsEntry, long groupId, long userId, int status,
11858                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
11859                    StringBundler query = null;
11860    
11861                    if (orderByComparator != null) {
11862                            query = new StringBundler(7 +
11863                                            (orderByComparator.getOrderByConditionFields().length * 3) +
11864                                            (orderByComparator.getOrderByFields().length * 3));
11865                    }
11866                    else {
11867                            query = new StringBundler(6);
11868                    }
11869    
11870                    if (getDB().isSupportsInlineDistinct()) {
11871                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
11872                    }
11873                    else {
11874                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
11875                    }
11876    
11877                    query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
11878    
11879                    query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
11880    
11881                    query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
11882    
11883                    if (!getDB().isSupportsInlineDistinct()) {
11884                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
11885                    }
11886    
11887                    if (orderByComparator != null) {
11888                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11889    
11890                            if (orderByConditionFields.length > 0) {
11891                                    query.append(WHERE_AND);
11892                            }
11893    
11894                            for (int i = 0; i < orderByConditionFields.length; i++) {
11895                                    if (getDB().isSupportsInlineDistinct()) {
11896                                            query.append(_ORDER_BY_ENTITY_ALIAS);
11897                                    }
11898                                    else {
11899                                            query.append(_ORDER_BY_ENTITY_TABLE);
11900                                    }
11901    
11902                                    query.append(orderByConditionFields[i]);
11903    
11904                                    if ((i + 1) < orderByConditionFields.length) {
11905                                            if (orderByComparator.isAscending() ^ previous) {
11906                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
11907                                            }
11908                                            else {
11909                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
11910                                            }
11911                                    }
11912                                    else {
11913                                            if (orderByComparator.isAscending() ^ previous) {
11914                                                    query.append(WHERE_GREATER_THAN);
11915                                            }
11916                                            else {
11917                                                    query.append(WHERE_LESSER_THAN);
11918                                            }
11919                                    }
11920                            }
11921    
11922                            query.append(ORDER_BY_CLAUSE);
11923    
11924                            String[] orderByFields = orderByComparator.getOrderByFields();
11925    
11926                            for (int i = 0; i < orderByFields.length; i++) {
11927                                    if (getDB().isSupportsInlineDistinct()) {
11928                                            query.append(_ORDER_BY_ENTITY_ALIAS);
11929                                    }
11930                                    else {
11931                                            query.append(_ORDER_BY_ENTITY_TABLE);
11932                                    }
11933    
11934                                    query.append(orderByFields[i]);
11935    
11936                                    if ((i + 1) < orderByFields.length) {
11937                                            if (orderByComparator.isAscending() ^ previous) {
11938                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
11939                                            }
11940                                            else {
11941                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
11942                                            }
11943                                    }
11944                                    else {
11945                                            if (orderByComparator.isAscending() ^ previous) {
11946                                                    query.append(ORDER_BY_ASC);
11947                                            }
11948                                            else {
11949                                                    query.append(ORDER_BY_DESC);
11950                                            }
11951                                    }
11952                            }
11953                    }
11954                    else {
11955                            if (getDB().isSupportsInlineDistinct()) {
11956                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
11957                            }
11958                            else {
11959                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
11960                            }
11961                    }
11962    
11963                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11964                                    BlogsEntry.class.getName(),
11965                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11966    
11967                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
11968    
11969                    q.setFirstResult(0);
11970                    q.setMaxResults(2);
11971    
11972                    if (getDB().isSupportsInlineDistinct()) {
11973                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
11974                    }
11975                    else {
11976                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
11977                    }
11978    
11979                    QueryPos qPos = QueryPos.getInstance(q);
11980    
11981                    qPos.add(groupId);
11982    
11983                    qPos.add(userId);
11984    
11985                    qPos.add(status);
11986    
11987                    if (orderByComparator != null) {
11988                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
11989    
11990                            for (Object value : values) {
11991                                    qPos.add(value);
11992                            }
11993                    }
11994    
11995                    List<BlogsEntry> list = q.list();
11996    
11997                    if (list.size() == 2) {
11998                            return list.get(1);
11999                    }
12000                    else {
12001                            return null;
12002                    }
12003            }
12004    
12005            /**
12006             * Removes all the blogs entries where groupId = &#63; and userId = &#63; and status &ne; &#63; from the database.
12007             *
12008             * @param groupId the group ID
12009             * @param userId the user ID
12010             * @param status the status
12011             */
12012            @Override
12013            public void removeByG_U_NotS(long groupId, long userId, int status) {
12014                    for (BlogsEntry blogsEntry : findByG_U_NotS(groupId, userId, status,
12015                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
12016                            remove(blogsEntry);
12017                    }
12018            }
12019    
12020            /**
12021             * Returns the number of blogs entries where groupId = &#63; and userId = &#63; and status &ne; &#63;.
12022             *
12023             * @param groupId the group ID
12024             * @param userId the user ID
12025             * @param status the status
12026             * @return the number of matching blogs entries
12027             */
12028            @Override
12029            public int countByG_U_NotS(long groupId, long userId, int status) {
12030                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_NOTS;
12031    
12032                    Object[] finderArgs = new Object[] { groupId, userId, status };
12033    
12034                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
12035    
12036                    if (count == null) {
12037                            StringBundler query = new StringBundler(4);
12038    
12039                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
12040    
12041                            query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
12042    
12043                            query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
12044    
12045                            query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
12046    
12047                            String sql = query.toString();
12048    
12049                            Session session = null;
12050    
12051                            try {
12052                                    session = openSession();
12053    
12054                                    Query q = session.createQuery(sql);
12055    
12056                                    QueryPos qPos = QueryPos.getInstance(q);
12057    
12058                                    qPos.add(groupId);
12059    
12060                                    qPos.add(userId);
12061    
12062                                    qPos.add(status);
12063    
12064                                    count = (Long)q.uniqueResult();
12065    
12066                                    finderCache.putResult(finderPath, finderArgs, count);
12067                            }
12068                            catch (Exception e) {
12069                                    finderCache.removeResult(finderPath, finderArgs);
12070    
12071                                    throw processException(e);
12072                            }
12073                            finally {
12074                                    closeSession(session);
12075                            }
12076                    }
12077    
12078                    return count.intValue();
12079            }
12080    
12081            /**
12082             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status &ne; &#63;.
12083             *
12084             * @param groupId the group ID
12085             * @param userId the user ID
12086             * @param status the status
12087             * @return the number of matching blogs entries that the user has permission to view
12088             */
12089            @Override
12090            public int filterCountByG_U_NotS(long groupId, long userId, int status) {
12091                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12092                            return countByG_U_NotS(groupId, userId, status);
12093                    }
12094    
12095                    StringBundler query = new StringBundler(4);
12096    
12097                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
12098    
12099                    query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
12100    
12101                    query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
12102    
12103                    query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
12104    
12105                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12106                                    BlogsEntry.class.getName(),
12107                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12108    
12109                    Session session = null;
12110    
12111                    try {
12112                            session = openSession();
12113    
12114                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
12115    
12116                            q.addScalar(COUNT_COLUMN_NAME,
12117                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
12118    
12119                            QueryPos qPos = QueryPos.getInstance(q);
12120    
12121                            qPos.add(groupId);
12122    
12123                            qPos.add(userId);
12124    
12125                            qPos.add(status);
12126    
12127                            Long count = (Long)q.uniqueResult();
12128    
12129                            return count.intValue();
12130                    }
12131                    catch (Exception e) {
12132                            throw processException(e);
12133                    }
12134                    finally {
12135                            closeSession(session);
12136                    }
12137            }
12138    
12139            private static final String _FINDER_COLUMN_G_U_NOTS_GROUPID_2 = "blogsEntry.groupId = ? AND ";
12140            private static final String _FINDER_COLUMN_G_U_NOTS_USERID_2 = "blogsEntry.userId = ? AND ";
12141            private static final String _FINDER_COLUMN_G_U_NOTS_STATUS_2 = "blogsEntry.status != ?";
12142            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
12143                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
12144                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_LtD_S",
12145                            new String[] {
12146                                    Long.class.getName(), Date.class.getName(),
12147                                    Integer.class.getName(),
12148                                    
12149                            Integer.class.getName(), Integer.class.getName(),
12150                                    OrderByComparator.class.getName()
12151                            });
12152            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
12153                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
12154                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_LtD_S",
12155                            new String[] {
12156                                    Long.class.getName(), Date.class.getName(),
12157                                    Integer.class.getName()
12158                            });
12159    
12160            /**
12161             * Returns all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
12162             *
12163             * @param groupId the group ID
12164             * @param displayDate the display date
12165             * @param status the status
12166             * @return the matching blogs entries
12167             */
12168            @Override
12169            public List<BlogsEntry> findByG_LtD_S(long groupId, Date displayDate,
12170                    int status) {
12171                    return findByG_LtD_S(groupId, displayDate, status, QueryUtil.ALL_POS,
12172                            QueryUtil.ALL_POS, null);
12173            }
12174    
12175            /**
12176             * Returns a range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
12177             *
12178             * <p>
12179             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
12180             * </p>
12181             *
12182             * @param groupId the group ID
12183             * @param displayDate the display date
12184             * @param status the status
12185             * @param start the lower bound of the range of blogs entries
12186             * @param end the upper bound of the range of blogs entries (not inclusive)
12187             * @return the range of matching blogs entries
12188             */
12189            @Override
12190            public List<BlogsEntry> findByG_LtD_S(long groupId, Date displayDate,
12191                    int status, int start, int end) {
12192                    return findByG_LtD_S(groupId, displayDate, status, start, end, null);
12193            }
12194    
12195            /**
12196             * Returns an ordered range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
12197             *
12198             * <p>
12199             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
12200             * </p>
12201             *
12202             * @param groupId the group ID
12203             * @param displayDate the display date
12204             * @param status the status
12205             * @param start the lower bound of the range of blogs entries
12206             * @param end the upper bound of the range of blogs entries (not inclusive)
12207             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12208             * @return the ordered range of matching blogs entries
12209             */
12210            @Override
12211            public List<BlogsEntry> findByG_LtD_S(long groupId, Date displayDate,
12212                    int status, int start, int end,
12213                    OrderByComparator<BlogsEntry> orderByComparator) {
12214                    return findByG_LtD_S(groupId, displayDate, status, start, end,
12215                            orderByComparator, true);
12216            }
12217    
12218            /**
12219             * Returns an ordered range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
12220             *
12221             * <p>
12222             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
12223             * </p>
12224             *
12225             * @param groupId the group ID
12226             * @param displayDate the display date
12227             * @param status the status
12228             * @param start the lower bound of the range of blogs entries
12229             * @param end the upper bound of the range of blogs entries (not inclusive)
12230             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12231             * @param retrieveFromCache whether to retrieve from the finder cache
12232             * @return the ordered range of matching blogs entries
12233             */
12234            @Override
12235            public List<BlogsEntry> findByG_LtD_S(long groupId, Date displayDate,
12236                    int status, int start, int end,
12237                    OrderByComparator<BlogsEntry> orderByComparator,
12238                    boolean retrieveFromCache) {
12239                    boolean pagination = true;
12240                    FinderPath finderPath = null;
12241                    Object[] finderArgs = null;
12242    
12243                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD_S;
12244                    finderArgs = new Object[] {
12245                                    groupId, displayDate, status,
12246                                    
12247                                    start, end, orderByComparator
12248                            };
12249    
12250                    List<BlogsEntry> list = null;
12251    
12252                    if (retrieveFromCache) {
12253                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
12254                                            finderArgs, this);
12255    
12256                            if ((list != null) && !list.isEmpty()) {
12257                                    for (BlogsEntry blogsEntry : list) {
12258                                            if ((groupId != blogsEntry.getGroupId()) ||
12259                                                            (displayDate.getTime() <= blogsEntry.getDisplayDate()
12260                                                                                                                                            .getTime()) ||
12261                                                            (status != blogsEntry.getStatus())) {
12262                                                    list = null;
12263    
12264                                                    break;
12265                                            }
12266                                    }
12267                            }
12268                    }
12269    
12270                    if (list == null) {
12271                            StringBundler query = null;
12272    
12273                            if (orderByComparator != null) {
12274                                    query = new StringBundler(5 +
12275                                                    (orderByComparator.getOrderByFields().length * 2));
12276                            }
12277                            else {
12278                                    query = new StringBundler(5);
12279                            }
12280    
12281                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
12282    
12283                            query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
12284    
12285                            boolean bindDisplayDate = false;
12286    
12287                            if (displayDate == null) {
12288                                    query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
12289                            }
12290                            else {
12291                                    bindDisplayDate = true;
12292    
12293                                    query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
12294                            }
12295    
12296                            query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
12297    
12298                            if (orderByComparator != null) {
12299                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12300                                            orderByComparator);
12301                            }
12302                            else
12303                             if (pagination) {
12304                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
12305                            }
12306    
12307                            String sql = query.toString();
12308    
12309                            Session session = null;
12310    
12311                            try {
12312                                    session = openSession();
12313    
12314                                    Query q = session.createQuery(sql);
12315    
12316                                    QueryPos qPos = QueryPos.getInstance(q);
12317    
12318                                    qPos.add(groupId);
12319    
12320                                    if (bindDisplayDate) {
12321                                            qPos.add(new Timestamp(displayDate.getTime()));
12322                                    }
12323    
12324                                    qPos.add(status);
12325    
12326                                    if (!pagination) {
12327                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
12328                                                            start, end, false);
12329    
12330                                            Collections.sort(list);
12331    
12332                                            list = Collections.unmodifiableList(list);
12333                                    }
12334                                    else {
12335                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
12336                                                            start, end);
12337                                    }
12338    
12339                                    cacheResult(list);
12340    
12341                                    finderCache.putResult(finderPath, finderArgs, list);
12342                            }
12343                            catch (Exception e) {
12344                                    finderCache.removeResult(finderPath, finderArgs);
12345    
12346                                    throw processException(e);
12347                            }
12348                            finally {
12349                                    closeSession(session);
12350                            }
12351                    }
12352    
12353                    return list;
12354            }
12355    
12356            /**
12357             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
12358             *
12359             * @param groupId the group ID
12360             * @param displayDate the display date
12361             * @param status the status
12362             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12363             * @return the first matching blogs entry
12364             * @throws NoSuchEntryException if a matching blogs entry could not be found
12365             */
12366            @Override
12367            public BlogsEntry findByG_LtD_S_First(long groupId, Date displayDate,
12368                    int status, OrderByComparator<BlogsEntry> orderByComparator)
12369                    throws NoSuchEntryException {
12370                    BlogsEntry blogsEntry = fetchByG_LtD_S_First(groupId, displayDate,
12371                                    status, orderByComparator);
12372    
12373                    if (blogsEntry != null) {
12374                            return blogsEntry;
12375                    }
12376    
12377                    StringBundler msg = new StringBundler(8);
12378    
12379                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12380    
12381                    msg.append("groupId=");
12382                    msg.append(groupId);
12383    
12384                    msg.append(", displayDate=");
12385                    msg.append(displayDate);
12386    
12387                    msg.append(", status=");
12388                    msg.append(status);
12389    
12390                    msg.append(StringPool.CLOSE_CURLY_BRACE);
12391    
12392                    throw new NoSuchEntryException(msg.toString());
12393            }
12394    
12395            /**
12396             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
12397             *
12398             * @param groupId the group ID
12399             * @param displayDate the display date
12400             * @param status the status
12401             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12402             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
12403             */
12404            @Override
12405            public BlogsEntry fetchByG_LtD_S_First(long groupId, Date displayDate,
12406                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
12407                    List<BlogsEntry> list = findByG_LtD_S(groupId, displayDate, status, 0,
12408                                    1, orderByComparator);
12409    
12410                    if (!list.isEmpty()) {
12411                            return list.get(0);
12412                    }
12413    
12414                    return null;
12415            }
12416    
12417            /**
12418             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
12419             *
12420             * @param groupId the group ID
12421             * @param displayDate the display date
12422             * @param status the status
12423             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12424             * @return the last matching blogs entry
12425             * @throws NoSuchEntryException if a matching blogs entry could not be found
12426             */
12427            @Override
12428            public BlogsEntry findByG_LtD_S_Last(long groupId, Date displayDate,
12429                    int status, OrderByComparator<BlogsEntry> orderByComparator)
12430                    throws NoSuchEntryException {
12431                    BlogsEntry blogsEntry = fetchByG_LtD_S_Last(groupId, displayDate,
12432                                    status, orderByComparator);
12433    
12434                    if (blogsEntry != null) {
12435                            return blogsEntry;
12436                    }
12437    
12438                    StringBundler msg = new StringBundler(8);
12439    
12440                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12441    
12442                    msg.append("groupId=");
12443                    msg.append(groupId);
12444    
12445                    msg.append(", displayDate=");
12446                    msg.append(displayDate);
12447    
12448                    msg.append(", status=");
12449                    msg.append(status);
12450    
12451                    msg.append(StringPool.CLOSE_CURLY_BRACE);
12452    
12453                    throw new NoSuchEntryException(msg.toString());
12454            }
12455    
12456            /**
12457             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
12458             *
12459             * @param groupId the group ID
12460             * @param displayDate the display date
12461             * @param status the status
12462             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12463             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
12464             */
12465            @Override
12466            public BlogsEntry fetchByG_LtD_S_Last(long groupId, Date displayDate,
12467                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
12468                    int count = countByG_LtD_S(groupId, displayDate, status);
12469    
12470                    if (count == 0) {
12471                            return null;
12472                    }
12473    
12474                    List<BlogsEntry> list = findByG_LtD_S(groupId, displayDate, status,
12475                                    count - 1, count, orderByComparator);
12476    
12477                    if (!list.isEmpty()) {
12478                            return list.get(0);
12479                    }
12480    
12481                    return null;
12482            }
12483    
12484            /**
12485             * 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;.
12486             *
12487             * @param entryId the primary key of the current blogs entry
12488             * @param groupId the group ID
12489             * @param displayDate the display date
12490             * @param status the status
12491             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12492             * @return the previous, current, and next blogs entry
12493             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
12494             */
12495            @Override
12496            public BlogsEntry[] findByG_LtD_S_PrevAndNext(long entryId, long groupId,
12497                    Date displayDate, int status,
12498                    OrderByComparator<BlogsEntry> orderByComparator)
12499                    throws NoSuchEntryException {
12500                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
12501    
12502                    Session session = null;
12503    
12504                    try {
12505                            session = openSession();
12506    
12507                            BlogsEntry[] array = new BlogsEntryImpl[3];
12508    
12509                            array[0] = getByG_LtD_S_PrevAndNext(session, blogsEntry, groupId,
12510                                            displayDate, status, orderByComparator, true);
12511    
12512                            array[1] = blogsEntry;
12513    
12514                            array[2] = getByG_LtD_S_PrevAndNext(session, blogsEntry, groupId,
12515                                            displayDate, status, orderByComparator, false);
12516    
12517                            return array;
12518                    }
12519                    catch (Exception e) {
12520                            throw processException(e);
12521                    }
12522                    finally {
12523                            closeSession(session);
12524                    }
12525            }
12526    
12527            protected BlogsEntry getByG_LtD_S_PrevAndNext(Session session,
12528                    BlogsEntry blogsEntry, long groupId, Date displayDate, int status,
12529                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
12530                    StringBundler query = null;
12531    
12532                    if (orderByComparator != null) {
12533                            query = new StringBundler(6 +
12534                                            (orderByComparator.getOrderByConditionFields().length * 3) +
12535                                            (orderByComparator.getOrderByFields().length * 3));
12536                    }
12537                    else {
12538                            query = new StringBundler(5);
12539                    }
12540    
12541                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
12542    
12543                    query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
12544    
12545                    boolean bindDisplayDate = false;
12546    
12547                    if (displayDate == null) {
12548                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
12549                    }
12550                    else {
12551                            bindDisplayDate = true;
12552    
12553                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
12554                    }
12555    
12556                    query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
12557    
12558                    if (orderByComparator != null) {
12559                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
12560    
12561                            if (orderByConditionFields.length > 0) {
12562                                    query.append(WHERE_AND);
12563                            }
12564    
12565                            for (int i = 0; i < orderByConditionFields.length; i++) {
12566                                    query.append(_ORDER_BY_ENTITY_ALIAS);
12567                                    query.append(orderByConditionFields[i]);
12568    
12569                                    if ((i + 1) < orderByConditionFields.length) {
12570                                            if (orderByComparator.isAscending() ^ previous) {
12571                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
12572                                            }
12573                                            else {
12574                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
12575                                            }
12576                                    }
12577                                    else {
12578                                            if (orderByComparator.isAscending() ^ previous) {
12579                                                    query.append(WHERE_GREATER_THAN);
12580                                            }
12581                                            else {
12582                                                    query.append(WHERE_LESSER_THAN);
12583                                            }
12584                                    }
12585                            }
12586    
12587                            query.append(ORDER_BY_CLAUSE);
12588    
12589                            String[] orderByFields = orderByComparator.getOrderByFields();
12590    
12591                            for (int i = 0; i < orderByFields.length; i++) {
12592                                    query.append(_ORDER_BY_ENTITY_ALIAS);
12593                                    query.append(orderByFields[i]);
12594    
12595                                    if ((i + 1) < orderByFields.length) {
12596                                            if (orderByComparator.isAscending() ^ previous) {
12597                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
12598                                            }
12599                                            else {
12600                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
12601                                            }
12602                                    }
12603                                    else {
12604                                            if (orderByComparator.isAscending() ^ previous) {
12605                                                    query.append(ORDER_BY_ASC);
12606                                            }
12607                                            else {
12608                                                    query.append(ORDER_BY_DESC);
12609                                            }
12610                                    }
12611                            }
12612                    }
12613                    else {
12614                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
12615                    }
12616    
12617                    String sql = query.toString();
12618    
12619                    Query q = session.createQuery(sql);
12620    
12621                    q.setFirstResult(0);
12622                    q.setMaxResults(2);
12623    
12624                    QueryPos qPos = QueryPos.getInstance(q);
12625    
12626                    qPos.add(groupId);
12627    
12628                    if (bindDisplayDate) {
12629                            qPos.add(new Timestamp(displayDate.getTime()));
12630                    }
12631    
12632                    qPos.add(status);
12633    
12634                    if (orderByComparator != null) {
12635                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
12636    
12637                            for (Object value : values) {
12638                                    qPos.add(value);
12639                            }
12640                    }
12641    
12642                    List<BlogsEntry> list = q.list();
12643    
12644                    if (list.size() == 2) {
12645                            return list.get(1);
12646                    }
12647                    else {
12648                            return null;
12649                    }
12650            }
12651    
12652            /**
12653             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
12654             *
12655             * @param groupId the group ID
12656             * @param displayDate the display date
12657             * @param status the status
12658             * @return the matching blogs entries that the user has permission to view
12659             */
12660            @Override
12661            public List<BlogsEntry> filterFindByG_LtD_S(long groupId, Date displayDate,
12662                    int status) {
12663                    return filterFindByG_LtD_S(groupId, displayDate, status,
12664                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
12665            }
12666    
12667            /**
12668             * 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;.
12669             *
12670             * <p>
12671             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
12672             * </p>
12673             *
12674             * @param groupId the group ID
12675             * @param displayDate the display date
12676             * @param status the status
12677             * @param start the lower bound of the range of blogs entries
12678             * @param end the upper bound of the range of blogs entries (not inclusive)
12679             * @return the range of matching blogs entries that the user has permission to view
12680             */
12681            @Override
12682            public List<BlogsEntry> filterFindByG_LtD_S(long groupId, Date displayDate,
12683                    int status, int start, int end) {
12684                    return filterFindByG_LtD_S(groupId, displayDate, status, start, end,
12685                            null);
12686            }
12687    
12688            /**
12689             * 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;.
12690             *
12691             * <p>
12692             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
12693             * </p>
12694             *
12695             * @param groupId the group ID
12696             * @param displayDate the display date
12697             * @param status the status
12698             * @param start the lower bound of the range of blogs entries
12699             * @param end the upper bound of the range of blogs entries (not inclusive)
12700             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12701             * @return the ordered range of matching blogs entries that the user has permission to view
12702             */
12703            @Override
12704            public List<BlogsEntry> filterFindByG_LtD_S(long groupId, Date displayDate,
12705                    int status, int start, int end,
12706                    OrderByComparator<BlogsEntry> orderByComparator) {
12707                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12708                            return findByG_LtD_S(groupId, displayDate, status, start, end,
12709                                    orderByComparator);
12710                    }
12711    
12712                    StringBundler query = null;
12713    
12714                    if (orderByComparator != null) {
12715                            query = new StringBundler(5 +
12716                                            (orderByComparator.getOrderByFields().length * 2));
12717                    }
12718                    else {
12719                            query = new StringBundler(6);
12720                    }
12721    
12722                    if (getDB().isSupportsInlineDistinct()) {
12723                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
12724                    }
12725                    else {
12726                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
12727                    }
12728    
12729                    query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
12730    
12731                    boolean bindDisplayDate = false;
12732    
12733                    if (displayDate == null) {
12734                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
12735                    }
12736                    else {
12737                            bindDisplayDate = true;
12738    
12739                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
12740                    }
12741    
12742                    query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
12743    
12744                    if (!getDB().isSupportsInlineDistinct()) {
12745                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
12746                    }
12747    
12748                    if (orderByComparator != null) {
12749                            if (getDB().isSupportsInlineDistinct()) {
12750                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12751                                            orderByComparator, true);
12752                            }
12753                            else {
12754                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
12755                                            orderByComparator, true);
12756                            }
12757                    }
12758                    else {
12759                            if (getDB().isSupportsInlineDistinct()) {
12760                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
12761                            }
12762                            else {
12763                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
12764                            }
12765                    }
12766    
12767                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12768                                    BlogsEntry.class.getName(),
12769                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12770    
12771                    Session session = null;
12772    
12773                    try {
12774                            session = openSession();
12775    
12776                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
12777    
12778                            if (getDB().isSupportsInlineDistinct()) {
12779                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
12780                            }
12781                            else {
12782                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
12783                            }
12784    
12785                            QueryPos qPos = QueryPos.getInstance(q);
12786    
12787                            qPos.add(groupId);
12788    
12789                            if (bindDisplayDate) {
12790                                    qPos.add(new Timestamp(displayDate.getTime()));
12791                            }
12792    
12793                            qPos.add(status);
12794    
12795                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
12796                    }
12797                    catch (Exception e) {
12798                            throw processException(e);
12799                    }
12800                    finally {
12801                            closeSession(session);
12802                    }
12803            }
12804    
12805            /**
12806             * 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;.
12807             *
12808             * @param entryId the primary key of the current blogs entry
12809             * @param groupId the group ID
12810             * @param displayDate the display date
12811             * @param status the status
12812             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12813             * @return the previous, current, and next blogs entry
12814             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
12815             */
12816            @Override
12817            public BlogsEntry[] filterFindByG_LtD_S_PrevAndNext(long entryId,
12818                    long groupId, Date displayDate, int status,
12819                    OrderByComparator<BlogsEntry> orderByComparator)
12820                    throws NoSuchEntryException {
12821                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12822                            return findByG_LtD_S_PrevAndNext(entryId, groupId, displayDate,
12823                                    status, orderByComparator);
12824                    }
12825    
12826                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
12827    
12828                    Session session = null;
12829    
12830                    try {
12831                            session = openSession();
12832    
12833                            BlogsEntry[] array = new BlogsEntryImpl[3];
12834    
12835                            array[0] = filterGetByG_LtD_S_PrevAndNext(session, blogsEntry,
12836                                            groupId, displayDate, status, orderByComparator, true);
12837    
12838                            array[1] = blogsEntry;
12839    
12840                            array[2] = filterGetByG_LtD_S_PrevAndNext(session, blogsEntry,
12841                                            groupId, displayDate, status, orderByComparator, false);
12842    
12843                            return array;
12844                    }
12845                    catch (Exception e) {
12846                            throw processException(e);
12847                    }
12848                    finally {
12849                            closeSession(session);
12850                    }
12851            }
12852    
12853            protected BlogsEntry filterGetByG_LtD_S_PrevAndNext(Session session,
12854                    BlogsEntry blogsEntry, long groupId, Date displayDate, int status,
12855                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
12856                    StringBundler query = null;
12857    
12858                    if (orderByComparator != null) {
12859                            query = new StringBundler(7 +
12860                                            (orderByComparator.getOrderByConditionFields().length * 3) +
12861                                            (orderByComparator.getOrderByFields().length * 3));
12862                    }
12863                    else {
12864                            query = new StringBundler(6);
12865                    }
12866    
12867                    if (getDB().isSupportsInlineDistinct()) {
12868                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
12869                    }
12870                    else {
12871                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
12872                    }
12873    
12874                    query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
12875    
12876                    boolean bindDisplayDate = false;
12877    
12878                    if (displayDate == null) {
12879                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
12880                    }
12881                    else {
12882                            bindDisplayDate = true;
12883    
12884                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
12885                    }
12886    
12887                    query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
12888    
12889                    if (!getDB().isSupportsInlineDistinct()) {
12890                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
12891                    }
12892    
12893                    if (orderByComparator != null) {
12894                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
12895    
12896                            if (orderByConditionFields.length > 0) {
12897                                    query.append(WHERE_AND);
12898                            }
12899    
12900                            for (int i = 0; i < orderByConditionFields.length; i++) {
12901                                    if (getDB().isSupportsInlineDistinct()) {
12902                                            query.append(_ORDER_BY_ENTITY_ALIAS);
12903                                    }
12904                                    else {
12905                                            query.append(_ORDER_BY_ENTITY_TABLE);
12906                                    }
12907    
12908                                    query.append(orderByConditionFields[i]);
12909    
12910                                    if ((i + 1) < orderByConditionFields.length) {
12911                                            if (orderByComparator.isAscending() ^ previous) {
12912                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
12913                                            }
12914                                            else {
12915                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
12916                                            }
12917                                    }
12918                                    else {
12919                                            if (orderByComparator.isAscending() ^ previous) {
12920                                                    query.append(WHERE_GREATER_THAN);
12921                                            }
12922                                            else {
12923                                                    query.append(WHERE_LESSER_THAN);
12924                                            }
12925                                    }
12926                            }
12927    
12928                            query.append(ORDER_BY_CLAUSE);
12929    
12930                            String[] orderByFields = orderByComparator.getOrderByFields();
12931    
12932                            for (int i = 0; i < orderByFields.length; i++) {
12933                                    if (getDB().isSupportsInlineDistinct()) {
12934                                            query.append(_ORDER_BY_ENTITY_ALIAS);
12935                                    }
12936                                    else {
12937                                            query.append(_ORDER_BY_ENTITY_TABLE);
12938                                    }
12939    
12940                                    query.append(orderByFields[i]);
12941    
12942                                    if ((i + 1) < orderByFields.length) {
12943                                            if (orderByComparator.isAscending() ^ previous) {
12944                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
12945                                            }
12946                                            else {
12947                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
12948                                            }
12949                                    }
12950                                    else {
12951                                            if (orderByComparator.isAscending() ^ previous) {
12952                                                    query.append(ORDER_BY_ASC);
12953                                            }
12954                                            else {
12955                                                    query.append(ORDER_BY_DESC);
12956                                            }
12957                                    }
12958                            }
12959                    }
12960                    else {
12961                            if (getDB().isSupportsInlineDistinct()) {
12962                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
12963                            }
12964                            else {
12965                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
12966                            }
12967                    }
12968    
12969                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12970                                    BlogsEntry.class.getName(),
12971                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12972    
12973                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
12974    
12975                    q.setFirstResult(0);
12976                    q.setMaxResults(2);
12977    
12978                    if (getDB().isSupportsInlineDistinct()) {
12979                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
12980                    }
12981                    else {
12982                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
12983                    }
12984    
12985                    QueryPos qPos = QueryPos.getInstance(q);
12986    
12987                    qPos.add(groupId);
12988    
12989                    if (bindDisplayDate) {
12990                            qPos.add(new Timestamp(displayDate.getTime()));
12991                    }
12992    
12993                    qPos.add(status);
12994    
12995                    if (orderByComparator != null) {
12996                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
12997    
12998                            for (Object value : values) {
12999                                    qPos.add(value);
13000                            }
13001                    }
13002    
13003                    List<BlogsEntry> list = q.list();
13004    
13005                    if (list.size() == 2) {
13006                            return list.get(1);
13007                    }
13008                    else {
13009                            return null;
13010                    }
13011            }
13012    
13013            /**
13014             * Removes all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63; from the database.
13015             *
13016             * @param groupId the group ID
13017             * @param displayDate the display date
13018             * @param status the status
13019             */
13020            @Override
13021            public void removeByG_LtD_S(long groupId, Date displayDate, int status) {
13022                    for (BlogsEntry blogsEntry : findByG_LtD_S(groupId, displayDate,
13023                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
13024                            remove(blogsEntry);
13025                    }
13026            }
13027    
13028            /**
13029             * Returns the number of blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
13030             *
13031             * @param groupId the group ID
13032             * @param displayDate the display date
13033             * @param status the status
13034             * @return the number of matching blogs entries
13035             */
13036            @Override
13037            public int countByG_LtD_S(long groupId, Date displayDate, int status) {
13038                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD_S;
13039    
13040                    Object[] finderArgs = new Object[] { groupId, displayDate, status };
13041    
13042                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
13043    
13044                    if (count == null) {
13045                            StringBundler query = new StringBundler(4);
13046    
13047                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
13048    
13049                            query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
13050    
13051                            boolean bindDisplayDate = false;
13052    
13053                            if (displayDate == null) {
13054                                    query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
13055                            }
13056                            else {
13057                                    bindDisplayDate = true;
13058    
13059                                    query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
13060                            }
13061    
13062                            query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
13063    
13064                            String sql = query.toString();
13065    
13066                            Session session = null;
13067    
13068                            try {
13069                                    session = openSession();
13070    
13071                                    Query q = session.createQuery(sql);
13072    
13073                                    QueryPos qPos = QueryPos.getInstance(q);
13074    
13075                                    qPos.add(groupId);
13076    
13077                                    if (bindDisplayDate) {
13078                                            qPos.add(new Timestamp(displayDate.getTime()));
13079                                    }
13080    
13081                                    qPos.add(status);
13082    
13083                                    count = (Long)q.uniqueResult();
13084    
13085                                    finderCache.putResult(finderPath, finderArgs, count);
13086                            }
13087                            catch (Exception e) {
13088                                    finderCache.removeResult(finderPath, finderArgs);
13089    
13090                                    throw processException(e);
13091                            }
13092                            finally {
13093                                    closeSession(session);
13094                            }
13095                    }
13096    
13097                    return count.intValue();
13098            }
13099    
13100            /**
13101             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
13102             *
13103             * @param groupId the group ID
13104             * @param displayDate the display date
13105             * @param status the status
13106             * @return the number of matching blogs entries that the user has permission to view
13107             */
13108            @Override
13109            public int filterCountByG_LtD_S(long groupId, Date displayDate, int status) {
13110                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13111                            return countByG_LtD_S(groupId, displayDate, status);
13112                    }
13113    
13114                    StringBundler query = new StringBundler(4);
13115    
13116                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
13117    
13118                    query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
13119    
13120                    boolean bindDisplayDate = false;
13121    
13122                    if (displayDate == null) {
13123                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
13124                    }
13125                    else {
13126                            bindDisplayDate = true;
13127    
13128                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
13129                    }
13130    
13131                    query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
13132    
13133                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13134                                    BlogsEntry.class.getName(),
13135                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13136    
13137                    Session session = null;
13138    
13139                    try {
13140                            session = openSession();
13141    
13142                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
13143    
13144                            q.addScalar(COUNT_COLUMN_NAME,
13145                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
13146    
13147                            QueryPos qPos = QueryPos.getInstance(q);
13148    
13149                            qPos.add(groupId);
13150    
13151                            if (bindDisplayDate) {
13152                                    qPos.add(new Timestamp(displayDate.getTime()));
13153                            }
13154    
13155                            qPos.add(status);
13156    
13157                            Long count = (Long)q.uniqueResult();
13158    
13159                            return count.intValue();
13160                    }
13161                    catch (Exception e) {
13162                            throw processException(e);
13163                    }
13164                    finally {
13165                            closeSession(session);
13166                    }
13167            }
13168    
13169            private static final String _FINDER_COLUMN_G_LTD_S_GROUPID_2 = "blogsEntry.groupId = ? AND ";
13170            private static final String _FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1 = "blogsEntry.displayDate IS NULL AND ";
13171            private static final String _FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
13172            private static final String _FINDER_COLUMN_G_LTD_S_STATUS_2 = "blogsEntry.status = ?";
13173            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD_NOTS =
13174                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
13175                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
13176                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_LtD_NotS",
13177                            new String[] {
13178                                    Long.class.getName(), Date.class.getName(),
13179                                    Integer.class.getName(),
13180                                    
13181                            Integer.class.getName(), Integer.class.getName(),
13182                                    OrderByComparator.class.getName()
13183                            });
13184            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD_NOTS =
13185                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
13186                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
13187                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_LtD_NotS",
13188                            new String[] {
13189                                    Long.class.getName(), Date.class.getName(),
13190                                    Integer.class.getName()
13191                            });
13192    
13193            /**
13194             * Returns all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13195             *
13196             * @param groupId the group ID
13197             * @param displayDate the display date
13198             * @param status the status
13199             * @return the matching blogs entries
13200             */
13201            @Override
13202            public List<BlogsEntry> findByG_LtD_NotS(long groupId, Date displayDate,
13203                    int status) {
13204                    return findByG_LtD_NotS(groupId, displayDate, status,
13205                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
13206            }
13207    
13208            /**
13209             * Returns a range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13210             *
13211             * <p>
13212             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
13213             * </p>
13214             *
13215             * @param groupId the group ID
13216             * @param displayDate the display date
13217             * @param status the status
13218             * @param start the lower bound of the range of blogs entries
13219             * @param end the upper bound of the range of blogs entries (not inclusive)
13220             * @return the range of matching blogs entries
13221             */
13222            @Override
13223            public List<BlogsEntry> findByG_LtD_NotS(long groupId, Date displayDate,
13224                    int status, int start, int end) {
13225                    return findByG_LtD_NotS(groupId, displayDate, status, start, end, null);
13226            }
13227    
13228            /**
13229             * Returns an ordered range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13230             *
13231             * <p>
13232             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
13233             * </p>
13234             *
13235             * @param groupId the group ID
13236             * @param displayDate the display date
13237             * @param status the status
13238             * @param start the lower bound of the range of blogs entries
13239             * @param end the upper bound of the range of blogs entries (not inclusive)
13240             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13241             * @return the ordered range of matching blogs entries
13242             */
13243            @Override
13244            public List<BlogsEntry> findByG_LtD_NotS(long groupId, Date displayDate,
13245                    int status, int start, int end,
13246                    OrderByComparator<BlogsEntry> orderByComparator) {
13247                    return findByG_LtD_NotS(groupId, displayDate, status, start, end,
13248                            orderByComparator, true);
13249            }
13250    
13251            /**
13252             * Returns an ordered range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13253             *
13254             * <p>
13255             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
13256             * </p>
13257             *
13258             * @param groupId the group ID
13259             * @param displayDate the display date
13260             * @param status the status
13261             * @param start the lower bound of the range of blogs entries
13262             * @param end the upper bound of the range of blogs entries (not inclusive)
13263             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13264             * @param retrieveFromCache whether to retrieve from the finder cache
13265             * @return the ordered range of matching blogs entries
13266             */
13267            @Override
13268            public List<BlogsEntry> findByG_LtD_NotS(long groupId, Date displayDate,
13269                    int status, int start, int end,
13270                    OrderByComparator<BlogsEntry> orderByComparator,
13271                    boolean retrieveFromCache) {
13272                    boolean pagination = true;
13273                    FinderPath finderPath = null;
13274                    Object[] finderArgs = null;
13275    
13276                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD_NOTS;
13277                    finderArgs = new Object[] {
13278                                    groupId, displayDate, status,
13279                                    
13280                                    start, end, orderByComparator
13281                            };
13282    
13283                    List<BlogsEntry> list = null;
13284    
13285                    if (retrieveFromCache) {
13286                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
13287                                            finderArgs, this);
13288    
13289                            if ((list != null) && !list.isEmpty()) {
13290                                    for (BlogsEntry blogsEntry : list) {
13291                                            if ((groupId != blogsEntry.getGroupId()) ||
13292                                                            (displayDate.getTime() <= blogsEntry.getDisplayDate()
13293                                                                                                                                            .getTime()) ||
13294                                                            (status == blogsEntry.getStatus())) {
13295                                                    list = null;
13296    
13297                                                    break;
13298                                            }
13299                                    }
13300                            }
13301                    }
13302    
13303                    if (list == null) {
13304                            StringBundler query = null;
13305    
13306                            if (orderByComparator != null) {
13307                                    query = new StringBundler(5 +
13308                                                    (orderByComparator.getOrderByFields().length * 2));
13309                            }
13310                            else {
13311                                    query = new StringBundler(5);
13312                            }
13313    
13314                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
13315    
13316                            query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
13317    
13318                            boolean bindDisplayDate = false;
13319    
13320                            if (displayDate == null) {
13321                                    query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
13322                            }
13323                            else {
13324                                    bindDisplayDate = true;
13325    
13326                                    query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
13327                            }
13328    
13329                            query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
13330    
13331                            if (orderByComparator != null) {
13332                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13333                                            orderByComparator);
13334                            }
13335                            else
13336                             if (pagination) {
13337                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
13338                            }
13339    
13340                            String sql = query.toString();
13341    
13342                            Session session = null;
13343    
13344                            try {
13345                                    session = openSession();
13346    
13347                                    Query q = session.createQuery(sql);
13348    
13349                                    QueryPos qPos = QueryPos.getInstance(q);
13350    
13351                                    qPos.add(groupId);
13352    
13353                                    if (bindDisplayDate) {
13354                                            qPos.add(new Timestamp(displayDate.getTime()));
13355                                    }
13356    
13357                                    qPos.add(status);
13358    
13359                                    if (!pagination) {
13360                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
13361                                                            start, end, false);
13362    
13363                                            Collections.sort(list);
13364    
13365                                            list = Collections.unmodifiableList(list);
13366                                    }
13367                                    else {
13368                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
13369                                                            start, end);
13370                                    }
13371    
13372                                    cacheResult(list);
13373    
13374                                    finderCache.putResult(finderPath, finderArgs, list);
13375                            }
13376                            catch (Exception e) {
13377                                    finderCache.removeResult(finderPath, finderArgs);
13378    
13379                                    throw processException(e);
13380                            }
13381                            finally {
13382                                    closeSession(session);
13383                            }
13384                    }
13385    
13386                    return list;
13387            }
13388    
13389            /**
13390             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13391             *
13392             * @param groupId the group ID
13393             * @param displayDate the display date
13394             * @param status the status
13395             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13396             * @return the first matching blogs entry
13397             * @throws NoSuchEntryException if a matching blogs entry could not be found
13398             */
13399            @Override
13400            public BlogsEntry findByG_LtD_NotS_First(long groupId, Date displayDate,
13401                    int status, OrderByComparator<BlogsEntry> orderByComparator)
13402                    throws NoSuchEntryException {
13403                    BlogsEntry blogsEntry = fetchByG_LtD_NotS_First(groupId, displayDate,
13404                                    status, orderByComparator);
13405    
13406                    if (blogsEntry != null) {
13407                            return blogsEntry;
13408                    }
13409    
13410                    StringBundler msg = new StringBundler(8);
13411    
13412                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13413    
13414                    msg.append("groupId=");
13415                    msg.append(groupId);
13416    
13417                    msg.append(", displayDate=");
13418                    msg.append(displayDate);
13419    
13420                    msg.append(", status=");
13421                    msg.append(status);
13422    
13423                    msg.append(StringPool.CLOSE_CURLY_BRACE);
13424    
13425                    throw new NoSuchEntryException(msg.toString());
13426            }
13427    
13428            /**
13429             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13430             *
13431             * @param groupId the group ID
13432             * @param displayDate the display date
13433             * @param status the status
13434             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13435             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
13436             */
13437            @Override
13438            public BlogsEntry fetchByG_LtD_NotS_First(long groupId, Date displayDate,
13439                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
13440                    List<BlogsEntry> list = findByG_LtD_NotS(groupId, displayDate, status,
13441                                    0, 1, orderByComparator);
13442    
13443                    if (!list.isEmpty()) {
13444                            return list.get(0);
13445                    }
13446    
13447                    return null;
13448            }
13449    
13450            /**
13451             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13452             *
13453             * @param groupId the group ID
13454             * @param displayDate the display date
13455             * @param status the status
13456             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13457             * @return the last matching blogs entry
13458             * @throws NoSuchEntryException if a matching blogs entry could not be found
13459             */
13460            @Override
13461            public BlogsEntry findByG_LtD_NotS_Last(long groupId, Date displayDate,
13462                    int status, OrderByComparator<BlogsEntry> orderByComparator)
13463                    throws NoSuchEntryException {
13464                    BlogsEntry blogsEntry = fetchByG_LtD_NotS_Last(groupId, displayDate,
13465                                    status, orderByComparator);
13466    
13467                    if (blogsEntry != null) {
13468                            return blogsEntry;
13469                    }
13470    
13471                    StringBundler msg = new StringBundler(8);
13472    
13473                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13474    
13475                    msg.append("groupId=");
13476                    msg.append(groupId);
13477    
13478                    msg.append(", displayDate=");
13479                    msg.append(displayDate);
13480    
13481                    msg.append(", status=");
13482                    msg.append(status);
13483    
13484                    msg.append(StringPool.CLOSE_CURLY_BRACE);
13485    
13486                    throw new NoSuchEntryException(msg.toString());
13487            }
13488    
13489            /**
13490             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13491             *
13492             * @param groupId the group ID
13493             * @param displayDate the display date
13494             * @param status the status
13495             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13496             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
13497             */
13498            @Override
13499            public BlogsEntry fetchByG_LtD_NotS_Last(long groupId, Date displayDate,
13500                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
13501                    int count = countByG_LtD_NotS(groupId, displayDate, status);
13502    
13503                    if (count == 0) {
13504                            return null;
13505                    }
13506    
13507                    List<BlogsEntry> list = findByG_LtD_NotS(groupId, displayDate, status,
13508                                    count - 1, count, orderByComparator);
13509    
13510                    if (!list.isEmpty()) {
13511                            return list.get(0);
13512                    }
13513    
13514                    return null;
13515            }
13516    
13517            /**
13518             * 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;.
13519             *
13520             * @param entryId the primary key of the current blogs entry
13521             * @param groupId the group ID
13522             * @param displayDate the display date
13523             * @param status the status
13524             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13525             * @return the previous, current, and next blogs entry
13526             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
13527             */
13528            @Override
13529            public BlogsEntry[] findByG_LtD_NotS_PrevAndNext(long entryId,
13530                    long groupId, Date displayDate, int status,
13531                    OrderByComparator<BlogsEntry> orderByComparator)
13532                    throws NoSuchEntryException {
13533                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
13534    
13535                    Session session = null;
13536    
13537                    try {
13538                            session = openSession();
13539    
13540                            BlogsEntry[] array = new BlogsEntryImpl[3];
13541    
13542                            array[0] = getByG_LtD_NotS_PrevAndNext(session, blogsEntry,
13543                                            groupId, displayDate, status, orderByComparator, true);
13544    
13545                            array[1] = blogsEntry;
13546    
13547                            array[2] = getByG_LtD_NotS_PrevAndNext(session, blogsEntry,
13548                                            groupId, displayDate, status, orderByComparator, false);
13549    
13550                            return array;
13551                    }
13552                    catch (Exception e) {
13553                            throw processException(e);
13554                    }
13555                    finally {
13556                            closeSession(session);
13557                    }
13558            }
13559    
13560            protected BlogsEntry getByG_LtD_NotS_PrevAndNext(Session session,
13561                    BlogsEntry blogsEntry, long groupId, Date displayDate, int status,
13562                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
13563                    StringBundler query = null;
13564    
13565                    if (orderByComparator != null) {
13566                            query = new StringBundler(6 +
13567                                            (orderByComparator.getOrderByConditionFields().length * 3) +
13568                                            (orderByComparator.getOrderByFields().length * 3));
13569                    }
13570                    else {
13571                            query = new StringBundler(5);
13572                    }
13573    
13574                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
13575    
13576                    query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
13577    
13578                    boolean bindDisplayDate = false;
13579    
13580                    if (displayDate == null) {
13581                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
13582                    }
13583                    else {
13584                            bindDisplayDate = true;
13585    
13586                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
13587                    }
13588    
13589                    query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
13590    
13591                    if (orderByComparator != null) {
13592                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
13593    
13594                            if (orderByConditionFields.length > 0) {
13595                                    query.append(WHERE_AND);
13596                            }
13597    
13598                            for (int i = 0; i < orderByConditionFields.length; i++) {
13599                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13600                                    query.append(orderByConditionFields[i]);
13601    
13602                                    if ((i + 1) < orderByConditionFields.length) {
13603                                            if (orderByComparator.isAscending() ^ previous) {
13604                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
13605                                            }
13606                                            else {
13607                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
13608                                            }
13609                                    }
13610                                    else {
13611                                            if (orderByComparator.isAscending() ^ previous) {
13612                                                    query.append(WHERE_GREATER_THAN);
13613                                            }
13614                                            else {
13615                                                    query.append(WHERE_LESSER_THAN);
13616                                            }
13617                                    }
13618                            }
13619    
13620                            query.append(ORDER_BY_CLAUSE);
13621    
13622                            String[] orderByFields = orderByComparator.getOrderByFields();
13623    
13624                            for (int i = 0; i < orderByFields.length; i++) {
13625                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13626                                    query.append(orderByFields[i]);
13627    
13628                                    if ((i + 1) < orderByFields.length) {
13629                                            if (orderByComparator.isAscending() ^ previous) {
13630                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
13631                                            }
13632                                            else {
13633                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
13634                                            }
13635                                    }
13636                                    else {
13637                                            if (orderByComparator.isAscending() ^ previous) {
13638                                                    query.append(ORDER_BY_ASC);
13639                                            }
13640                                            else {
13641                                                    query.append(ORDER_BY_DESC);
13642                                            }
13643                                    }
13644                            }
13645                    }
13646                    else {
13647                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
13648                    }
13649    
13650                    String sql = query.toString();
13651    
13652                    Query q = session.createQuery(sql);
13653    
13654                    q.setFirstResult(0);
13655                    q.setMaxResults(2);
13656    
13657                    QueryPos qPos = QueryPos.getInstance(q);
13658    
13659                    qPos.add(groupId);
13660    
13661                    if (bindDisplayDate) {
13662                            qPos.add(new Timestamp(displayDate.getTime()));
13663                    }
13664    
13665                    qPos.add(status);
13666    
13667                    if (orderByComparator != null) {
13668                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
13669    
13670                            for (Object value : values) {
13671                                    qPos.add(value);
13672                            }
13673                    }
13674    
13675                    List<BlogsEntry> list = q.list();
13676    
13677                    if (list.size() == 2) {
13678                            return list.get(1);
13679                    }
13680                    else {
13681                            return null;
13682                    }
13683            }
13684    
13685            /**
13686             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13687             *
13688             * @param groupId the group ID
13689             * @param displayDate the display date
13690             * @param status the status
13691             * @return the matching blogs entries that the user has permission to view
13692             */
13693            @Override
13694            public List<BlogsEntry> filterFindByG_LtD_NotS(long groupId,
13695                    Date displayDate, int status) {
13696                    return filterFindByG_LtD_NotS(groupId, displayDate, status,
13697                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
13698            }
13699    
13700            /**
13701             * 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;.
13702             *
13703             * <p>
13704             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
13705             * </p>
13706             *
13707             * @param groupId the group ID
13708             * @param displayDate the display date
13709             * @param status the status
13710             * @param start the lower bound of the range of blogs entries
13711             * @param end the upper bound of the range of blogs entries (not inclusive)
13712             * @return the range of matching blogs entries that the user has permission to view
13713             */
13714            @Override
13715            public List<BlogsEntry> filterFindByG_LtD_NotS(long groupId,
13716                    Date displayDate, int status, int start, int end) {
13717                    return filterFindByG_LtD_NotS(groupId, displayDate, status, start, end,
13718                            null);
13719            }
13720    
13721            /**
13722             * 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;.
13723             *
13724             * <p>
13725             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
13726             * </p>
13727             *
13728             * @param groupId the group ID
13729             * @param displayDate the display date
13730             * @param status the status
13731             * @param start the lower bound of the range of blogs entries
13732             * @param end the upper bound of the range of blogs entries (not inclusive)
13733             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13734             * @return the ordered range of matching blogs entries that the user has permission to view
13735             */
13736            @Override
13737            public List<BlogsEntry> filterFindByG_LtD_NotS(long groupId,
13738                    Date displayDate, int status, int start, int end,
13739                    OrderByComparator<BlogsEntry> orderByComparator) {
13740                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13741                            return findByG_LtD_NotS(groupId, displayDate, status, start, end,
13742                                    orderByComparator);
13743                    }
13744    
13745                    StringBundler query = null;
13746    
13747                    if (orderByComparator != null) {
13748                            query = new StringBundler(5 +
13749                                            (orderByComparator.getOrderByFields().length * 2));
13750                    }
13751                    else {
13752                            query = new StringBundler(6);
13753                    }
13754    
13755                    if (getDB().isSupportsInlineDistinct()) {
13756                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
13757                    }
13758                    else {
13759                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
13760                    }
13761    
13762                    query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
13763    
13764                    boolean bindDisplayDate = false;
13765    
13766                    if (displayDate == null) {
13767                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
13768                    }
13769                    else {
13770                            bindDisplayDate = true;
13771    
13772                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
13773                    }
13774    
13775                    query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
13776    
13777                    if (!getDB().isSupportsInlineDistinct()) {
13778                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
13779                    }
13780    
13781                    if (orderByComparator != null) {
13782                            if (getDB().isSupportsInlineDistinct()) {
13783                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13784                                            orderByComparator, true);
13785                            }
13786                            else {
13787                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
13788                                            orderByComparator, true);
13789                            }
13790                    }
13791                    else {
13792                            if (getDB().isSupportsInlineDistinct()) {
13793                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
13794                            }
13795                            else {
13796                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
13797                            }
13798                    }
13799    
13800                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13801                                    BlogsEntry.class.getName(),
13802                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13803    
13804                    Session session = null;
13805    
13806                    try {
13807                            session = openSession();
13808    
13809                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
13810    
13811                            if (getDB().isSupportsInlineDistinct()) {
13812                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
13813                            }
13814                            else {
13815                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
13816                            }
13817    
13818                            QueryPos qPos = QueryPos.getInstance(q);
13819    
13820                            qPos.add(groupId);
13821    
13822                            if (bindDisplayDate) {
13823                                    qPos.add(new Timestamp(displayDate.getTime()));
13824                            }
13825    
13826                            qPos.add(status);
13827    
13828                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
13829                    }
13830                    catch (Exception e) {
13831                            throw processException(e);
13832                    }
13833                    finally {
13834                            closeSession(session);
13835                    }
13836            }
13837    
13838            /**
13839             * 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;.
13840             *
13841             * @param entryId the primary key of the current blogs entry
13842             * @param groupId the group ID
13843             * @param displayDate the display date
13844             * @param status the status
13845             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13846             * @return the previous, current, and next blogs entry
13847             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
13848             */
13849            @Override
13850            public BlogsEntry[] filterFindByG_LtD_NotS_PrevAndNext(long entryId,
13851                    long groupId, Date displayDate, int status,
13852                    OrderByComparator<BlogsEntry> orderByComparator)
13853                    throws NoSuchEntryException {
13854                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13855                            return findByG_LtD_NotS_PrevAndNext(entryId, groupId, displayDate,
13856                                    status, orderByComparator);
13857                    }
13858    
13859                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
13860    
13861                    Session session = null;
13862    
13863                    try {
13864                            session = openSession();
13865    
13866                            BlogsEntry[] array = new BlogsEntryImpl[3];
13867    
13868                            array[0] = filterGetByG_LtD_NotS_PrevAndNext(session, blogsEntry,
13869                                            groupId, displayDate, status, orderByComparator, true);
13870    
13871                            array[1] = blogsEntry;
13872    
13873                            array[2] = filterGetByG_LtD_NotS_PrevAndNext(session, blogsEntry,
13874                                            groupId, displayDate, status, orderByComparator, false);
13875    
13876                            return array;
13877                    }
13878                    catch (Exception e) {
13879                            throw processException(e);
13880                    }
13881                    finally {
13882                            closeSession(session);
13883                    }
13884            }
13885    
13886            protected BlogsEntry filterGetByG_LtD_NotS_PrevAndNext(Session session,
13887                    BlogsEntry blogsEntry, long groupId, Date displayDate, int status,
13888                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
13889                    StringBundler query = null;
13890    
13891                    if (orderByComparator != null) {
13892                            query = new StringBundler(7 +
13893                                            (orderByComparator.getOrderByConditionFields().length * 3) +
13894                                            (orderByComparator.getOrderByFields().length * 3));
13895                    }
13896                    else {
13897                            query = new StringBundler(6);
13898                    }
13899    
13900                    if (getDB().isSupportsInlineDistinct()) {
13901                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
13902                    }
13903                    else {
13904                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
13905                    }
13906    
13907                    query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
13908    
13909                    boolean bindDisplayDate = false;
13910    
13911                    if (displayDate == null) {
13912                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
13913                    }
13914                    else {
13915                            bindDisplayDate = true;
13916    
13917                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
13918                    }
13919    
13920                    query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
13921    
13922                    if (!getDB().isSupportsInlineDistinct()) {
13923                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
13924                    }
13925    
13926                    if (orderByComparator != null) {
13927                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
13928    
13929                            if (orderByConditionFields.length > 0) {
13930                                    query.append(WHERE_AND);
13931                            }
13932    
13933                            for (int i = 0; i < orderByConditionFields.length; i++) {
13934                                    if (getDB().isSupportsInlineDistinct()) {
13935                                            query.append(_ORDER_BY_ENTITY_ALIAS);
13936                                    }
13937                                    else {
13938                                            query.append(_ORDER_BY_ENTITY_TABLE);
13939                                    }
13940    
13941                                    query.append(orderByConditionFields[i]);
13942    
13943                                    if ((i + 1) < orderByConditionFields.length) {
13944                                            if (orderByComparator.isAscending() ^ previous) {
13945                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
13946                                            }
13947                                            else {
13948                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
13949                                            }
13950                                    }
13951                                    else {
13952                                            if (orderByComparator.isAscending() ^ previous) {
13953                                                    query.append(WHERE_GREATER_THAN);
13954                                            }
13955                                            else {
13956                                                    query.append(WHERE_LESSER_THAN);
13957                                            }
13958                                    }
13959                            }
13960    
13961                            query.append(ORDER_BY_CLAUSE);
13962    
13963                            String[] orderByFields = orderByComparator.getOrderByFields();
13964    
13965                            for (int i = 0; i < orderByFields.length; i++) {
13966                                    if (getDB().isSupportsInlineDistinct()) {
13967                                            query.append(_ORDER_BY_ENTITY_ALIAS);
13968                                    }
13969                                    else {
13970                                            query.append(_ORDER_BY_ENTITY_TABLE);
13971                                    }
13972    
13973                                    query.append(orderByFields[i]);
13974    
13975                                    if ((i + 1) < orderByFields.length) {
13976                                            if (orderByComparator.isAscending() ^ previous) {
13977                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
13978                                            }
13979                                            else {
13980                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
13981                                            }
13982                                    }
13983                                    else {
13984                                            if (orderByComparator.isAscending() ^ previous) {
13985                                                    query.append(ORDER_BY_ASC);
13986                                            }
13987                                            else {
13988                                                    query.append(ORDER_BY_DESC);
13989                                            }
13990                                    }
13991                            }
13992                    }
13993                    else {
13994                            if (getDB().isSupportsInlineDistinct()) {
13995                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
13996                            }
13997                            else {
13998                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
13999                            }
14000                    }
14001    
14002                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
14003                                    BlogsEntry.class.getName(),
14004                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
14005    
14006                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
14007    
14008                    q.setFirstResult(0);
14009                    q.setMaxResults(2);
14010    
14011                    if (getDB().isSupportsInlineDistinct()) {
14012                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
14013                    }
14014                    else {
14015                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
14016                    }
14017    
14018                    QueryPos qPos = QueryPos.getInstance(q);
14019    
14020                    qPos.add(groupId);
14021    
14022                    if (bindDisplayDate) {
14023                            qPos.add(new Timestamp(displayDate.getTime()));
14024                    }
14025    
14026                    qPos.add(status);
14027    
14028                    if (orderByComparator != null) {
14029                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
14030    
14031                            for (Object value : values) {
14032                                    qPos.add(value);
14033                            }
14034                    }
14035    
14036                    List<BlogsEntry> list = q.list();
14037    
14038                    if (list.size() == 2) {
14039                            return list.get(1);
14040                    }
14041                    else {
14042                            return null;
14043                    }
14044            }
14045    
14046            /**
14047             * Removes all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63; from the database.
14048             *
14049             * @param groupId the group ID
14050             * @param displayDate the display date
14051             * @param status the status
14052             */
14053            @Override
14054            public void removeByG_LtD_NotS(long groupId, Date displayDate, int status) {
14055                    for (BlogsEntry blogsEntry : findByG_LtD_NotS(groupId, displayDate,
14056                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
14057                            remove(blogsEntry);
14058                    }
14059            }
14060    
14061            /**
14062             * Returns the number of blogs entries where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
14063             *
14064             * @param groupId the group ID
14065             * @param displayDate the display date
14066             * @param status the status
14067             * @return the number of matching blogs entries
14068             */
14069            @Override
14070            public int countByG_LtD_NotS(long groupId, Date displayDate, int status) {
14071                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD_NOTS;
14072    
14073                    Object[] finderArgs = new Object[] { groupId, displayDate, status };
14074    
14075                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
14076    
14077                    if (count == null) {
14078                            StringBundler query = new StringBundler(4);
14079    
14080                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
14081    
14082                            query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
14083    
14084                            boolean bindDisplayDate = false;
14085    
14086                            if (displayDate == null) {
14087                                    query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
14088                            }
14089                            else {
14090                                    bindDisplayDate = true;
14091    
14092                                    query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
14093                            }
14094    
14095                            query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
14096    
14097                            String sql = query.toString();
14098    
14099                            Session session = null;
14100    
14101                            try {
14102                                    session = openSession();
14103    
14104                                    Query q = session.createQuery(sql);
14105    
14106                                    QueryPos qPos = QueryPos.getInstance(q);
14107    
14108                                    qPos.add(groupId);
14109    
14110                                    if (bindDisplayDate) {
14111                                            qPos.add(new Timestamp(displayDate.getTime()));
14112                                    }
14113    
14114                                    qPos.add(status);
14115    
14116                                    count = (Long)q.uniqueResult();
14117    
14118                                    finderCache.putResult(finderPath, finderArgs, count);
14119                            }
14120                            catch (Exception e) {
14121                                    finderCache.removeResult(finderPath, finderArgs);
14122    
14123                                    throw processException(e);
14124                            }
14125                            finally {
14126                                    closeSession(session);
14127                            }
14128                    }
14129    
14130                    return count.intValue();
14131            }
14132    
14133            /**
14134             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
14135             *
14136             * @param groupId the group ID
14137             * @param displayDate the display date
14138             * @param status the status
14139             * @return the number of matching blogs entries that the user has permission to view
14140             */
14141            @Override
14142            public int filterCountByG_LtD_NotS(long groupId, Date displayDate,
14143                    int status) {
14144                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
14145                            return countByG_LtD_NotS(groupId, displayDate, status);
14146                    }
14147    
14148                    StringBundler query = new StringBundler(4);
14149    
14150                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
14151    
14152                    query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
14153    
14154                    boolean bindDisplayDate = false;
14155    
14156                    if (displayDate == null) {
14157                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
14158                    }
14159                    else {
14160                            bindDisplayDate = true;
14161    
14162                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
14163                    }
14164    
14165                    query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
14166    
14167                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
14168                                    BlogsEntry.class.getName(),
14169                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
14170    
14171                    Session session = null;
14172    
14173                    try {
14174                            session = openSession();
14175    
14176                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
14177    
14178                            q.addScalar(COUNT_COLUMN_NAME,
14179                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
14180    
14181                            QueryPos qPos = QueryPos.getInstance(q);
14182    
14183                            qPos.add(groupId);
14184    
14185                            if (bindDisplayDate) {
14186                                    qPos.add(new Timestamp(displayDate.getTime()));
14187                            }
14188    
14189                            qPos.add(status);
14190    
14191                            Long count = (Long)q.uniqueResult();
14192    
14193                            return count.intValue();
14194                    }
14195                    catch (Exception e) {
14196                            throw processException(e);
14197                    }
14198                    finally {
14199                            closeSession(session);
14200                    }
14201            }
14202    
14203            private static final String _FINDER_COLUMN_G_LTD_NOTS_GROUPID_2 = "blogsEntry.groupId = ? AND ";
14204            private static final String _FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1 = "blogsEntry.displayDate IS NULL AND ";
14205            private static final String _FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
14206            private static final String _FINDER_COLUMN_G_LTD_NOTS_STATUS_2 = "blogsEntry.status != ?";
14207            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
14208                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
14209                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_U_S",
14210                            new String[] {
14211                                    Long.class.getName(), Long.class.getName(),
14212                                    Integer.class.getName(),
14213                                    
14214                            Integer.class.getName(), Integer.class.getName(),
14215                                    OrderByComparator.class.getName()
14216                            });
14217            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
14218                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
14219                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_U_S",
14220                            new String[] {
14221                                    Long.class.getName(), Long.class.getName(),
14222                                    Integer.class.getName()
14223                            },
14224                            BlogsEntryModelImpl.COMPANYID_COLUMN_BITMASK |
14225                            BlogsEntryModelImpl.USERID_COLUMN_BITMASK |
14226                            BlogsEntryModelImpl.STATUS_COLUMN_BITMASK |
14227                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
14228                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
14229            public static final FinderPath FINDER_PATH_COUNT_BY_C_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
14230                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
14231                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_U_S",
14232                            new String[] {
14233                                    Long.class.getName(), Long.class.getName(),
14234                                    Integer.class.getName()
14235                            });
14236    
14237            /**
14238             * Returns all the blogs entries where companyId = &#63; and userId = &#63; and status = &#63;.
14239             *
14240             * @param companyId the company ID
14241             * @param userId the user ID
14242             * @param status the status
14243             * @return the matching blogs entries
14244             */
14245            @Override
14246            public List<BlogsEntry> findByC_U_S(long companyId, long userId, int status) {
14247                    return findByC_U_S(companyId, userId, status, QueryUtil.ALL_POS,
14248                            QueryUtil.ALL_POS, null);
14249            }
14250    
14251            /**
14252             * Returns a range of all the blogs entries where companyId = &#63; and userId = &#63; and status = &#63;.
14253             *
14254             * <p>
14255             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
14256             * </p>
14257             *
14258             * @param companyId the company ID
14259             * @param userId the user ID
14260             * @param status the status
14261             * @param start the lower bound of the range of blogs entries
14262             * @param end the upper bound of the range of blogs entries (not inclusive)
14263             * @return the range of matching blogs entries
14264             */
14265            @Override
14266            public List<BlogsEntry> findByC_U_S(long companyId, long userId,
14267                    int status, int start, int end) {
14268                    return findByC_U_S(companyId, userId, status, start, end, null);
14269            }
14270    
14271            /**
14272             * Returns an ordered range of all the blogs entries where companyId = &#63; and userId = &#63; and status = &#63;.
14273             *
14274             * <p>
14275             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
14276             * </p>
14277             *
14278             * @param companyId the company ID
14279             * @param userId the user ID
14280             * @param status the status
14281             * @param start the lower bound of the range of blogs entries
14282             * @param end the upper bound of the range of blogs entries (not inclusive)
14283             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14284             * @return the ordered range of matching blogs entries
14285             */
14286            @Override
14287            public List<BlogsEntry> findByC_U_S(long companyId, long userId,
14288                    int status, int start, int end,
14289                    OrderByComparator<BlogsEntry> orderByComparator) {
14290                    return findByC_U_S(companyId, userId, status, start, end,
14291                            orderByComparator, true);
14292            }
14293    
14294            /**
14295             * Returns an ordered range of all the blogs entries where companyId = &#63; and userId = &#63; and status = &#63;.
14296             *
14297             * <p>
14298             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
14299             * </p>
14300             *
14301             * @param companyId the company ID
14302             * @param userId the user ID
14303             * @param status the status
14304             * @param start the lower bound of the range of blogs entries
14305             * @param end the upper bound of the range of blogs entries (not inclusive)
14306             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14307             * @param retrieveFromCache whether to retrieve from the finder cache
14308             * @return the ordered range of matching blogs entries
14309             */
14310            @Override
14311            public List<BlogsEntry> findByC_U_S(long companyId, long userId,
14312                    int status, int start, int end,
14313                    OrderByComparator<BlogsEntry> orderByComparator,
14314                    boolean retrieveFromCache) {
14315                    boolean pagination = true;
14316                    FinderPath finderPath = null;
14317                    Object[] finderArgs = null;
14318    
14319                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
14320                                    (orderByComparator == null)) {
14321                            pagination = false;
14322                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U_S;
14323                            finderArgs = new Object[] { companyId, userId, status };
14324                    }
14325                    else {
14326                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U_S;
14327                            finderArgs = new Object[] {
14328                                            companyId, userId, status,
14329                                            
14330                                            start, end, orderByComparator
14331                                    };
14332                    }
14333    
14334                    List<BlogsEntry> list = null;
14335    
14336                    if (retrieveFromCache) {
14337                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
14338                                            finderArgs, this);
14339    
14340                            if ((list != null) && !list.isEmpty()) {
14341                                    for (BlogsEntry blogsEntry : list) {
14342                                            if ((companyId != blogsEntry.getCompanyId()) ||
14343                                                            (userId != blogsEntry.getUserId()) ||
14344                                                            (status != blogsEntry.getStatus())) {
14345                                                    list = null;
14346    
14347                                                    break;
14348                                            }
14349                                    }
14350                            }
14351                    }
14352    
14353                    if (list == null) {
14354                            StringBundler query = null;
14355    
14356                            if (orderByComparator != null) {
14357                                    query = new StringBundler(5 +
14358                                                    (orderByComparator.getOrderByFields().length * 2));
14359                            }
14360                            else {
14361                                    query = new StringBundler(5);
14362                            }
14363    
14364                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
14365    
14366                            query.append(_FINDER_COLUMN_C_U_S_COMPANYID_2);
14367    
14368                            query.append(_FINDER_COLUMN_C_U_S_USERID_2);
14369    
14370                            query.append(_FINDER_COLUMN_C_U_S_STATUS_2);
14371    
14372                            if (orderByComparator != null) {
14373                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
14374                                            orderByComparator);
14375                            }
14376                            else
14377                             if (pagination) {
14378                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
14379                            }
14380    
14381                            String sql = query.toString();
14382    
14383                            Session session = null;
14384    
14385                            try {
14386                                    session = openSession();
14387    
14388                                    Query q = session.createQuery(sql);
14389    
14390                                    QueryPos qPos = QueryPos.getInstance(q);
14391    
14392                                    qPos.add(companyId);
14393    
14394                                    qPos.add(userId);
14395    
14396                                    qPos.add(status);
14397    
14398                                    if (!pagination) {
14399                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
14400                                                            start, end, false);
14401    
14402                                            Collections.sort(list);
14403    
14404                                            list = Collections.unmodifiableList(list);
14405                                    }
14406                                    else {
14407                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
14408                                                            start, end);
14409                                    }
14410    
14411                                    cacheResult(list);
14412    
14413                                    finderCache.putResult(finderPath, finderArgs, list);
14414                            }
14415                            catch (Exception e) {
14416                                    finderCache.removeResult(finderPath, finderArgs);
14417    
14418                                    throw processException(e);
14419                            }
14420                            finally {
14421                                    closeSession(session);
14422                            }
14423                    }
14424    
14425                    return list;
14426            }
14427    
14428            /**
14429             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status = &#63;.
14430             *
14431             * @param companyId the company ID
14432             * @param userId the user ID
14433             * @param status the status
14434             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14435             * @return the first matching blogs entry
14436             * @throws NoSuchEntryException if a matching blogs entry could not be found
14437             */
14438            @Override
14439            public BlogsEntry findByC_U_S_First(long companyId, long userId,
14440                    int status, OrderByComparator<BlogsEntry> orderByComparator)
14441                    throws NoSuchEntryException {
14442                    BlogsEntry blogsEntry = fetchByC_U_S_First(companyId, userId, status,
14443                                    orderByComparator);
14444    
14445                    if (blogsEntry != null) {
14446                            return blogsEntry;
14447                    }
14448    
14449                    StringBundler msg = new StringBundler(8);
14450    
14451                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
14452    
14453                    msg.append("companyId=");
14454                    msg.append(companyId);
14455    
14456                    msg.append(", userId=");
14457                    msg.append(userId);
14458    
14459                    msg.append(", status=");
14460                    msg.append(status);
14461    
14462                    msg.append(StringPool.CLOSE_CURLY_BRACE);
14463    
14464                    throw new NoSuchEntryException(msg.toString());
14465            }
14466    
14467            /**
14468             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status = &#63;.
14469             *
14470             * @param companyId the company ID
14471             * @param userId the user ID
14472             * @param status the status
14473             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14474             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
14475             */
14476            @Override
14477            public BlogsEntry fetchByC_U_S_First(long companyId, long userId,
14478                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
14479                    List<BlogsEntry> list = findByC_U_S(companyId, userId, status, 0, 1,
14480                                    orderByComparator);
14481    
14482                    if (!list.isEmpty()) {
14483                            return list.get(0);
14484                    }
14485    
14486                    return null;
14487            }
14488    
14489            /**
14490             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status = &#63;.
14491             *
14492             * @param companyId the company ID
14493             * @param userId the user ID
14494             * @param status the status
14495             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14496             * @return the last matching blogs entry
14497             * @throws NoSuchEntryException if a matching blogs entry could not be found
14498             */
14499            @Override
14500            public BlogsEntry findByC_U_S_Last(long companyId, long userId, int status,
14501                    OrderByComparator<BlogsEntry> orderByComparator)
14502                    throws NoSuchEntryException {
14503                    BlogsEntry blogsEntry = fetchByC_U_S_Last(companyId, userId, status,
14504                                    orderByComparator);
14505    
14506                    if (blogsEntry != null) {
14507                            return blogsEntry;
14508                    }
14509    
14510                    StringBundler msg = new StringBundler(8);
14511    
14512                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
14513    
14514                    msg.append("companyId=");
14515                    msg.append(companyId);
14516    
14517                    msg.append(", userId=");
14518                    msg.append(userId);
14519    
14520                    msg.append(", status=");
14521                    msg.append(status);
14522    
14523                    msg.append(StringPool.CLOSE_CURLY_BRACE);
14524    
14525                    throw new NoSuchEntryException(msg.toString());
14526            }
14527    
14528            /**
14529             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status = &#63;.
14530             *
14531             * @param companyId the company ID
14532             * @param userId the user ID
14533             * @param status the status
14534             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14535             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
14536             */
14537            @Override
14538            public BlogsEntry fetchByC_U_S_Last(long companyId, long userId,
14539                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
14540                    int count = countByC_U_S(companyId, userId, status);
14541    
14542                    if (count == 0) {
14543                            return null;
14544                    }
14545    
14546                    List<BlogsEntry> list = findByC_U_S(companyId, userId, status,
14547                                    count - 1, count, orderByComparator);
14548    
14549                    if (!list.isEmpty()) {
14550                            return list.get(0);
14551                    }
14552    
14553                    return null;
14554            }
14555    
14556            /**
14557             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status = &#63;.
14558             *
14559             * @param entryId the primary key of the current blogs entry
14560             * @param companyId the company ID
14561             * @param userId the user ID
14562             * @param status the status
14563             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14564             * @return the previous, current, and next blogs entry
14565             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
14566             */
14567            @Override
14568            public BlogsEntry[] findByC_U_S_PrevAndNext(long entryId, long companyId,
14569                    long userId, int status, OrderByComparator<BlogsEntry> orderByComparator)
14570                    throws NoSuchEntryException {
14571                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
14572    
14573                    Session session = null;
14574    
14575                    try {
14576                            session = openSession();
14577    
14578                            BlogsEntry[] array = new BlogsEntryImpl[3];
14579    
14580                            array[0] = getByC_U_S_PrevAndNext(session, blogsEntry, companyId,
14581                                            userId, status, orderByComparator, true);
14582    
14583                            array[1] = blogsEntry;
14584    
14585                            array[2] = getByC_U_S_PrevAndNext(session, blogsEntry, companyId,
14586                                            userId, status, orderByComparator, false);
14587    
14588                            return array;
14589                    }
14590                    catch (Exception e) {
14591                            throw processException(e);
14592                    }
14593                    finally {
14594                            closeSession(session);
14595                    }
14596            }
14597    
14598            protected BlogsEntry getByC_U_S_PrevAndNext(Session session,
14599                    BlogsEntry blogsEntry, long companyId, long userId, int status,
14600                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
14601                    StringBundler query = null;
14602    
14603                    if (orderByComparator != null) {
14604                            query = new StringBundler(6 +
14605                                            (orderByComparator.getOrderByConditionFields().length * 3) +
14606                                            (orderByComparator.getOrderByFields().length * 3));
14607                    }
14608                    else {
14609                            query = new StringBundler(5);
14610                    }
14611    
14612                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
14613    
14614                    query.append(_FINDER_COLUMN_C_U_S_COMPANYID_2);
14615    
14616                    query.append(_FINDER_COLUMN_C_U_S_USERID_2);
14617    
14618                    query.append(_FINDER_COLUMN_C_U_S_STATUS_2);
14619    
14620                    if (orderByComparator != null) {
14621                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
14622    
14623                            if (orderByConditionFields.length > 0) {
14624                                    query.append(WHERE_AND);
14625                            }
14626    
14627                            for (int i = 0; i < orderByConditionFields.length; i++) {
14628                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14629                                    query.append(orderByConditionFields[i]);
14630    
14631                                    if ((i + 1) < orderByConditionFields.length) {
14632                                            if (orderByComparator.isAscending() ^ previous) {
14633                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
14634                                            }
14635                                            else {
14636                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
14637                                            }
14638                                    }
14639                                    else {
14640                                            if (orderByComparator.isAscending() ^ previous) {
14641                                                    query.append(WHERE_GREATER_THAN);
14642                                            }
14643                                            else {
14644                                                    query.append(WHERE_LESSER_THAN);
14645                                            }
14646                                    }
14647                            }
14648    
14649                            query.append(ORDER_BY_CLAUSE);
14650    
14651                            String[] orderByFields = orderByComparator.getOrderByFields();
14652    
14653                            for (int i = 0; i < orderByFields.length; i++) {
14654                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14655                                    query.append(orderByFields[i]);
14656    
14657                                    if ((i + 1) < orderByFields.length) {
14658                                            if (orderByComparator.isAscending() ^ previous) {
14659                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
14660                                            }
14661                                            else {
14662                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
14663                                            }
14664                                    }
14665                                    else {
14666                                            if (orderByComparator.isAscending() ^ previous) {
14667                                                    query.append(ORDER_BY_ASC);
14668                                            }
14669                                            else {
14670                                                    query.append(ORDER_BY_DESC);
14671                                            }
14672                                    }
14673                            }
14674                    }
14675                    else {
14676                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
14677                    }
14678    
14679                    String sql = query.toString();
14680    
14681                    Query q = session.createQuery(sql);
14682    
14683                    q.setFirstResult(0);
14684                    q.setMaxResults(2);
14685    
14686                    QueryPos qPos = QueryPos.getInstance(q);
14687    
14688                    qPos.add(companyId);
14689    
14690                    qPos.add(userId);
14691    
14692                    qPos.add(status);
14693    
14694                    if (orderByComparator != null) {
14695                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
14696    
14697                            for (Object value : values) {
14698                                    qPos.add(value);
14699                            }
14700                    }
14701    
14702                    List<BlogsEntry> list = q.list();
14703    
14704                    if (list.size() == 2) {
14705                            return list.get(1);
14706                    }
14707                    else {
14708                            return null;
14709                    }
14710            }
14711    
14712            /**
14713             * Removes all the blogs entries where companyId = &#63; and userId = &#63; and status = &#63; from the database.
14714             *
14715             * @param companyId the company ID
14716             * @param userId the user ID
14717             * @param status the status
14718             */
14719            @Override
14720            public void removeByC_U_S(long companyId, long userId, int status) {
14721                    for (BlogsEntry blogsEntry : findByC_U_S(companyId, userId, status,
14722                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
14723                            remove(blogsEntry);
14724                    }
14725            }
14726    
14727            /**
14728             * Returns the number of blogs entries where companyId = &#63; and userId = &#63; and status = &#63;.
14729             *
14730             * @param companyId the company ID
14731             * @param userId the user ID
14732             * @param status the status
14733             * @return the number of matching blogs entries
14734             */
14735            @Override
14736            public int countByC_U_S(long companyId, long userId, int status) {
14737                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_U_S;
14738    
14739                    Object[] finderArgs = new Object[] { companyId, userId, status };
14740    
14741                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
14742    
14743                    if (count == null) {
14744                            StringBundler query = new StringBundler(4);
14745    
14746                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
14747    
14748                            query.append(_FINDER_COLUMN_C_U_S_COMPANYID_2);
14749    
14750                            query.append(_FINDER_COLUMN_C_U_S_USERID_2);
14751    
14752                            query.append(_FINDER_COLUMN_C_U_S_STATUS_2);
14753    
14754                            String sql = query.toString();
14755    
14756                            Session session = null;
14757    
14758                            try {
14759                                    session = openSession();
14760    
14761                                    Query q = session.createQuery(sql);
14762    
14763                                    QueryPos qPos = QueryPos.getInstance(q);
14764    
14765                                    qPos.add(companyId);
14766    
14767                                    qPos.add(userId);
14768    
14769                                    qPos.add(status);
14770    
14771                                    count = (Long)q.uniqueResult();
14772    
14773                                    finderCache.putResult(finderPath, finderArgs, count);
14774                            }
14775                            catch (Exception e) {
14776                                    finderCache.removeResult(finderPath, finderArgs);
14777    
14778                                    throw processException(e);
14779                            }
14780                            finally {
14781                                    closeSession(session);
14782                            }
14783                    }
14784    
14785                    return count.intValue();
14786            }
14787    
14788            private static final String _FINDER_COLUMN_C_U_S_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
14789            private static final String _FINDER_COLUMN_C_U_S_USERID_2 = "blogsEntry.userId = ? AND ";
14790            private static final String _FINDER_COLUMN_C_U_S_STATUS_2 = "blogsEntry.status = ?";
14791            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U_NOTS = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
14792                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
14793                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_U_NotS",
14794                            new String[] {
14795                                    Long.class.getName(), Long.class.getName(),
14796                                    Integer.class.getName(),
14797                                    
14798                            Integer.class.getName(), Integer.class.getName(),
14799                                    OrderByComparator.class.getName()
14800                            });
14801            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_U_NOTS =
14802                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
14803                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
14804                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_U_NotS",
14805                            new String[] {
14806                                    Long.class.getName(), Long.class.getName(),
14807                                    Integer.class.getName()
14808                            });
14809    
14810            /**
14811             * Returns all the blogs entries where companyId = &#63; and userId = &#63; and status &ne; &#63;.
14812             *
14813             * @param companyId the company ID
14814             * @param userId the user ID
14815             * @param status the status
14816             * @return the matching blogs entries
14817             */
14818            @Override
14819            public List<BlogsEntry> findByC_U_NotS(long companyId, long userId,
14820                    int status) {
14821                    return findByC_U_NotS(companyId, userId, status, QueryUtil.ALL_POS,
14822                            QueryUtil.ALL_POS, null);
14823            }
14824    
14825            /**
14826             * Returns a range of all the blogs entries where companyId = &#63; and userId = &#63; and status &ne; &#63;.
14827             *
14828             * <p>
14829             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
14830             * </p>
14831             *
14832             * @param companyId the company ID
14833             * @param userId the user ID
14834             * @param status the status
14835             * @param start the lower bound of the range of blogs entries
14836             * @param end the upper bound of the range of blogs entries (not inclusive)
14837             * @return the range of matching blogs entries
14838             */
14839            @Override
14840            public List<BlogsEntry> findByC_U_NotS(long companyId, long userId,
14841                    int status, int start, int end) {
14842                    return findByC_U_NotS(companyId, userId, status, start, end, null);
14843            }
14844    
14845            /**
14846             * Returns an ordered range of all the blogs entries where companyId = &#63; and userId = &#63; and status &ne; &#63;.
14847             *
14848             * <p>
14849             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
14850             * </p>
14851             *
14852             * @param companyId the company ID
14853             * @param userId the user ID
14854             * @param status the status
14855             * @param start the lower bound of the range of blogs entries
14856             * @param end the upper bound of the range of blogs entries (not inclusive)
14857             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14858             * @return the ordered range of matching blogs entries
14859             */
14860            @Override
14861            public List<BlogsEntry> findByC_U_NotS(long companyId, long userId,
14862                    int status, int start, int end,
14863                    OrderByComparator<BlogsEntry> orderByComparator) {
14864                    return findByC_U_NotS(companyId, userId, status, start, end,
14865                            orderByComparator, true);
14866            }
14867    
14868            /**
14869             * Returns an ordered range of all the blogs entries where companyId = &#63; and userId = &#63; and status &ne; &#63;.
14870             *
14871             * <p>
14872             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
14873             * </p>
14874             *
14875             * @param companyId the company ID
14876             * @param userId the user ID
14877             * @param status the status
14878             * @param start the lower bound of the range of blogs entries
14879             * @param end the upper bound of the range of blogs entries (not inclusive)
14880             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14881             * @param retrieveFromCache whether to retrieve from the finder cache
14882             * @return the ordered range of matching blogs entries
14883             */
14884            @Override
14885            public List<BlogsEntry> findByC_U_NotS(long companyId, long userId,
14886                    int status, int start, int end,
14887                    OrderByComparator<BlogsEntry> orderByComparator,
14888                    boolean retrieveFromCache) {
14889                    boolean pagination = true;
14890                    FinderPath finderPath = null;
14891                    Object[] finderArgs = null;
14892    
14893                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U_NOTS;
14894                    finderArgs = new Object[] {
14895                                    companyId, userId, status,
14896                                    
14897                                    start, end, orderByComparator
14898                            };
14899    
14900                    List<BlogsEntry> list = null;
14901    
14902                    if (retrieveFromCache) {
14903                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
14904                                            finderArgs, this);
14905    
14906                            if ((list != null) && !list.isEmpty()) {
14907                                    for (BlogsEntry blogsEntry : list) {
14908                                            if ((companyId != blogsEntry.getCompanyId()) ||
14909                                                            (userId != blogsEntry.getUserId()) ||
14910                                                            (status == blogsEntry.getStatus())) {
14911                                                    list = null;
14912    
14913                                                    break;
14914                                            }
14915                                    }
14916                            }
14917                    }
14918    
14919                    if (list == null) {
14920                            StringBundler query = null;
14921    
14922                            if (orderByComparator != null) {
14923                                    query = new StringBundler(5 +
14924                                                    (orderByComparator.getOrderByFields().length * 2));
14925                            }
14926                            else {
14927                                    query = new StringBundler(5);
14928                            }
14929    
14930                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
14931    
14932                            query.append(_FINDER_COLUMN_C_U_NOTS_COMPANYID_2);
14933    
14934                            query.append(_FINDER_COLUMN_C_U_NOTS_USERID_2);
14935    
14936                            query.append(_FINDER_COLUMN_C_U_NOTS_STATUS_2);
14937    
14938                            if (orderByComparator != null) {
14939                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
14940                                            orderByComparator);
14941                            }
14942                            else
14943                             if (pagination) {
14944                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
14945                            }
14946    
14947                            String sql = query.toString();
14948    
14949                            Session session = null;
14950    
14951                            try {
14952                                    session = openSession();
14953    
14954                                    Query q = session.createQuery(sql);
14955    
14956                                    QueryPos qPos = QueryPos.getInstance(q);
14957    
14958                                    qPos.add(companyId);
14959    
14960                                    qPos.add(userId);
14961    
14962                                    qPos.add(status);
14963    
14964                                    if (!pagination) {
14965                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
14966                                                            start, end, false);
14967    
14968                                            Collections.sort(list);
14969    
14970                                            list = Collections.unmodifiableList(list);
14971                                    }
14972                                    else {
14973                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
14974                                                            start, end);
14975                                    }
14976    
14977                                    cacheResult(list);
14978    
14979                                    finderCache.putResult(finderPath, finderArgs, list);
14980                            }
14981                            catch (Exception e) {
14982                                    finderCache.removeResult(finderPath, finderArgs);
14983    
14984                                    throw processException(e);
14985                            }
14986                            finally {
14987                                    closeSession(session);
14988                            }
14989                    }
14990    
14991                    return list;
14992            }
14993    
14994            /**
14995             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status &ne; &#63;.
14996             *
14997             * @param companyId the company ID
14998             * @param userId the user ID
14999             * @param status the status
15000             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15001             * @return the first matching blogs entry
15002             * @throws NoSuchEntryException if a matching blogs entry could not be found
15003             */
15004            @Override
15005            public BlogsEntry findByC_U_NotS_First(long companyId, long userId,
15006                    int status, OrderByComparator<BlogsEntry> orderByComparator)
15007                    throws NoSuchEntryException {
15008                    BlogsEntry blogsEntry = fetchByC_U_NotS_First(companyId, userId,
15009                                    status, orderByComparator);
15010    
15011                    if (blogsEntry != null) {
15012                            return blogsEntry;
15013                    }
15014    
15015                    StringBundler msg = new StringBundler(8);
15016    
15017                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15018    
15019                    msg.append("companyId=");
15020                    msg.append(companyId);
15021    
15022                    msg.append(", userId=");
15023                    msg.append(userId);
15024    
15025                    msg.append(", status=");
15026                    msg.append(status);
15027    
15028                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15029    
15030                    throw new NoSuchEntryException(msg.toString());
15031            }
15032    
15033            /**
15034             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status &ne; &#63;.
15035             *
15036             * @param companyId the company ID
15037             * @param userId the user ID
15038             * @param status the status
15039             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15040             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
15041             */
15042            @Override
15043            public BlogsEntry fetchByC_U_NotS_First(long companyId, long userId,
15044                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
15045                    List<BlogsEntry> list = findByC_U_NotS(companyId, userId, status, 0, 1,
15046                                    orderByComparator);
15047    
15048                    if (!list.isEmpty()) {
15049                            return list.get(0);
15050                    }
15051    
15052                    return null;
15053            }
15054    
15055            /**
15056             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status &ne; &#63;.
15057             *
15058             * @param companyId the company ID
15059             * @param userId the user ID
15060             * @param status the status
15061             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15062             * @return the last matching blogs entry
15063             * @throws NoSuchEntryException if a matching blogs entry could not be found
15064             */
15065            @Override
15066            public BlogsEntry findByC_U_NotS_Last(long companyId, long userId,
15067                    int status, OrderByComparator<BlogsEntry> orderByComparator)
15068                    throws NoSuchEntryException {
15069                    BlogsEntry blogsEntry = fetchByC_U_NotS_Last(companyId, userId, status,
15070                                    orderByComparator);
15071    
15072                    if (blogsEntry != null) {
15073                            return blogsEntry;
15074                    }
15075    
15076                    StringBundler msg = new StringBundler(8);
15077    
15078                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15079    
15080                    msg.append("companyId=");
15081                    msg.append(companyId);
15082    
15083                    msg.append(", userId=");
15084                    msg.append(userId);
15085    
15086                    msg.append(", status=");
15087                    msg.append(status);
15088    
15089                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15090    
15091                    throw new NoSuchEntryException(msg.toString());
15092            }
15093    
15094            /**
15095             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status &ne; &#63;.
15096             *
15097             * @param companyId the company ID
15098             * @param userId the user ID
15099             * @param status the status
15100             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15101             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
15102             */
15103            @Override
15104            public BlogsEntry fetchByC_U_NotS_Last(long companyId, long userId,
15105                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
15106                    int count = countByC_U_NotS(companyId, userId, status);
15107    
15108                    if (count == 0) {
15109                            return null;
15110                    }
15111    
15112                    List<BlogsEntry> list = findByC_U_NotS(companyId, userId, status,
15113                                    count - 1, count, orderByComparator);
15114    
15115                    if (!list.isEmpty()) {
15116                            return list.get(0);
15117                    }
15118    
15119                    return null;
15120            }
15121    
15122            /**
15123             * 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;.
15124             *
15125             * @param entryId the primary key of the current blogs entry
15126             * @param companyId the company ID
15127             * @param userId the user ID
15128             * @param status the status
15129             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15130             * @return the previous, current, and next blogs entry
15131             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
15132             */
15133            @Override
15134            public BlogsEntry[] findByC_U_NotS_PrevAndNext(long entryId,
15135                    long companyId, long userId, int status,
15136                    OrderByComparator<BlogsEntry> orderByComparator)
15137                    throws NoSuchEntryException {
15138                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
15139    
15140                    Session session = null;
15141    
15142                    try {
15143                            session = openSession();
15144    
15145                            BlogsEntry[] array = new BlogsEntryImpl[3];
15146    
15147                            array[0] = getByC_U_NotS_PrevAndNext(session, blogsEntry,
15148                                            companyId, userId, status, orderByComparator, true);
15149    
15150                            array[1] = blogsEntry;
15151    
15152                            array[2] = getByC_U_NotS_PrevAndNext(session, blogsEntry,
15153                                            companyId, userId, status, orderByComparator, false);
15154    
15155                            return array;
15156                    }
15157                    catch (Exception e) {
15158                            throw processException(e);
15159                    }
15160                    finally {
15161                            closeSession(session);
15162                    }
15163            }
15164    
15165            protected BlogsEntry getByC_U_NotS_PrevAndNext(Session session,
15166                    BlogsEntry blogsEntry, long companyId, long userId, int status,
15167                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
15168                    StringBundler query = null;
15169    
15170                    if (orderByComparator != null) {
15171                            query = new StringBundler(6 +
15172                                            (orderByComparator.getOrderByConditionFields().length * 3) +
15173                                            (orderByComparator.getOrderByFields().length * 3));
15174                    }
15175                    else {
15176                            query = new StringBundler(5);
15177                    }
15178    
15179                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
15180    
15181                    query.append(_FINDER_COLUMN_C_U_NOTS_COMPANYID_2);
15182    
15183                    query.append(_FINDER_COLUMN_C_U_NOTS_USERID_2);
15184    
15185                    query.append(_FINDER_COLUMN_C_U_NOTS_STATUS_2);
15186    
15187                    if (orderByComparator != null) {
15188                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
15189    
15190                            if (orderByConditionFields.length > 0) {
15191                                    query.append(WHERE_AND);
15192                            }
15193    
15194                            for (int i = 0; i < orderByConditionFields.length; i++) {
15195                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15196                                    query.append(orderByConditionFields[i]);
15197    
15198                                    if ((i + 1) < orderByConditionFields.length) {
15199                                            if (orderByComparator.isAscending() ^ previous) {
15200                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
15201                                            }
15202                                            else {
15203                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
15204                                            }
15205                                    }
15206                                    else {
15207                                            if (orderByComparator.isAscending() ^ previous) {
15208                                                    query.append(WHERE_GREATER_THAN);
15209                                            }
15210                                            else {
15211                                                    query.append(WHERE_LESSER_THAN);
15212                                            }
15213                                    }
15214                            }
15215    
15216                            query.append(ORDER_BY_CLAUSE);
15217    
15218                            String[] orderByFields = orderByComparator.getOrderByFields();
15219    
15220                            for (int i = 0; i < orderByFields.length; i++) {
15221                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15222                                    query.append(orderByFields[i]);
15223    
15224                                    if ((i + 1) < orderByFields.length) {
15225                                            if (orderByComparator.isAscending() ^ previous) {
15226                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
15227                                            }
15228                                            else {
15229                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
15230                                            }
15231                                    }
15232                                    else {
15233                                            if (orderByComparator.isAscending() ^ previous) {
15234                                                    query.append(ORDER_BY_ASC);
15235                                            }
15236                                            else {
15237                                                    query.append(ORDER_BY_DESC);
15238                                            }
15239                                    }
15240                            }
15241                    }
15242                    else {
15243                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
15244                    }
15245    
15246                    String sql = query.toString();
15247    
15248                    Query q = session.createQuery(sql);
15249    
15250                    q.setFirstResult(0);
15251                    q.setMaxResults(2);
15252    
15253                    QueryPos qPos = QueryPos.getInstance(q);
15254    
15255                    qPos.add(companyId);
15256    
15257                    qPos.add(userId);
15258    
15259                    qPos.add(status);
15260    
15261                    if (orderByComparator != null) {
15262                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
15263    
15264                            for (Object value : values) {
15265                                    qPos.add(value);
15266                            }
15267                    }
15268    
15269                    List<BlogsEntry> list = q.list();
15270    
15271                    if (list.size() == 2) {
15272                            return list.get(1);
15273                    }
15274                    else {
15275                            return null;
15276                    }
15277            }
15278    
15279            /**
15280             * Removes all the blogs entries where companyId = &#63; and userId = &#63; and status &ne; &#63; from the database.
15281             *
15282             * @param companyId the company ID
15283             * @param userId the user ID
15284             * @param status the status
15285             */
15286            @Override
15287            public void removeByC_U_NotS(long companyId, long userId, int status) {
15288                    for (BlogsEntry blogsEntry : findByC_U_NotS(companyId, userId, status,
15289                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
15290                            remove(blogsEntry);
15291                    }
15292            }
15293    
15294            /**
15295             * Returns the number of blogs entries where companyId = &#63; and userId = &#63; and status &ne; &#63;.
15296             *
15297             * @param companyId the company ID
15298             * @param userId the user ID
15299             * @param status the status
15300             * @return the number of matching blogs entries
15301             */
15302            @Override
15303            public int countByC_U_NotS(long companyId, long userId, int status) {
15304                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_U_NOTS;
15305    
15306                    Object[] finderArgs = new Object[] { companyId, userId, status };
15307    
15308                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
15309    
15310                    if (count == null) {
15311                            StringBundler query = new StringBundler(4);
15312    
15313                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
15314    
15315                            query.append(_FINDER_COLUMN_C_U_NOTS_COMPANYID_2);
15316    
15317                            query.append(_FINDER_COLUMN_C_U_NOTS_USERID_2);
15318    
15319                            query.append(_FINDER_COLUMN_C_U_NOTS_STATUS_2);
15320    
15321                            String sql = query.toString();
15322    
15323                            Session session = null;
15324    
15325                            try {
15326                                    session = openSession();
15327    
15328                                    Query q = session.createQuery(sql);
15329    
15330                                    QueryPos qPos = QueryPos.getInstance(q);
15331    
15332                                    qPos.add(companyId);
15333    
15334                                    qPos.add(userId);
15335    
15336                                    qPos.add(status);
15337    
15338                                    count = (Long)q.uniqueResult();
15339    
15340                                    finderCache.putResult(finderPath, finderArgs, count);
15341                            }
15342                            catch (Exception e) {
15343                                    finderCache.removeResult(finderPath, finderArgs);
15344    
15345                                    throw processException(e);
15346                            }
15347                            finally {
15348                                    closeSession(session);
15349                            }
15350                    }
15351    
15352                    return count.intValue();
15353            }
15354    
15355            private static final String _FINDER_COLUMN_C_U_NOTS_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
15356            private static final String _FINDER_COLUMN_C_U_NOTS_USERID_2 = "blogsEntry.userId = ? AND ";
15357            private static final String _FINDER_COLUMN_C_U_NOTS_STATUS_2 = "blogsEntry.status != ?";
15358            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
15359                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
15360                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_LtD_S",
15361                            new String[] {
15362                                    Long.class.getName(), Date.class.getName(),
15363                                    Integer.class.getName(),
15364                                    
15365                            Integer.class.getName(), Integer.class.getName(),
15366                                    OrderByComparator.class.getName()
15367                            });
15368            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
15369                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
15370                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_LtD_S",
15371                            new String[] {
15372                                    Long.class.getName(), Date.class.getName(),
15373                                    Integer.class.getName()
15374                            });
15375    
15376            /**
15377             * Returns all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
15378             *
15379             * @param companyId the company ID
15380             * @param displayDate the display date
15381             * @param status the status
15382             * @return the matching blogs entries
15383             */
15384            @Override
15385            public List<BlogsEntry> findByC_LtD_S(long companyId, Date displayDate,
15386                    int status) {
15387                    return findByC_LtD_S(companyId, displayDate, status, QueryUtil.ALL_POS,
15388                            QueryUtil.ALL_POS, null);
15389            }
15390    
15391            /**
15392             * Returns a range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
15393             *
15394             * <p>
15395             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
15396             * </p>
15397             *
15398             * @param companyId the company ID
15399             * @param displayDate the display date
15400             * @param status the status
15401             * @param start the lower bound of the range of blogs entries
15402             * @param end the upper bound of the range of blogs entries (not inclusive)
15403             * @return the range of matching blogs entries
15404             */
15405            @Override
15406            public List<BlogsEntry> findByC_LtD_S(long companyId, Date displayDate,
15407                    int status, int start, int end) {
15408                    return findByC_LtD_S(companyId, displayDate, status, start, end, null);
15409            }
15410    
15411            /**
15412             * Returns an ordered range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
15413             *
15414             * <p>
15415             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
15416             * </p>
15417             *
15418             * @param companyId the company ID
15419             * @param displayDate the display date
15420             * @param status the status
15421             * @param start the lower bound of the range of blogs entries
15422             * @param end the upper bound of the range of blogs entries (not inclusive)
15423             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
15424             * @return the ordered range of matching blogs entries
15425             */
15426            @Override
15427            public List<BlogsEntry> findByC_LtD_S(long companyId, Date displayDate,
15428                    int status, int start, int end,
15429                    OrderByComparator<BlogsEntry> orderByComparator) {
15430                    return findByC_LtD_S(companyId, displayDate, status, start, end,
15431                            orderByComparator, true);
15432            }
15433    
15434            /**
15435             * Returns an ordered range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
15436             *
15437             * <p>
15438             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
15439             * </p>
15440             *
15441             * @param companyId the company ID
15442             * @param displayDate the display date
15443             * @param status the status
15444             * @param start the lower bound of the range of blogs entries
15445             * @param end the upper bound of the range of blogs entries (not inclusive)
15446             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
15447             * @param retrieveFromCache whether to retrieve from the finder cache
15448             * @return the ordered range of matching blogs entries
15449             */
15450            @Override
15451            public List<BlogsEntry> findByC_LtD_S(long companyId, Date displayDate,
15452                    int status, int start, int end,
15453                    OrderByComparator<BlogsEntry> orderByComparator,
15454                    boolean retrieveFromCache) {
15455                    boolean pagination = true;
15456                    FinderPath finderPath = null;
15457                    Object[] finderArgs = null;
15458    
15459                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD_S;
15460                    finderArgs = new Object[] {
15461                                    companyId, displayDate, status,
15462                                    
15463                                    start, end, orderByComparator
15464                            };
15465    
15466                    List<BlogsEntry> list = null;
15467    
15468                    if (retrieveFromCache) {
15469                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
15470                                            finderArgs, this);
15471    
15472                            if ((list != null) && !list.isEmpty()) {
15473                                    for (BlogsEntry blogsEntry : list) {
15474                                            if ((companyId != blogsEntry.getCompanyId()) ||
15475                                                            (displayDate.getTime() <= blogsEntry.getDisplayDate()
15476                                                                                                                                            .getTime()) ||
15477                                                            (status != blogsEntry.getStatus())) {
15478                                                    list = null;
15479    
15480                                                    break;
15481                                            }
15482                                    }
15483                            }
15484                    }
15485    
15486                    if (list == null) {
15487                            StringBundler query = null;
15488    
15489                            if (orderByComparator != null) {
15490                                    query = new StringBundler(5 +
15491                                                    (orderByComparator.getOrderByFields().length * 2));
15492                            }
15493                            else {
15494                                    query = new StringBundler(5);
15495                            }
15496    
15497                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
15498    
15499                            query.append(_FINDER_COLUMN_C_LTD_S_COMPANYID_2);
15500    
15501                            boolean bindDisplayDate = false;
15502    
15503                            if (displayDate == null) {
15504                                    query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_1);
15505                            }
15506                            else {
15507                                    bindDisplayDate = true;
15508    
15509                                    query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_2);
15510                            }
15511    
15512                            query.append(_FINDER_COLUMN_C_LTD_S_STATUS_2);
15513    
15514                            if (orderByComparator != null) {
15515                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
15516                                            orderByComparator);
15517                            }
15518                            else
15519                             if (pagination) {
15520                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
15521                            }
15522    
15523                            String sql = query.toString();
15524    
15525                            Session session = null;
15526    
15527                            try {
15528                                    session = openSession();
15529    
15530                                    Query q = session.createQuery(sql);
15531    
15532                                    QueryPos qPos = QueryPos.getInstance(q);
15533    
15534                                    qPos.add(companyId);
15535    
15536                                    if (bindDisplayDate) {
15537                                            qPos.add(new Timestamp(displayDate.getTime()));
15538                                    }
15539    
15540                                    qPos.add(status);
15541    
15542                                    if (!pagination) {
15543                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
15544                                                            start, end, false);
15545    
15546                                            Collections.sort(list);
15547    
15548                                            list = Collections.unmodifiableList(list);
15549                                    }
15550                                    else {
15551                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
15552                                                            start, end);
15553                                    }
15554    
15555                                    cacheResult(list);
15556    
15557                                    finderCache.putResult(finderPath, finderArgs, list);
15558                            }
15559                            catch (Exception e) {
15560                                    finderCache.removeResult(finderPath, finderArgs);
15561    
15562                                    throw processException(e);
15563                            }
15564                            finally {
15565                                    closeSession(session);
15566                            }
15567                    }
15568    
15569                    return list;
15570            }
15571    
15572            /**
15573             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
15574             *
15575             * @param companyId the company ID
15576             * @param displayDate the display date
15577             * @param status the status
15578             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15579             * @return the first matching blogs entry
15580             * @throws NoSuchEntryException if a matching blogs entry could not be found
15581             */
15582            @Override
15583            public BlogsEntry findByC_LtD_S_First(long companyId, Date displayDate,
15584                    int status, OrderByComparator<BlogsEntry> orderByComparator)
15585                    throws NoSuchEntryException {
15586                    BlogsEntry blogsEntry = fetchByC_LtD_S_First(companyId, displayDate,
15587                                    status, orderByComparator);
15588    
15589                    if (blogsEntry != null) {
15590                            return blogsEntry;
15591                    }
15592    
15593                    StringBundler msg = new StringBundler(8);
15594    
15595                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15596    
15597                    msg.append("companyId=");
15598                    msg.append(companyId);
15599    
15600                    msg.append(", displayDate=");
15601                    msg.append(displayDate);
15602    
15603                    msg.append(", status=");
15604                    msg.append(status);
15605    
15606                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15607    
15608                    throw new NoSuchEntryException(msg.toString());
15609            }
15610    
15611            /**
15612             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
15613             *
15614             * @param companyId the company ID
15615             * @param displayDate the display date
15616             * @param status the status
15617             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15618             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
15619             */
15620            @Override
15621            public BlogsEntry fetchByC_LtD_S_First(long companyId, Date displayDate,
15622                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
15623                    List<BlogsEntry> list = findByC_LtD_S(companyId, displayDate, status,
15624                                    0, 1, orderByComparator);
15625    
15626                    if (!list.isEmpty()) {
15627                            return list.get(0);
15628                    }
15629    
15630                    return null;
15631            }
15632    
15633            /**
15634             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
15635             *
15636             * @param companyId the company ID
15637             * @param displayDate the display date
15638             * @param status the status
15639             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15640             * @return the last matching blogs entry
15641             * @throws NoSuchEntryException if a matching blogs entry could not be found
15642             */
15643            @Override
15644            public BlogsEntry findByC_LtD_S_Last(long companyId, Date displayDate,
15645                    int status, OrderByComparator<BlogsEntry> orderByComparator)
15646                    throws NoSuchEntryException {
15647                    BlogsEntry blogsEntry = fetchByC_LtD_S_Last(companyId, displayDate,
15648                                    status, orderByComparator);
15649    
15650                    if (blogsEntry != null) {
15651                            return blogsEntry;
15652                    }
15653    
15654                    StringBundler msg = new StringBundler(8);
15655    
15656                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15657    
15658                    msg.append("companyId=");
15659                    msg.append(companyId);
15660    
15661                    msg.append(", displayDate=");
15662                    msg.append(displayDate);
15663    
15664                    msg.append(", status=");
15665                    msg.append(status);
15666    
15667                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15668    
15669                    throw new NoSuchEntryException(msg.toString());
15670            }
15671    
15672            /**
15673             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
15674             *
15675             * @param companyId the company ID
15676             * @param displayDate the display date
15677             * @param status the status
15678             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15679             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
15680             */
15681            @Override
15682            public BlogsEntry fetchByC_LtD_S_Last(long companyId, Date displayDate,
15683                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
15684                    int count = countByC_LtD_S(companyId, displayDate, status);
15685    
15686                    if (count == 0) {
15687                            return null;
15688                    }
15689    
15690                    List<BlogsEntry> list = findByC_LtD_S(companyId, displayDate, status,
15691                                    count - 1, count, orderByComparator);
15692    
15693                    if (!list.isEmpty()) {
15694                            return list.get(0);
15695                    }
15696    
15697                    return null;
15698            }
15699    
15700            /**
15701             * 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;.
15702             *
15703             * @param entryId the primary key of the current blogs entry
15704             * @param companyId the company ID
15705             * @param displayDate the display date
15706             * @param status the status
15707             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15708             * @return the previous, current, and next blogs entry
15709             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
15710             */
15711            @Override
15712            public BlogsEntry[] findByC_LtD_S_PrevAndNext(long entryId, long companyId,
15713                    Date displayDate, int status,
15714                    OrderByComparator<BlogsEntry> orderByComparator)
15715                    throws NoSuchEntryException {
15716                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
15717    
15718                    Session session = null;
15719    
15720                    try {
15721                            session = openSession();
15722    
15723                            BlogsEntry[] array = new BlogsEntryImpl[3];
15724    
15725                            array[0] = getByC_LtD_S_PrevAndNext(session, blogsEntry, companyId,
15726                                            displayDate, status, orderByComparator, true);
15727    
15728                            array[1] = blogsEntry;
15729    
15730                            array[2] = getByC_LtD_S_PrevAndNext(session, blogsEntry, companyId,
15731                                            displayDate, status, orderByComparator, false);
15732    
15733                            return array;
15734                    }
15735                    catch (Exception e) {
15736                            throw processException(e);
15737                    }
15738                    finally {
15739                            closeSession(session);
15740                    }
15741            }
15742    
15743            protected BlogsEntry getByC_LtD_S_PrevAndNext(Session session,
15744                    BlogsEntry blogsEntry, long companyId, Date displayDate, int status,
15745                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
15746                    StringBundler query = null;
15747    
15748                    if (orderByComparator != null) {
15749                            query = new StringBundler(6 +
15750                                            (orderByComparator.getOrderByConditionFields().length * 3) +
15751                                            (orderByComparator.getOrderByFields().length * 3));
15752                    }
15753                    else {
15754                            query = new StringBundler(5);
15755                    }
15756    
15757                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
15758    
15759                    query.append(_FINDER_COLUMN_C_LTD_S_COMPANYID_2);
15760    
15761                    boolean bindDisplayDate = false;
15762    
15763                    if (displayDate == null) {
15764                            query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_1);
15765                    }
15766                    else {
15767                            bindDisplayDate = true;
15768    
15769                            query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_2);
15770                    }
15771    
15772                    query.append(_FINDER_COLUMN_C_LTD_S_STATUS_2);
15773    
15774                    if (orderByComparator != null) {
15775                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
15776    
15777                            if (orderByConditionFields.length > 0) {
15778                                    query.append(WHERE_AND);
15779                            }
15780    
15781                            for (int i = 0; i < orderByConditionFields.length; i++) {
15782                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15783                                    query.append(orderByConditionFields[i]);
15784    
15785                                    if ((i + 1) < orderByConditionFields.length) {
15786                                            if (orderByComparator.isAscending() ^ previous) {
15787                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
15788                                            }
15789                                            else {
15790                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
15791                                            }
15792                                    }
15793                                    else {
15794                                            if (orderByComparator.isAscending() ^ previous) {
15795                                                    query.append(WHERE_GREATER_THAN);
15796                                            }
15797                                            else {
15798                                                    query.append(WHERE_LESSER_THAN);
15799                                            }
15800                                    }
15801                            }
15802    
15803                            query.append(ORDER_BY_CLAUSE);
15804    
15805                            String[] orderByFields = orderByComparator.getOrderByFields();
15806    
15807                            for (int i = 0; i < orderByFields.length; i++) {
15808                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15809                                    query.append(orderByFields[i]);
15810    
15811                                    if ((i + 1) < orderByFields.length) {
15812                                            if (orderByComparator.isAscending() ^ previous) {
15813                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
15814                                            }
15815                                            else {
15816                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
15817                                            }
15818                                    }
15819                                    else {
15820                                            if (orderByComparator.isAscending() ^ previous) {
15821                                                    query.append(ORDER_BY_ASC);
15822                                            }
15823                                            else {
15824                                                    query.append(ORDER_BY_DESC);
15825                                            }
15826                                    }
15827                            }
15828                    }
15829                    else {
15830                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
15831                    }
15832    
15833                    String sql = query.toString();
15834    
15835                    Query q = session.createQuery(sql);
15836    
15837                    q.setFirstResult(0);
15838                    q.setMaxResults(2);
15839    
15840                    QueryPos qPos = QueryPos.getInstance(q);
15841    
15842                    qPos.add(companyId);
15843    
15844                    if (bindDisplayDate) {
15845                            qPos.add(new Timestamp(displayDate.getTime()));
15846                    }
15847    
15848                    qPos.add(status);
15849    
15850                    if (orderByComparator != null) {
15851                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
15852    
15853                            for (Object value : values) {
15854                                    qPos.add(value);
15855                            }
15856                    }
15857    
15858                    List<BlogsEntry> list = q.list();
15859    
15860                    if (list.size() == 2) {
15861                            return list.get(1);
15862                    }
15863                    else {
15864                            return null;
15865                    }
15866            }
15867    
15868            /**
15869             * Removes all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63; from the database.
15870             *
15871             * @param companyId the company ID
15872             * @param displayDate the display date
15873             * @param status the status
15874             */
15875            @Override
15876            public void removeByC_LtD_S(long companyId, Date displayDate, int status) {
15877                    for (BlogsEntry blogsEntry : findByC_LtD_S(companyId, displayDate,
15878                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
15879                            remove(blogsEntry);
15880                    }
15881            }
15882    
15883            /**
15884             * Returns the number of blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
15885             *
15886             * @param companyId the company ID
15887             * @param displayDate the display date
15888             * @param status the status
15889             * @return the number of matching blogs entries
15890             */
15891            @Override
15892            public int countByC_LtD_S(long companyId, Date displayDate, int status) {
15893                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD_S;
15894    
15895                    Object[] finderArgs = new Object[] { companyId, displayDate, status };
15896    
15897                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
15898    
15899                    if (count == null) {
15900                            StringBundler query = new StringBundler(4);
15901    
15902                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
15903    
15904                            query.append(_FINDER_COLUMN_C_LTD_S_COMPANYID_2);
15905    
15906                            boolean bindDisplayDate = false;
15907    
15908                            if (displayDate == null) {
15909                                    query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_1);
15910                            }
15911                            else {
15912                                    bindDisplayDate = true;
15913    
15914                                    query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_2);
15915                            }
15916    
15917                            query.append(_FINDER_COLUMN_C_LTD_S_STATUS_2);
15918    
15919                            String sql = query.toString();
15920    
15921                            Session session = null;
15922    
15923                            try {
15924                                    session = openSession();
15925    
15926                                    Query q = session.createQuery(sql);
15927    
15928                                    QueryPos qPos = QueryPos.getInstance(q);
15929    
15930                                    qPos.add(companyId);
15931    
15932                                    if (bindDisplayDate) {
15933                                            qPos.add(new Timestamp(displayDate.getTime()));
15934                                    }
15935    
15936                                    qPos.add(status);
15937    
15938                                    count = (Long)q.uniqueResult();
15939    
15940                                    finderCache.putResult(finderPath, finderArgs, count);
15941                            }
15942                            catch (Exception e) {
15943                                    finderCache.removeResult(finderPath, finderArgs);
15944    
15945                                    throw processException(e);
15946                            }
15947                            finally {
15948                                    closeSession(session);
15949                            }
15950                    }
15951    
15952                    return count.intValue();
15953            }
15954    
15955            private static final String _FINDER_COLUMN_C_LTD_S_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
15956            private static final String _FINDER_COLUMN_C_LTD_S_DISPLAYDATE_1 = "blogsEntry.displayDate IS NULL AND ";
15957            private static final String _FINDER_COLUMN_C_LTD_S_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
15958            private static final String _FINDER_COLUMN_C_LTD_S_STATUS_2 = "blogsEntry.status = ?";
15959            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD_NOTS =
15960                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
15961                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
15962                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_LtD_NotS",
15963                            new String[] {
15964                                    Long.class.getName(), Date.class.getName(),
15965                                    Integer.class.getName(),
15966                                    
15967                            Integer.class.getName(), Integer.class.getName(),
15968                                    OrderByComparator.class.getName()
15969                            });
15970            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD_NOTS =
15971                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
15972                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
15973                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_LtD_NotS",
15974                            new String[] {
15975                                    Long.class.getName(), Date.class.getName(),
15976                                    Integer.class.getName()
15977                            });
15978    
15979            /**
15980             * Returns all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
15981             *
15982             * @param companyId the company ID
15983             * @param displayDate the display date
15984             * @param status the status
15985             * @return the matching blogs entries
15986             */
15987            @Override
15988            public List<BlogsEntry> findByC_LtD_NotS(long companyId, Date displayDate,
15989                    int status) {
15990                    return findByC_LtD_NotS(companyId, displayDate, status,
15991                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
15992            }
15993    
15994            /**
15995             * Returns a range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
15996             *
15997             * <p>
15998             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
15999             * </p>
16000             *
16001             * @param companyId the company ID
16002             * @param displayDate the display date
16003             * @param status the status
16004             * @param start the lower bound of the range of blogs entries
16005             * @param end the upper bound of the range of blogs entries (not inclusive)
16006             * @return the range of matching blogs entries
16007             */
16008            @Override
16009            public List<BlogsEntry> findByC_LtD_NotS(long companyId, Date displayDate,
16010                    int status, int start, int end) {
16011                    return findByC_LtD_NotS(companyId, displayDate, status, start, end, null);
16012            }
16013    
16014            /**
16015             * Returns an ordered range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
16016             *
16017             * <p>
16018             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
16019             * </p>
16020             *
16021             * @param companyId the company ID
16022             * @param displayDate the display date
16023             * @param status the status
16024             * @param start the lower bound of the range of blogs entries
16025             * @param end the upper bound of the range of blogs entries (not inclusive)
16026             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
16027             * @return the ordered range of matching blogs entries
16028             */
16029            @Override
16030            public List<BlogsEntry> findByC_LtD_NotS(long companyId, Date displayDate,
16031                    int status, int start, int end,
16032                    OrderByComparator<BlogsEntry> orderByComparator) {
16033                    return findByC_LtD_NotS(companyId, displayDate, status, start, end,
16034                            orderByComparator, true);
16035            }
16036    
16037            /**
16038             * Returns an ordered range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
16039             *
16040             * <p>
16041             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
16042             * </p>
16043             *
16044             * @param companyId the company ID
16045             * @param displayDate the display date
16046             * @param status the status
16047             * @param start the lower bound of the range of blogs entries
16048             * @param end the upper bound of the range of blogs entries (not inclusive)
16049             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
16050             * @param retrieveFromCache whether to retrieve from the finder cache
16051             * @return the ordered range of matching blogs entries
16052             */
16053            @Override
16054            public List<BlogsEntry> findByC_LtD_NotS(long companyId, Date displayDate,
16055                    int status, int start, int end,
16056                    OrderByComparator<BlogsEntry> orderByComparator,
16057                    boolean retrieveFromCache) {
16058                    boolean pagination = true;
16059                    FinderPath finderPath = null;
16060                    Object[] finderArgs = null;
16061    
16062                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD_NOTS;
16063                    finderArgs = new Object[] {
16064                                    companyId, displayDate, status,
16065                                    
16066                                    start, end, orderByComparator
16067                            };
16068    
16069                    List<BlogsEntry> list = null;
16070    
16071                    if (retrieveFromCache) {
16072                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
16073                                            finderArgs, this);
16074    
16075                            if ((list != null) && !list.isEmpty()) {
16076                                    for (BlogsEntry blogsEntry : list) {
16077                                            if ((companyId != blogsEntry.getCompanyId()) ||
16078                                                            (displayDate.getTime() <= blogsEntry.getDisplayDate()
16079                                                                                                                                            .getTime()) ||
16080                                                            (status == blogsEntry.getStatus())) {
16081                                                    list = null;
16082    
16083                                                    break;
16084                                            }
16085                                    }
16086                            }
16087                    }
16088    
16089                    if (list == null) {
16090                            StringBundler query = null;
16091    
16092                            if (orderByComparator != null) {
16093                                    query = new StringBundler(5 +
16094                                                    (orderByComparator.getOrderByFields().length * 2));
16095                            }
16096                            else {
16097                                    query = new StringBundler(5);
16098                            }
16099    
16100                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
16101    
16102                            query.append(_FINDER_COLUMN_C_LTD_NOTS_COMPANYID_2);
16103    
16104                            boolean bindDisplayDate = false;
16105    
16106                            if (displayDate == null) {
16107                                    query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_1);
16108                            }
16109                            else {
16110                                    bindDisplayDate = true;
16111    
16112                                    query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_2);
16113                            }
16114    
16115                            query.append(_FINDER_COLUMN_C_LTD_NOTS_STATUS_2);
16116    
16117                            if (orderByComparator != null) {
16118                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
16119                                            orderByComparator);
16120                            }
16121                            else
16122                             if (pagination) {
16123                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
16124                            }
16125    
16126                            String sql = query.toString();
16127    
16128                            Session session = null;
16129    
16130                            try {
16131                                    session = openSession();
16132    
16133                                    Query q = session.createQuery(sql);
16134    
16135                                    QueryPos qPos = QueryPos.getInstance(q);
16136    
16137                                    qPos.add(companyId);
16138    
16139                                    if (bindDisplayDate) {
16140                                            qPos.add(new Timestamp(displayDate.getTime()));
16141                                    }
16142    
16143                                    qPos.add(status);
16144    
16145                                    if (!pagination) {
16146                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
16147                                                            start, end, false);
16148    
16149                                            Collections.sort(list);
16150    
16151                                            list = Collections.unmodifiableList(list);
16152                                    }
16153                                    else {
16154                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
16155                                                            start, end);
16156                                    }
16157    
16158                                    cacheResult(list);
16159    
16160                                    finderCache.putResult(finderPath, finderArgs, list);
16161                            }
16162                            catch (Exception e) {
16163                                    finderCache.removeResult(finderPath, finderArgs);
16164    
16165                                    throw processException(e);
16166                            }
16167                            finally {
16168                                    closeSession(session);
16169                            }
16170                    }
16171    
16172                    return list;
16173            }
16174    
16175            /**
16176             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
16177             *
16178             * @param companyId the company ID
16179             * @param displayDate the display date
16180             * @param status the status
16181             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16182             * @return the first matching blogs entry
16183             * @throws NoSuchEntryException if a matching blogs entry could not be found
16184             */
16185            @Override
16186            public BlogsEntry findByC_LtD_NotS_First(long companyId, Date displayDate,
16187                    int status, OrderByComparator<BlogsEntry> orderByComparator)
16188                    throws NoSuchEntryException {
16189                    BlogsEntry blogsEntry = fetchByC_LtD_NotS_First(companyId, displayDate,
16190                                    status, orderByComparator);
16191    
16192                    if (blogsEntry != null) {
16193                            return blogsEntry;
16194                    }
16195    
16196                    StringBundler msg = new StringBundler(8);
16197    
16198                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
16199    
16200                    msg.append("companyId=");
16201                    msg.append(companyId);
16202    
16203                    msg.append(", displayDate=");
16204                    msg.append(displayDate);
16205    
16206                    msg.append(", status=");
16207                    msg.append(status);
16208    
16209                    msg.append(StringPool.CLOSE_CURLY_BRACE);
16210    
16211                    throw new NoSuchEntryException(msg.toString());
16212            }
16213    
16214            /**
16215             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
16216             *
16217             * @param companyId the company ID
16218             * @param displayDate the display date
16219             * @param status the status
16220             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16221             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
16222             */
16223            @Override
16224            public BlogsEntry fetchByC_LtD_NotS_First(long companyId, Date displayDate,
16225                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
16226                    List<BlogsEntry> list = findByC_LtD_NotS(companyId, displayDate,
16227                                    status, 0, 1, orderByComparator);
16228    
16229                    if (!list.isEmpty()) {
16230                            return list.get(0);
16231                    }
16232    
16233                    return null;
16234            }
16235    
16236            /**
16237             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
16238             *
16239             * @param companyId the company ID
16240             * @param displayDate the display date
16241             * @param status the status
16242             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16243             * @return the last matching blogs entry
16244             * @throws NoSuchEntryException if a matching blogs entry could not be found
16245             */
16246            @Override
16247            public BlogsEntry findByC_LtD_NotS_Last(long companyId, Date displayDate,
16248                    int status, OrderByComparator<BlogsEntry> orderByComparator)
16249                    throws NoSuchEntryException {
16250                    BlogsEntry blogsEntry = fetchByC_LtD_NotS_Last(companyId, displayDate,
16251                                    status, orderByComparator);
16252    
16253                    if (blogsEntry != null) {
16254                            return blogsEntry;
16255                    }
16256    
16257                    StringBundler msg = new StringBundler(8);
16258    
16259                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
16260    
16261                    msg.append("companyId=");
16262                    msg.append(companyId);
16263    
16264                    msg.append(", displayDate=");
16265                    msg.append(displayDate);
16266    
16267                    msg.append(", status=");
16268                    msg.append(status);
16269    
16270                    msg.append(StringPool.CLOSE_CURLY_BRACE);
16271    
16272                    throw new NoSuchEntryException(msg.toString());
16273            }
16274    
16275            /**
16276             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
16277             *
16278             * @param companyId the company ID
16279             * @param displayDate the display date
16280             * @param status the status
16281             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16282             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
16283             */
16284            @Override
16285            public BlogsEntry fetchByC_LtD_NotS_Last(long companyId, Date displayDate,
16286                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
16287                    int count = countByC_LtD_NotS(companyId, displayDate, status);
16288    
16289                    if (count == 0) {
16290                            return null;
16291                    }
16292    
16293                    List<BlogsEntry> list = findByC_LtD_NotS(companyId, displayDate,
16294                                    status, count - 1, count, orderByComparator);
16295    
16296                    if (!list.isEmpty()) {
16297                            return list.get(0);
16298                    }
16299    
16300                    return null;
16301            }
16302    
16303            /**
16304             * 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;.
16305             *
16306             * @param entryId the primary key of the current blogs entry
16307             * @param companyId the company ID
16308             * @param displayDate the display date
16309             * @param status the status
16310             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16311             * @return the previous, current, and next blogs entry
16312             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
16313             */
16314            @Override
16315            public BlogsEntry[] findByC_LtD_NotS_PrevAndNext(long entryId,
16316                    long companyId, Date displayDate, int status,
16317                    OrderByComparator<BlogsEntry> orderByComparator)
16318                    throws NoSuchEntryException {
16319                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
16320    
16321                    Session session = null;
16322    
16323                    try {
16324                            session = openSession();
16325    
16326                            BlogsEntry[] array = new BlogsEntryImpl[3];
16327    
16328                            array[0] = getByC_LtD_NotS_PrevAndNext(session, blogsEntry,
16329                                            companyId, displayDate, status, orderByComparator, true);
16330    
16331                            array[1] = blogsEntry;
16332    
16333                            array[2] = getByC_LtD_NotS_PrevAndNext(session, blogsEntry,
16334                                            companyId, displayDate, status, orderByComparator, false);
16335    
16336                            return array;
16337                    }
16338                    catch (Exception e) {
16339                            throw processException(e);
16340                    }
16341                    finally {
16342                            closeSession(session);
16343                    }
16344            }
16345    
16346            protected BlogsEntry getByC_LtD_NotS_PrevAndNext(Session session,
16347                    BlogsEntry blogsEntry, long companyId, Date displayDate, int status,
16348                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
16349                    StringBundler query = null;
16350    
16351                    if (orderByComparator != null) {
16352                            query = new StringBundler(6 +
16353                                            (orderByComparator.getOrderByConditionFields().length * 3) +
16354                                            (orderByComparator.getOrderByFields().length * 3));
16355                    }
16356                    else {
16357                            query = new StringBundler(5);
16358                    }
16359    
16360                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
16361    
16362                    query.append(_FINDER_COLUMN_C_LTD_NOTS_COMPANYID_2);
16363    
16364                    boolean bindDisplayDate = false;
16365    
16366                    if (displayDate == null) {
16367                            query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_1);
16368                    }
16369                    else {
16370                            bindDisplayDate = true;
16371    
16372                            query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_2);
16373                    }
16374    
16375                    query.append(_FINDER_COLUMN_C_LTD_NOTS_STATUS_2);
16376    
16377                    if (orderByComparator != null) {
16378                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
16379    
16380                            if (orderByConditionFields.length > 0) {
16381                                    query.append(WHERE_AND);
16382                            }
16383    
16384                            for (int i = 0; i < orderByConditionFields.length; i++) {
16385                                    query.append(_ORDER_BY_ENTITY_ALIAS);
16386                                    query.append(orderByConditionFields[i]);
16387    
16388                                    if ((i + 1) < orderByConditionFields.length) {
16389                                            if (orderByComparator.isAscending() ^ previous) {
16390                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
16391                                            }
16392                                            else {
16393                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
16394                                            }
16395                                    }
16396                                    else {
16397                                            if (orderByComparator.isAscending() ^ previous) {
16398                                                    query.append(WHERE_GREATER_THAN);
16399                                            }
16400                                            else {
16401                                                    query.append(WHERE_LESSER_THAN);
16402                                            }
16403                                    }
16404                            }
16405    
16406                            query.append(ORDER_BY_CLAUSE);
16407    
16408                            String[] orderByFields = orderByComparator.getOrderByFields();
16409    
16410                            for (int i = 0; i < orderByFields.length; i++) {
16411                                    query.append(_ORDER_BY_ENTITY_ALIAS);
16412                                    query.append(orderByFields[i]);
16413    
16414                                    if ((i + 1) < orderByFields.length) {
16415                                            if (orderByComparator.isAscending() ^ previous) {
16416                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
16417                                            }
16418                                            else {
16419                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
16420                                            }
16421                                    }
16422                                    else {
16423                                            if (orderByComparator.isAscending() ^ previous) {
16424                                                    query.append(ORDER_BY_ASC);
16425                                            }
16426                                            else {
16427                                                    query.append(ORDER_BY_DESC);
16428                                            }
16429                                    }
16430                            }
16431                    }
16432                    else {
16433                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
16434                    }
16435    
16436                    String sql = query.toString();
16437    
16438                    Query q = session.createQuery(sql);
16439    
16440                    q.setFirstResult(0);
16441                    q.setMaxResults(2);
16442    
16443                    QueryPos qPos = QueryPos.getInstance(q);
16444    
16445                    qPos.add(companyId);
16446    
16447                    if (bindDisplayDate) {
16448                            qPos.add(new Timestamp(displayDate.getTime()));
16449                    }
16450    
16451                    qPos.add(status);
16452    
16453                    if (orderByComparator != null) {
16454                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
16455    
16456                            for (Object value : values) {
16457                                    qPos.add(value);
16458                            }
16459                    }
16460    
16461                    List<BlogsEntry> list = q.list();
16462    
16463                    if (list.size() == 2) {
16464                            return list.get(1);
16465                    }
16466                    else {
16467                            return null;
16468                    }
16469            }
16470    
16471            /**
16472             * Removes all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63; from the database.
16473             *
16474             * @param companyId the company ID
16475             * @param displayDate the display date
16476             * @param status the status
16477             */
16478            @Override
16479            public void removeByC_LtD_NotS(long companyId, Date displayDate, int status) {
16480                    for (BlogsEntry blogsEntry : findByC_LtD_NotS(companyId, displayDate,
16481                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
16482                            remove(blogsEntry);
16483                    }
16484            }
16485    
16486            /**
16487             * Returns the number of blogs entries where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
16488             *
16489             * @param companyId the company ID
16490             * @param displayDate the display date
16491             * @param status the status
16492             * @return the number of matching blogs entries
16493             */
16494            @Override
16495            public int countByC_LtD_NotS(long companyId, Date displayDate, int status) {
16496                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD_NOTS;
16497    
16498                    Object[] finderArgs = new Object[] { companyId, displayDate, status };
16499    
16500                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
16501    
16502                    if (count == null) {
16503                            StringBundler query = new StringBundler(4);
16504    
16505                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
16506    
16507                            query.append(_FINDER_COLUMN_C_LTD_NOTS_COMPANYID_2);
16508    
16509                            boolean bindDisplayDate = false;
16510    
16511                            if (displayDate == null) {
16512                                    query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_1);
16513                            }
16514                            else {
16515                                    bindDisplayDate = true;
16516    
16517                                    query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_2);
16518                            }
16519    
16520                            query.append(_FINDER_COLUMN_C_LTD_NOTS_STATUS_2);
16521    
16522                            String sql = query.toString();
16523    
16524                            Session session = null;
16525    
16526                            try {
16527                                    session = openSession();
16528    
16529                                    Query q = session.createQuery(sql);
16530    
16531                                    QueryPos qPos = QueryPos.getInstance(q);
16532    
16533                                    qPos.add(companyId);
16534    
16535                                    if (bindDisplayDate) {
16536                                            qPos.add(new Timestamp(displayDate.getTime()));
16537                                    }
16538    
16539                                    qPos.add(status);
16540    
16541                                    count = (Long)q.uniqueResult();
16542    
16543                                    finderCache.putResult(finderPath, finderArgs, count);
16544                            }
16545                            catch (Exception e) {
16546                                    finderCache.removeResult(finderPath, finderArgs);
16547    
16548                                    throw processException(e);
16549                            }
16550                            finally {
16551                                    closeSession(session);
16552                            }
16553                    }
16554    
16555                    return count.intValue();
16556            }
16557    
16558            private static final String _FINDER_COLUMN_C_LTD_NOTS_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
16559            private static final String _FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_1 = "blogsEntry.displayDate IS NULL AND ";
16560            private static final String _FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
16561            private static final String _FINDER_COLUMN_C_LTD_NOTS_STATUS_2 = "blogsEntry.status != ?";
16562            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD_S =
16563                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
16564                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
16565                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_LtD_S",
16566                            new String[] {
16567                                    Long.class.getName(), Long.class.getName(), Date.class.getName(),
16568                                    Integer.class.getName(),
16569                                    
16570                            Integer.class.getName(), Integer.class.getName(),
16571                                    OrderByComparator.class.getName()
16572                            });
16573            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD_S =
16574                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
16575                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
16576                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_U_LtD_S",
16577                            new String[] {
16578                                    Long.class.getName(), Long.class.getName(), Date.class.getName(),
16579                                    Integer.class.getName()
16580                            });
16581    
16582            /**
16583             * Returns all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16584             *
16585             * @param groupId the group ID
16586             * @param userId the user ID
16587             * @param displayDate the display date
16588             * @param status the status
16589             * @return the matching blogs entries
16590             */
16591            @Override
16592            public List<BlogsEntry> findByG_U_LtD_S(long groupId, long userId,
16593                    Date displayDate, int status) {
16594                    return findByG_U_LtD_S(groupId, userId, displayDate, status,
16595                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
16596            }
16597    
16598            /**
16599             * Returns a range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16600             *
16601             * <p>
16602             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
16603             * </p>
16604             *
16605             * @param groupId the group ID
16606             * @param userId the user ID
16607             * @param displayDate the display date
16608             * @param status the status
16609             * @param start the lower bound of the range of blogs entries
16610             * @param end the upper bound of the range of blogs entries (not inclusive)
16611             * @return the range of matching blogs entries
16612             */
16613            @Override
16614            public List<BlogsEntry> findByG_U_LtD_S(long groupId, long userId,
16615                    Date displayDate, int status, int start, int end) {
16616                    return findByG_U_LtD_S(groupId, userId, displayDate, status, start,
16617                            end, null);
16618            }
16619    
16620            /**
16621             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16622             *
16623             * <p>
16624             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
16625             * </p>
16626             *
16627             * @param groupId the group ID
16628             * @param userId the user ID
16629             * @param displayDate the display date
16630             * @param status the status
16631             * @param start the lower bound of the range of blogs entries
16632             * @param end the upper bound of the range of blogs entries (not inclusive)
16633             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
16634             * @return the ordered range of matching blogs entries
16635             */
16636            @Override
16637            public List<BlogsEntry> findByG_U_LtD_S(long groupId, long userId,
16638                    Date displayDate, int status, int start, int end,
16639                    OrderByComparator<BlogsEntry> orderByComparator) {
16640                    return findByG_U_LtD_S(groupId, userId, displayDate, status, start,
16641                            end, orderByComparator, true);
16642            }
16643    
16644            /**
16645             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16646             *
16647             * <p>
16648             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
16649             * </p>
16650             *
16651             * @param groupId the group ID
16652             * @param userId the user ID
16653             * @param displayDate the display date
16654             * @param status the status
16655             * @param start the lower bound of the range of blogs entries
16656             * @param end the upper bound of the range of blogs entries (not inclusive)
16657             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
16658             * @param retrieveFromCache whether to retrieve from the finder cache
16659             * @return the ordered range of matching blogs entries
16660             */
16661            @Override
16662            public List<BlogsEntry> findByG_U_LtD_S(long groupId, long userId,
16663                    Date displayDate, int status, int start, int end,
16664                    OrderByComparator<BlogsEntry> orderByComparator,
16665                    boolean retrieveFromCache) {
16666                    boolean pagination = true;
16667                    FinderPath finderPath = null;
16668                    Object[] finderArgs = null;
16669    
16670                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD_S;
16671                    finderArgs = new Object[] {
16672                                    groupId, userId, displayDate, status,
16673                                    
16674                                    start, end, orderByComparator
16675                            };
16676    
16677                    List<BlogsEntry> list = null;
16678    
16679                    if (retrieveFromCache) {
16680                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
16681                                            finderArgs, this);
16682    
16683                            if ((list != null) && !list.isEmpty()) {
16684                                    for (BlogsEntry blogsEntry : list) {
16685                                            if ((groupId != blogsEntry.getGroupId()) ||
16686                                                            (userId != blogsEntry.getUserId()) ||
16687                                                            (displayDate.getTime() <= blogsEntry.getDisplayDate()
16688                                                                                                                                            .getTime()) ||
16689                                                            (status != blogsEntry.getStatus())) {
16690                                                    list = null;
16691    
16692                                                    break;
16693                                            }
16694                                    }
16695                            }
16696                    }
16697    
16698                    if (list == null) {
16699                            StringBundler query = null;
16700    
16701                            if (orderByComparator != null) {
16702                                    query = new StringBundler(6 +
16703                                                    (orderByComparator.getOrderByFields().length * 2));
16704                            }
16705                            else {
16706                                    query = new StringBundler(6);
16707                            }
16708    
16709                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
16710    
16711                            query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
16712    
16713                            query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
16714    
16715                            boolean bindDisplayDate = false;
16716    
16717                            if (displayDate == null) {
16718                                    query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
16719                            }
16720                            else {
16721                                    bindDisplayDate = true;
16722    
16723                                    query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
16724                            }
16725    
16726                            query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
16727    
16728                            if (orderByComparator != null) {
16729                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
16730                                            orderByComparator);
16731                            }
16732                            else
16733                             if (pagination) {
16734                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
16735                            }
16736    
16737                            String sql = query.toString();
16738    
16739                            Session session = null;
16740    
16741                            try {
16742                                    session = openSession();
16743    
16744                                    Query q = session.createQuery(sql);
16745    
16746                                    QueryPos qPos = QueryPos.getInstance(q);
16747    
16748                                    qPos.add(groupId);
16749    
16750                                    qPos.add(userId);
16751    
16752                                    if (bindDisplayDate) {
16753                                            qPos.add(new Timestamp(displayDate.getTime()));
16754                                    }
16755    
16756                                    qPos.add(status);
16757    
16758                                    if (!pagination) {
16759                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
16760                                                            start, end, false);
16761    
16762                                            Collections.sort(list);
16763    
16764                                            list = Collections.unmodifiableList(list);
16765                                    }
16766                                    else {
16767                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
16768                                                            start, end);
16769                                    }
16770    
16771                                    cacheResult(list);
16772    
16773                                    finderCache.putResult(finderPath, finderArgs, list);
16774                            }
16775                            catch (Exception e) {
16776                                    finderCache.removeResult(finderPath, finderArgs);
16777    
16778                                    throw processException(e);
16779                            }
16780                            finally {
16781                                    closeSession(session);
16782                            }
16783                    }
16784    
16785                    return list;
16786            }
16787    
16788            /**
16789             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16790             *
16791             * @param groupId the group ID
16792             * @param userId the user ID
16793             * @param displayDate the display date
16794             * @param status the status
16795             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16796             * @return the first matching blogs entry
16797             * @throws NoSuchEntryException if a matching blogs entry could not be found
16798             */
16799            @Override
16800            public BlogsEntry findByG_U_LtD_S_First(long groupId, long userId,
16801                    Date displayDate, int status,
16802                    OrderByComparator<BlogsEntry> orderByComparator)
16803                    throws NoSuchEntryException {
16804                    BlogsEntry blogsEntry = fetchByG_U_LtD_S_First(groupId, userId,
16805                                    displayDate, status, orderByComparator);
16806    
16807                    if (blogsEntry != null) {
16808                            return blogsEntry;
16809                    }
16810    
16811                    StringBundler msg = new StringBundler(10);
16812    
16813                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
16814    
16815                    msg.append("groupId=");
16816                    msg.append(groupId);
16817    
16818                    msg.append(", userId=");
16819                    msg.append(userId);
16820    
16821                    msg.append(", displayDate=");
16822                    msg.append(displayDate);
16823    
16824                    msg.append(", status=");
16825                    msg.append(status);
16826    
16827                    msg.append(StringPool.CLOSE_CURLY_BRACE);
16828    
16829                    throw new NoSuchEntryException(msg.toString());
16830            }
16831    
16832            /**
16833             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16834             *
16835             * @param groupId the group ID
16836             * @param userId the user ID
16837             * @param displayDate the display date
16838             * @param status the status
16839             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16840             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
16841             */
16842            @Override
16843            public BlogsEntry fetchByG_U_LtD_S_First(long groupId, long userId,
16844                    Date displayDate, int status,
16845                    OrderByComparator<BlogsEntry> orderByComparator) {
16846                    List<BlogsEntry> list = findByG_U_LtD_S(groupId, userId, displayDate,
16847                                    status, 0, 1, orderByComparator);
16848    
16849                    if (!list.isEmpty()) {
16850                            return list.get(0);
16851                    }
16852    
16853                    return null;
16854            }
16855    
16856            /**
16857             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16858             *
16859             * @param groupId the group ID
16860             * @param userId the user ID
16861             * @param displayDate the display date
16862             * @param status the status
16863             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16864             * @return the last matching blogs entry
16865             * @throws NoSuchEntryException if a matching blogs entry could not be found
16866             */
16867            @Override
16868            public BlogsEntry findByG_U_LtD_S_Last(long groupId, long userId,
16869                    Date displayDate, int status,
16870                    OrderByComparator<BlogsEntry> orderByComparator)
16871                    throws NoSuchEntryException {
16872                    BlogsEntry blogsEntry = fetchByG_U_LtD_S_Last(groupId, userId,
16873                                    displayDate, status, orderByComparator);
16874    
16875                    if (blogsEntry != null) {
16876                            return blogsEntry;
16877                    }
16878    
16879                    StringBundler msg = new StringBundler(10);
16880    
16881                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
16882    
16883                    msg.append("groupId=");
16884                    msg.append(groupId);
16885    
16886                    msg.append(", userId=");
16887                    msg.append(userId);
16888    
16889                    msg.append(", displayDate=");
16890                    msg.append(displayDate);
16891    
16892                    msg.append(", status=");
16893                    msg.append(status);
16894    
16895                    msg.append(StringPool.CLOSE_CURLY_BRACE);
16896    
16897                    throw new NoSuchEntryException(msg.toString());
16898            }
16899    
16900            /**
16901             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16902             *
16903             * @param groupId the group ID
16904             * @param userId the user ID
16905             * @param displayDate the display date
16906             * @param status the status
16907             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16908             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
16909             */
16910            @Override
16911            public BlogsEntry fetchByG_U_LtD_S_Last(long groupId, long userId,
16912                    Date displayDate, int status,
16913                    OrderByComparator<BlogsEntry> orderByComparator) {
16914                    int count = countByG_U_LtD_S(groupId, userId, displayDate, status);
16915    
16916                    if (count == 0) {
16917                            return null;
16918                    }
16919    
16920                    List<BlogsEntry> list = findByG_U_LtD_S(groupId, userId, displayDate,
16921                                    status, count - 1, count, orderByComparator);
16922    
16923                    if (!list.isEmpty()) {
16924                            return list.get(0);
16925                    }
16926    
16927                    return null;
16928            }
16929    
16930            /**
16931             * 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;.
16932             *
16933             * @param entryId the primary key of the current blogs entry
16934             * @param groupId the group ID
16935             * @param userId the user ID
16936             * @param displayDate the display date
16937             * @param status the status
16938             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16939             * @return the previous, current, and next blogs entry
16940             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
16941             */
16942            @Override
16943            public BlogsEntry[] findByG_U_LtD_S_PrevAndNext(long entryId, long groupId,
16944                    long userId, Date displayDate, int status,
16945                    OrderByComparator<BlogsEntry> orderByComparator)
16946                    throws NoSuchEntryException {
16947                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
16948    
16949                    Session session = null;
16950    
16951                    try {
16952                            session = openSession();
16953    
16954                            BlogsEntry[] array = new BlogsEntryImpl[3];
16955    
16956                            array[0] = getByG_U_LtD_S_PrevAndNext(session, blogsEntry, groupId,
16957                                            userId, displayDate, status, orderByComparator, true);
16958    
16959                            array[1] = blogsEntry;
16960    
16961                            array[2] = getByG_U_LtD_S_PrevAndNext(session, blogsEntry, groupId,
16962                                            userId, displayDate, status, orderByComparator, false);
16963    
16964                            return array;
16965                    }
16966                    catch (Exception e) {
16967                            throw processException(e);
16968                    }
16969                    finally {
16970                            closeSession(session);
16971                    }
16972            }
16973    
16974            protected BlogsEntry getByG_U_LtD_S_PrevAndNext(Session session,
16975                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
16976                    int status, OrderByComparator<BlogsEntry> orderByComparator,
16977                    boolean previous) {
16978                    StringBundler query = null;
16979    
16980                    if (orderByComparator != null) {
16981                            query = new StringBundler(7 +
16982                                            (orderByComparator.getOrderByConditionFields().length * 3) +
16983                                            (orderByComparator.getOrderByFields().length * 3));
16984                    }
16985                    else {
16986                            query = new StringBundler(6);
16987                    }
16988    
16989                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
16990    
16991                    query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
16992    
16993                    query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
16994    
16995                    boolean bindDisplayDate = false;
16996    
16997                    if (displayDate == null) {
16998                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
16999                    }
17000                    else {
17001                            bindDisplayDate = true;
17002    
17003                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
17004                    }
17005    
17006                    query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
17007    
17008                    if (orderByComparator != null) {
17009                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
17010    
17011                            if (orderByConditionFields.length > 0) {
17012                                    query.append(WHERE_AND);
17013                            }
17014    
17015                            for (int i = 0; i < orderByConditionFields.length; i++) {
17016                                    query.append(_ORDER_BY_ENTITY_ALIAS);
17017                                    query.append(orderByConditionFields[i]);
17018    
17019                                    if ((i + 1) < orderByConditionFields.length) {
17020                                            if (orderByComparator.isAscending() ^ previous) {
17021                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
17022                                            }
17023                                            else {
17024                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
17025                                            }
17026                                    }
17027                                    else {
17028                                            if (orderByComparator.isAscending() ^ previous) {
17029                                                    query.append(WHERE_GREATER_THAN);
17030                                            }
17031                                            else {
17032                                                    query.append(WHERE_LESSER_THAN);
17033                                            }
17034                                    }
17035                            }
17036    
17037                            query.append(ORDER_BY_CLAUSE);
17038    
17039                            String[] orderByFields = orderByComparator.getOrderByFields();
17040    
17041                            for (int i = 0; i < orderByFields.length; i++) {
17042                                    query.append(_ORDER_BY_ENTITY_ALIAS);
17043                                    query.append(orderByFields[i]);
17044    
17045                                    if ((i + 1) < orderByFields.length) {
17046                                            if (orderByComparator.isAscending() ^ previous) {
17047                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
17048                                            }
17049                                            else {
17050                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
17051                                            }
17052                                    }
17053                                    else {
17054                                            if (orderByComparator.isAscending() ^ previous) {
17055                                                    query.append(ORDER_BY_ASC);
17056                                            }
17057                                            else {
17058                                                    query.append(ORDER_BY_DESC);
17059                                            }
17060                                    }
17061                            }
17062                    }
17063                    else {
17064                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
17065                    }
17066    
17067                    String sql = query.toString();
17068    
17069                    Query q = session.createQuery(sql);
17070    
17071                    q.setFirstResult(0);
17072                    q.setMaxResults(2);
17073    
17074                    QueryPos qPos = QueryPos.getInstance(q);
17075    
17076                    qPos.add(groupId);
17077    
17078                    qPos.add(userId);
17079    
17080                    if (bindDisplayDate) {
17081                            qPos.add(new Timestamp(displayDate.getTime()));
17082                    }
17083    
17084                    qPos.add(status);
17085    
17086                    if (orderByComparator != null) {
17087                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
17088    
17089                            for (Object value : values) {
17090                                    qPos.add(value);
17091                            }
17092                    }
17093    
17094                    List<BlogsEntry> list = q.list();
17095    
17096                    if (list.size() == 2) {
17097                            return list.get(1);
17098                    }
17099                    else {
17100                            return null;
17101                    }
17102            }
17103    
17104            /**
17105             * 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;.
17106             *
17107             * @param groupId the group ID
17108             * @param userId the user ID
17109             * @param displayDate the display date
17110             * @param status the status
17111             * @return the matching blogs entries that the user has permission to view
17112             */
17113            @Override
17114            public List<BlogsEntry> filterFindByG_U_LtD_S(long groupId, long userId,
17115                    Date displayDate, int status) {
17116                    return filterFindByG_U_LtD_S(groupId, userId, displayDate, status,
17117                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
17118            }
17119    
17120            /**
17121             * 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;.
17122             *
17123             * <p>
17124             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
17125             * </p>
17126             *
17127             * @param groupId the group ID
17128             * @param userId the user ID
17129             * @param displayDate the display date
17130             * @param status the status
17131             * @param start the lower bound of the range of blogs entries
17132             * @param end the upper bound of the range of blogs entries (not inclusive)
17133             * @return the range of matching blogs entries that the user has permission to view
17134             */
17135            @Override
17136            public List<BlogsEntry> filterFindByG_U_LtD_S(long groupId, long userId,
17137                    Date displayDate, int status, int start, int end) {
17138                    return filterFindByG_U_LtD_S(groupId, userId, displayDate, status,
17139                            start, end, null);
17140            }
17141    
17142            /**
17143             * 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;.
17144             *
17145             * <p>
17146             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
17147             * </p>
17148             *
17149             * @param groupId the group ID
17150             * @param userId the user ID
17151             * @param displayDate the display date
17152             * @param status the status
17153             * @param start the lower bound of the range of blogs entries
17154             * @param end the upper bound of the range of blogs entries (not inclusive)
17155             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
17156             * @return the ordered range of matching blogs entries that the user has permission to view
17157             */
17158            @Override
17159            public List<BlogsEntry> filterFindByG_U_LtD_S(long groupId, long userId,
17160                    Date displayDate, int status, int start, int end,
17161                    OrderByComparator<BlogsEntry> orderByComparator) {
17162                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17163                            return findByG_U_LtD_S(groupId, userId, displayDate, status, start,
17164                                    end, orderByComparator);
17165                    }
17166    
17167                    StringBundler query = null;
17168    
17169                    if (orderByComparator != null) {
17170                            query = new StringBundler(6 +
17171                                            (orderByComparator.getOrderByFields().length * 2));
17172                    }
17173                    else {
17174                            query = new StringBundler(7);
17175                    }
17176    
17177                    if (getDB().isSupportsInlineDistinct()) {
17178                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
17179                    }
17180                    else {
17181                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
17182                    }
17183    
17184                    query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
17185    
17186                    query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
17187    
17188                    boolean bindDisplayDate = false;
17189    
17190                    if (displayDate == null) {
17191                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
17192                    }
17193                    else {
17194                            bindDisplayDate = true;
17195    
17196                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
17197                    }
17198    
17199                    query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
17200    
17201                    if (!getDB().isSupportsInlineDistinct()) {
17202                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
17203                    }
17204    
17205                    if (orderByComparator != null) {
17206                            if (getDB().isSupportsInlineDistinct()) {
17207                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
17208                                            orderByComparator, true);
17209                            }
17210                            else {
17211                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
17212                                            orderByComparator, true);
17213                            }
17214                    }
17215                    else {
17216                            if (getDB().isSupportsInlineDistinct()) {
17217                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
17218                            }
17219                            else {
17220                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
17221                            }
17222                    }
17223    
17224                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17225                                    BlogsEntry.class.getName(),
17226                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17227    
17228                    Session session = null;
17229    
17230                    try {
17231                            session = openSession();
17232    
17233                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
17234    
17235                            if (getDB().isSupportsInlineDistinct()) {
17236                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
17237                            }
17238                            else {
17239                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
17240                            }
17241    
17242                            QueryPos qPos = QueryPos.getInstance(q);
17243    
17244                            qPos.add(groupId);
17245    
17246                            qPos.add(userId);
17247    
17248                            if (bindDisplayDate) {
17249                                    qPos.add(new Timestamp(displayDate.getTime()));
17250                            }
17251    
17252                            qPos.add(status);
17253    
17254                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
17255                    }
17256                    catch (Exception e) {
17257                            throw processException(e);
17258                    }
17259                    finally {
17260                            closeSession(session);
17261                    }
17262            }
17263    
17264            /**
17265             * 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;.
17266             *
17267             * @param entryId the primary key of the current blogs entry
17268             * @param groupId the group ID
17269             * @param userId the user ID
17270             * @param displayDate the display date
17271             * @param status the status
17272             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17273             * @return the previous, current, and next blogs entry
17274             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
17275             */
17276            @Override
17277            public BlogsEntry[] filterFindByG_U_LtD_S_PrevAndNext(long entryId,
17278                    long groupId, long userId, Date displayDate, int status,
17279                    OrderByComparator<BlogsEntry> orderByComparator)
17280                    throws NoSuchEntryException {
17281                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17282                            return findByG_U_LtD_S_PrevAndNext(entryId, groupId, userId,
17283                                    displayDate, status, orderByComparator);
17284                    }
17285    
17286                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
17287    
17288                    Session session = null;
17289    
17290                    try {
17291                            session = openSession();
17292    
17293                            BlogsEntry[] array = new BlogsEntryImpl[3];
17294    
17295                            array[0] = filterGetByG_U_LtD_S_PrevAndNext(session, blogsEntry,
17296                                            groupId, userId, displayDate, status, orderByComparator,
17297                                            true);
17298    
17299                            array[1] = blogsEntry;
17300    
17301                            array[2] = filterGetByG_U_LtD_S_PrevAndNext(session, blogsEntry,
17302                                            groupId, userId, displayDate, status, orderByComparator,
17303                                            false);
17304    
17305                            return array;
17306                    }
17307                    catch (Exception e) {
17308                            throw processException(e);
17309                    }
17310                    finally {
17311                            closeSession(session);
17312                    }
17313            }
17314    
17315            protected BlogsEntry filterGetByG_U_LtD_S_PrevAndNext(Session session,
17316                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
17317                    int status, OrderByComparator<BlogsEntry> orderByComparator,
17318                    boolean previous) {
17319                    StringBundler query = null;
17320    
17321                    if (orderByComparator != null) {
17322                            query = new StringBundler(8 +
17323                                            (orderByComparator.getOrderByConditionFields().length * 3) +
17324                                            (orderByComparator.getOrderByFields().length * 3));
17325                    }
17326                    else {
17327                            query = new StringBundler(7);
17328                    }
17329    
17330                    if (getDB().isSupportsInlineDistinct()) {
17331                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
17332                    }
17333                    else {
17334                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
17335                    }
17336    
17337                    query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
17338    
17339                    query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
17340    
17341                    boolean bindDisplayDate = false;
17342    
17343                    if (displayDate == null) {
17344                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
17345                    }
17346                    else {
17347                            bindDisplayDate = true;
17348    
17349                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
17350                    }
17351    
17352                    query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
17353    
17354                    if (!getDB().isSupportsInlineDistinct()) {
17355                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
17356                    }
17357    
17358                    if (orderByComparator != null) {
17359                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
17360    
17361                            if (orderByConditionFields.length > 0) {
17362                                    query.append(WHERE_AND);
17363                            }
17364    
17365                            for (int i = 0; i < orderByConditionFields.length; i++) {
17366                                    if (getDB().isSupportsInlineDistinct()) {
17367                                            query.append(_ORDER_BY_ENTITY_ALIAS);
17368                                    }
17369                                    else {
17370                                            query.append(_ORDER_BY_ENTITY_TABLE);
17371                                    }
17372    
17373                                    query.append(orderByConditionFields[i]);
17374    
17375                                    if ((i + 1) < orderByConditionFields.length) {
17376                                            if (orderByComparator.isAscending() ^ previous) {
17377                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
17378                                            }
17379                                            else {
17380                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
17381                                            }
17382                                    }
17383                                    else {
17384                                            if (orderByComparator.isAscending() ^ previous) {
17385                                                    query.append(WHERE_GREATER_THAN);
17386                                            }
17387                                            else {
17388                                                    query.append(WHERE_LESSER_THAN);
17389                                            }
17390                                    }
17391                            }
17392    
17393                            query.append(ORDER_BY_CLAUSE);
17394    
17395                            String[] orderByFields = orderByComparator.getOrderByFields();
17396    
17397                            for (int i = 0; i < orderByFields.length; i++) {
17398                                    if (getDB().isSupportsInlineDistinct()) {
17399                                            query.append(_ORDER_BY_ENTITY_ALIAS);
17400                                    }
17401                                    else {
17402                                            query.append(_ORDER_BY_ENTITY_TABLE);
17403                                    }
17404    
17405                                    query.append(orderByFields[i]);
17406    
17407                                    if ((i + 1) < orderByFields.length) {
17408                                            if (orderByComparator.isAscending() ^ previous) {
17409                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
17410                                            }
17411                                            else {
17412                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
17413                                            }
17414                                    }
17415                                    else {
17416                                            if (orderByComparator.isAscending() ^ previous) {
17417                                                    query.append(ORDER_BY_ASC);
17418                                            }
17419                                            else {
17420                                                    query.append(ORDER_BY_DESC);
17421                                            }
17422                                    }
17423                            }
17424                    }
17425                    else {
17426                            if (getDB().isSupportsInlineDistinct()) {
17427                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
17428                            }
17429                            else {
17430                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
17431                            }
17432                    }
17433    
17434                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17435                                    BlogsEntry.class.getName(),
17436                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17437    
17438                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
17439    
17440                    q.setFirstResult(0);
17441                    q.setMaxResults(2);
17442    
17443                    if (getDB().isSupportsInlineDistinct()) {
17444                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
17445                    }
17446                    else {
17447                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
17448                    }
17449    
17450                    QueryPos qPos = QueryPos.getInstance(q);
17451    
17452                    qPos.add(groupId);
17453    
17454                    qPos.add(userId);
17455    
17456                    if (bindDisplayDate) {
17457                            qPos.add(new Timestamp(displayDate.getTime()));
17458                    }
17459    
17460                    qPos.add(status);
17461    
17462                    if (orderByComparator != null) {
17463                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
17464    
17465                            for (Object value : values) {
17466                                    qPos.add(value);
17467                            }
17468                    }
17469    
17470                    List<BlogsEntry> list = q.list();
17471    
17472                    if (list.size() == 2) {
17473                            return list.get(1);
17474                    }
17475                    else {
17476                            return null;
17477                    }
17478            }
17479    
17480            /**
17481             * Removes all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63; from the database.
17482             *
17483             * @param groupId the group ID
17484             * @param userId the user ID
17485             * @param displayDate the display date
17486             * @param status the status
17487             */
17488            @Override
17489            public void removeByG_U_LtD_S(long groupId, long userId, Date displayDate,
17490                    int status) {
17491                    for (BlogsEntry blogsEntry : findByG_U_LtD_S(groupId, userId,
17492                                    displayDate, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
17493                            remove(blogsEntry);
17494                    }
17495            }
17496    
17497            /**
17498             * Returns the number of blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
17499             *
17500             * @param groupId the group ID
17501             * @param userId the user ID
17502             * @param displayDate the display date
17503             * @param status the status
17504             * @return the number of matching blogs entries
17505             */
17506            @Override
17507            public int countByG_U_LtD_S(long groupId, long userId, Date displayDate,
17508                    int status) {
17509                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD_S;
17510    
17511                    Object[] finderArgs = new Object[] { groupId, userId, displayDate, status };
17512    
17513                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
17514    
17515                    if (count == null) {
17516                            StringBundler query = new StringBundler(5);
17517    
17518                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
17519    
17520                            query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
17521    
17522                            query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
17523    
17524                            boolean bindDisplayDate = false;
17525    
17526                            if (displayDate == null) {
17527                                    query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
17528                            }
17529                            else {
17530                                    bindDisplayDate = true;
17531    
17532                                    query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
17533                            }
17534    
17535                            query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
17536    
17537                            String sql = query.toString();
17538    
17539                            Session session = null;
17540    
17541                            try {
17542                                    session = openSession();
17543    
17544                                    Query q = session.createQuery(sql);
17545    
17546                                    QueryPos qPos = QueryPos.getInstance(q);
17547    
17548                                    qPos.add(groupId);
17549    
17550                                    qPos.add(userId);
17551    
17552                                    if (bindDisplayDate) {
17553                                            qPos.add(new Timestamp(displayDate.getTime()));
17554                                    }
17555    
17556                                    qPos.add(status);
17557    
17558                                    count = (Long)q.uniqueResult();
17559    
17560                                    finderCache.putResult(finderPath, finderArgs, count);
17561                            }
17562                            catch (Exception e) {
17563                                    finderCache.removeResult(finderPath, finderArgs);
17564    
17565                                    throw processException(e);
17566                            }
17567                            finally {
17568                                    closeSession(session);
17569                            }
17570                    }
17571    
17572                    return count.intValue();
17573            }
17574    
17575            /**
17576             * 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;.
17577             *
17578             * @param groupId the group ID
17579             * @param userId the user ID
17580             * @param displayDate the display date
17581             * @param status the status
17582             * @return the number of matching blogs entries that the user has permission to view
17583             */
17584            @Override
17585            public int filterCountByG_U_LtD_S(long groupId, long userId,
17586                    Date displayDate, int status) {
17587                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17588                            return countByG_U_LtD_S(groupId, userId, displayDate, status);
17589                    }
17590    
17591                    StringBundler query = new StringBundler(5);
17592    
17593                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
17594    
17595                    query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
17596    
17597                    query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
17598    
17599                    boolean bindDisplayDate = false;
17600    
17601                    if (displayDate == null) {
17602                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
17603                    }
17604                    else {
17605                            bindDisplayDate = true;
17606    
17607                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
17608                    }
17609    
17610                    query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
17611    
17612                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17613                                    BlogsEntry.class.getName(),
17614                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17615    
17616                    Session session = null;
17617    
17618                    try {
17619                            session = openSession();
17620    
17621                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
17622    
17623                            q.addScalar(COUNT_COLUMN_NAME,
17624                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
17625    
17626                            QueryPos qPos = QueryPos.getInstance(q);
17627    
17628                            qPos.add(groupId);
17629    
17630                            qPos.add(userId);
17631    
17632                            if (bindDisplayDate) {
17633                                    qPos.add(new Timestamp(displayDate.getTime()));
17634                            }
17635    
17636                            qPos.add(status);
17637    
17638                            Long count = (Long)q.uniqueResult();
17639    
17640                            return count.intValue();
17641                    }
17642                    catch (Exception e) {
17643                            throw processException(e);
17644                    }
17645                    finally {
17646                            closeSession(session);
17647                    }
17648            }
17649    
17650            private static final String _FINDER_COLUMN_G_U_LTD_S_GROUPID_2 = "blogsEntry.groupId = ? AND ";
17651            private static final String _FINDER_COLUMN_G_U_LTD_S_USERID_2 = "blogsEntry.userId = ? AND ";
17652            private static final String _FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1 = "blogsEntry.displayDate IS NULL AND ";
17653            private static final String _FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
17654            private static final String _FINDER_COLUMN_G_U_LTD_S_STATUS_2 = "blogsEntry.status = ?";
17655            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD_NOTS =
17656                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
17657                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
17658                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_LtD_NotS",
17659                            new String[] {
17660                                    Long.class.getName(), Long.class.getName(), Date.class.getName(),
17661                                    Integer.class.getName(),
17662                                    
17663                            Integer.class.getName(), Integer.class.getName(),
17664                                    OrderByComparator.class.getName()
17665                            });
17666            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD_NOTS =
17667                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
17668                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
17669                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_U_LtD_NotS",
17670                            new String[] {
17671                                    Long.class.getName(), Long.class.getName(), Date.class.getName(),
17672                                    Integer.class.getName()
17673                            });
17674    
17675            /**
17676             * Returns all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
17677             *
17678             * @param groupId the group ID
17679             * @param userId the user ID
17680             * @param displayDate the display date
17681             * @param status the status
17682             * @return the matching blogs entries
17683             */
17684            @Override
17685            public List<BlogsEntry> findByG_U_LtD_NotS(long groupId, long userId,
17686                    Date displayDate, int status) {
17687                    return findByG_U_LtD_NotS(groupId, userId, displayDate, status,
17688                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
17689            }
17690    
17691            /**
17692             * Returns a range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
17693             *
17694             * <p>
17695             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
17696             * </p>
17697             *
17698             * @param groupId the group ID
17699             * @param userId the user ID
17700             * @param displayDate the display date
17701             * @param status the status
17702             * @param start the lower bound of the range of blogs entries
17703             * @param end the upper bound of the range of blogs entries (not inclusive)
17704             * @return the range of matching blogs entries
17705             */
17706            @Override
17707            public List<BlogsEntry> findByG_U_LtD_NotS(long groupId, long userId,
17708                    Date displayDate, int status, int start, int end) {
17709                    return findByG_U_LtD_NotS(groupId, userId, displayDate, status, start,
17710                            end, null);
17711            }
17712    
17713            /**
17714             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
17715             *
17716             * <p>
17717             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
17718             * </p>
17719             *
17720             * @param groupId the group ID
17721             * @param userId the user ID
17722             * @param displayDate the display date
17723             * @param status the status
17724             * @param start the lower bound of the range of blogs entries
17725             * @param end the upper bound of the range of blogs entries (not inclusive)
17726             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
17727             * @return the ordered range of matching blogs entries
17728             */
17729            @Override
17730            public List<BlogsEntry> findByG_U_LtD_NotS(long groupId, long userId,
17731                    Date displayDate, int status, int start, int end,
17732                    OrderByComparator<BlogsEntry> orderByComparator) {
17733                    return findByG_U_LtD_NotS(groupId, userId, displayDate, status, start,
17734                            end, orderByComparator, true);
17735            }
17736    
17737            /**
17738             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
17739             *
17740             * <p>
17741             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
17742             * </p>
17743             *
17744             * @param groupId the group ID
17745             * @param userId the user ID
17746             * @param displayDate the display date
17747             * @param status the status
17748             * @param start the lower bound of the range of blogs entries
17749             * @param end the upper bound of the range of blogs entries (not inclusive)
17750             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
17751             * @param retrieveFromCache whether to retrieve from the finder cache
17752             * @return the ordered range of matching blogs entries
17753             */
17754            @Override
17755            public List<BlogsEntry> findByG_U_LtD_NotS(long groupId, long userId,
17756                    Date displayDate, int status, int start, int end,
17757                    OrderByComparator<BlogsEntry> orderByComparator,
17758                    boolean retrieveFromCache) {
17759                    boolean pagination = true;
17760                    FinderPath finderPath = null;
17761                    Object[] finderArgs = null;
17762    
17763                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD_NOTS;
17764                    finderArgs = new Object[] {
17765                                    groupId, userId, displayDate, status,
17766                                    
17767                                    start, end, orderByComparator
17768                            };
17769    
17770                    List<BlogsEntry> list = null;
17771    
17772                    if (retrieveFromCache) {
17773                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
17774                                            finderArgs, this);
17775    
17776                            if ((list != null) && !list.isEmpty()) {
17777                                    for (BlogsEntry blogsEntry : list) {
17778                                            if ((groupId != blogsEntry.getGroupId()) ||
17779                                                            (userId != blogsEntry.getUserId()) ||
17780                                                            (displayDate.getTime() <= blogsEntry.getDisplayDate()
17781                                                                                                                                            .getTime()) ||
17782                                                            (status == blogsEntry.getStatus())) {
17783                                                    list = null;
17784    
17785                                                    break;
17786                                            }
17787                                    }
17788                            }
17789                    }
17790    
17791                    if (list == null) {
17792                            StringBundler query = null;
17793    
17794                            if (orderByComparator != null) {
17795                                    query = new StringBundler(6 +
17796                                                    (orderByComparator.getOrderByFields().length * 2));
17797                            }
17798                            else {
17799                                    query = new StringBundler(6);
17800                            }
17801    
17802                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
17803    
17804                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
17805    
17806                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
17807    
17808                            boolean bindDisplayDate = false;
17809    
17810                            if (displayDate == null) {
17811                                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
17812                            }
17813                            else {
17814                                    bindDisplayDate = true;
17815    
17816                                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
17817                            }
17818    
17819                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
17820    
17821                            if (orderByComparator != null) {
17822                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
17823                                            orderByComparator);
17824                            }
17825                            else
17826                             if (pagination) {
17827                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
17828                            }
17829    
17830                            String sql = query.toString();
17831    
17832                            Session session = null;
17833    
17834                            try {
17835                                    session = openSession();
17836    
17837                                    Query q = session.createQuery(sql);
17838    
17839                                    QueryPos qPos = QueryPos.getInstance(q);
17840    
17841                                    qPos.add(groupId);
17842    
17843                                    qPos.add(userId);
17844    
17845                                    if (bindDisplayDate) {
17846                                            qPos.add(new Timestamp(displayDate.getTime()));
17847                                    }
17848    
17849                                    qPos.add(status);
17850    
17851                                    if (!pagination) {
17852                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
17853                                                            start, end, false);
17854    
17855                                            Collections.sort(list);
17856    
17857                                            list = Collections.unmodifiableList(list);
17858                                    }
17859                                    else {
17860                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
17861                                                            start, end);
17862                                    }
17863    
17864                                    cacheResult(list);
17865    
17866                                    finderCache.putResult(finderPath, finderArgs, list);
17867                            }
17868                            catch (Exception e) {
17869                                    finderCache.removeResult(finderPath, finderArgs);
17870    
17871                                    throw processException(e);
17872                            }
17873                            finally {
17874                                    closeSession(session);
17875                            }
17876                    }
17877    
17878                    return list;
17879            }
17880    
17881            /**
17882             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
17883             *
17884             * @param groupId the group ID
17885             * @param userId the user ID
17886             * @param displayDate the display date
17887             * @param status the status
17888             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17889             * @return the first matching blogs entry
17890             * @throws NoSuchEntryException if a matching blogs entry could not be found
17891             */
17892            @Override
17893            public BlogsEntry findByG_U_LtD_NotS_First(long groupId, long userId,
17894                    Date displayDate, int status,
17895                    OrderByComparator<BlogsEntry> orderByComparator)
17896                    throws NoSuchEntryException {
17897                    BlogsEntry blogsEntry = fetchByG_U_LtD_NotS_First(groupId, userId,
17898                                    displayDate, status, orderByComparator);
17899    
17900                    if (blogsEntry != null) {
17901                            return blogsEntry;
17902                    }
17903    
17904                    StringBundler msg = new StringBundler(10);
17905    
17906                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
17907    
17908                    msg.append("groupId=");
17909                    msg.append(groupId);
17910    
17911                    msg.append(", userId=");
17912                    msg.append(userId);
17913    
17914                    msg.append(", displayDate=");
17915                    msg.append(displayDate);
17916    
17917                    msg.append(", status=");
17918                    msg.append(status);
17919    
17920                    msg.append(StringPool.CLOSE_CURLY_BRACE);
17921    
17922                    throw new NoSuchEntryException(msg.toString());
17923            }
17924    
17925            /**
17926             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
17927             *
17928             * @param groupId the group ID
17929             * @param userId the user ID
17930             * @param displayDate the display date
17931             * @param status the status
17932             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17933             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
17934             */
17935            @Override
17936            public BlogsEntry fetchByG_U_LtD_NotS_First(long groupId, long userId,
17937                    Date displayDate, int status,
17938                    OrderByComparator<BlogsEntry> orderByComparator) {
17939                    List<BlogsEntry> list = findByG_U_LtD_NotS(groupId, userId,
17940                                    displayDate, status, 0, 1, orderByComparator);
17941    
17942                    if (!list.isEmpty()) {
17943                            return list.get(0);
17944                    }
17945    
17946                    return null;
17947            }
17948    
17949            /**
17950             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
17951             *
17952             * @param groupId the group ID
17953             * @param userId the user ID
17954             * @param displayDate the display date
17955             * @param status the status
17956             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17957             * @return the last matching blogs entry
17958             * @throws NoSuchEntryException if a matching blogs entry could not be found
17959             */
17960            @Override
17961            public BlogsEntry findByG_U_LtD_NotS_Last(long groupId, long userId,
17962                    Date displayDate, int status,
17963                    OrderByComparator<BlogsEntry> orderByComparator)
17964                    throws NoSuchEntryException {
17965                    BlogsEntry blogsEntry = fetchByG_U_LtD_NotS_Last(groupId, userId,
17966                                    displayDate, status, orderByComparator);
17967    
17968                    if (blogsEntry != null) {
17969                            return blogsEntry;
17970                    }
17971    
17972                    StringBundler msg = new StringBundler(10);
17973    
17974                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
17975    
17976                    msg.append("groupId=");
17977                    msg.append(groupId);
17978    
17979                    msg.append(", userId=");
17980                    msg.append(userId);
17981    
17982                    msg.append(", displayDate=");
17983                    msg.append(displayDate);
17984    
17985                    msg.append(", status=");
17986                    msg.append(status);
17987    
17988                    msg.append(StringPool.CLOSE_CURLY_BRACE);
17989    
17990                    throw new NoSuchEntryException(msg.toString());
17991            }
17992    
17993            /**
17994             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
17995             *
17996             * @param groupId the group ID
17997             * @param userId the user ID
17998             * @param displayDate the display date
17999             * @param status the status
18000             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18001             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
18002             */
18003            @Override
18004            public BlogsEntry fetchByG_U_LtD_NotS_Last(long groupId, long userId,
18005                    Date displayDate, int status,
18006                    OrderByComparator<BlogsEntry> orderByComparator) {
18007                    int count = countByG_U_LtD_NotS(groupId, userId, displayDate, status);
18008    
18009                    if (count == 0) {
18010                            return null;
18011                    }
18012    
18013                    List<BlogsEntry> list = findByG_U_LtD_NotS(groupId, userId,
18014                                    displayDate, status, count - 1, count, orderByComparator);
18015    
18016                    if (!list.isEmpty()) {
18017                            return list.get(0);
18018                    }
18019    
18020                    return null;
18021            }
18022    
18023            /**
18024             * 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;.
18025             *
18026             * @param entryId the primary key of the current blogs entry
18027             * @param groupId the group ID
18028             * @param userId the user ID
18029             * @param displayDate the display date
18030             * @param status the status
18031             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18032             * @return the previous, current, and next blogs entry
18033             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
18034             */
18035            @Override
18036            public BlogsEntry[] findByG_U_LtD_NotS_PrevAndNext(long entryId,
18037                    long groupId, long userId, Date displayDate, int status,
18038                    OrderByComparator<BlogsEntry> orderByComparator)
18039                    throws NoSuchEntryException {
18040                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
18041    
18042                    Session session = null;
18043    
18044                    try {
18045                            session = openSession();
18046    
18047                            BlogsEntry[] array = new BlogsEntryImpl[3];
18048    
18049                            array[0] = getByG_U_LtD_NotS_PrevAndNext(session, blogsEntry,
18050                                            groupId, userId, displayDate, status, orderByComparator,
18051                                            true);
18052    
18053                            array[1] = blogsEntry;
18054    
18055                            array[2] = getByG_U_LtD_NotS_PrevAndNext(session, blogsEntry,
18056                                            groupId, userId, displayDate, status, orderByComparator,
18057                                            false);
18058    
18059                            return array;
18060                    }
18061                    catch (Exception e) {
18062                            throw processException(e);
18063                    }
18064                    finally {
18065                            closeSession(session);
18066                    }
18067            }
18068    
18069            protected BlogsEntry getByG_U_LtD_NotS_PrevAndNext(Session session,
18070                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
18071                    int status, OrderByComparator<BlogsEntry> orderByComparator,
18072                    boolean previous) {
18073                    StringBundler query = null;
18074    
18075                    if (orderByComparator != null) {
18076                            query = new StringBundler(7 +
18077                                            (orderByComparator.getOrderByConditionFields().length * 3) +
18078                                            (orderByComparator.getOrderByFields().length * 3));
18079                    }
18080                    else {
18081                            query = new StringBundler(6);
18082                    }
18083    
18084                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
18085    
18086                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
18087    
18088                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
18089    
18090                    boolean bindDisplayDate = false;
18091    
18092                    if (displayDate == null) {
18093                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
18094                    }
18095                    else {
18096                            bindDisplayDate = true;
18097    
18098                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
18099                    }
18100    
18101                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
18102    
18103                    if (orderByComparator != null) {
18104                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
18105    
18106                            if (orderByConditionFields.length > 0) {
18107                                    query.append(WHERE_AND);
18108                            }
18109    
18110                            for (int i = 0; i < orderByConditionFields.length; i++) {
18111                                    query.append(_ORDER_BY_ENTITY_ALIAS);
18112                                    query.append(orderByConditionFields[i]);
18113    
18114                                    if ((i + 1) < orderByConditionFields.length) {
18115                                            if (orderByComparator.isAscending() ^ previous) {
18116                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
18117                                            }
18118                                            else {
18119                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
18120                                            }
18121                                    }
18122                                    else {
18123                                            if (orderByComparator.isAscending() ^ previous) {
18124                                                    query.append(WHERE_GREATER_THAN);
18125                                            }
18126                                            else {
18127                                                    query.append(WHERE_LESSER_THAN);
18128                                            }
18129                                    }
18130                            }
18131    
18132                            query.append(ORDER_BY_CLAUSE);
18133    
18134                            String[] orderByFields = orderByComparator.getOrderByFields();
18135    
18136                            for (int i = 0; i < orderByFields.length; i++) {
18137                                    query.append(_ORDER_BY_ENTITY_ALIAS);
18138                                    query.append(orderByFields[i]);
18139    
18140                                    if ((i + 1) < orderByFields.length) {
18141                                            if (orderByComparator.isAscending() ^ previous) {
18142                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
18143                                            }
18144                                            else {
18145                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
18146                                            }
18147                                    }
18148                                    else {
18149                                            if (orderByComparator.isAscending() ^ previous) {
18150                                                    query.append(ORDER_BY_ASC);
18151                                            }
18152                                            else {
18153                                                    query.append(ORDER_BY_DESC);
18154                                            }
18155                                    }
18156                            }
18157                    }
18158                    else {
18159                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
18160                    }
18161    
18162                    String sql = query.toString();
18163    
18164                    Query q = session.createQuery(sql);
18165    
18166                    q.setFirstResult(0);
18167                    q.setMaxResults(2);
18168    
18169                    QueryPos qPos = QueryPos.getInstance(q);
18170    
18171                    qPos.add(groupId);
18172    
18173                    qPos.add(userId);
18174    
18175                    if (bindDisplayDate) {
18176                            qPos.add(new Timestamp(displayDate.getTime()));
18177                    }
18178    
18179                    qPos.add(status);
18180    
18181                    if (orderByComparator != null) {
18182                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
18183    
18184                            for (Object value : values) {
18185                                    qPos.add(value);
18186                            }
18187                    }
18188    
18189                    List<BlogsEntry> list = q.list();
18190    
18191                    if (list.size() == 2) {
18192                            return list.get(1);
18193                    }
18194                    else {
18195                            return null;
18196                    }
18197            }
18198    
18199            /**
18200             * 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;.
18201             *
18202             * @param groupId the group ID
18203             * @param userId the user ID
18204             * @param displayDate the display date
18205             * @param status the status
18206             * @return the matching blogs entries that the user has permission to view
18207             */
18208            @Override
18209            public List<BlogsEntry> filterFindByG_U_LtD_NotS(long groupId, long userId,
18210                    Date displayDate, int status) {
18211                    return filterFindByG_U_LtD_NotS(groupId, userId, displayDate, status,
18212                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
18213            }
18214    
18215            /**
18216             * 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;.
18217             *
18218             * <p>
18219             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
18220             * </p>
18221             *
18222             * @param groupId the group ID
18223             * @param userId the user ID
18224             * @param displayDate the display date
18225             * @param status the status
18226             * @param start the lower bound of the range of blogs entries
18227             * @param end the upper bound of the range of blogs entries (not inclusive)
18228             * @return the range of matching blogs entries that the user has permission to view
18229             */
18230            @Override
18231            public List<BlogsEntry> filterFindByG_U_LtD_NotS(long groupId, long userId,
18232                    Date displayDate, int status, int start, int end) {
18233                    return filterFindByG_U_LtD_NotS(groupId, userId, displayDate, status,
18234                            start, end, null);
18235            }
18236    
18237            /**
18238             * 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;.
18239             *
18240             * <p>
18241             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
18242             * </p>
18243             *
18244             * @param groupId the group ID
18245             * @param userId the user ID
18246             * @param displayDate the display date
18247             * @param status the status
18248             * @param start the lower bound of the range of blogs entries
18249             * @param end the upper bound of the range of blogs entries (not inclusive)
18250             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
18251             * @return the ordered range of matching blogs entries that the user has permission to view
18252             */
18253            @Override
18254            public List<BlogsEntry> filterFindByG_U_LtD_NotS(long groupId, long userId,
18255                    Date displayDate, int status, int start, int end,
18256                    OrderByComparator<BlogsEntry> orderByComparator) {
18257                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
18258                            return findByG_U_LtD_NotS(groupId, userId, displayDate, status,
18259                                    start, end, orderByComparator);
18260                    }
18261    
18262                    StringBundler query = null;
18263    
18264                    if (orderByComparator != null) {
18265                            query = new StringBundler(6 +
18266                                            (orderByComparator.getOrderByFields().length * 2));
18267                    }
18268                    else {
18269                            query = new StringBundler(7);
18270                    }
18271    
18272                    if (getDB().isSupportsInlineDistinct()) {
18273                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
18274                    }
18275                    else {
18276                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
18277                    }
18278    
18279                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
18280    
18281                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
18282    
18283                    boolean bindDisplayDate = false;
18284    
18285                    if (displayDate == null) {
18286                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
18287                    }
18288                    else {
18289                            bindDisplayDate = true;
18290    
18291                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
18292                    }
18293    
18294                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
18295    
18296                    if (!getDB().isSupportsInlineDistinct()) {
18297                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
18298                    }
18299    
18300                    if (orderByComparator != null) {
18301                            if (getDB().isSupportsInlineDistinct()) {
18302                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
18303                                            orderByComparator, true);
18304                            }
18305                            else {
18306                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
18307                                            orderByComparator, true);
18308                            }
18309                    }
18310                    else {
18311                            if (getDB().isSupportsInlineDistinct()) {
18312                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
18313                            }
18314                            else {
18315                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
18316                            }
18317                    }
18318    
18319                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
18320                                    BlogsEntry.class.getName(),
18321                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
18322    
18323                    Session session = null;
18324    
18325                    try {
18326                            session = openSession();
18327    
18328                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
18329    
18330                            if (getDB().isSupportsInlineDistinct()) {
18331                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
18332                            }
18333                            else {
18334                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
18335                            }
18336    
18337                            QueryPos qPos = QueryPos.getInstance(q);
18338    
18339                            qPos.add(groupId);
18340    
18341                            qPos.add(userId);
18342    
18343                            if (bindDisplayDate) {
18344                                    qPos.add(new Timestamp(displayDate.getTime()));
18345                            }
18346    
18347                            qPos.add(status);
18348    
18349                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
18350                    }
18351                    catch (Exception e) {
18352                            throw processException(e);
18353                    }
18354                    finally {
18355                            closeSession(session);
18356                    }
18357            }
18358    
18359            /**
18360             * 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;.
18361             *
18362             * @param entryId the primary key of the current blogs entry
18363             * @param groupId the group ID
18364             * @param userId the user ID
18365             * @param displayDate the display date
18366             * @param status the status
18367             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
18368             * @return the previous, current, and next blogs entry
18369             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
18370             */
18371            @Override
18372            public BlogsEntry[] filterFindByG_U_LtD_NotS_PrevAndNext(long entryId,
18373                    long groupId, long userId, Date displayDate, int status,
18374                    OrderByComparator<BlogsEntry> orderByComparator)
18375                    throws NoSuchEntryException {
18376                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
18377                            return findByG_U_LtD_NotS_PrevAndNext(entryId, groupId, userId,
18378                                    displayDate, status, orderByComparator);
18379                    }
18380    
18381                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
18382    
18383                    Session session = null;
18384    
18385                    try {
18386                            session = openSession();
18387    
18388                            BlogsEntry[] array = new BlogsEntryImpl[3];
18389    
18390                            array[0] = filterGetByG_U_LtD_NotS_PrevAndNext(session, blogsEntry,
18391                                            groupId, userId, displayDate, status, orderByComparator,
18392                                            true);
18393    
18394                            array[1] = blogsEntry;
18395    
18396                            array[2] = filterGetByG_U_LtD_NotS_PrevAndNext(session, blogsEntry,
18397                                            groupId, userId, displayDate, status, orderByComparator,
18398                                            false);
18399    
18400                            return array;
18401                    }
18402                    catch (Exception e) {
18403                            throw processException(e);
18404                    }
18405                    finally {
18406                            closeSession(session);
18407                    }
18408            }
18409    
18410            protected BlogsEntry filterGetByG_U_LtD_NotS_PrevAndNext(Session session,
18411                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
18412                    int status, OrderByComparator<BlogsEntry> orderByComparator,
18413                    boolean previous) {
18414                    StringBundler query = null;
18415    
18416                    if (orderByComparator != null) {
18417                            query = new StringBundler(8 +
18418                                            (orderByComparator.getOrderByConditionFields().length * 3) +
18419                                            (orderByComparator.getOrderByFields().length * 3));
18420                    }
18421                    else {
18422                            query = new StringBundler(7);
18423                    }
18424    
18425                    if (getDB().isSupportsInlineDistinct()) {
18426                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
18427                    }
18428                    else {
18429                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
18430                    }
18431    
18432                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
18433    
18434                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
18435    
18436                    boolean bindDisplayDate = false;
18437    
18438                    if (displayDate == null) {
18439                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
18440                    }
18441                    else {
18442                            bindDisplayDate = true;
18443    
18444                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
18445                    }
18446    
18447                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
18448    
18449                    if (!getDB().isSupportsInlineDistinct()) {
18450                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
18451                    }
18452    
18453                    if (orderByComparator != null) {
18454                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
18455    
18456                            if (orderByConditionFields.length > 0) {
18457                                    query.append(WHERE_AND);
18458                            }
18459    
18460                            for (int i = 0; i < orderByConditionFields.length; i++) {
18461                                    if (getDB().isSupportsInlineDistinct()) {
18462                                            query.append(_ORDER_BY_ENTITY_ALIAS);
18463                                    }
18464                                    else {
18465                                            query.append(_ORDER_BY_ENTITY_TABLE);
18466                                    }
18467    
18468                                    query.append(orderByConditionFields[i]);
18469    
18470                                    if ((i + 1) < orderByConditionFields.length) {
18471                                            if (orderByComparator.isAscending() ^ previous) {
18472                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
18473                                            }
18474                                            else {
18475                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
18476                                            }
18477                                    }
18478                                    else {
18479                                            if (orderByComparator.isAscending() ^ previous) {
18480                                                    query.append(WHERE_GREATER_THAN);
18481                                            }
18482                                            else {
18483                                                    query.append(WHERE_LESSER_THAN);
18484                                            }
18485                                    }
18486                            }
18487    
18488                            query.append(ORDER_BY_CLAUSE);
18489    
18490                            String[] orderByFields = orderByComparator.getOrderByFields();
18491    
18492                            for (int i = 0; i < orderByFields.length; i++) {
18493                                    if (getDB().isSupportsInlineDistinct()) {
18494                                            query.append(_ORDER_BY_ENTITY_ALIAS);
18495                                    }
18496                                    else {
18497                                            query.append(_ORDER_BY_ENTITY_TABLE);
18498                                    }
18499    
18500                                    query.append(orderByFields[i]);
18501    
18502                                    if ((i + 1) < orderByFields.length) {
18503                                            if (orderByComparator.isAscending() ^ previous) {
18504                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
18505                                            }
18506                                            else {
18507                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
18508                                            }
18509                                    }
18510                                    else {
18511                                            if (orderByComparator.isAscending() ^ previous) {
18512                                                    query.append(ORDER_BY_ASC);
18513                                            }
18514                                            else {
18515                                                    query.append(ORDER_BY_DESC);
18516                                            }
18517                                    }
18518                            }
18519                    }
18520                    else {
18521                            if (getDB().isSupportsInlineDistinct()) {
18522                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
18523                            }
18524                            else {
18525                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
18526                            }
18527                    }
18528    
18529                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
18530                                    BlogsEntry.class.getName(),
18531                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
18532    
18533                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
18534    
18535                    q.setFirstResult(0);
18536                    q.setMaxResults(2);
18537    
18538                    if (getDB().isSupportsInlineDistinct()) {
18539                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
18540                    }
18541                    else {
18542                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
18543                    }
18544    
18545                    QueryPos qPos = QueryPos.getInstance(q);
18546    
18547                    qPos.add(groupId);
18548    
18549                    qPos.add(userId);
18550    
18551                    if (bindDisplayDate) {
18552                            qPos.add(new Timestamp(displayDate.getTime()));
18553                    }
18554    
18555                    qPos.add(status);
18556    
18557                    if (orderByComparator != null) {
18558                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
18559    
18560                            for (Object value : values) {
18561                                    qPos.add(value);
18562                            }
18563                    }
18564    
18565                    List<BlogsEntry> list = q.list();
18566    
18567                    if (list.size() == 2) {
18568                            return list.get(1);
18569                    }
18570                    else {
18571                            return null;
18572                    }
18573            }
18574    
18575            /**
18576             * Removes all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63; from the database.
18577             *
18578             * @param groupId the group ID
18579             * @param userId the user ID
18580             * @param displayDate the display date
18581             * @param status the status
18582             */
18583            @Override
18584            public void removeByG_U_LtD_NotS(long groupId, long userId,
18585                    Date displayDate, int status) {
18586                    for (BlogsEntry blogsEntry : findByG_U_LtD_NotS(groupId, userId,
18587                                    displayDate, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
18588                            remove(blogsEntry);
18589                    }
18590            }
18591    
18592            /**
18593             * Returns the number of blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
18594             *
18595             * @param groupId the group ID
18596             * @param userId the user ID
18597             * @param displayDate the display date
18598             * @param status the status
18599             * @return the number of matching blogs entries
18600             */
18601            @Override
18602            public int countByG_U_LtD_NotS(long groupId, long userId, Date displayDate,
18603                    int status) {
18604                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD_NOTS;
18605    
18606                    Object[] finderArgs = new Object[] { groupId, userId, displayDate, status };
18607    
18608                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
18609    
18610                    if (count == null) {
18611                            StringBundler query = new StringBundler(5);
18612    
18613                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
18614    
18615                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
18616    
18617                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
18618    
18619                            boolean bindDisplayDate = false;
18620    
18621                            if (displayDate == null) {
18622                                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
18623                            }
18624                            else {
18625                                    bindDisplayDate = true;
18626    
18627                                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
18628                            }
18629    
18630                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
18631    
18632                            String sql = query.toString();
18633    
18634                            Session session = null;
18635    
18636                            try {
18637                                    session = openSession();
18638    
18639                                    Query q = session.createQuery(sql);
18640    
18641                                    QueryPos qPos = QueryPos.getInstance(q);
18642    
18643                                    qPos.add(groupId);
18644    
18645                                    qPos.add(userId);
18646    
18647                                    if (bindDisplayDate) {
18648                                            qPos.add(new Timestamp(displayDate.getTime()));
18649                                    }
18650    
18651                                    qPos.add(status);
18652    
18653                                    count = (Long)q.uniqueResult();
18654    
18655                                    finderCache.putResult(finderPath, finderArgs, count);
18656                            }
18657                            catch (Exception e) {
18658                                    finderCache.removeResult(finderPath, finderArgs);
18659    
18660                                    throw processException(e);
18661                            }
18662                            finally {
18663                                    closeSession(session);
18664                            }
18665                    }
18666    
18667                    return count.intValue();
18668            }
18669    
18670            /**
18671             * 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;.
18672             *
18673             * @param groupId the group ID
18674             * @param userId the user ID
18675             * @param displayDate the display date
18676             * @param status the status
18677             * @return the number of matching blogs entries that the user has permission to view
18678             */
18679            @Override
18680            public int filterCountByG_U_LtD_NotS(long groupId, long userId,
18681                    Date displayDate, int status) {
18682                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
18683                            return countByG_U_LtD_NotS(groupId, userId, displayDate, status);
18684                    }
18685    
18686                    StringBundler query = new StringBundler(5);
18687    
18688                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
18689    
18690                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
18691    
18692                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
18693    
18694                    boolean bindDisplayDate = false;
18695    
18696                    if (displayDate == null) {
18697                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
18698                    }
18699                    else {
18700                            bindDisplayDate = true;
18701    
18702                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
18703                    }
18704    
18705                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
18706    
18707                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
18708                                    BlogsEntry.class.getName(),
18709                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
18710    
18711                    Session session = null;
18712    
18713                    try {
18714                            session = openSession();
18715    
18716                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
18717    
18718                            q.addScalar(COUNT_COLUMN_NAME,
18719                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
18720    
18721                            QueryPos qPos = QueryPos.getInstance(q);
18722    
18723                            qPos.add(groupId);
18724    
18725                            qPos.add(userId);
18726    
18727                            if (bindDisplayDate) {
18728                                    qPos.add(new Timestamp(displayDate.getTime()));
18729                            }
18730    
18731                            qPos.add(status);
18732    
18733                            Long count = (Long)q.uniqueResult();
18734    
18735                            return count.intValue();
18736                    }
18737                    catch (Exception e) {
18738                            throw processException(e);
18739                    }
18740                    finally {
18741                            closeSession(session);
18742                    }
18743            }
18744    
18745            private static final String _FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2 = "blogsEntry.groupId = ? AND ";
18746            private static final String _FINDER_COLUMN_G_U_LTD_NOTS_USERID_2 = "blogsEntry.userId = ? AND ";
18747            private static final String _FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1 = "blogsEntry.displayDate IS NULL AND ";
18748            private static final String _FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
18749            private static final String _FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2 = "blogsEntry.status != ?";
18750    
18751            public BlogsEntryPersistenceImpl() {
18752                    setModelClass(BlogsEntry.class);
18753            }
18754    
18755            /**
18756             * Caches the blogs entry in the entity cache if it is enabled.
18757             *
18758             * @param blogsEntry the blogs entry
18759             */
18760            @Override
18761            public void cacheResult(BlogsEntry blogsEntry) {
18762                    entityCache.putResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18763                            BlogsEntryImpl.class, blogsEntry.getPrimaryKey(), blogsEntry);
18764    
18765                    finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G,
18766                            new Object[] { blogsEntry.getUuid(), blogsEntry.getGroupId() },
18767                            blogsEntry);
18768    
18769                    finderCache.putResult(FINDER_PATH_FETCH_BY_G_UT,
18770                            new Object[] { blogsEntry.getGroupId(), blogsEntry.getUrlTitle() },
18771                            blogsEntry);
18772    
18773                    blogsEntry.resetOriginalValues();
18774            }
18775    
18776            /**
18777             * Caches the blogs entries in the entity cache if it is enabled.
18778             *
18779             * @param blogsEntries the blogs entries
18780             */
18781            @Override
18782            public void cacheResult(List<BlogsEntry> blogsEntries) {
18783                    for (BlogsEntry blogsEntry : blogsEntries) {
18784                            if (entityCache.getResult(
18785                                                    BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18786                                                    BlogsEntryImpl.class, blogsEntry.getPrimaryKey()) == null) {
18787                                    cacheResult(blogsEntry);
18788                            }
18789                            else {
18790                                    blogsEntry.resetOriginalValues();
18791                            }
18792                    }
18793            }
18794    
18795            /**
18796             * Clears the cache for all blogs entries.
18797             *
18798             * <p>
18799             * The {@link EntityCache} and {@link FinderCache} are both cleared by this method.
18800             * </p>
18801             */
18802            @Override
18803            public void clearCache() {
18804                    entityCache.clearCache(BlogsEntryImpl.class);
18805    
18806                    finderCache.clearCache(FINDER_CLASS_NAME_ENTITY);
18807                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
18808                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
18809            }
18810    
18811            /**
18812             * Clears the cache for the blogs entry.
18813             *
18814             * <p>
18815             * The {@link EntityCache} and {@link FinderCache} are both cleared by this method.
18816             * </p>
18817             */
18818            @Override
18819            public void clearCache(BlogsEntry blogsEntry) {
18820                    entityCache.removeResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18821                            BlogsEntryImpl.class, blogsEntry.getPrimaryKey());
18822    
18823                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
18824                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
18825    
18826                    clearUniqueFindersCache((BlogsEntryModelImpl)blogsEntry);
18827            }
18828    
18829            @Override
18830            public void clearCache(List<BlogsEntry> blogsEntries) {
18831                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
18832                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
18833    
18834                    for (BlogsEntry blogsEntry : blogsEntries) {
18835                            entityCache.removeResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18836                                    BlogsEntryImpl.class, blogsEntry.getPrimaryKey());
18837    
18838                            clearUniqueFindersCache((BlogsEntryModelImpl)blogsEntry);
18839                    }
18840            }
18841    
18842            protected void cacheUniqueFindersCache(
18843                    BlogsEntryModelImpl blogsEntryModelImpl, boolean isNew) {
18844                    if (isNew) {
18845                            Object[] args = new Object[] {
18846                                            blogsEntryModelImpl.getUuid(),
18847                                            blogsEntryModelImpl.getGroupId()
18848                                    };
18849    
18850                            finderCache.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
18851                                    Long.valueOf(1));
18852                            finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
18853                                    blogsEntryModelImpl);
18854    
18855                            args = new Object[] {
18856                                            blogsEntryModelImpl.getGroupId(),
18857                                            blogsEntryModelImpl.getUrlTitle()
18858                                    };
18859    
18860                            finderCache.putResult(FINDER_PATH_COUNT_BY_G_UT, args,
18861                                    Long.valueOf(1));
18862                            finderCache.putResult(FINDER_PATH_FETCH_BY_G_UT, args,
18863                                    blogsEntryModelImpl);
18864                    }
18865                    else {
18866                            if ((blogsEntryModelImpl.getColumnBitmask() &
18867                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
18868                                    Object[] args = new Object[] {
18869                                                    blogsEntryModelImpl.getUuid(),
18870                                                    blogsEntryModelImpl.getGroupId()
18871                                            };
18872    
18873                                    finderCache.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
18874                                            Long.valueOf(1));
18875                                    finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
18876                                            blogsEntryModelImpl);
18877                            }
18878    
18879                            if ((blogsEntryModelImpl.getColumnBitmask() &
18880                                            FINDER_PATH_FETCH_BY_G_UT.getColumnBitmask()) != 0) {
18881                                    Object[] args = new Object[] {
18882                                                    blogsEntryModelImpl.getGroupId(),
18883                                                    blogsEntryModelImpl.getUrlTitle()
18884                                            };
18885    
18886                                    finderCache.putResult(FINDER_PATH_COUNT_BY_G_UT, args,
18887                                            Long.valueOf(1));
18888                                    finderCache.putResult(FINDER_PATH_FETCH_BY_G_UT, args,
18889                                            blogsEntryModelImpl);
18890                            }
18891                    }
18892            }
18893    
18894            protected void clearUniqueFindersCache(
18895                    BlogsEntryModelImpl blogsEntryModelImpl) {
18896                    Object[] args = new Object[] {
18897                                    blogsEntryModelImpl.getUuid(), blogsEntryModelImpl.getGroupId()
18898                            };
18899    
18900                    finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
18901                    finderCache.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
18902    
18903                    if ((blogsEntryModelImpl.getColumnBitmask() &
18904                                    FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
18905                            args = new Object[] {
18906                                            blogsEntryModelImpl.getOriginalUuid(),
18907                                            blogsEntryModelImpl.getOriginalGroupId()
18908                                    };
18909    
18910                            finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
18911                            finderCache.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
18912                    }
18913    
18914                    args = new Object[] {
18915                                    blogsEntryModelImpl.getGroupId(),
18916                                    blogsEntryModelImpl.getUrlTitle()
18917                            };
18918    
18919                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_UT, args);
18920                    finderCache.removeResult(FINDER_PATH_FETCH_BY_G_UT, args);
18921    
18922                    if ((blogsEntryModelImpl.getColumnBitmask() &
18923                                    FINDER_PATH_FETCH_BY_G_UT.getColumnBitmask()) != 0) {
18924                            args = new Object[] {
18925                                            blogsEntryModelImpl.getOriginalGroupId(),
18926                                            blogsEntryModelImpl.getOriginalUrlTitle()
18927                                    };
18928    
18929                            finderCache.removeResult(FINDER_PATH_COUNT_BY_G_UT, args);
18930                            finderCache.removeResult(FINDER_PATH_FETCH_BY_G_UT, args);
18931                    }
18932            }
18933    
18934            /**
18935             * Creates a new blogs entry with the primary key. Does not add the blogs entry to the database.
18936             *
18937             * @param entryId the primary key for the new blogs entry
18938             * @return the new blogs entry
18939             */
18940            @Override
18941            public BlogsEntry create(long entryId) {
18942                    BlogsEntry blogsEntry = new BlogsEntryImpl();
18943    
18944                    blogsEntry.setNew(true);
18945                    blogsEntry.setPrimaryKey(entryId);
18946    
18947                    String uuid = PortalUUIDUtil.generate();
18948    
18949                    blogsEntry.setUuid(uuid);
18950    
18951                    blogsEntry.setCompanyId(companyProvider.getCompanyId());
18952    
18953                    return blogsEntry;
18954            }
18955    
18956            /**
18957             * Removes the blogs entry with the primary key from the database. Also notifies the appropriate model listeners.
18958             *
18959             * @param entryId the primary key of the blogs entry
18960             * @return the blogs entry that was removed
18961             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
18962             */
18963            @Override
18964            public BlogsEntry remove(long entryId) throws NoSuchEntryException {
18965                    return remove((Serializable)entryId);
18966            }
18967    
18968            /**
18969             * Removes the blogs entry with the primary key from the database. Also notifies the appropriate model listeners.
18970             *
18971             * @param primaryKey the primary key of the blogs entry
18972             * @return the blogs entry that was removed
18973             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
18974             */
18975            @Override
18976            public BlogsEntry remove(Serializable primaryKey)
18977                    throws NoSuchEntryException {
18978                    Session session = null;
18979    
18980                    try {
18981                            session = openSession();
18982    
18983                            BlogsEntry blogsEntry = (BlogsEntry)session.get(BlogsEntryImpl.class,
18984                                            primaryKey);
18985    
18986                            if (blogsEntry == null) {
18987                                    if (_log.isWarnEnabled()) {
18988                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
18989                                    }
18990    
18991                                    throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
18992                                            primaryKey);
18993                            }
18994    
18995                            return remove(blogsEntry);
18996                    }
18997                    catch (NoSuchEntryException nsee) {
18998                            throw nsee;
18999                    }
19000                    catch (Exception e) {
19001                            throw processException(e);
19002                    }
19003                    finally {
19004                            closeSession(session);
19005                    }
19006            }
19007    
19008            @Override
19009            protected BlogsEntry removeImpl(BlogsEntry blogsEntry) {
19010                    blogsEntry = toUnwrappedModel(blogsEntry);
19011    
19012                    Session session = null;
19013    
19014                    try {
19015                            session = openSession();
19016    
19017                            if (!session.contains(blogsEntry)) {
19018                                    blogsEntry = (BlogsEntry)session.get(BlogsEntryImpl.class,
19019                                                    blogsEntry.getPrimaryKeyObj());
19020                            }
19021    
19022                            if (blogsEntry != null) {
19023                                    session.delete(blogsEntry);
19024                            }
19025                    }
19026                    catch (Exception e) {
19027                            throw processException(e);
19028                    }
19029                    finally {
19030                            closeSession(session);
19031                    }
19032    
19033                    if (blogsEntry != null) {
19034                            clearCache(blogsEntry);
19035                    }
19036    
19037                    return blogsEntry;
19038            }
19039    
19040            @Override
19041            public BlogsEntry updateImpl(BlogsEntry blogsEntry) {
19042                    blogsEntry = toUnwrappedModel(blogsEntry);
19043    
19044                    boolean isNew = blogsEntry.isNew();
19045    
19046                    BlogsEntryModelImpl blogsEntryModelImpl = (BlogsEntryModelImpl)blogsEntry;
19047    
19048                    if (Validator.isNull(blogsEntry.getUuid())) {
19049                            String uuid = PortalUUIDUtil.generate();
19050    
19051                            blogsEntry.setUuid(uuid);
19052                    }
19053    
19054                    ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();
19055    
19056                    Date now = new Date();
19057    
19058                    if (isNew && (blogsEntry.getCreateDate() == null)) {
19059                            if (serviceContext == null) {
19060                                    blogsEntry.setCreateDate(now);
19061                            }
19062                            else {
19063                                    blogsEntry.setCreateDate(serviceContext.getCreateDate(now));
19064                            }
19065                    }
19066    
19067                    if (!blogsEntryModelImpl.hasSetModifiedDate()) {
19068                            if (serviceContext == null) {
19069                                    blogsEntry.setModifiedDate(now);
19070                            }
19071                            else {
19072                                    blogsEntry.setModifiedDate(serviceContext.getModifiedDate(now));
19073                            }
19074                    }
19075    
19076                    long userId = GetterUtil.getLong(PrincipalThreadLocal.getName());
19077    
19078                    if (userId > 0) {
19079                            long companyId = blogsEntry.getCompanyId();
19080    
19081                            long groupId = blogsEntry.getGroupId();
19082    
19083                            long entryId = 0;
19084    
19085                            if (!isNew) {
19086                                    entryId = blogsEntry.getPrimaryKey();
19087                            }
19088    
19089                            try {
19090                                    blogsEntry.setTitle(SanitizerUtil.sanitize(companyId, groupId,
19091                                                    userId,
19092                                                    com.liferay.blogs.kernel.model.BlogsEntry.class.getName(),
19093                                                    entryId, ContentTypes.TEXT_PLAIN, Sanitizer.MODE_ALL,
19094                                                    blogsEntry.getTitle(), null));
19095    
19096                                    blogsEntry.setContent(SanitizerUtil.sanitize(companyId,
19097                                                    groupId, userId,
19098                                                    com.liferay.blogs.kernel.model.BlogsEntry.class.getName(),
19099                                                    entryId, ContentTypes.TEXT_HTML, Sanitizer.MODE_ALL,
19100                                                    blogsEntry.getContent(), null));
19101                            }
19102                            catch (SanitizerException se) {
19103                                    throw new SystemException(se);
19104                            }
19105                    }
19106    
19107                    Session session = null;
19108    
19109                    try {
19110                            session = openSession();
19111    
19112                            if (blogsEntry.isNew()) {
19113                                    session.save(blogsEntry);
19114    
19115                                    blogsEntry.setNew(false);
19116                            }
19117                            else {
19118                                    blogsEntry = (BlogsEntry)session.merge(blogsEntry);
19119                            }
19120                    }
19121                    catch (Exception e) {
19122                            throw processException(e);
19123                    }
19124                    finally {
19125                            closeSession(session);
19126                    }
19127    
19128                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
19129    
19130                    if (isNew || !BlogsEntryModelImpl.COLUMN_BITMASK_ENABLED) {
19131                            finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
19132                    }
19133    
19134                    else {
19135                            if ((blogsEntryModelImpl.getColumnBitmask() &
19136                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
19137                                    Object[] args = new Object[] {
19138                                                    blogsEntryModelImpl.getOriginalUuid()
19139                                            };
19140    
19141                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
19142                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
19143                                            args);
19144    
19145                                    args = new Object[] { blogsEntryModelImpl.getUuid() };
19146    
19147                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
19148                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
19149                                            args);
19150                            }
19151    
19152                            if ((blogsEntryModelImpl.getColumnBitmask() &
19153                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
19154                                    Object[] args = new Object[] {
19155                                                    blogsEntryModelImpl.getOriginalUuid(),
19156                                                    blogsEntryModelImpl.getOriginalCompanyId()
19157                                            };
19158    
19159                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
19160                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
19161                                            args);
19162    
19163                                    args = new Object[] {
19164                                                    blogsEntryModelImpl.getUuid(),
19165                                                    blogsEntryModelImpl.getCompanyId()
19166                                            };
19167    
19168                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
19169                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
19170                                            args);
19171                            }
19172    
19173                            if ((blogsEntryModelImpl.getColumnBitmask() &
19174                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
19175                                    Object[] args = new Object[] {
19176                                                    blogsEntryModelImpl.getOriginalGroupId()
19177                                            };
19178    
19179                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
19180                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
19181                                            args);
19182    
19183                                    args = new Object[] { blogsEntryModelImpl.getGroupId() };
19184    
19185                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
19186                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
19187                                            args);
19188                            }
19189    
19190                            if ((blogsEntryModelImpl.getColumnBitmask() &
19191                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
19192                                    Object[] args = new Object[] {
19193                                                    blogsEntryModelImpl.getOriginalCompanyId()
19194                                            };
19195    
19196                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_COMPANYID, args);
19197                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
19198                                            args);
19199    
19200                                    args = new Object[] { blogsEntryModelImpl.getCompanyId() };
19201    
19202                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_COMPANYID, args);
19203                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
19204                                            args);
19205                            }
19206    
19207                            if ((blogsEntryModelImpl.getColumnBitmask() &
19208                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S.getColumnBitmask()) != 0) {
19209                                    Object[] args = new Object[] {
19210                                                    blogsEntryModelImpl.getOriginalGroupId(),
19211                                                    blogsEntryModelImpl.getOriginalStatus()
19212                                            };
19213    
19214                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
19215                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
19216                                            args);
19217    
19218                                    args = new Object[] {
19219                                                    blogsEntryModelImpl.getGroupId(),
19220                                                    blogsEntryModelImpl.getStatus()
19221                                            };
19222    
19223                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
19224                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
19225                                            args);
19226                            }
19227    
19228                            if ((blogsEntryModelImpl.getColumnBitmask() &
19229                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U.getColumnBitmask()) != 0) {
19230                                    Object[] args = new Object[] {
19231                                                    blogsEntryModelImpl.getOriginalCompanyId(),
19232                                                    blogsEntryModelImpl.getOriginalUserId()
19233                                            };
19234    
19235                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_C_U, args);
19236                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U,
19237                                            args);
19238    
19239                                    args = new Object[] {
19240                                                    blogsEntryModelImpl.getCompanyId(),
19241                                                    blogsEntryModelImpl.getUserId()
19242                                            };
19243    
19244                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_C_U, args);
19245                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U,
19246                                            args);
19247                            }
19248    
19249                            if ((blogsEntryModelImpl.getColumnBitmask() &
19250                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S.getColumnBitmask()) != 0) {
19251                                    Object[] args = new Object[] {
19252                                                    blogsEntryModelImpl.getOriginalCompanyId(),
19253                                                    blogsEntryModelImpl.getOriginalStatus()
19254                                            };
19255    
19256                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_C_S, args);
19257                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S,
19258                                            args);
19259    
19260                                    args = new Object[] {
19261                                                    blogsEntryModelImpl.getCompanyId(),
19262                                                    blogsEntryModelImpl.getStatus()
19263                                            };
19264    
19265                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_C_S, args);
19266                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S,
19267                                            args);
19268                            }
19269    
19270                            if ((blogsEntryModelImpl.getColumnBitmask() &
19271                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S.getColumnBitmask()) != 0) {
19272                                    Object[] args = new Object[] {
19273                                                    blogsEntryModelImpl.getOriginalGroupId(),
19274                                                    blogsEntryModelImpl.getOriginalUserId(),
19275                                                    blogsEntryModelImpl.getOriginalStatus()
19276                                            };
19277    
19278                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_U_S, args);
19279                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S,
19280                                            args);
19281    
19282                                    args = new Object[] {
19283                                                    blogsEntryModelImpl.getGroupId(),
19284                                                    blogsEntryModelImpl.getUserId(),
19285                                                    blogsEntryModelImpl.getStatus()
19286                                            };
19287    
19288                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_U_S, args);
19289                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S,
19290                                            args);
19291                            }
19292    
19293                            if ((blogsEntryModelImpl.getColumnBitmask() &
19294                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U_S.getColumnBitmask()) != 0) {
19295                                    Object[] args = new Object[] {
19296                                                    blogsEntryModelImpl.getOriginalCompanyId(),
19297                                                    blogsEntryModelImpl.getOriginalUserId(),
19298                                                    blogsEntryModelImpl.getOriginalStatus()
19299                                            };
19300    
19301                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_C_U_S, args);
19302                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U_S,
19303                                            args);
19304    
19305                                    args = new Object[] {
19306                                                    blogsEntryModelImpl.getCompanyId(),
19307                                                    blogsEntryModelImpl.getUserId(),
19308                                                    blogsEntryModelImpl.getStatus()
19309                                            };
19310    
19311                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_C_U_S, args);
19312                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U_S,
19313                                            args);
19314                            }
19315                    }
19316    
19317                    entityCache.putResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
19318                            BlogsEntryImpl.class, blogsEntry.getPrimaryKey(), blogsEntry, false);
19319    
19320                    clearUniqueFindersCache(blogsEntryModelImpl);
19321                    cacheUniqueFindersCache(blogsEntryModelImpl, isNew);
19322    
19323                    blogsEntry.resetOriginalValues();
19324    
19325                    return blogsEntry;
19326            }
19327    
19328            protected BlogsEntry toUnwrappedModel(BlogsEntry blogsEntry) {
19329                    if (blogsEntry instanceof BlogsEntryImpl) {
19330                            return blogsEntry;
19331                    }
19332    
19333                    BlogsEntryImpl blogsEntryImpl = new BlogsEntryImpl();
19334    
19335                    blogsEntryImpl.setNew(blogsEntry.isNew());
19336                    blogsEntryImpl.setPrimaryKey(blogsEntry.getPrimaryKey());
19337    
19338                    blogsEntryImpl.setUuid(blogsEntry.getUuid());
19339                    blogsEntryImpl.setEntryId(blogsEntry.getEntryId());
19340                    blogsEntryImpl.setGroupId(blogsEntry.getGroupId());
19341                    blogsEntryImpl.setCompanyId(blogsEntry.getCompanyId());
19342                    blogsEntryImpl.setUserId(blogsEntry.getUserId());
19343                    blogsEntryImpl.setUserName(blogsEntry.getUserName());
19344                    blogsEntryImpl.setCreateDate(blogsEntry.getCreateDate());
19345                    blogsEntryImpl.setModifiedDate(blogsEntry.getModifiedDate());
19346                    blogsEntryImpl.setTitle(blogsEntry.getTitle());
19347                    blogsEntryImpl.setSubtitle(blogsEntry.getSubtitle());
19348                    blogsEntryImpl.setUrlTitle(blogsEntry.getUrlTitle());
19349                    blogsEntryImpl.setDescription(blogsEntry.getDescription());
19350                    blogsEntryImpl.setContent(blogsEntry.getContent());
19351                    blogsEntryImpl.setDisplayDate(blogsEntry.getDisplayDate());
19352                    blogsEntryImpl.setAllowPingbacks(blogsEntry.isAllowPingbacks());
19353                    blogsEntryImpl.setAllowTrackbacks(blogsEntry.isAllowTrackbacks());
19354                    blogsEntryImpl.setTrackbacks(blogsEntry.getTrackbacks());
19355                    blogsEntryImpl.setCoverImageCaption(blogsEntry.getCoverImageCaption());
19356                    blogsEntryImpl.setCoverImageFileEntryId(blogsEntry.getCoverImageFileEntryId());
19357                    blogsEntryImpl.setCoverImageURL(blogsEntry.getCoverImageURL());
19358                    blogsEntryImpl.setSmallImage(blogsEntry.isSmallImage());
19359                    blogsEntryImpl.setSmallImageFileEntryId(blogsEntry.getSmallImageFileEntryId());
19360                    blogsEntryImpl.setSmallImageId(blogsEntry.getSmallImageId());
19361                    blogsEntryImpl.setSmallImageURL(blogsEntry.getSmallImageURL());
19362                    blogsEntryImpl.setLastPublishDate(blogsEntry.getLastPublishDate());
19363                    blogsEntryImpl.setStatus(blogsEntry.getStatus());
19364                    blogsEntryImpl.setStatusByUserId(blogsEntry.getStatusByUserId());
19365                    blogsEntryImpl.setStatusByUserName(blogsEntry.getStatusByUserName());
19366                    blogsEntryImpl.setStatusDate(blogsEntry.getStatusDate());
19367    
19368                    return blogsEntryImpl;
19369            }
19370    
19371            /**
19372             * Returns the blogs entry with the primary key or throws a {@link com.liferay.portal.kernel.exception.NoSuchModelException} if it could not be found.
19373             *
19374             * @param primaryKey the primary key of the blogs entry
19375             * @return the blogs entry
19376             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
19377             */
19378            @Override
19379            public BlogsEntry findByPrimaryKey(Serializable primaryKey)
19380                    throws NoSuchEntryException {
19381                    BlogsEntry blogsEntry = fetchByPrimaryKey(primaryKey);
19382    
19383                    if (blogsEntry == null) {
19384                            if (_log.isWarnEnabled()) {
19385                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
19386                            }
19387    
19388                            throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
19389                                    primaryKey);
19390                    }
19391    
19392                    return blogsEntry;
19393            }
19394    
19395            /**
19396             * Returns the blogs entry with the primary key or throws a {@link NoSuchEntryException} if it could not be found.
19397             *
19398             * @param entryId the primary key of the blogs entry
19399             * @return the blogs entry
19400             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
19401             */
19402            @Override
19403            public BlogsEntry findByPrimaryKey(long entryId)
19404                    throws NoSuchEntryException {
19405                    return findByPrimaryKey((Serializable)entryId);
19406            }
19407    
19408            /**
19409             * Returns the blogs entry with the primary key or returns <code>null</code> if it could not be found.
19410             *
19411             * @param primaryKey the primary key of the blogs entry
19412             * @return the blogs entry, or <code>null</code> if a blogs entry with the primary key could not be found
19413             */
19414            @Override
19415            public BlogsEntry fetchByPrimaryKey(Serializable primaryKey) {
19416                    BlogsEntry blogsEntry = (BlogsEntry)entityCache.getResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
19417                                    BlogsEntryImpl.class, primaryKey);
19418    
19419                    if (blogsEntry == _nullBlogsEntry) {
19420                            return null;
19421                    }
19422    
19423                    if (blogsEntry == null) {
19424                            Session session = null;
19425    
19426                            try {
19427                                    session = openSession();
19428    
19429                                    blogsEntry = (BlogsEntry)session.get(BlogsEntryImpl.class,
19430                                                    primaryKey);
19431    
19432                                    if (blogsEntry != null) {
19433                                            cacheResult(blogsEntry);
19434                                    }
19435                                    else {
19436                                            entityCache.putResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
19437                                                    BlogsEntryImpl.class, primaryKey, _nullBlogsEntry);
19438                                    }
19439                            }
19440                            catch (Exception e) {
19441                                    entityCache.removeResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
19442                                            BlogsEntryImpl.class, primaryKey);
19443    
19444                                    throw processException(e);
19445                            }
19446                            finally {
19447                                    closeSession(session);
19448                            }
19449                    }
19450    
19451                    return blogsEntry;
19452            }
19453    
19454            /**
19455             * Returns the blogs entry with the primary key or returns <code>null</code> if it could not be found.
19456             *
19457             * @param entryId the primary key of the blogs entry
19458             * @return the blogs entry, or <code>null</code> if a blogs entry with the primary key could not be found
19459             */
19460            @Override
19461            public BlogsEntry fetchByPrimaryKey(long entryId) {
19462                    return fetchByPrimaryKey((Serializable)entryId);
19463            }
19464    
19465            @Override
19466            public Map<Serializable, BlogsEntry> fetchByPrimaryKeys(
19467                    Set<Serializable> primaryKeys) {
19468                    if (primaryKeys.isEmpty()) {
19469                            return Collections.emptyMap();
19470                    }
19471    
19472                    Map<Serializable, BlogsEntry> map = new HashMap<Serializable, BlogsEntry>();
19473    
19474                    if (primaryKeys.size() == 1) {
19475                            Iterator<Serializable> iterator = primaryKeys.iterator();
19476    
19477                            Serializable primaryKey = iterator.next();
19478    
19479                            BlogsEntry blogsEntry = fetchByPrimaryKey(primaryKey);
19480    
19481                            if (blogsEntry != null) {
19482                                    map.put(primaryKey, blogsEntry);
19483                            }
19484    
19485                            return map;
19486                    }
19487    
19488                    Set<Serializable> uncachedPrimaryKeys = null;
19489    
19490                    for (Serializable primaryKey : primaryKeys) {
19491                            BlogsEntry blogsEntry = (BlogsEntry)entityCache.getResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
19492                                            BlogsEntryImpl.class, primaryKey);
19493    
19494                            if (blogsEntry == null) {
19495                                    if (uncachedPrimaryKeys == null) {
19496                                            uncachedPrimaryKeys = new HashSet<Serializable>();
19497                                    }
19498    
19499                                    uncachedPrimaryKeys.add(primaryKey);
19500                            }
19501                            else {
19502                                    map.put(primaryKey, blogsEntry);
19503                            }
19504                    }
19505    
19506                    if (uncachedPrimaryKeys == null) {
19507                            return map;
19508                    }
19509    
19510                    StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
19511                                    1);
19512    
19513                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE_PKS_IN);
19514    
19515                    for (Serializable primaryKey : uncachedPrimaryKeys) {
19516                            query.append(String.valueOf(primaryKey));
19517    
19518                            query.append(StringPool.COMMA);
19519                    }
19520    
19521                    query.setIndex(query.index() - 1);
19522    
19523                    query.append(StringPool.CLOSE_PARENTHESIS);
19524    
19525                    String sql = query.toString();
19526    
19527                    Session session = null;
19528    
19529                    try {
19530                            session = openSession();
19531    
19532                            Query q = session.createQuery(sql);
19533    
19534                            for (BlogsEntry blogsEntry : (List<BlogsEntry>)q.list()) {
19535                                    map.put(blogsEntry.getPrimaryKeyObj(), blogsEntry);
19536    
19537                                    cacheResult(blogsEntry);
19538    
19539                                    uncachedPrimaryKeys.remove(blogsEntry.getPrimaryKeyObj());
19540                            }
19541    
19542                            for (Serializable primaryKey : uncachedPrimaryKeys) {
19543                                    entityCache.putResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
19544                                            BlogsEntryImpl.class, primaryKey, _nullBlogsEntry);
19545                            }
19546                    }
19547                    catch (Exception e) {
19548                            throw processException(e);
19549                    }
19550                    finally {
19551                            closeSession(session);
19552                    }
19553    
19554                    return map;
19555            }
19556    
19557            /**
19558             * Returns all the blogs entries.
19559             *
19560             * @return the blogs entries
19561             */
19562            @Override
19563            public List<BlogsEntry> findAll() {
19564                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
19565            }
19566    
19567            /**
19568             * Returns a range of all the blogs entries.
19569             *
19570             * <p>
19571             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
19572             * </p>
19573             *
19574             * @param start the lower bound of the range of blogs entries
19575             * @param end the upper bound of the range of blogs entries (not inclusive)
19576             * @return the range of blogs entries
19577             */
19578            @Override
19579            public List<BlogsEntry> findAll(int start, int end) {
19580                    return findAll(start, end, null);
19581            }
19582    
19583            /**
19584             * Returns an ordered range of all the blogs entries.
19585             *
19586             * <p>
19587             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
19588             * </p>
19589             *
19590             * @param start the lower bound of the range of blogs entries
19591             * @param end the upper bound of the range of blogs entries (not inclusive)
19592             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
19593             * @return the ordered range of blogs entries
19594             */
19595            @Override
19596            public List<BlogsEntry> findAll(int start, int end,
19597                    OrderByComparator<BlogsEntry> orderByComparator) {
19598                    return findAll(start, end, orderByComparator, true);
19599            }
19600    
19601            /**
19602             * Returns an ordered range of all the blogs entries.
19603             *
19604             * <p>
19605             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
19606             * </p>
19607             *
19608             * @param start the lower bound of the range of blogs entries
19609             * @param end the upper bound of the range of blogs entries (not inclusive)
19610             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
19611             * @param retrieveFromCache whether to retrieve from the finder cache
19612             * @return the ordered range of blogs entries
19613             */
19614            @Override
19615            public List<BlogsEntry> findAll(int start, int end,
19616                    OrderByComparator<BlogsEntry> orderByComparator,
19617                    boolean retrieveFromCache) {
19618                    boolean pagination = true;
19619                    FinderPath finderPath = null;
19620                    Object[] finderArgs = null;
19621    
19622                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
19623                                    (orderByComparator == null)) {
19624                            pagination = false;
19625                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
19626                            finderArgs = FINDER_ARGS_EMPTY;
19627                    }
19628                    else {
19629                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
19630                            finderArgs = new Object[] { start, end, orderByComparator };
19631                    }
19632    
19633                    List<BlogsEntry> list = null;
19634    
19635                    if (retrieveFromCache) {
19636                            list = (List<BlogsEntry>)finderCache.getResult(finderPath,
19637                                            finderArgs, this);
19638                    }
19639    
19640                    if (list == null) {
19641                            StringBundler query = null;
19642                            String sql = null;
19643    
19644                            if (orderByComparator != null) {
19645                                    query = new StringBundler(2 +
19646                                                    (orderByComparator.getOrderByFields().length * 2));
19647    
19648                                    query.append(_SQL_SELECT_BLOGSENTRY);
19649    
19650                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
19651                                            orderByComparator);
19652    
19653                                    sql = query.toString();
19654                            }
19655                            else {
19656                                    sql = _SQL_SELECT_BLOGSENTRY;
19657    
19658                                    if (pagination) {
19659                                            sql = sql.concat(BlogsEntryModelImpl.ORDER_BY_JPQL);
19660                                    }
19661                            }
19662    
19663                            Session session = null;
19664    
19665                            try {
19666                                    session = openSession();
19667    
19668                                    Query q = session.createQuery(sql);
19669    
19670                                    if (!pagination) {
19671                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
19672                                                            start, end, false);
19673    
19674                                            Collections.sort(list);
19675    
19676                                            list = Collections.unmodifiableList(list);
19677                                    }
19678                                    else {
19679                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
19680                                                            start, end);
19681                                    }
19682    
19683                                    cacheResult(list);
19684    
19685                                    finderCache.putResult(finderPath, finderArgs, list);
19686                            }
19687                            catch (Exception e) {
19688                                    finderCache.removeResult(finderPath, finderArgs);
19689    
19690                                    throw processException(e);
19691                            }
19692                            finally {
19693                                    closeSession(session);
19694                            }
19695                    }
19696    
19697                    return list;
19698            }
19699    
19700            /**
19701             * Removes all the blogs entries from the database.
19702             *
19703             */
19704            @Override
19705            public void removeAll() {
19706                    for (BlogsEntry blogsEntry : findAll()) {
19707                            remove(blogsEntry);
19708                    }
19709            }
19710    
19711            /**
19712             * Returns the number of blogs entries.
19713             *
19714             * @return the number of blogs entries
19715             */
19716            @Override
19717            public int countAll() {
19718                    Long count = (Long)finderCache.getResult(FINDER_PATH_COUNT_ALL,
19719                                    FINDER_ARGS_EMPTY, this);
19720    
19721                    if (count == null) {
19722                            Session session = null;
19723    
19724                            try {
19725                                    session = openSession();
19726    
19727                                    Query q = session.createQuery(_SQL_COUNT_BLOGSENTRY);
19728    
19729                                    count = (Long)q.uniqueResult();
19730    
19731                                    finderCache.putResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY,
19732                                            count);
19733                            }
19734                            catch (Exception e) {
19735                                    finderCache.removeResult(FINDER_PATH_COUNT_ALL,
19736                                            FINDER_ARGS_EMPTY);
19737    
19738                                    throw processException(e);
19739                            }
19740                            finally {
19741                                    closeSession(session);
19742                            }
19743                    }
19744    
19745                    return count.intValue();
19746            }
19747    
19748            @Override
19749            public Set<String> getBadColumnNames() {
19750                    return _badColumnNames;
19751            }
19752    
19753            @Override
19754            protected Map<String, Integer> getTableColumnsMap() {
19755                    return BlogsEntryModelImpl.TABLE_COLUMNS_MAP;
19756            }
19757    
19758            /**
19759             * Initializes the blogs entry persistence.
19760             */
19761            public void afterPropertiesSet() {
19762            }
19763    
19764            public void destroy() {
19765                    entityCache.removeCache(BlogsEntryImpl.class.getName());
19766                    finderCache.removeCache(FINDER_CLASS_NAME_ENTITY);
19767                    finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
19768                    finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
19769            }
19770    
19771            @BeanReference(type = CompanyProviderWrapper.class)
19772            protected CompanyProvider companyProvider;
19773            protected EntityCache entityCache = EntityCacheUtil.getEntityCache();
19774            protected FinderCache finderCache = FinderCacheUtil.getFinderCache();
19775            private static final String _SQL_SELECT_BLOGSENTRY = "SELECT blogsEntry FROM BlogsEntry blogsEntry";
19776            private static final String _SQL_SELECT_BLOGSENTRY_WHERE_PKS_IN = "SELECT blogsEntry FROM BlogsEntry blogsEntry WHERE entryId IN (";
19777            private static final String _SQL_SELECT_BLOGSENTRY_WHERE = "SELECT blogsEntry FROM BlogsEntry blogsEntry WHERE ";
19778            private static final String _SQL_COUNT_BLOGSENTRY = "SELECT COUNT(blogsEntry) FROM BlogsEntry blogsEntry";
19779            private static final String _SQL_COUNT_BLOGSENTRY_WHERE = "SELECT COUNT(blogsEntry) FROM BlogsEntry blogsEntry WHERE ";
19780            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "blogsEntry.entryId";
19781            private static final String _FILTER_SQL_SELECT_BLOGSENTRY_WHERE = "SELECT DISTINCT {blogsEntry.*} FROM BlogsEntry blogsEntry WHERE ";
19782            private static final String _FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1 =
19783                    "SELECT {BlogsEntry.*} FROM (SELECT DISTINCT blogsEntry.entryId FROM BlogsEntry blogsEntry WHERE ";
19784            private static final String _FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2 =
19785                    ") TEMP_TABLE INNER JOIN BlogsEntry ON TEMP_TABLE.entryId = BlogsEntry.entryId";
19786            private static final String _FILTER_SQL_COUNT_BLOGSENTRY_WHERE = "SELECT COUNT(DISTINCT blogsEntry.entryId) AS COUNT_VALUE FROM BlogsEntry blogsEntry WHERE ";
19787            private static final String _FILTER_ENTITY_ALIAS = "blogsEntry";
19788            private static final String _FILTER_ENTITY_TABLE = "BlogsEntry";
19789            private static final String _ORDER_BY_ENTITY_ALIAS = "blogsEntry.";
19790            private static final String _ORDER_BY_ENTITY_TABLE = "BlogsEntry.";
19791            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No BlogsEntry exists with the primary key ";
19792            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No BlogsEntry exists with the key {";
19793            private static final Log _log = LogFactoryUtil.getLog(BlogsEntryPersistenceImpl.class);
19794            private static final Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
19795                                    "uuid"
19796                            });
19797            private static final BlogsEntry _nullBlogsEntry = new BlogsEntryImpl() {
19798                            @Override
19799                            public Object clone() {
19800                                    return this;
19801                            }
19802    
19803                            @Override
19804                            public CacheModel<BlogsEntry> toCacheModel() {
19805                                    return _nullBlogsEntryCacheModel;
19806                            }
19807                    };
19808    
19809            private static final CacheModel<BlogsEntry> _nullBlogsEntryCacheModel = new CacheModel<BlogsEntry>() {
19810                            @Override
19811                            public BlogsEntry toEntityModel() {
19812                                    return _nullBlogsEntry;
19813                            }
19814                    };
19815    }