001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.blogs.service.persistence.impl;
016    
017    import aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
020    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
021    import com.liferay.portal.kernel.dao.orm.FinderPath;
022    import com.liferay.portal.kernel.dao.orm.Query;
023    import com.liferay.portal.kernel.dao.orm.QueryPos;
024    import com.liferay.portal.kernel.dao.orm.QueryUtil;
025    import com.liferay.portal.kernel.dao.orm.SQLQuery;
026    import com.liferay.portal.kernel.dao.orm.Session;
027    import com.liferay.portal.kernel.exception.SystemException;
028    import com.liferay.portal.kernel.log.Log;
029    import com.liferay.portal.kernel.log.LogFactoryUtil;
030    import com.liferay.portal.kernel.sanitizer.Sanitizer;
031    import com.liferay.portal.kernel.sanitizer.SanitizerException;
032    import com.liferay.portal.kernel.sanitizer.SanitizerUtil;
033    import com.liferay.portal.kernel.util.ContentTypes;
034    import com.liferay.portal.kernel.util.GetterUtil;
035    import com.liferay.portal.kernel.util.OrderByComparator;
036    import com.liferay.portal.kernel.util.SetUtil;
037    import com.liferay.portal.kernel.util.StringBundler;
038    import com.liferay.portal.kernel.util.StringPool;
039    import com.liferay.portal.kernel.util.Validator;
040    import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
041    import com.liferay.portal.model.CacheModel;
042    import com.liferay.portal.security.auth.PrincipalThreadLocal;
043    import com.liferay.portal.security.permission.InlineSQLHelperUtil;
044    import com.liferay.portal.service.ServiceContext;
045    import com.liferay.portal.service.ServiceContextThreadLocal;
046    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
047    
048    import com.liferay.portlet.blogs.NoSuchEntryException;
049    import com.liferay.portlet.blogs.model.BlogsEntry;
050    import com.liferay.portlet.blogs.model.impl.BlogsEntryImpl;
051    import com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl;
052    import com.liferay.portlet.blogs.service.persistence.BlogsEntryPersistence;
053    
054    import java.io.Serializable;
055    
056    import java.sql.Timestamp;
057    
058    import java.util.Collections;
059    import java.util.Date;
060    import java.util.HashMap;
061    import java.util.HashSet;
062    import java.util.Iterator;
063    import java.util.List;
064    import java.util.Map;
065    import java.util.Set;
066    
067    /**
068     * The persistence implementation for the blogs entry service.
069     *
070     * <p>
071     * Caching information and settings can be found in <code>portal.properties</code>
072     * </p>
073     *
074     * @author Brian Wing Shun Chan
075     * @see BlogsEntryPersistence
076     * @see com.liferay.portlet.blogs.service.persistence.BlogsEntryUtil
077     * @generated
078     */
079    @ProviderType
080    public class BlogsEntryPersistenceImpl extends BasePersistenceImpl<BlogsEntry>
081            implements BlogsEntryPersistence {
082            /*
083             * NOTE FOR DEVELOPERS:
084             *
085             * 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.
086             */
087            public static final String FINDER_CLASS_NAME_ENTITY = BlogsEntryImpl.class.getName();
088            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
089                    ".List1";
090            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
091                    ".List2";
092            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
093                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
094                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
095            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
096                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
097                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
098            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
099                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
100                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
101            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
102                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
103                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
104                            new String[] {
105                                    String.class.getName(),
106                                    
107                            Integer.class.getName(), Integer.class.getName(),
108                                    OrderByComparator.class.getName()
109                            });
110            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
111                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
112                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
113                            new String[] { String.class.getName() },
114                            BlogsEntryModelImpl.UUID_COLUMN_BITMASK |
115                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
116                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
117            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
118                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
119                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
120                            new String[] { String.class.getName() });
121    
122            /**
123             * Returns all the blogs entries where uuid = &#63;.
124             *
125             * @param uuid the uuid
126             * @return the matching blogs entries
127             */
128            @Override
129            public List<BlogsEntry> findByUuid(String uuid) {
130                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
131            }
132    
133            /**
134             * Returns a range of all the blogs entries where uuid = &#63;.
135             *
136             * <p>
137             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
138             * </p>
139             *
140             * @param uuid the uuid
141             * @param start the lower bound of the range of blogs entries
142             * @param end the upper bound of the range of blogs entries (not inclusive)
143             * @return the range of matching blogs entries
144             */
145            @Override
146            public List<BlogsEntry> findByUuid(String uuid, int start, int end) {
147                    return findByUuid(uuid, start, end, null);
148            }
149    
150            /**
151             * Returns an ordered range of all the blogs entries where uuid = &#63;.
152             *
153             * <p>
154             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
155             * </p>
156             *
157             * @param uuid the uuid
158             * @param start the lower bound of the range of blogs entries
159             * @param end the upper bound of the range of blogs entries (not inclusive)
160             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
161             * @return the ordered range of matching blogs entries
162             */
163            @Override
164            public List<BlogsEntry> findByUuid(String uuid, int start, int end,
165                    OrderByComparator<BlogsEntry> orderByComparator) {
166                    boolean pagination = true;
167                    FinderPath finderPath = null;
168                    Object[] finderArgs = null;
169    
170                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
171                                    (orderByComparator == null)) {
172                            pagination = false;
173                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
174                            finderArgs = new Object[] { uuid };
175                    }
176                    else {
177                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
178                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
179                    }
180    
181                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
182                                    finderArgs, this);
183    
184                    if ((list != null) && !list.isEmpty()) {
185                            for (BlogsEntry blogsEntry : list) {
186                                    if (!Validator.equals(uuid, blogsEntry.getUuid())) {
187                                            list = null;
188    
189                                            break;
190                                    }
191                            }
192                    }
193    
194                    if (list == null) {
195                            StringBundler query = null;
196    
197                            if (orderByComparator != null) {
198                                    query = new StringBundler(3 +
199                                                    (orderByComparator.getOrderByFields().length * 3));
200                            }
201                            else {
202                                    query = new StringBundler(3);
203                            }
204    
205                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
206    
207                            boolean bindUuid = false;
208    
209                            if (uuid == null) {
210                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
211                            }
212                            else if (uuid.equals(StringPool.BLANK)) {
213                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
214                            }
215                            else {
216                                    bindUuid = true;
217    
218                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
219                            }
220    
221                            if (orderByComparator != null) {
222                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
223                                            orderByComparator);
224                            }
225                            else
226                             if (pagination) {
227                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
228                            }
229    
230                            String sql = query.toString();
231    
232                            Session session = null;
233    
234                            try {
235                                    session = openSession();
236    
237                                    Query q = session.createQuery(sql);
238    
239                                    QueryPos qPos = QueryPos.getInstance(q);
240    
241                                    if (bindUuid) {
242                                            qPos.add(uuid);
243                                    }
244    
245                                    if (!pagination) {
246                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
247                                                            start, end, false);
248    
249                                            Collections.sort(list);
250    
251                                            list = Collections.unmodifiableList(list);
252                                    }
253                                    else {
254                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
255                                                            start, end);
256                                    }
257    
258                                    cacheResult(list);
259    
260                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
261                            }
262                            catch (Exception e) {
263                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
264    
265                                    throw processException(e);
266                            }
267                            finally {
268                                    closeSession(session);
269                            }
270                    }
271    
272                    return list;
273            }
274    
275            /**
276             * Returns the first blogs entry in the ordered set where uuid = &#63;.
277             *
278             * @param uuid the uuid
279             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
280             * @return the first matching blogs entry
281             * @throws NoSuchEntryException if a matching blogs entry could not be found
282             */
283            @Override
284            public BlogsEntry findByUuid_First(String uuid,
285                    OrderByComparator<BlogsEntry> orderByComparator)
286                    throws NoSuchEntryException {
287                    BlogsEntry blogsEntry = fetchByUuid_First(uuid, orderByComparator);
288    
289                    if (blogsEntry != null) {
290                            return blogsEntry;
291                    }
292    
293                    StringBundler msg = new StringBundler(4);
294    
295                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
296    
297                    msg.append("uuid=");
298                    msg.append(uuid);
299    
300                    msg.append(StringPool.CLOSE_CURLY_BRACE);
301    
302                    throw new NoSuchEntryException(msg.toString());
303            }
304    
305            /**
306             * Returns the first blogs entry in the ordered set where uuid = &#63;.
307             *
308             * @param uuid the uuid
309             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
310             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
311             */
312            @Override
313            public BlogsEntry fetchByUuid_First(String uuid,
314                    OrderByComparator<BlogsEntry> orderByComparator) {
315                    List<BlogsEntry> list = findByUuid(uuid, 0, 1, orderByComparator);
316    
317                    if (!list.isEmpty()) {
318                            return list.get(0);
319                    }
320    
321                    return null;
322            }
323    
324            /**
325             * Returns the last blogs entry in the ordered set where uuid = &#63;.
326             *
327             * @param uuid the uuid
328             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
329             * @return the last matching blogs entry
330             * @throws NoSuchEntryException if a matching blogs entry could not be found
331             */
332            @Override
333            public BlogsEntry findByUuid_Last(String uuid,
334                    OrderByComparator<BlogsEntry> orderByComparator)
335                    throws NoSuchEntryException {
336                    BlogsEntry blogsEntry = fetchByUuid_Last(uuid, orderByComparator);
337    
338                    if (blogsEntry != null) {
339                            return blogsEntry;
340                    }
341    
342                    StringBundler msg = new StringBundler(4);
343    
344                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
345    
346                    msg.append("uuid=");
347                    msg.append(uuid);
348    
349                    msg.append(StringPool.CLOSE_CURLY_BRACE);
350    
351                    throw new NoSuchEntryException(msg.toString());
352            }
353    
354            /**
355             * Returns the last blogs entry in the ordered set where uuid = &#63;.
356             *
357             * @param uuid the uuid
358             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
359             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
360             */
361            @Override
362            public BlogsEntry fetchByUuid_Last(String uuid,
363                    OrderByComparator<BlogsEntry> orderByComparator) {
364                    int count = countByUuid(uuid);
365    
366                    if (count == 0) {
367                            return null;
368                    }
369    
370                    List<BlogsEntry> list = findByUuid(uuid, count - 1, count,
371                                    orderByComparator);
372    
373                    if (!list.isEmpty()) {
374                            return list.get(0);
375                    }
376    
377                    return null;
378            }
379    
380            /**
381             * Returns the blogs entries before and after the current blogs entry in the ordered set where uuid = &#63;.
382             *
383             * @param entryId the primary key of the current blogs entry
384             * @param uuid the uuid
385             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
386             * @return the previous, current, and next blogs entry
387             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
388             */
389            @Override
390            public BlogsEntry[] findByUuid_PrevAndNext(long entryId, String uuid,
391                    OrderByComparator<BlogsEntry> orderByComparator)
392                    throws NoSuchEntryException {
393                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
394    
395                    Session session = null;
396    
397                    try {
398                            session = openSession();
399    
400                            BlogsEntry[] array = new BlogsEntryImpl[3];
401    
402                            array[0] = getByUuid_PrevAndNext(session, blogsEntry, uuid,
403                                            orderByComparator, true);
404    
405                            array[1] = blogsEntry;
406    
407                            array[2] = getByUuid_PrevAndNext(session, blogsEntry, uuid,
408                                            orderByComparator, false);
409    
410                            return array;
411                    }
412                    catch (Exception e) {
413                            throw processException(e);
414                    }
415                    finally {
416                            closeSession(session);
417                    }
418            }
419    
420            protected BlogsEntry getByUuid_PrevAndNext(Session session,
421                    BlogsEntry blogsEntry, String uuid,
422                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
423                    StringBundler query = null;
424    
425                    if (orderByComparator != null) {
426                            query = new StringBundler(6 +
427                                            (orderByComparator.getOrderByFields().length * 6));
428                    }
429                    else {
430                            query = new StringBundler(3);
431                    }
432    
433                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
434    
435                    boolean bindUuid = false;
436    
437                    if (uuid == null) {
438                            query.append(_FINDER_COLUMN_UUID_UUID_1);
439                    }
440                    else if (uuid.equals(StringPool.BLANK)) {
441                            query.append(_FINDER_COLUMN_UUID_UUID_3);
442                    }
443                    else {
444                            bindUuid = true;
445    
446                            query.append(_FINDER_COLUMN_UUID_UUID_2);
447                    }
448    
449                    if (orderByComparator != null) {
450                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
451    
452                            if (orderByConditionFields.length > 0) {
453                                    query.append(WHERE_AND);
454                            }
455    
456                            for (int i = 0; i < orderByConditionFields.length; i++) {
457                                    query.append(_ORDER_BY_ENTITY_ALIAS);
458                                    query.append(orderByConditionFields[i]);
459    
460                                    if ((i + 1) < orderByConditionFields.length) {
461                                            if (orderByComparator.isAscending() ^ previous) {
462                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
463                                            }
464                                            else {
465                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
466                                            }
467                                    }
468                                    else {
469                                            if (orderByComparator.isAscending() ^ previous) {
470                                                    query.append(WHERE_GREATER_THAN);
471                                            }
472                                            else {
473                                                    query.append(WHERE_LESSER_THAN);
474                                            }
475                                    }
476                            }
477    
478                            query.append(ORDER_BY_CLAUSE);
479    
480                            String[] orderByFields = orderByComparator.getOrderByFields();
481    
482                            for (int i = 0; i < orderByFields.length; i++) {
483                                    query.append(_ORDER_BY_ENTITY_ALIAS);
484                                    query.append(orderByFields[i]);
485    
486                                    if ((i + 1) < orderByFields.length) {
487                                            if (orderByComparator.isAscending() ^ previous) {
488                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
489                                            }
490                                            else {
491                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
492                                            }
493                                    }
494                                    else {
495                                            if (orderByComparator.isAscending() ^ previous) {
496                                                    query.append(ORDER_BY_ASC);
497                                            }
498                                            else {
499                                                    query.append(ORDER_BY_DESC);
500                                            }
501                                    }
502                            }
503                    }
504                    else {
505                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
506                    }
507    
508                    String sql = query.toString();
509    
510                    Query q = session.createQuery(sql);
511    
512                    q.setFirstResult(0);
513                    q.setMaxResults(2);
514    
515                    QueryPos qPos = QueryPos.getInstance(q);
516    
517                    if (bindUuid) {
518                            qPos.add(uuid);
519                    }
520    
521                    if (orderByComparator != null) {
522                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
523    
524                            for (Object value : values) {
525                                    qPos.add(value);
526                            }
527                    }
528    
529                    List<BlogsEntry> list = q.list();
530    
531                    if (list.size() == 2) {
532                            return list.get(1);
533                    }
534                    else {
535                            return null;
536                    }
537            }
538    
539            /**
540             * Removes all the blogs entries where uuid = &#63; from the database.
541             *
542             * @param uuid the uuid
543             */
544            @Override
545            public void removeByUuid(String uuid) {
546                    for (BlogsEntry blogsEntry : findByUuid(uuid, QueryUtil.ALL_POS,
547                                    QueryUtil.ALL_POS, null)) {
548                            remove(blogsEntry);
549                    }
550            }
551    
552            /**
553             * Returns the number of blogs entries where uuid = &#63;.
554             *
555             * @param uuid the uuid
556             * @return the number of matching blogs entries
557             */
558            @Override
559            public int countByUuid(String uuid) {
560                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
561    
562                    Object[] finderArgs = new Object[] { uuid };
563    
564                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
565                                    this);
566    
567                    if (count == null) {
568                            StringBundler query = new StringBundler(2);
569    
570                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
571    
572                            boolean bindUuid = false;
573    
574                            if (uuid == null) {
575                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
576                            }
577                            else if (uuid.equals(StringPool.BLANK)) {
578                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
579                            }
580                            else {
581                                    bindUuid = true;
582    
583                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
584                            }
585    
586                            String sql = query.toString();
587    
588                            Session session = null;
589    
590                            try {
591                                    session = openSession();
592    
593                                    Query q = session.createQuery(sql);
594    
595                                    QueryPos qPos = QueryPos.getInstance(q);
596    
597                                    if (bindUuid) {
598                                            qPos.add(uuid);
599                                    }
600    
601                                    count = (Long)q.uniqueResult();
602    
603                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
604                            }
605                            catch (Exception e) {
606                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
607    
608                                    throw processException(e);
609                            }
610                            finally {
611                                    closeSession(session);
612                            }
613                    }
614    
615                    return count.intValue();
616            }
617    
618            private static final String _FINDER_COLUMN_UUID_UUID_1 = "blogsEntry.uuid IS NULL";
619            private static final String _FINDER_COLUMN_UUID_UUID_2 = "blogsEntry.uuid = ?";
620            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(blogsEntry.uuid IS NULL OR blogsEntry.uuid = '')";
621            public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
622                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
623                            FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
624                            new String[] { String.class.getName(), Long.class.getName() },
625                            BlogsEntryModelImpl.UUID_COLUMN_BITMASK |
626                            BlogsEntryModelImpl.GROUPID_COLUMN_BITMASK);
627            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
628                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
629                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
630                            new String[] { String.class.getName(), Long.class.getName() });
631    
632            /**
633             * Returns the blogs entry where uuid = &#63; and groupId = &#63; or throws a {@link NoSuchEntryException} if it could not be found.
634             *
635             * @param uuid the uuid
636             * @param groupId the group ID
637             * @return the matching blogs entry
638             * @throws NoSuchEntryException if a matching blogs entry could not be found
639             */
640            @Override
641            public BlogsEntry findByUUID_G(String uuid, long groupId)
642                    throws NoSuchEntryException {
643                    BlogsEntry blogsEntry = fetchByUUID_G(uuid, groupId);
644    
645                    if (blogsEntry == null) {
646                            StringBundler msg = new StringBundler(6);
647    
648                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
649    
650                            msg.append("uuid=");
651                            msg.append(uuid);
652    
653                            msg.append(", groupId=");
654                            msg.append(groupId);
655    
656                            msg.append(StringPool.CLOSE_CURLY_BRACE);
657    
658                            if (_log.isWarnEnabled()) {
659                                    _log.warn(msg.toString());
660                            }
661    
662                            throw new NoSuchEntryException(msg.toString());
663                    }
664    
665                    return blogsEntry;
666            }
667    
668            /**
669             * 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.
670             *
671             * @param uuid the uuid
672             * @param groupId the group ID
673             * @return the matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
674             */
675            @Override
676            public BlogsEntry fetchByUUID_G(String uuid, long groupId) {
677                    return fetchByUUID_G(uuid, groupId, true);
678            }
679    
680            /**
681             * 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.
682             *
683             * @param uuid the uuid
684             * @param groupId the group ID
685             * @param retrieveFromCache whether to use the finder cache
686             * @return the matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
687             */
688            @Override
689            public BlogsEntry fetchByUUID_G(String uuid, long groupId,
690                    boolean retrieveFromCache) {
691                    Object[] finderArgs = new Object[] { uuid, groupId };
692    
693                    Object result = null;
694    
695                    if (retrieveFromCache) {
696                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
697                                            finderArgs, this);
698                    }
699    
700                    if (result instanceof BlogsEntry) {
701                            BlogsEntry blogsEntry = (BlogsEntry)result;
702    
703                            if (!Validator.equals(uuid, blogsEntry.getUuid()) ||
704                                            (groupId != blogsEntry.getGroupId())) {
705                                    result = null;
706                            }
707                    }
708    
709                    if (result == null) {
710                            StringBundler query = new StringBundler(4);
711    
712                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
713    
714                            boolean bindUuid = false;
715    
716                            if (uuid == null) {
717                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
718                            }
719                            else if (uuid.equals(StringPool.BLANK)) {
720                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
721                            }
722                            else {
723                                    bindUuid = true;
724    
725                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
726                            }
727    
728                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
729    
730                            String sql = query.toString();
731    
732                            Session session = null;
733    
734                            try {
735                                    session = openSession();
736    
737                                    Query q = session.createQuery(sql);
738    
739                                    QueryPos qPos = QueryPos.getInstance(q);
740    
741                                    if (bindUuid) {
742                                            qPos.add(uuid);
743                                    }
744    
745                                    qPos.add(groupId);
746    
747                                    List<BlogsEntry> list = q.list();
748    
749                                    if (list.isEmpty()) {
750                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
751                                                    finderArgs, list);
752                                    }
753                                    else {
754                                            BlogsEntry blogsEntry = list.get(0);
755    
756                                            result = blogsEntry;
757    
758                                            cacheResult(blogsEntry);
759    
760                                            if ((blogsEntry.getUuid() == null) ||
761                                                            !blogsEntry.getUuid().equals(uuid) ||
762                                                            (blogsEntry.getGroupId() != groupId)) {
763                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
764                                                            finderArgs, blogsEntry);
765                                            }
766                                    }
767                            }
768                            catch (Exception e) {
769                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
770                                            finderArgs);
771    
772                                    throw processException(e);
773                            }
774                            finally {
775                                    closeSession(session);
776                            }
777                    }
778    
779                    if (result instanceof List<?>) {
780                            return null;
781                    }
782                    else {
783                            return (BlogsEntry)result;
784                    }
785            }
786    
787            /**
788             * Removes the blogs entry where uuid = &#63; and groupId = &#63; from the database.
789             *
790             * @param uuid the uuid
791             * @param groupId the group ID
792             * @return the blogs entry that was removed
793             */
794            @Override
795            public BlogsEntry removeByUUID_G(String uuid, long groupId)
796                    throws NoSuchEntryException {
797                    BlogsEntry blogsEntry = findByUUID_G(uuid, groupId);
798    
799                    return remove(blogsEntry);
800            }
801    
802            /**
803             * Returns the number of blogs entries where uuid = &#63; and groupId = &#63;.
804             *
805             * @param uuid the uuid
806             * @param groupId the group ID
807             * @return the number of matching blogs entries
808             */
809            @Override
810            public int countByUUID_G(String uuid, long groupId) {
811                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_G;
812    
813                    Object[] finderArgs = new Object[] { uuid, groupId };
814    
815                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
816                                    this);
817    
818                    if (count == null) {
819                            StringBundler query = new StringBundler(3);
820    
821                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
822    
823                            boolean bindUuid = false;
824    
825                            if (uuid == null) {
826                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
827                            }
828                            else if (uuid.equals(StringPool.BLANK)) {
829                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
830                            }
831                            else {
832                                    bindUuid = true;
833    
834                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
835                            }
836    
837                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
838    
839                            String sql = query.toString();
840    
841                            Session session = null;
842    
843                            try {
844                                    session = openSession();
845    
846                                    Query q = session.createQuery(sql);
847    
848                                    QueryPos qPos = QueryPos.getInstance(q);
849    
850                                    if (bindUuid) {
851                                            qPos.add(uuid);
852                                    }
853    
854                                    qPos.add(groupId);
855    
856                                    count = (Long)q.uniqueResult();
857    
858                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
859                            }
860                            catch (Exception e) {
861                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
862    
863                                    throw processException(e);
864                            }
865                            finally {
866                                    closeSession(session);
867                            }
868                    }
869    
870                    return count.intValue();
871            }
872    
873            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "blogsEntry.uuid IS NULL AND ";
874            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "blogsEntry.uuid = ? AND ";
875            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(blogsEntry.uuid IS NULL OR blogsEntry.uuid = '') AND ";
876            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "blogsEntry.groupId = ?";
877            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
878                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
879                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C",
880                            new String[] {
881                                    String.class.getName(), Long.class.getName(),
882                                    
883                            Integer.class.getName(), Integer.class.getName(),
884                                    OrderByComparator.class.getName()
885                            });
886            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
887                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
888                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
889                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
890                            new String[] { String.class.getName(), Long.class.getName() },
891                            BlogsEntryModelImpl.UUID_COLUMN_BITMASK |
892                            BlogsEntryModelImpl.COMPANYID_COLUMN_BITMASK |
893                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
894                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
895            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
896                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
897                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
898                            new String[] { String.class.getName(), Long.class.getName() });
899    
900            /**
901             * Returns all the blogs entries where uuid = &#63; and companyId = &#63;.
902             *
903             * @param uuid the uuid
904             * @param companyId the company ID
905             * @return the matching blogs entries
906             */
907            @Override
908            public List<BlogsEntry> findByUuid_C(String uuid, long companyId) {
909                    return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
910                            QueryUtil.ALL_POS, null);
911            }
912    
913            /**
914             * Returns a range of all the blogs entries where uuid = &#63; and companyId = &#63;.
915             *
916             * <p>
917             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
918             * </p>
919             *
920             * @param uuid the uuid
921             * @param companyId the company ID
922             * @param start the lower bound of the range of blogs entries
923             * @param end the upper bound of the range of blogs entries (not inclusive)
924             * @return the range of matching blogs entries
925             */
926            @Override
927            public List<BlogsEntry> findByUuid_C(String uuid, long companyId,
928                    int start, int end) {
929                    return findByUuid_C(uuid, companyId, start, end, null);
930            }
931    
932            /**
933             * Returns an ordered range of all the blogs entries where uuid = &#63; and companyId = &#63;.
934             *
935             * <p>
936             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
937             * </p>
938             *
939             * @param uuid the uuid
940             * @param companyId the company ID
941             * @param start the lower bound of the range of blogs entries
942             * @param end the upper bound of the range of blogs entries (not inclusive)
943             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
944             * @return the ordered range of matching blogs entries
945             */
946            @Override
947            public List<BlogsEntry> findByUuid_C(String uuid, long companyId,
948                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator) {
949                    boolean pagination = true;
950                    FinderPath finderPath = null;
951                    Object[] finderArgs = null;
952    
953                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
954                                    (orderByComparator == null)) {
955                            pagination = false;
956                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
957                            finderArgs = new Object[] { uuid, companyId };
958                    }
959                    else {
960                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
961                            finderArgs = new Object[] {
962                                            uuid, companyId,
963                                            
964                                            start, end, orderByComparator
965                                    };
966                    }
967    
968                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
969                                    finderArgs, this);
970    
971                    if ((list != null) && !list.isEmpty()) {
972                            for (BlogsEntry blogsEntry : list) {
973                                    if (!Validator.equals(uuid, blogsEntry.getUuid()) ||
974                                                    (companyId != blogsEntry.getCompanyId())) {
975                                            list = null;
976    
977                                            break;
978                                    }
979                            }
980                    }
981    
982                    if (list == null) {
983                            StringBundler query = null;
984    
985                            if (orderByComparator != null) {
986                                    query = new StringBundler(4 +
987                                                    (orderByComparator.getOrderByFields().length * 3));
988                            }
989                            else {
990                                    query = new StringBundler(4);
991                            }
992    
993                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
994    
995                            boolean bindUuid = false;
996    
997                            if (uuid == null) {
998                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
999                            }
1000                            else if (uuid.equals(StringPool.BLANK)) {
1001                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1002                            }
1003                            else {
1004                                    bindUuid = true;
1005    
1006                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1007                            }
1008    
1009                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1010    
1011                            if (orderByComparator != null) {
1012                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1013                                            orderByComparator);
1014                            }
1015                            else
1016                             if (pagination) {
1017                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
1018                            }
1019    
1020                            String sql = query.toString();
1021    
1022                            Session session = null;
1023    
1024                            try {
1025                                    session = openSession();
1026    
1027                                    Query q = session.createQuery(sql);
1028    
1029                                    QueryPos qPos = QueryPos.getInstance(q);
1030    
1031                                    if (bindUuid) {
1032                                            qPos.add(uuid);
1033                                    }
1034    
1035                                    qPos.add(companyId);
1036    
1037                                    if (!pagination) {
1038                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
1039                                                            start, end, false);
1040    
1041                                            Collections.sort(list);
1042    
1043                                            list = Collections.unmodifiableList(list);
1044                                    }
1045                                    else {
1046                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
1047                                                            start, end);
1048                                    }
1049    
1050                                    cacheResult(list);
1051    
1052                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1053                            }
1054                            catch (Exception e) {
1055                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1056    
1057                                    throw processException(e);
1058                            }
1059                            finally {
1060                                    closeSession(session);
1061                            }
1062                    }
1063    
1064                    return list;
1065            }
1066    
1067            /**
1068             * Returns the first blogs entry in the ordered set where uuid = &#63; and companyId = &#63;.
1069             *
1070             * @param uuid the uuid
1071             * @param companyId the company ID
1072             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1073             * @return the first matching blogs entry
1074             * @throws NoSuchEntryException if a matching blogs entry could not be found
1075             */
1076            @Override
1077            public BlogsEntry findByUuid_C_First(String uuid, long companyId,
1078                    OrderByComparator<BlogsEntry> orderByComparator)
1079                    throws NoSuchEntryException {
1080                    BlogsEntry blogsEntry = fetchByUuid_C_First(uuid, companyId,
1081                                    orderByComparator);
1082    
1083                    if (blogsEntry != null) {
1084                            return blogsEntry;
1085                    }
1086    
1087                    StringBundler msg = new StringBundler(6);
1088    
1089                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1090    
1091                    msg.append("uuid=");
1092                    msg.append(uuid);
1093    
1094                    msg.append(", companyId=");
1095                    msg.append(companyId);
1096    
1097                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1098    
1099                    throw new NoSuchEntryException(msg.toString());
1100            }
1101    
1102            /**
1103             * Returns the first blogs entry in the ordered set where uuid = &#63; and companyId = &#63;.
1104             *
1105             * @param uuid the uuid
1106             * @param companyId the company ID
1107             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1108             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
1109             */
1110            @Override
1111            public BlogsEntry fetchByUuid_C_First(String uuid, long companyId,
1112                    OrderByComparator<BlogsEntry> orderByComparator) {
1113                    List<BlogsEntry> list = findByUuid_C(uuid, companyId, 0, 1,
1114                                    orderByComparator);
1115    
1116                    if (!list.isEmpty()) {
1117                            return list.get(0);
1118                    }
1119    
1120                    return null;
1121            }
1122    
1123            /**
1124             * Returns the last blogs entry in the ordered set where uuid = &#63; and companyId = &#63;.
1125             *
1126             * @param uuid the uuid
1127             * @param companyId the company ID
1128             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1129             * @return the last matching blogs entry
1130             * @throws NoSuchEntryException if a matching blogs entry could not be found
1131             */
1132            @Override
1133            public BlogsEntry findByUuid_C_Last(String uuid, long companyId,
1134                    OrderByComparator<BlogsEntry> orderByComparator)
1135                    throws NoSuchEntryException {
1136                    BlogsEntry blogsEntry = fetchByUuid_C_Last(uuid, companyId,
1137                                    orderByComparator);
1138    
1139                    if (blogsEntry != null) {
1140                            return blogsEntry;
1141                    }
1142    
1143                    StringBundler msg = new StringBundler(6);
1144    
1145                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1146    
1147                    msg.append("uuid=");
1148                    msg.append(uuid);
1149    
1150                    msg.append(", companyId=");
1151                    msg.append(companyId);
1152    
1153                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1154    
1155                    throw new NoSuchEntryException(msg.toString());
1156            }
1157    
1158            /**
1159             * Returns the last blogs entry in the ordered set where uuid = &#63; and companyId = &#63;.
1160             *
1161             * @param uuid the uuid
1162             * @param companyId the company ID
1163             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1164             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
1165             */
1166            @Override
1167            public BlogsEntry fetchByUuid_C_Last(String uuid, long companyId,
1168                    OrderByComparator<BlogsEntry> orderByComparator) {
1169                    int count = countByUuid_C(uuid, companyId);
1170    
1171                    if (count == 0) {
1172                            return null;
1173                    }
1174    
1175                    List<BlogsEntry> list = findByUuid_C(uuid, companyId, count - 1, count,
1176                                    orderByComparator);
1177    
1178                    if (!list.isEmpty()) {
1179                            return list.get(0);
1180                    }
1181    
1182                    return null;
1183            }
1184    
1185            /**
1186             * Returns the blogs entries before and after the current blogs entry in the ordered set where uuid = &#63; and companyId = &#63;.
1187             *
1188             * @param entryId the primary key of the current blogs entry
1189             * @param uuid the uuid
1190             * @param companyId the company ID
1191             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1192             * @return the previous, current, and next blogs entry
1193             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
1194             */
1195            @Override
1196            public BlogsEntry[] findByUuid_C_PrevAndNext(long entryId, String uuid,
1197                    long companyId, OrderByComparator<BlogsEntry> orderByComparator)
1198                    throws NoSuchEntryException {
1199                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
1200    
1201                    Session session = null;
1202    
1203                    try {
1204                            session = openSession();
1205    
1206                            BlogsEntry[] array = new BlogsEntryImpl[3];
1207    
1208                            array[0] = getByUuid_C_PrevAndNext(session, blogsEntry, uuid,
1209                                            companyId, orderByComparator, true);
1210    
1211                            array[1] = blogsEntry;
1212    
1213                            array[2] = getByUuid_C_PrevAndNext(session, blogsEntry, uuid,
1214                                            companyId, orderByComparator, false);
1215    
1216                            return array;
1217                    }
1218                    catch (Exception e) {
1219                            throw processException(e);
1220                    }
1221                    finally {
1222                            closeSession(session);
1223                    }
1224            }
1225    
1226            protected BlogsEntry getByUuid_C_PrevAndNext(Session session,
1227                    BlogsEntry blogsEntry, String uuid, long companyId,
1228                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
1229                    StringBundler query = null;
1230    
1231                    if (orderByComparator != null) {
1232                            query = new StringBundler(6 +
1233                                            (orderByComparator.getOrderByFields().length * 6));
1234                    }
1235                    else {
1236                            query = new StringBundler(3);
1237                    }
1238    
1239                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
1240    
1241                    boolean bindUuid = false;
1242    
1243                    if (uuid == null) {
1244                            query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1245                    }
1246                    else if (uuid.equals(StringPool.BLANK)) {
1247                            query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1248                    }
1249                    else {
1250                            bindUuid = true;
1251    
1252                            query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1253                    }
1254    
1255                    query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1256    
1257                    if (orderByComparator != null) {
1258                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1259    
1260                            if (orderByConditionFields.length > 0) {
1261                                    query.append(WHERE_AND);
1262                            }
1263    
1264                            for (int i = 0; i < orderByConditionFields.length; i++) {
1265                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1266                                    query.append(orderByConditionFields[i]);
1267    
1268                                    if ((i + 1) < orderByConditionFields.length) {
1269                                            if (orderByComparator.isAscending() ^ previous) {
1270                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1271                                            }
1272                                            else {
1273                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1274                                            }
1275                                    }
1276                                    else {
1277                                            if (orderByComparator.isAscending() ^ previous) {
1278                                                    query.append(WHERE_GREATER_THAN);
1279                                            }
1280                                            else {
1281                                                    query.append(WHERE_LESSER_THAN);
1282                                            }
1283                                    }
1284                            }
1285    
1286                            query.append(ORDER_BY_CLAUSE);
1287    
1288                            String[] orderByFields = orderByComparator.getOrderByFields();
1289    
1290                            for (int i = 0; i < orderByFields.length; i++) {
1291                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1292                                    query.append(orderByFields[i]);
1293    
1294                                    if ((i + 1) < orderByFields.length) {
1295                                            if (orderByComparator.isAscending() ^ previous) {
1296                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1297                                            }
1298                                            else {
1299                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1300                                            }
1301                                    }
1302                                    else {
1303                                            if (orderByComparator.isAscending() ^ previous) {
1304                                                    query.append(ORDER_BY_ASC);
1305                                            }
1306                                            else {
1307                                                    query.append(ORDER_BY_DESC);
1308                                            }
1309                                    }
1310                            }
1311                    }
1312                    else {
1313                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
1314                    }
1315    
1316                    String sql = query.toString();
1317    
1318                    Query q = session.createQuery(sql);
1319    
1320                    q.setFirstResult(0);
1321                    q.setMaxResults(2);
1322    
1323                    QueryPos qPos = QueryPos.getInstance(q);
1324    
1325                    if (bindUuid) {
1326                            qPos.add(uuid);
1327                    }
1328    
1329                    qPos.add(companyId);
1330    
1331                    if (orderByComparator != null) {
1332                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
1333    
1334                            for (Object value : values) {
1335                                    qPos.add(value);
1336                            }
1337                    }
1338    
1339                    List<BlogsEntry> list = q.list();
1340    
1341                    if (list.size() == 2) {
1342                            return list.get(1);
1343                    }
1344                    else {
1345                            return null;
1346                    }
1347            }
1348    
1349            /**
1350             * Removes all the blogs entries where uuid = &#63; and companyId = &#63; from the database.
1351             *
1352             * @param uuid the uuid
1353             * @param companyId the company ID
1354             */
1355            @Override
1356            public void removeByUuid_C(String uuid, long companyId) {
1357                    for (BlogsEntry blogsEntry : findByUuid_C(uuid, companyId,
1358                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1359                            remove(blogsEntry);
1360                    }
1361            }
1362    
1363            /**
1364             * Returns the number of blogs entries where uuid = &#63; and companyId = &#63;.
1365             *
1366             * @param uuid the uuid
1367             * @param companyId the company ID
1368             * @return the number of matching blogs entries
1369             */
1370            @Override
1371            public int countByUuid_C(String uuid, long companyId) {
1372                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1373    
1374                    Object[] finderArgs = new Object[] { uuid, companyId };
1375    
1376                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1377                                    this);
1378    
1379                    if (count == null) {
1380                            StringBundler query = new StringBundler(3);
1381    
1382                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
1383    
1384                            boolean bindUuid = false;
1385    
1386                            if (uuid == null) {
1387                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1388                            }
1389                            else if (uuid.equals(StringPool.BLANK)) {
1390                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1391                            }
1392                            else {
1393                                    bindUuid = true;
1394    
1395                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1396                            }
1397    
1398                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1399    
1400                            String sql = query.toString();
1401    
1402                            Session session = null;
1403    
1404                            try {
1405                                    session = openSession();
1406    
1407                                    Query q = session.createQuery(sql);
1408    
1409                                    QueryPos qPos = QueryPos.getInstance(q);
1410    
1411                                    if (bindUuid) {
1412                                            qPos.add(uuid);
1413                                    }
1414    
1415                                    qPos.add(companyId);
1416    
1417                                    count = (Long)q.uniqueResult();
1418    
1419                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
1420                            }
1421                            catch (Exception e) {
1422                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1423    
1424                                    throw processException(e);
1425                            }
1426                            finally {
1427                                    closeSession(session);
1428                            }
1429                    }
1430    
1431                    return count.intValue();
1432            }
1433    
1434            private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "blogsEntry.uuid IS NULL AND ";
1435            private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "blogsEntry.uuid = ? AND ";
1436            private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(blogsEntry.uuid IS NULL OR blogsEntry.uuid = '') AND ";
1437            private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "blogsEntry.companyId = ?";
1438            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
1439                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
1440                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId",
1441                            new String[] {
1442                                    Long.class.getName(),
1443                                    
1444                            Integer.class.getName(), Integer.class.getName(),
1445                                    OrderByComparator.class.getName()
1446                            });
1447            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
1448                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
1449                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
1450                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
1451                            new String[] { Long.class.getName() },
1452                            BlogsEntryModelImpl.GROUPID_COLUMN_BITMASK |
1453                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
1454                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
1455            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
1456                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
1457                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
1458                            new String[] { Long.class.getName() });
1459    
1460            /**
1461             * Returns all the blogs entries where groupId = &#63;.
1462             *
1463             * @param groupId the group ID
1464             * @return the matching blogs entries
1465             */
1466            @Override
1467            public List<BlogsEntry> findByGroupId(long groupId) {
1468                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1469            }
1470    
1471            /**
1472             * Returns a range of all the blogs entries where groupId = &#63;.
1473             *
1474             * <p>
1475             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1476             * </p>
1477             *
1478             * @param groupId the group ID
1479             * @param start the lower bound of the range of blogs entries
1480             * @param end the upper bound of the range of blogs entries (not inclusive)
1481             * @return the range of matching blogs entries
1482             */
1483            @Override
1484            public List<BlogsEntry> findByGroupId(long groupId, int start, int end) {
1485                    return findByGroupId(groupId, start, end, null);
1486            }
1487    
1488            /**
1489             * Returns an ordered range of all the blogs entries where groupId = &#63;.
1490             *
1491             * <p>
1492             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1493             * </p>
1494             *
1495             * @param groupId the group ID
1496             * @param start the lower bound of the range of blogs entries
1497             * @param end the upper bound of the range of blogs entries (not inclusive)
1498             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1499             * @return the ordered range of matching blogs entries
1500             */
1501            @Override
1502            public List<BlogsEntry> findByGroupId(long groupId, int start, int end,
1503                    OrderByComparator<BlogsEntry> orderByComparator) {
1504                    boolean pagination = true;
1505                    FinderPath finderPath = null;
1506                    Object[] finderArgs = null;
1507    
1508                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1509                                    (orderByComparator == null)) {
1510                            pagination = false;
1511                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1512                            finderArgs = new Object[] { groupId };
1513                    }
1514                    else {
1515                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1516                            finderArgs = new Object[] { groupId, start, end, orderByComparator };
1517                    }
1518    
1519                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
1520                                    finderArgs, this);
1521    
1522                    if ((list != null) && !list.isEmpty()) {
1523                            for (BlogsEntry blogsEntry : list) {
1524                                    if ((groupId != blogsEntry.getGroupId())) {
1525                                            list = null;
1526    
1527                                            break;
1528                                    }
1529                            }
1530                    }
1531    
1532                    if (list == null) {
1533                            StringBundler query = null;
1534    
1535                            if (orderByComparator != null) {
1536                                    query = new StringBundler(3 +
1537                                                    (orderByComparator.getOrderByFields().length * 3));
1538                            }
1539                            else {
1540                                    query = new StringBundler(3);
1541                            }
1542    
1543                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
1544    
1545                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1546    
1547                            if (orderByComparator != null) {
1548                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1549                                            orderByComparator);
1550                            }
1551                            else
1552                             if (pagination) {
1553                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
1554                            }
1555    
1556                            String sql = query.toString();
1557    
1558                            Session session = null;
1559    
1560                            try {
1561                                    session = openSession();
1562    
1563                                    Query q = session.createQuery(sql);
1564    
1565                                    QueryPos qPos = QueryPos.getInstance(q);
1566    
1567                                    qPos.add(groupId);
1568    
1569                                    if (!pagination) {
1570                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
1571                                                            start, end, false);
1572    
1573                                            Collections.sort(list);
1574    
1575                                            list = Collections.unmodifiableList(list);
1576                                    }
1577                                    else {
1578                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
1579                                                            start, end);
1580                                    }
1581    
1582                                    cacheResult(list);
1583    
1584                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1585                            }
1586                            catch (Exception e) {
1587                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1588    
1589                                    throw processException(e);
1590                            }
1591                            finally {
1592                                    closeSession(session);
1593                            }
1594                    }
1595    
1596                    return list;
1597            }
1598    
1599            /**
1600             * Returns the first blogs entry in the ordered set where groupId = &#63;.
1601             *
1602             * @param groupId the group ID
1603             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1604             * @return the first matching blogs entry
1605             * @throws NoSuchEntryException if a matching blogs entry could not be found
1606             */
1607            @Override
1608            public BlogsEntry findByGroupId_First(long groupId,
1609                    OrderByComparator<BlogsEntry> orderByComparator)
1610                    throws NoSuchEntryException {
1611                    BlogsEntry blogsEntry = fetchByGroupId_First(groupId, orderByComparator);
1612    
1613                    if (blogsEntry != null) {
1614                            return blogsEntry;
1615                    }
1616    
1617                    StringBundler msg = new StringBundler(4);
1618    
1619                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1620    
1621                    msg.append("groupId=");
1622                    msg.append(groupId);
1623    
1624                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1625    
1626                    throw new NoSuchEntryException(msg.toString());
1627            }
1628    
1629            /**
1630             * Returns the first blogs entry in the ordered set where groupId = &#63;.
1631             *
1632             * @param groupId the group ID
1633             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1634             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
1635             */
1636            @Override
1637            public BlogsEntry fetchByGroupId_First(long groupId,
1638                    OrderByComparator<BlogsEntry> orderByComparator) {
1639                    List<BlogsEntry> list = findByGroupId(groupId, 0, 1, orderByComparator);
1640    
1641                    if (!list.isEmpty()) {
1642                            return list.get(0);
1643                    }
1644    
1645                    return null;
1646            }
1647    
1648            /**
1649             * Returns the last blogs entry in the ordered set where groupId = &#63;.
1650             *
1651             * @param groupId the group ID
1652             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1653             * @return the last matching blogs entry
1654             * @throws NoSuchEntryException if a matching blogs entry could not be found
1655             */
1656            @Override
1657            public BlogsEntry findByGroupId_Last(long groupId,
1658                    OrderByComparator<BlogsEntry> orderByComparator)
1659                    throws NoSuchEntryException {
1660                    BlogsEntry blogsEntry = fetchByGroupId_Last(groupId, orderByComparator);
1661    
1662                    if (blogsEntry != null) {
1663                            return blogsEntry;
1664                    }
1665    
1666                    StringBundler msg = new StringBundler(4);
1667    
1668                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1669    
1670                    msg.append("groupId=");
1671                    msg.append(groupId);
1672    
1673                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1674    
1675                    throw new NoSuchEntryException(msg.toString());
1676            }
1677    
1678            /**
1679             * Returns the last blogs entry in the ordered set where groupId = &#63;.
1680             *
1681             * @param groupId the group ID
1682             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1683             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
1684             */
1685            @Override
1686            public BlogsEntry fetchByGroupId_Last(long groupId,
1687                    OrderByComparator<BlogsEntry> orderByComparator) {
1688                    int count = countByGroupId(groupId);
1689    
1690                    if (count == 0) {
1691                            return null;
1692                    }
1693    
1694                    List<BlogsEntry> list = findByGroupId(groupId, count - 1, count,
1695                                    orderByComparator);
1696    
1697                    if (!list.isEmpty()) {
1698                            return list.get(0);
1699                    }
1700    
1701                    return null;
1702            }
1703    
1704            /**
1705             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63;.
1706             *
1707             * @param entryId the primary key of the current blogs entry
1708             * @param groupId the group ID
1709             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1710             * @return the previous, current, and next blogs entry
1711             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
1712             */
1713            @Override
1714            public BlogsEntry[] findByGroupId_PrevAndNext(long entryId, long groupId,
1715                    OrderByComparator<BlogsEntry> orderByComparator)
1716                    throws NoSuchEntryException {
1717                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
1718    
1719                    Session session = null;
1720    
1721                    try {
1722                            session = openSession();
1723    
1724                            BlogsEntry[] array = new BlogsEntryImpl[3];
1725    
1726                            array[0] = getByGroupId_PrevAndNext(session, blogsEntry, groupId,
1727                                            orderByComparator, true);
1728    
1729                            array[1] = blogsEntry;
1730    
1731                            array[2] = getByGroupId_PrevAndNext(session, blogsEntry, groupId,
1732                                            orderByComparator, false);
1733    
1734                            return array;
1735                    }
1736                    catch (Exception e) {
1737                            throw processException(e);
1738                    }
1739                    finally {
1740                            closeSession(session);
1741                    }
1742            }
1743    
1744            protected BlogsEntry getByGroupId_PrevAndNext(Session session,
1745                    BlogsEntry blogsEntry, long groupId,
1746                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
1747                    StringBundler query = null;
1748    
1749                    if (orderByComparator != null) {
1750                            query = new StringBundler(6 +
1751                                            (orderByComparator.getOrderByFields().length * 6));
1752                    }
1753                    else {
1754                            query = new StringBundler(3);
1755                    }
1756    
1757                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
1758    
1759                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1760    
1761                    if (orderByComparator != null) {
1762                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1763    
1764                            if (orderByConditionFields.length > 0) {
1765                                    query.append(WHERE_AND);
1766                            }
1767    
1768                            for (int i = 0; i < orderByConditionFields.length; i++) {
1769                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1770                                    query.append(orderByConditionFields[i]);
1771    
1772                                    if ((i + 1) < orderByConditionFields.length) {
1773                                            if (orderByComparator.isAscending() ^ previous) {
1774                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1775                                            }
1776                                            else {
1777                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1778                                            }
1779                                    }
1780                                    else {
1781                                            if (orderByComparator.isAscending() ^ previous) {
1782                                                    query.append(WHERE_GREATER_THAN);
1783                                            }
1784                                            else {
1785                                                    query.append(WHERE_LESSER_THAN);
1786                                            }
1787                                    }
1788                            }
1789    
1790                            query.append(ORDER_BY_CLAUSE);
1791    
1792                            String[] orderByFields = orderByComparator.getOrderByFields();
1793    
1794                            for (int i = 0; i < orderByFields.length; i++) {
1795                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1796                                    query.append(orderByFields[i]);
1797    
1798                                    if ((i + 1) < orderByFields.length) {
1799                                            if (orderByComparator.isAscending() ^ previous) {
1800                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1801                                            }
1802                                            else {
1803                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1804                                            }
1805                                    }
1806                                    else {
1807                                            if (orderByComparator.isAscending() ^ previous) {
1808                                                    query.append(ORDER_BY_ASC);
1809                                            }
1810                                            else {
1811                                                    query.append(ORDER_BY_DESC);
1812                                            }
1813                                    }
1814                            }
1815                    }
1816                    else {
1817                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
1818                    }
1819    
1820                    String sql = query.toString();
1821    
1822                    Query q = session.createQuery(sql);
1823    
1824                    q.setFirstResult(0);
1825                    q.setMaxResults(2);
1826    
1827                    QueryPos qPos = QueryPos.getInstance(q);
1828    
1829                    qPos.add(groupId);
1830    
1831                    if (orderByComparator != null) {
1832                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
1833    
1834                            for (Object value : values) {
1835                                    qPos.add(value);
1836                            }
1837                    }
1838    
1839                    List<BlogsEntry> list = q.list();
1840    
1841                    if (list.size() == 2) {
1842                            return list.get(1);
1843                    }
1844                    else {
1845                            return null;
1846                    }
1847            }
1848    
1849            /**
1850             * Returns all the blogs entries that the user has permission to view where groupId = &#63;.
1851             *
1852             * @param groupId the group ID
1853             * @return the matching blogs entries that the user has permission to view
1854             */
1855            @Override
1856            public List<BlogsEntry> filterFindByGroupId(long groupId) {
1857                    return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1858                            QueryUtil.ALL_POS, null);
1859            }
1860    
1861            /**
1862             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63;.
1863             *
1864             * <p>
1865             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1866             * </p>
1867             *
1868             * @param groupId the group ID
1869             * @param start the lower bound of the range of blogs entries
1870             * @param end the upper bound of the range of blogs entries (not inclusive)
1871             * @return the range of matching blogs entries that the user has permission to view
1872             */
1873            @Override
1874            public List<BlogsEntry> filterFindByGroupId(long groupId, int start, int end) {
1875                    return filterFindByGroupId(groupId, start, end, null);
1876            }
1877    
1878            /**
1879             * Returns an ordered range of all the blogs entries that the user has permissions to view where groupId = &#63;.
1880             *
1881             * <p>
1882             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1883             * </p>
1884             *
1885             * @param groupId the group ID
1886             * @param start the lower bound of the range of blogs entries
1887             * @param end the upper bound of the range of blogs entries (not inclusive)
1888             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1889             * @return the ordered range of matching blogs entries that the user has permission to view
1890             */
1891            @Override
1892            public List<BlogsEntry> filterFindByGroupId(long groupId, int start,
1893                    int end, OrderByComparator<BlogsEntry> orderByComparator) {
1894                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1895                            return findByGroupId(groupId, start, end, orderByComparator);
1896                    }
1897    
1898                    StringBundler query = null;
1899    
1900                    if (orderByComparator != null) {
1901                            query = new StringBundler(3 +
1902                                            (orderByComparator.getOrderByFields().length * 3));
1903                    }
1904                    else {
1905                            query = new StringBundler(3);
1906                    }
1907    
1908                    if (getDB().isSupportsInlineDistinct()) {
1909                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
1910                    }
1911                    else {
1912                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
1913                    }
1914    
1915                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1916    
1917                    if (!getDB().isSupportsInlineDistinct()) {
1918                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
1919                    }
1920    
1921                    if (orderByComparator != null) {
1922                            if (getDB().isSupportsInlineDistinct()) {
1923                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1924                                            orderByComparator, true);
1925                            }
1926                            else {
1927                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1928                                            orderByComparator, true);
1929                            }
1930                    }
1931                    else {
1932                            if (getDB().isSupportsInlineDistinct()) {
1933                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
1934                            }
1935                            else {
1936                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
1937                            }
1938                    }
1939    
1940                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1941                                    BlogsEntry.class.getName(),
1942                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1943    
1944                    Session session = null;
1945    
1946                    try {
1947                            session = openSession();
1948    
1949                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
1950    
1951                            if (getDB().isSupportsInlineDistinct()) {
1952                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
1953                            }
1954                            else {
1955                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
1956                            }
1957    
1958                            QueryPos qPos = QueryPos.getInstance(q);
1959    
1960                            qPos.add(groupId);
1961    
1962                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
1963                    }
1964                    catch (Exception e) {
1965                            throw processException(e);
1966                    }
1967                    finally {
1968                            closeSession(session);
1969                    }
1970            }
1971    
1972            /**
1973             * 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;.
1974             *
1975             * @param entryId the primary key of the current blogs entry
1976             * @param groupId the group ID
1977             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1978             * @return the previous, current, and next blogs entry
1979             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
1980             */
1981            @Override
1982            public BlogsEntry[] filterFindByGroupId_PrevAndNext(long entryId,
1983                    long groupId, OrderByComparator<BlogsEntry> orderByComparator)
1984                    throws NoSuchEntryException {
1985                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1986                            return findByGroupId_PrevAndNext(entryId, groupId, orderByComparator);
1987                    }
1988    
1989                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
1990    
1991                    Session session = null;
1992    
1993                    try {
1994                            session = openSession();
1995    
1996                            BlogsEntry[] array = new BlogsEntryImpl[3];
1997    
1998                            array[0] = filterGetByGroupId_PrevAndNext(session, blogsEntry,
1999                                            groupId, orderByComparator, true);
2000    
2001                            array[1] = blogsEntry;
2002    
2003                            array[2] = filterGetByGroupId_PrevAndNext(session, blogsEntry,
2004                                            groupId, orderByComparator, false);
2005    
2006                            return array;
2007                    }
2008                    catch (Exception e) {
2009                            throw processException(e);
2010                    }
2011                    finally {
2012                            closeSession(session);
2013                    }
2014            }
2015    
2016            protected BlogsEntry filterGetByGroupId_PrevAndNext(Session session,
2017                    BlogsEntry blogsEntry, long groupId,
2018                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
2019                    StringBundler query = null;
2020    
2021                    if (orderByComparator != null) {
2022                            query = new StringBundler(6 +
2023                                            (orderByComparator.getOrderByFields().length * 6));
2024                    }
2025                    else {
2026                            query = new StringBundler(3);
2027                    }
2028    
2029                    if (getDB().isSupportsInlineDistinct()) {
2030                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
2031                    }
2032                    else {
2033                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
2034                    }
2035    
2036                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2037    
2038                    if (!getDB().isSupportsInlineDistinct()) {
2039                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
2040                    }
2041    
2042                    if (orderByComparator != null) {
2043                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2044    
2045                            if (orderByConditionFields.length > 0) {
2046                                    query.append(WHERE_AND);
2047                            }
2048    
2049                            for (int i = 0; i < orderByConditionFields.length; i++) {
2050                                    if (getDB().isSupportsInlineDistinct()) {
2051                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2052                                    }
2053                                    else {
2054                                            query.append(_ORDER_BY_ENTITY_TABLE);
2055                                    }
2056    
2057                                    query.append(orderByConditionFields[i]);
2058    
2059                                    if ((i + 1) < orderByConditionFields.length) {
2060                                            if (orderByComparator.isAscending() ^ previous) {
2061                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2062                                            }
2063                                            else {
2064                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2065                                            }
2066                                    }
2067                                    else {
2068                                            if (orderByComparator.isAscending() ^ previous) {
2069                                                    query.append(WHERE_GREATER_THAN);
2070                                            }
2071                                            else {
2072                                                    query.append(WHERE_LESSER_THAN);
2073                                            }
2074                                    }
2075                            }
2076    
2077                            query.append(ORDER_BY_CLAUSE);
2078    
2079                            String[] orderByFields = orderByComparator.getOrderByFields();
2080    
2081                            for (int i = 0; i < orderByFields.length; i++) {
2082                                    if (getDB().isSupportsInlineDistinct()) {
2083                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2084                                    }
2085                                    else {
2086                                            query.append(_ORDER_BY_ENTITY_TABLE);
2087                                    }
2088    
2089                                    query.append(orderByFields[i]);
2090    
2091                                    if ((i + 1) < orderByFields.length) {
2092                                            if (orderByComparator.isAscending() ^ previous) {
2093                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2094                                            }
2095                                            else {
2096                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2097                                            }
2098                                    }
2099                                    else {
2100                                            if (orderByComparator.isAscending() ^ previous) {
2101                                                    query.append(ORDER_BY_ASC);
2102                                            }
2103                                            else {
2104                                                    query.append(ORDER_BY_DESC);
2105                                            }
2106                                    }
2107                            }
2108                    }
2109                    else {
2110                            if (getDB().isSupportsInlineDistinct()) {
2111                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
2112                            }
2113                            else {
2114                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
2115                            }
2116                    }
2117    
2118                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2119                                    BlogsEntry.class.getName(),
2120                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2121    
2122                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
2123    
2124                    q.setFirstResult(0);
2125                    q.setMaxResults(2);
2126    
2127                    if (getDB().isSupportsInlineDistinct()) {
2128                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
2129                    }
2130                    else {
2131                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
2132                    }
2133    
2134                    QueryPos qPos = QueryPos.getInstance(q);
2135    
2136                    qPos.add(groupId);
2137    
2138                    if (orderByComparator != null) {
2139                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
2140    
2141                            for (Object value : values) {
2142                                    qPos.add(value);
2143                            }
2144                    }
2145    
2146                    List<BlogsEntry> list = q.list();
2147    
2148                    if (list.size() == 2) {
2149                            return list.get(1);
2150                    }
2151                    else {
2152                            return null;
2153                    }
2154            }
2155    
2156            /**
2157             * Removes all the blogs entries where groupId = &#63; from the database.
2158             *
2159             * @param groupId the group ID
2160             */
2161            @Override
2162            public void removeByGroupId(long groupId) {
2163                    for (BlogsEntry blogsEntry : findByGroupId(groupId, QueryUtil.ALL_POS,
2164                                    QueryUtil.ALL_POS, null)) {
2165                            remove(blogsEntry);
2166                    }
2167            }
2168    
2169            /**
2170             * Returns the number of blogs entries where groupId = &#63;.
2171             *
2172             * @param groupId the group ID
2173             * @return the number of matching blogs entries
2174             */
2175            @Override
2176            public int countByGroupId(long groupId) {
2177                    FinderPath finderPath = FINDER_PATH_COUNT_BY_GROUPID;
2178    
2179                    Object[] finderArgs = new Object[] { groupId };
2180    
2181                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2182                                    this);
2183    
2184                    if (count == null) {
2185                            StringBundler query = new StringBundler(2);
2186    
2187                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
2188    
2189                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2190    
2191                            String sql = query.toString();
2192    
2193                            Session session = null;
2194    
2195                            try {
2196                                    session = openSession();
2197    
2198                                    Query q = session.createQuery(sql);
2199    
2200                                    QueryPos qPos = QueryPos.getInstance(q);
2201    
2202                                    qPos.add(groupId);
2203    
2204                                    count = (Long)q.uniqueResult();
2205    
2206                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
2207                            }
2208                            catch (Exception e) {
2209                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2210    
2211                                    throw processException(e);
2212                            }
2213                            finally {
2214                                    closeSession(session);
2215                            }
2216                    }
2217    
2218                    return count.intValue();
2219            }
2220    
2221            /**
2222             * Returns the number of blogs entries that the user has permission to view where groupId = &#63;.
2223             *
2224             * @param groupId the group ID
2225             * @return the number of matching blogs entries that the user has permission to view
2226             */
2227            @Override
2228            public int filterCountByGroupId(long groupId) {
2229                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2230                            return countByGroupId(groupId);
2231                    }
2232    
2233                    StringBundler query = new StringBundler(2);
2234    
2235                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
2236    
2237                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2238    
2239                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2240                                    BlogsEntry.class.getName(),
2241                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2242    
2243                    Session session = null;
2244    
2245                    try {
2246                            session = openSession();
2247    
2248                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
2249    
2250                            q.addScalar(COUNT_COLUMN_NAME,
2251                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
2252    
2253                            QueryPos qPos = QueryPos.getInstance(q);
2254    
2255                            qPos.add(groupId);
2256    
2257                            Long count = (Long)q.uniqueResult();
2258    
2259                            return count.intValue();
2260                    }
2261                    catch (Exception e) {
2262                            throw processException(e);
2263                    }
2264                    finally {
2265                            closeSession(session);
2266                    }
2267            }
2268    
2269            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "blogsEntry.groupId = ?";
2270            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
2271                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
2272                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
2273                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId",
2274                            new String[] {
2275                                    Long.class.getName(),
2276                                    
2277                            Integer.class.getName(), Integer.class.getName(),
2278                                    OrderByComparator.class.getName()
2279                            });
2280            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
2281                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
2282                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
2283                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
2284                            new String[] { Long.class.getName() },
2285                            BlogsEntryModelImpl.COMPANYID_COLUMN_BITMASK |
2286                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
2287                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
2288            public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
2289                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
2290                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
2291                            new String[] { Long.class.getName() });
2292    
2293            /**
2294             * Returns all the blogs entries where companyId = &#63;.
2295             *
2296             * @param companyId the company ID
2297             * @return the matching blogs entries
2298             */
2299            @Override
2300            public List<BlogsEntry> findByCompanyId(long companyId) {
2301                    return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2302                            null);
2303            }
2304    
2305            /**
2306             * Returns a range of all the blogs entries where companyId = &#63;.
2307             *
2308             * <p>
2309             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2310             * </p>
2311             *
2312             * @param companyId the company ID
2313             * @param start the lower bound of the range of blogs entries
2314             * @param end the upper bound of the range of blogs entries (not inclusive)
2315             * @return the range of matching blogs entries
2316             */
2317            @Override
2318            public List<BlogsEntry> findByCompanyId(long companyId, int start, int end) {
2319                    return findByCompanyId(companyId, start, end, null);
2320            }
2321    
2322            /**
2323             * Returns an ordered range of all the blogs entries where companyId = &#63;.
2324             *
2325             * <p>
2326             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2327             * </p>
2328             *
2329             * @param companyId the company ID
2330             * @param start the lower bound of the range of blogs entries
2331             * @param end the upper bound of the range of blogs entries (not inclusive)
2332             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2333             * @return the ordered range of matching blogs entries
2334             */
2335            @Override
2336            public List<BlogsEntry> findByCompanyId(long companyId, int start, int end,
2337                    OrderByComparator<BlogsEntry> orderByComparator) {
2338                    boolean pagination = true;
2339                    FinderPath finderPath = null;
2340                    Object[] finderArgs = null;
2341    
2342                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2343                                    (orderByComparator == null)) {
2344                            pagination = false;
2345                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
2346                            finderArgs = new Object[] { companyId };
2347                    }
2348                    else {
2349                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
2350                            finderArgs = new Object[] { companyId, start, end, orderByComparator };
2351                    }
2352    
2353                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
2354                                    finderArgs, this);
2355    
2356                    if ((list != null) && !list.isEmpty()) {
2357                            for (BlogsEntry blogsEntry : list) {
2358                                    if ((companyId != blogsEntry.getCompanyId())) {
2359                                            list = null;
2360    
2361                                            break;
2362                                    }
2363                            }
2364                    }
2365    
2366                    if (list == null) {
2367                            StringBundler query = null;
2368    
2369                            if (orderByComparator != null) {
2370                                    query = new StringBundler(3 +
2371                                                    (orderByComparator.getOrderByFields().length * 3));
2372                            }
2373                            else {
2374                                    query = new StringBundler(3);
2375                            }
2376    
2377                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
2378    
2379                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2380    
2381                            if (orderByComparator != null) {
2382                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2383                                            orderByComparator);
2384                            }
2385                            else
2386                             if (pagination) {
2387                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
2388                            }
2389    
2390                            String sql = query.toString();
2391    
2392                            Session session = null;
2393    
2394                            try {
2395                                    session = openSession();
2396    
2397                                    Query q = session.createQuery(sql);
2398    
2399                                    QueryPos qPos = QueryPos.getInstance(q);
2400    
2401                                    qPos.add(companyId);
2402    
2403                                    if (!pagination) {
2404                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
2405                                                            start, end, false);
2406    
2407                                            Collections.sort(list);
2408    
2409                                            list = Collections.unmodifiableList(list);
2410                                    }
2411                                    else {
2412                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
2413                                                            start, end);
2414                                    }
2415    
2416                                    cacheResult(list);
2417    
2418                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
2419                            }
2420                            catch (Exception e) {
2421                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2422    
2423                                    throw processException(e);
2424                            }
2425                            finally {
2426                                    closeSession(session);
2427                            }
2428                    }
2429    
2430                    return list;
2431            }
2432    
2433            /**
2434             * Returns the first blogs entry in the ordered set where companyId = &#63;.
2435             *
2436             * @param companyId the company ID
2437             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2438             * @return the first matching blogs entry
2439             * @throws NoSuchEntryException if a matching blogs entry could not be found
2440             */
2441            @Override
2442            public BlogsEntry findByCompanyId_First(long companyId,
2443                    OrderByComparator<BlogsEntry> orderByComparator)
2444                    throws NoSuchEntryException {
2445                    BlogsEntry blogsEntry = fetchByCompanyId_First(companyId,
2446                                    orderByComparator);
2447    
2448                    if (blogsEntry != null) {
2449                            return blogsEntry;
2450                    }
2451    
2452                    StringBundler msg = new StringBundler(4);
2453    
2454                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2455    
2456                    msg.append("companyId=");
2457                    msg.append(companyId);
2458    
2459                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2460    
2461                    throw new NoSuchEntryException(msg.toString());
2462            }
2463    
2464            /**
2465             * Returns the first blogs entry in the ordered set where companyId = &#63;.
2466             *
2467             * @param companyId the company ID
2468             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2469             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
2470             */
2471            @Override
2472            public BlogsEntry fetchByCompanyId_First(long companyId,
2473                    OrderByComparator<BlogsEntry> orderByComparator) {
2474                    List<BlogsEntry> list = findByCompanyId(companyId, 0, 1,
2475                                    orderByComparator);
2476    
2477                    if (!list.isEmpty()) {
2478                            return list.get(0);
2479                    }
2480    
2481                    return null;
2482            }
2483    
2484            /**
2485             * Returns the last blogs entry in the ordered set where companyId = &#63;.
2486             *
2487             * @param companyId the company ID
2488             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2489             * @return the last matching blogs entry
2490             * @throws NoSuchEntryException if a matching blogs entry could not be found
2491             */
2492            @Override
2493            public BlogsEntry findByCompanyId_Last(long companyId,
2494                    OrderByComparator<BlogsEntry> orderByComparator)
2495                    throws NoSuchEntryException {
2496                    BlogsEntry blogsEntry = fetchByCompanyId_Last(companyId,
2497                                    orderByComparator);
2498    
2499                    if (blogsEntry != null) {
2500                            return blogsEntry;
2501                    }
2502    
2503                    StringBundler msg = new StringBundler(4);
2504    
2505                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2506    
2507                    msg.append("companyId=");
2508                    msg.append(companyId);
2509    
2510                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2511    
2512                    throw new NoSuchEntryException(msg.toString());
2513            }
2514    
2515            /**
2516             * Returns the last blogs entry in the ordered set where companyId = &#63;.
2517             *
2518             * @param companyId the company ID
2519             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2520             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
2521             */
2522            @Override
2523            public BlogsEntry fetchByCompanyId_Last(long companyId,
2524                    OrderByComparator<BlogsEntry> orderByComparator) {
2525                    int count = countByCompanyId(companyId);
2526    
2527                    if (count == 0) {
2528                            return null;
2529                    }
2530    
2531                    List<BlogsEntry> list = findByCompanyId(companyId, count - 1, count,
2532                                    orderByComparator);
2533    
2534                    if (!list.isEmpty()) {
2535                            return list.get(0);
2536                    }
2537    
2538                    return null;
2539            }
2540    
2541            /**
2542             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63;.
2543             *
2544             * @param entryId the primary key of the current blogs entry
2545             * @param companyId the company ID
2546             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2547             * @return the previous, current, and next blogs entry
2548             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
2549             */
2550            @Override
2551            public BlogsEntry[] findByCompanyId_PrevAndNext(long entryId,
2552                    long companyId, OrderByComparator<BlogsEntry> orderByComparator)
2553                    throws NoSuchEntryException {
2554                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
2555    
2556                    Session session = null;
2557    
2558                    try {
2559                            session = openSession();
2560    
2561                            BlogsEntry[] array = new BlogsEntryImpl[3];
2562    
2563                            array[0] = getByCompanyId_PrevAndNext(session, blogsEntry,
2564                                            companyId, orderByComparator, true);
2565    
2566                            array[1] = blogsEntry;
2567    
2568                            array[2] = getByCompanyId_PrevAndNext(session, blogsEntry,
2569                                            companyId, orderByComparator, false);
2570    
2571                            return array;
2572                    }
2573                    catch (Exception e) {
2574                            throw processException(e);
2575                    }
2576                    finally {
2577                            closeSession(session);
2578                    }
2579            }
2580    
2581            protected BlogsEntry getByCompanyId_PrevAndNext(Session session,
2582                    BlogsEntry blogsEntry, long companyId,
2583                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
2584                    StringBundler query = null;
2585    
2586                    if (orderByComparator != null) {
2587                            query = new StringBundler(6 +
2588                                            (orderByComparator.getOrderByFields().length * 6));
2589                    }
2590                    else {
2591                            query = new StringBundler(3);
2592                    }
2593    
2594                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
2595    
2596                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2597    
2598                    if (orderByComparator != null) {
2599                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2600    
2601                            if (orderByConditionFields.length > 0) {
2602                                    query.append(WHERE_AND);
2603                            }
2604    
2605                            for (int i = 0; i < orderByConditionFields.length; i++) {
2606                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2607                                    query.append(orderByConditionFields[i]);
2608    
2609                                    if ((i + 1) < orderByConditionFields.length) {
2610                                            if (orderByComparator.isAscending() ^ previous) {
2611                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2612                                            }
2613                                            else {
2614                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2615                                            }
2616                                    }
2617                                    else {
2618                                            if (orderByComparator.isAscending() ^ previous) {
2619                                                    query.append(WHERE_GREATER_THAN);
2620                                            }
2621                                            else {
2622                                                    query.append(WHERE_LESSER_THAN);
2623                                            }
2624                                    }
2625                            }
2626    
2627                            query.append(ORDER_BY_CLAUSE);
2628    
2629                            String[] orderByFields = orderByComparator.getOrderByFields();
2630    
2631                            for (int i = 0; i < orderByFields.length; i++) {
2632                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2633                                    query.append(orderByFields[i]);
2634    
2635                                    if ((i + 1) < orderByFields.length) {
2636                                            if (orderByComparator.isAscending() ^ previous) {
2637                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2638                                            }
2639                                            else {
2640                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2641                                            }
2642                                    }
2643                                    else {
2644                                            if (orderByComparator.isAscending() ^ previous) {
2645                                                    query.append(ORDER_BY_ASC);
2646                                            }
2647                                            else {
2648                                                    query.append(ORDER_BY_DESC);
2649                                            }
2650                                    }
2651                            }
2652                    }
2653                    else {
2654                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
2655                    }
2656    
2657                    String sql = query.toString();
2658    
2659                    Query q = session.createQuery(sql);
2660    
2661                    q.setFirstResult(0);
2662                    q.setMaxResults(2);
2663    
2664                    QueryPos qPos = QueryPos.getInstance(q);
2665    
2666                    qPos.add(companyId);
2667    
2668                    if (orderByComparator != null) {
2669                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
2670    
2671                            for (Object value : values) {
2672                                    qPos.add(value);
2673                            }
2674                    }
2675    
2676                    List<BlogsEntry> list = q.list();
2677    
2678                    if (list.size() == 2) {
2679                            return list.get(1);
2680                    }
2681                    else {
2682                            return null;
2683                    }
2684            }
2685    
2686            /**
2687             * Removes all the blogs entries where companyId = &#63; from the database.
2688             *
2689             * @param companyId the company ID
2690             */
2691            @Override
2692            public void removeByCompanyId(long companyId) {
2693                    for (BlogsEntry blogsEntry : findByCompanyId(companyId,
2694                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2695                            remove(blogsEntry);
2696                    }
2697            }
2698    
2699            /**
2700             * Returns the number of blogs entries where companyId = &#63;.
2701             *
2702             * @param companyId the company ID
2703             * @return the number of matching blogs entries
2704             */
2705            @Override
2706            public int countByCompanyId(long companyId) {
2707                    FinderPath finderPath = FINDER_PATH_COUNT_BY_COMPANYID;
2708    
2709                    Object[] finderArgs = new Object[] { companyId };
2710    
2711                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2712                                    this);
2713    
2714                    if (count == null) {
2715                            StringBundler query = new StringBundler(2);
2716    
2717                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
2718    
2719                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2720    
2721                            String sql = query.toString();
2722    
2723                            Session session = null;
2724    
2725                            try {
2726                                    session = openSession();
2727    
2728                                    Query q = session.createQuery(sql);
2729    
2730                                    QueryPos qPos = QueryPos.getInstance(q);
2731    
2732                                    qPos.add(companyId);
2733    
2734                                    count = (Long)q.uniqueResult();
2735    
2736                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
2737                            }
2738                            catch (Exception e) {
2739                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2740    
2741                                    throw processException(e);
2742                            }
2743                            finally {
2744                                    closeSession(session);
2745                            }
2746                    }
2747    
2748                    return count.intValue();
2749            }
2750    
2751            private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "blogsEntry.companyId = ?";
2752            public static final FinderPath FINDER_PATH_FETCH_BY_G_UT = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
2753                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
2754                            FINDER_CLASS_NAME_ENTITY, "fetchByG_UT",
2755                            new String[] { Long.class.getName(), String.class.getName() },
2756                            BlogsEntryModelImpl.GROUPID_COLUMN_BITMASK |
2757                            BlogsEntryModelImpl.URLTITLE_COLUMN_BITMASK);
2758            public static final FinderPath FINDER_PATH_COUNT_BY_G_UT = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
2759                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
2760                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_UT",
2761                            new String[] { Long.class.getName(), String.class.getName() });
2762    
2763            /**
2764             * Returns the blogs entry where groupId = &#63; and urlTitle = &#63; or throws a {@link NoSuchEntryException} if it could not be found.
2765             *
2766             * @param groupId the group ID
2767             * @param urlTitle the url title
2768             * @return the matching blogs entry
2769             * @throws NoSuchEntryException if a matching blogs entry could not be found
2770             */
2771            @Override
2772            public BlogsEntry findByG_UT(long groupId, String urlTitle)
2773                    throws NoSuchEntryException {
2774                    BlogsEntry blogsEntry = fetchByG_UT(groupId, urlTitle);
2775    
2776                    if (blogsEntry == null) {
2777                            StringBundler msg = new StringBundler(6);
2778    
2779                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2780    
2781                            msg.append("groupId=");
2782                            msg.append(groupId);
2783    
2784                            msg.append(", urlTitle=");
2785                            msg.append(urlTitle);
2786    
2787                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2788    
2789                            if (_log.isWarnEnabled()) {
2790                                    _log.warn(msg.toString());
2791                            }
2792    
2793                            throw new NoSuchEntryException(msg.toString());
2794                    }
2795    
2796                    return blogsEntry;
2797            }
2798    
2799            /**
2800             * 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.
2801             *
2802             * @param groupId the group ID
2803             * @param urlTitle the url title
2804             * @return the matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
2805             */
2806            @Override
2807            public BlogsEntry fetchByG_UT(long groupId, String urlTitle) {
2808                    return fetchByG_UT(groupId, urlTitle, true);
2809            }
2810    
2811            /**
2812             * 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.
2813             *
2814             * @param groupId the group ID
2815             * @param urlTitle the url title
2816             * @param retrieveFromCache whether to use the finder cache
2817             * @return the matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
2818             */
2819            @Override
2820            public BlogsEntry fetchByG_UT(long groupId, String urlTitle,
2821                    boolean retrieveFromCache) {
2822                    Object[] finderArgs = new Object[] { groupId, urlTitle };
2823    
2824                    Object result = null;
2825    
2826                    if (retrieveFromCache) {
2827                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_UT,
2828                                            finderArgs, this);
2829                    }
2830    
2831                    if (result instanceof BlogsEntry) {
2832                            BlogsEntry blogsEntry = (BlogsEntry)result;
2833    
2834                            if ((groupId != blogsEntry.getGroupId()) ||
2835                                            !Validator.equals(urlTitle, blogsEntry.getUrlTitle())) {
2836                                    result = null;
2837                            }
2838                    }
2839    
2840                    if (result == null) {
2841                            StringBundler query = new StringBundler(4);
2842    
2843                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
2844    
2845                            query.append(_FINDER_COLUMN_G_UT_GROUPID_2);
2846    
2847                            boolean bindUrlTitle = false;
2848    
2849                            if (urlTitle == null) {
2850                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_1);
2851                            }
2852                            else if (urlTitle.equals(StringPool.BLANK)) {
2853                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_3);
2854                            }
2855                            else {
2856                                    bindUrlTitle = true;
2857    
2858                                    query.append(_FINDER_COLUMN_G_UT_URLTITLE_2);
2859                            }
2860    
2861                            String sql = query.toString();
2862    
2863                            Session session = null;
2864    
2865                            try {
2866                                    session = openSession();
2867    
2868                                    Query q = session.createQuery(sql);
2869    
2870                                    QueryPos qPos = QueryPos.getInstance(q);
2871    
2872                                    qPos.add(groupId);
2873    
2874                                    if (bindUrlTitle) {
2875                                            qPos.add(urlTitle);
2876                                    }
2877    
2878                                    List<BlogsEntry> list = q.list();
2879    
2880                                    if (list.isEmpty()) {
2881                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_UT,
2882                                                    finderArgs, list);
2883                                    }
2884                                    else {
2885                                            BlogsEntry blogsEntry = list.get(0);
2886    
2887                                            result = blogsEntry;
2888    
2889                                            cacheResult(blogsEntry);
2890    
2891                                            if ((blogsEntry.getGroupId() != groupId) ||
2892                                                            (blogsEntry.getUrlTitle() == null) ||
2893                                                            !blogsEntry.getUrlTitle().equals(urlTitle)) {
2894                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_UT,
2895                                                            finderArgs, blogsEntry);
2896                                            }
2897                                    }
2898                            }
2899                            catch (Exception e) {
2900                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_UT,
2901                                            finderArgs);
2902    
2903                                    throw processException(e);
2904                            }
2905                            finally {
2906                                    closeSession(session);
2907                            }
2908                    }
2909    
2910                    if (result instanceof List<?>) {
2911                            return null;
2912                    }
2913                    else {
2914                            return (BlogsEntry)result;
2915                    }
2916            }
2917    
2918            /**
2919             * Removes the blogs entry where groupId = &#63; and urlTitle = &#63; from the database.
2920             *
2921             * @param groupId the group ID
2922             * @param urlTitle the url title
2923             * @return the blogs entry that was removed
2924             */
2925            @Override
2926            public BlogsEntry removeByG_UT(long groupId, String urlTitle)
2927                    throws NoSuchEntryException {
2928                    BlogsEntry blogsEntry = findByG_UT(groupId, urlTitle);
2929    
2930                    return remove(blogsEntry);
2931            }
2932    
2933            /**
2934             * Returns the number of blogs entries where groupId = &#63; and urlTitle = &#63;.
2935             *
2936             * @param groupId the group ID
2937             * @param urlTitle the url title
2938             * @return the number of matching blogs entries
2939             */
2940            @Override
2941            public int countByG_UT(long groupId, String urlTitle) {
2942                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_UT;
2943    
2944                    Object[] finderArgs = new Object[] { groupId, urlTitle };
2945    
2946                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2947                                    this);
2948    
2949                    if (count == null) {
2950                            StringBundler query = new StringBundler(3);
2951    
2952                            query.append(_SQL_COUNT_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                                    count = (Long)q.uniqueResult();
2988    
2989                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
2990                            }
2991                            catch (Exception e) {
2992                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2993    
2994                                    throw processException(e);
2995                            }
2996                            finally {
2997                                    closeSession(session);
2998                            }
2999                    }
3000    
3001                    return count.intValue();
3002            }
3003    
3004            private static final String _FINDER_COLUMN_G_UT_GROUPID_2 = "blogsEntry.groupId = ? AND ";
3005            private static final String _FINDER_COLUMN_G_UT_URLTITLE_1 = "blogsEntry.urlTitle IS NULL";
3006            private static final String _FINDER_COLUMN_G_UT_URLTITLE_2 = "blogsEntry.urlTitle = ?";
3007            private static final String _FINDER_COLUMN_G_UT_URLTITLE_3 = "(blogsEntry.urlTitle IS NULL OR blogsEntry.urlTitle = '')";
3008            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
3009                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
3010                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_LtD",
3011                            new String[] {
3012                                    Long.class.getName(), Date.class.getName(),
3013                                    
3014                            Integer.class.getName(), Integer.class.getName(),
3015                                    OrderByComparator.class.getName()
3016                            });
3017            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
3018                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
3019                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_LtD",
3020                            new String[] { Long.class.getName(), Date.class.getName() });
3021    
3022            /**
3023             * Returns all the blogs entries where groupId = &#63; and displayDate &lt; &#63;.
3024             *
3025             * @param groupId the group ID
3026             * @param displayDate the display date
3027             * @return the matching blogs entries
3028             */
3029            @Override
3030            public List<BlogsEntry> findByG_LtD(long groupId, Date displayDate) {
3031                    return findByG_LtD(groupId, displayDate, QueryUtil.ALL_POS,
3032                            QueryUtil.ALL_POS, null);
3033            }
3034    
3035            /**
3036             * Returns a range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63;.
3037             *
3038             * <p>
3039             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3040             * </p>
3041             *
3042             * @param groupId the group ID
3043             * @param displayDate the display date
3044             * @param start the lower bound of the range of blogs entries
3045             * @param end the upper bound of the range of blogs entries (not inclusive)
3046             * @return the range of matching blogs entries
3047             */
3048            @Override
3049            public List<BlogsEntry> findByG_LtD(long groupId, Date displayDate,
3050                    int start, int end) {
3051                    return findByG_LtD(groupId, displayDate, start, end, null);
3052            }
3053    
3054            /**
3055             * Returns an ordered range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63;.
3056             *
3057             * <p>
3058             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3059             * </p>
3060             *
3061             * @param groupId the group ID
3062             * @param displayDate the display date
3063             * @param start the lower bound of the range of blogs entries
3064             * @param end the upper bound of the range of blogs entries (not inclusive)
3065             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3066             * @return the ordered range of matching blogs entries
3067             */
3068            @Override
3069            public List<BlogsEntry> findByG_LtD(long groupId, Date displayDate,
3070                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator) {
3071                    boolean pagination = true;
3072                    FinderPath finderPath = null;
3073                    Object[] finderArgs = null;
3074    
3075                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD;
3076                    finderArgs = new Object[] {
3077                                    groupId, displayDate,
3078                                    
3079                                    start, end, orderByComparator
3080                            };
3081    
3082                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
3083                                    finderArgs, this);
3084    
3085                    if ((list != null) && !list.isEmpty()) {
3086                            for (BlogsEntry blogsEntry : list) {
3087                                    if ((groupId != blogsEntry.getGroupId()) ||
3088                                                    (displayDate.getTime() <= blogsEntry.getDisplayDate()
3089                                                                                                                                    .getTime())) {
3090                                            list = null;
3091    
3092                                            break;
3093                                    }
3094                            }
3095                    }
3096    
3097                    if (list == null) {
3098                            StringBundler query = null;
3099    
3100                            if (orderByComparator != null) {
3101                                    query = new StringBundler(4 +
3102                                                    (orderByComparator.getOrderByFields().length * 3));
3103                            }
3104                            else {
3105                                    query = new StringBundler(4);
3106                            }
3107    
3108                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
3109    
3110                            query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
3111    
3112                            boolean bindDisplayDate = false;
3113    
3114                            if (displayDate == null) {
3115                                    query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
3116                            }
3117                            else {
3118                                    bindDisplayDate = true;
3119    
3120                                    query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
3121                            }
3122    
3123                            if (orderByComparator != null) {
3124                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3125                                            orderByComparator);
3126                            }
3127                            else
3128                             if (pagination) {
3129                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
3130                            }
3131    
3132                            String sql = query.toString();
3133    
3134                            Session session = null;
3135    
3136                            try {
3137                                    session = openSession();
3138    
3139                                    Query q = session.createQuery(sql);
3140    
3141                                    QueryPos qPos = QueryPos.getInstance(q);
3142    
3143                                    qPos.add(groupId);
3144    
3145                                    if (bindDisplayDate) {
3146                                            qPos.add(new Timestamp(displayDate.getTime()));
3147                                    }
3148    
3149                                    if (!pagination) {
3150                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
3151                                                            start, end, false);
3152    
3153                                            Collections.sort(list);
3154    
3155                                            list = Collections.unmodifiableList(list);
3156                                    }
3157                                    else {
3158                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
3159                                                            start, end);
3160                                    }
3161    
3162                                    cacheResult(list);
3163    
3164                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
3165                            }
3166                            catch (Exception e) {
3167                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3168    
3169                                    throw processException(e);
3170                            }
3171                            finally {
3172                                    closeSession(session);
3173                            }
3174                    }
3175    
3176                    return list;
3177            }
3178    
3179            /**
3180             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63;.
3181             *
3182             * @param groupId the group ID
3183             * @param displayDate the display date
3184             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3185             * @return the first matching blogs entry
3186             * @throws NoSuchEntryException if a matching blogs entry could not be found
3187             */
3188            @Override
3189            public BlogsEntry findByG_LtD_First(long groupId, Date displayDate,
3190                    OrderByComparator<BlogsEntry> orderByComparator)
3191                    throws NoSuchEntryException {
3192                    BlogsEntry blogsEntry = fetchByG_LtD_First(groupId, displayDate,
3193                                    orderByComparator);
3194    
3195                    if (blogsEntry != null) {
3196                            return blogsEntry;
3197                    }
3198    
3199                    StringBundler msg = new StringBundler(6);
3200    
3201                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3202    
3203                    msg.append("groupId=");
3204                    msg.append(groupId);
3205    
3206                    msg.append(", displayDate=");
3207                    msg.append(displayDate);
3208    
3209                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3210    
3211                    throw new NoSuchEntryException(msg.toString());
3212            }
3213    
3214            /**
3215             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63;.
3216             *
3217             * @param groupId the group ID
3218             * @param displayDate the display date
3219             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3220             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
3221             */
3222            @Override
3223            public BlogsEntry fetchByG_LtD_First(long groupId, Date displayDate,
3224                    OrderByComparator<BlogsEntry> orderByComparator) {
3225                    List<BlogsEntry> list = findByG_LtD(groupId, displayDate, 0, 1,
3226                                    orderByComparator);
3227    
3228                    if (!list.isEmpty()) {
3229                            return list.get(0);
3230                    }
3231    
3232                    return null;
3233            }
3234    
3235            /**
3236             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63;.
3237             *
3238             * @param groupId the group ID
3239             * @param displayDate the display date
3240             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3241             * @return the last matching blogs entry
3242             * @throws NoSuchEntryException if a matching blogs entry could not be found
3243             */
3244            @Override
3245            public BlogsEntry findByG_LtD_Last(long groupId, Date displayDate,
3246                    OrderByComparator<BlogsEntry> orderByComparator)
3247                    throws NoSuchEntryException {
3248                    BlogsEntry blogsEntry = fetchByG_LtD_Last(groupId, displayDate,
3249                                    orderByComparator);
3250    
3251                    if (blogsEntry != null) {
3252                            return blogsEntry;
3253                    }
3254    
3255                    StringBundler msg = new StringBundler(6);
3256    
3257                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3258    
3259                    msg.append("groupId=");
3260                    msg.append(groupId);
3261    
3262                    msg.append(", displayDate=");
3263                    msg.append(displayDate);
3264    
3265                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3266    
3267                    throw new NoSuchEntryException(msg.toString());
3268            }
3269    
3270            /**
3271             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63;.
3272             *
3273             * @param groupId the group ID
3274             * @param displayDate the display date
3275             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3276             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
3277             */
3278            @Override
3279            public BlogsEntry fetchByG_LtD_Last(long groupId, Date displayDate,
3280                    OrderByComparator<BlogsEntry> orderByComparator) {
3281                    int count = countByG_LtD(groupId, displayDate);
3282    
3283                    if (count == 0) {
3284                            return null;
3285                    }
3286    
3287                    List<BlogsEntry> list = findByG_LtD(groupId, displayDate, count - 1,
3288                                    count, orderByComparator);
3289    
3290                    if (!list.isEmpty()) {
3291                            return list.get(0);
3292                    }
3293    
3294                    return null;
3295            }
3296    
3297            /**
3298             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63;.
3299             *
3300             * @param entryId the primary key of the current blogs entry
3301             * @param groupId the group ID
3302             * @param displayDate the display date
3303             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3304             * @return the previous, current, and next blogs entry
3305             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
3306             */
3307            @Override
3308            public BlogsEntry[] findByG_LtD_PrevAndNext(long entryId, long groupId,
3309                    Date displayDate, OrderByComparator<BlogsEntry> orderByComparator)
3310                    throws NoSuchEntryException {
3311                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
3312    
3313                    Session session = null;
3314    
3315                    try {
3316                            session = openSession();
3317    
3318                            BlogsEntry[] array = new BlogsEntryImpl[3];
3319    
3320                            array[0] = getByG_LtD_PrevAndNext(session, blogsEntry, groupId,
3321                                            displayDate, orderByComparator, true);
3322    
3323                            array[1] = blogsEntry;
3324    
3325                            array[2] = getByG_LtD_PrevAndNext(session, blogsEntry, groupId,
3326                                            displayDate, orderByComparator, false);
3327    
3328                            return array;
3329                    }
3330                    catch (Exception e) {
3331                            throw processException(e);
3332                    }
3333                    finally {
3334                            closeSession(session);
3335                    }
3336            }
3337    
3338            protected BlogsEntry getByG_LtD_PrevAndNext(Session session,
3339                    BlogsEntry blogsEntry, long groupId, Date displayDate,
3340                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
3341                    StringBundler query = null;
3342    
3343                    if (orderByComparator != null) {
3344                            query = new StringBundler(6 +
3345                                            (orderByComparator.getOrderByFields().length * 6));
3346                    }
3347                    else {
3348                            query = new StringBundler(3);
3349                    }
3350    
3351                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
3352    
3353                    query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
3354    
3355                    boolean bindDisplayDate = false;
3356    
3357                    if (displayDate == null) {
3358                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
3359                    }
3360                    else {
3361                            bindDisplayDate = true;
3362    
3363                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
3364                    }
3365    
3366                    if (orderByComparator != null) {
3367                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3368    
3369                            if (orderByConditionFields.length > 0) {
3370                                    query.append(WHERE_AND);
3371                            }
3372    
3373                            for (int i = 0; i < orderByConditionFields.length; i++) {
3374                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3375                                    query.append(orderByConditionFields[i]);
3376    
3377                                    if ((i + 1) < orderByConditionFields.length) {
3378                                            if (orderByComparator.isAscending() ^ previous) {
3379                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3380                                            }
3381                                            else {
3382                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3383                                            }
3384                                    }
3385                                    else {
3386                                            if (orderByComparator.isAscending() ^ previous) {
3387                                                    query.append(WHERE_GREATER_THAN);
3388                                            }
3389                                            else {
3390                                                    query.append(WHERE_LESSER_THAN);
3391                                            }
3392                                    }
3393                            }
3394    
3395                            query.append(ORDER_BY_CLAUSE);
3396    
3397                            String[] orderByFields = orderByComparator.getOrderByFields();
3398    
3399                            for (int i = 0; i < orderByFields.length; i++) {
3400                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3401                                    query.append(orderByFields[i]);
3402    
3403                                    if ((i + 1) < orderByFields.length) {
3404                                            if (orderByComparator.isAscending() ^ previous) {
3405                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3406                                            }
3407                                            else {
3408                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3409                                            }
3410                                    }
3411                                    else {
3412                                            if (orderByComparator.isAscending() ^ previous) {
3413                                                    query.append(ORDER_BY_ASC);
3414                                            }
3415                                            else {
3416                                                    query.append(ORDER_BY_DESC);
3417                                            }
3418                                    }
3419                            }
3420                    }
3421                    else {
3422                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
3423                    }
3424    
3425                    String sql = query.toString();
3426    
3427                    Query q = session.createQuery(sql);
3428    
3429                    q.setFirstResult(0);
3430                    q.setMaxResults(2);
3431    
3432                    QueryPos qPos = QueryPos.getInstance(q);
3433    
3434                    qPos.add(groupId);
3435    
3436                    if (bindDisplayDate) {
3437                            qPos.add(new Timestamp(displayDate.getTime()));
3438                    }
3439    
3440                    if (orderByComparator != null) {
3441                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
3442    
3443                            for (Object value : values) {
3444                                    qPos.add(value);
3445                            }
3446                    }
3447    
3448                    List<BlogsEntry> list = q.list();
3449    
3450                    if (list.size() == 2) {
3451                            return list.get(1);
3452                    }
3453                    else {
3454                            return null;
3455                    }
3456            }
3457    
3458            /**
3459             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63;.
3460             *
3461             * @param groupId the group ID
3462             * @param displayDate the display date
3463             * @return the matching blogs entries that the user has permission to view
3464             */
3465            @Override
3466            public List<BlogsEntry> filterFindByG_LtD(long groupId, Date displayDate) {
3467                    return filterFindByG_LtD(groupId, displayDate, QueryUtil.ALL_POS,
3468                            QueryUtil.ALL_POS, null);
3469            }
3470    
3471            /**
3472             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63;.
3473             *
3474             * <p>
3475             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3476             * </p>
3477             *
3478             * @param groupId the group ID
3479             * @param displayDate the display date
3480             * @param start the lower bound of the range of blogs entries
3481             * @param end the upper bound of the range of blogs entries (not inclusive)
3482             * @return the range of matching blogs entries that the user has permission to view
3483             */
3484            @Override
3485            public List<BlogsEntry> filterFindByG_LtD(long groupId, Date displayDate,
3486                    int start, int end) {
3487                    return filterFindByG_LtD(groupId, displayDate, start, end, null);
3488            }
3489    
3490            /**
3491             * Returns an ordered range of all the blogs entries that the user has permissions to view where groupId = &#63; and displayDate &lt; &#63;.
3492             *
3493             * <p>
3494             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3495             * </p>
3496             *
3497             * @param groupId the group ID
3498             * @param displayDate the display date
3499             * @param start the lower bound of the range of blogs entries
3500             * @param end the upper bound of the range of blogs entries (not inclusive)
3501             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3502             * @return the ordered range of matching blogs entries that the user has permission to view
3503             */
3504            @Override
3505            public List<BlogsEntry> filterFindByG_LtD(long groupId, Date displayDate,
3506                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator) {
3507                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3508                            return findByG_LtD(groupId, displayDate, start, end,
3509                                    orderByComparator);
3510                    }
3511    
3512                    StringBundler query = null;
3513    
3514                    if (orderByComparator != null) {
3515                            query = new StringBundler(4 +
3516                                            (orderByComparator.getOrderByFields().length * 3));
3517                    }
3518                    else {
3519                            query = new StringBundler(4);
3520                    }
3521    
3522                    if (getDB().isSupportsInlineDistinct()) {
3523                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
3524                    }
3525                    else {
3526                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
3527                    }
3528    
3529                    query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
3530    
3531                    boolean bindDisplayDate = false;
3532    
3533                    if (displayDate == null) {
3534                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
3535                    }
3536                    else {
3537                            bindDisplayDate = true;
3538    
3539                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
3540                    }
3541    
3542                    if (!getDB().isSupportsInlineDistinct()) {
3543                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
3544                    }
3545    
3546                    if (orderByComparator != null) {
3547                            if (getDB().isSupportsInlineDistinct()) {
3548                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3549                                            orderByComparator, true);
3550                            }
3551                            else {
3552                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
3553                                            orderByComparator, true);
3554                            }
3555                    }
3556                    else {
3557                            if (getDB().isSupportsInlineDistinct()) {
3558                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
3559                            }
3560                            else {
3561                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
3562                            }
3563                    }
3564    
3565                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3566                                    BlogsEntry.class.getName(),
3567                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3568    
3569                    Session session = null;
3570    
3571                    try {
3572                            session = openSession();
3573    
3574                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
3575    
3576                            if (getDB().isSupportsInlineDistinct()) {
3577                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
3578                            }
3579                            else {
3580                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
3581                            }
3582    
3583                            QueryPos qPos = QueryPos.getInstance(q);
3584    
3585                            qPos.add(groupId);
3586    
3587                            if (bindDisplayDate) {
3588                                    qPos.add(new Timestamp(displayDate.getTime()));
3589                            }
3590    
3591                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
3592                    }
3593                    catch (Exception e) {
3594                            throw processException(e);
3595                    }
3596                    finally {
3597                            closeSession(session);
3598                    }
3599            }
3600    
3601            /**
3602             * 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;.
3603             *
3604             * @param entryId the primary key of the current blogs entry
3605             * @param groupId the group ID
3606             * @param displayDate the display date
3607             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3608             * @return the previous, current, and next blogs entry
3609             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
3610             */
3611            @Override
3612            public BlogsEntry[] filterFindByG_LtD_PrevAndNext(long entryId,
3613                    long groupId, Date displayDate,
3614                    OrderByComparator<BlogsEntry> orderByComparator)
3615                    throws NoSuchEntryException {
3616                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3617                            return findByG_LtD_PrevAndNext(entryId, groupId, displayDate,
3618                                    orderByComparator);
3619                    }
3620    
3621                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
3622    
3623                    Session session = null;
3624    
3625                    try {
3626                            session = openSession();
3627    
3628                            BlogsEntry[] array = new BlogsEntryImpl[3];
3629    
3630                            array[0] = filterGetByG_LtD_PrevAndNext(session, blogsEntry,
3631                                            groupId, displayDate, orderByComparator, true);
3632    
3633                            array[1] = blogsEntry;
3634    
3635                            array[2] = filterGetByG_LtD_PrevAndNext(session, blogsEntry,
3636                                            groupId, displayDate, orderByComparator, false);
3637    
3638                            return array;
3639                    }
3640                    catch (Exception e) {
3641                            throw processException(e);
3642                    }
3643                    finally {
3644                            closeSession(session);
3645                    }
3646            }
3647    
3648            protected BlogsEntry filterGetByG_LtD_PrevAndNext(Session session,
3649                    BlogsEntry blogsEntry, long groupId, Date displayDate,
3650                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
3651                    StringBundler query = null;
3652    
3653                    if (orderByComparator != null) {
3654                            query = new StringBundler(6 +
3655                                            (orderByComparator.getOrderByFields().length * 6));
3656                    }
3657                    else {
3658                            query = new StringBundler(3);
3659                    }
3660    
3661                    if (getDB().isSupportsInlineDistinct()) {
3662                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
3663                    }
3664                    else {
3665                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
3666                    }
3667    
3668                    query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
3669    
3670                    boolean bindDisplayDate = false;
3671    
3672                    if (displayDate == null) {
3673                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
3674                    }
3675                    else {
3676                            bindDisplayDate = true;
3677    
3678                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
3679                    }
3680    
3681                    if (!getDB().isSupportsInlineDistinct()) {
3682                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
3683                    }
3684    
3685                    if (orderByComparator != null) {
3686                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3687    
3688                            if (orderByConditionFields.length > 0) {
3689                                    query.append(WHERE_AND);
3690                            }
3691    
3692                            for (int i = 0; i < orderByConditionFields.length; i++) {
3693                                    if (getDB().isSupportsInlineDistinct()) {
3694                                            query.append(_ORDER_BY_ENTITY_ALIAS);
3695                                    }
3696                                    else {
3697                                            query.append(_ORDER_BY_ENTITY_TABLE);
3698                                    }
3699    
3700                                    query.append(orderByConditionFields[i]);
3701    
3702                                    if ((i + 1) < orderByConditionFields.length) {
3703                                            if (orderByComparator.isAscending() ^ previous) {
3704                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3705                                            }
3706                                            else {
3707                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3708                                            }
3709                                    }
3710                                    else {
3711                                            if (orderByComparator.isAscending() ^ previous) {
3712                                                    query.append(WHERE_GREATER_THAN);
3713                                            }
3714                                            else {
3715                                                    query.append(WHERE_LESSER_THAN);
3716                                            }
3717                                    }
3718                            }
3719    
3720                            query.append(ORDER_BY_CLAUSE);
3721    
3722                            String[] orderByFields = orderByComparator.getOrderByFields();
3723    
3724                            for (int i = 0; i < orderByFields.length; i++) {
3725                                    if (getDB().isSupportsInlineDistinct()) {
3726                                            query.append(_ORDER_BY_ENTITY_ALIAS);
3727                                    }
3728                                    else {
3729                                            query.append(_ORDER_BY_ENTITY_TABLE);
3730                                    }
3731    
3732                                    query.append(orderByFields[i]);
3733    
3734                                    if ((i + 1) < orderByFields.length) {
3735                                            if (orderByComparator.isAscending() ^ previous) {
3736                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3737                                            }
3738                                            else {
3739                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3740                                            }
3741                                    }
3742                                    else {
3743                                            if (orderByComparator.isAscending() ^ previous) {
3744                                                    query.append(ORDER_BY_ASC);
3745                                            }
3746                                            else {
3747                                                    query.append(ORDER_BY_DESC);
3748                                            }
3749                                    }
3750                            }
3751                    }
3752                    else {
3753                            if (getDB().isSupportsInlineDistinct()) {
3754                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
3755                            }
3756                            else {
3757                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
3758                            }
3759                    }
3760    
3761                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3762                                    BlogsEntry.class.getName(),
3763                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3764    
3765                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
3766    
3767                    q.setFirstResult(0);
3768                    q.setMaxResults(2);
3769    
3770                    if (getDB().isSupportsInlineDistinct()) {
3771                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
3772                    }
3773                    else {
3774                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
3775                    }
3776    
3777                    QueryPos qPos = QueryPos.getInstance(q);
3778    
3779                    qPos.add(groupId);
3780    
3781                    if (bindDisplayDate) {
3782                            qPos.add(new Timestamp(displayDate.getTime()));
3783                    }
3784    
3785                    if (orderByComparator != null) {
3786                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
3787    
3788                            for (Object value : values) {
3789                                    qPos.add(value);
3790                            }
3791                    }
3792    
3793                    List<BlogsEntry> list = q.list();
3794    
3795                    if (list.size() == 2) {
3796                            return list.get(1);
3797                    }
3798                    else {
3799                            return null;
3800                    }
3801            }
3802    
3803            /**
3804             * Removes all the blogs entries where groupId = &#63; and displayDate &lt; &#63; from the database.
3805             *
3806             * @param groupId the group ID
3807             * @param displayDate the display date
3808             */
3809            @Override
3810            public void removeByG_LtD(long groupId, Date displayDate) {
3811                    for (BlogsEntry blogsEntry : findByG_LtD(groupId, displayDate,
3812                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3813                            remove(blogsEntry);
3814                    }
3815            }
3816    
3817            /**
3818             * Returns the number of blogs entries where groupId = &#63; and displayDate &lt; &#63;.
3819             *
3820             * @param groupId the group ID
3821             * @param displayDate the display date
3822             * @return the number of matching blogs entries
3823             */
3824            @Override
3825            public int countByG_LtD(long groupId, Date displayDate) {
3826                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD;
3827    
3828                    Object[] finderArgs = new Object[] { groupId, displayDate };
3829    
3830                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3831                                    this);
3832    
3833                    if (count == null) {
3834                            StringBundler query = new StringBundler(3);
3835    
3836                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
3837    
3838                            query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
3839    
3840                            boolean bindDisplayDate = false;
3841    
3842                            if (displayDate == null) {
3843                                    query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
3844                            }
3845                            else {
3846                                    bindDisplayDate = true;
3847    
3848                                    query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
3849                            }
3850    
3851                            String sql = query.toString();
3852    
3853                            Session session = null;
3854    
3855                            try {
3856                                    session = openSession();
3857    
3858                                    Query q = session.createQuery(sql);
3859    
3860                                    QueryPos qPos = QueryPos.getInstance(q);
3861    
3862                                    qPos.add(groupId);
3863    
3864                                    if (bindDisplayDate) {
3865                                            qPos.add(new Timestamp(displayDate.getTime()));
3866                                    }
3867    
3868                                    count = (Long)q.uniqueResult();
3869    
3870                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
3871                            }
3872                            catch (Exception e) {
3873                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3874    
3875                                    throw processException(e);
3876                            }
3877                            finally {
3878                                    closeSession(session);
3879                            }
3880                    }
3881    
3882                    return count.intValue();
3883            }
3884    
3885            /**
3886             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63;.
3887             *
3888             * @param groupId the group ID
3889             * @param displayDate the display date
3890             * @return the number of matching blogs entries that the user has permission to view
3891             */
3892            @Override
3893            public int filterCountByG_LtD(long groupId, Date displayDate) {
3894                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3895                            return countByG_LtD(groupId, displayDate);
3896                    }
3897    
3898                    StringBundler query = new StringBundler(3);
3899    
3900                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
3901    
3902                    query.append(_FINDER_COLUMN_G_LTD_GROUPID_2);
3903    
3904                    boolean bindDisplayDate = false;
3905    
3906                    if (displayDate == null) {
3907                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_1);
3908                    }
3909                    else {
3910                            bindDisplayDate = true;
3911    
3912                            query.append(_FINDER_COLUMN_G_LTD_DISPLAYDATE_2);
3913                    }
3914    
3915                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3916                                    BlogsEntry.class.getName(),
3917                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3918    
3919                    Session session = null;
3920    
3921                    try {
3922                            session = openSession();
3923    
3924                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
3925    
3926                            q.addScalar(COUNT_COLUMN_NAME,
3927                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
3928    
3929                            QueryPos qPos = QueryPos.getInstance(q);
3930    
3931                            qPos.add(groupId);
3932    
3933                            if (bindDisplayDate) {
3934                                    qPos.add(new Timestamp(displayDate.getTime()));
3935                            }
3936    
3937                            Long count = (Long)q.uniqueResult();
3938    
3939                            return count.intValue();
3940                    }
3941                    catch (Exception e) {
3942                            throw processException(e);
3943                    }
3944                    finally {
3945                            closeSession(session);
3946                    }
3947            }
3948    
3949            private static final String _FINDER_COLUMN_G_LTD_GROUPID_2 = "blogsEntry.groupId = ? AND ";
3950            private static final String _FINDER_COLUMN_G_LTD_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL";
3951            private static final String _FINDER_COLUMN_G_LTD_DISPLAYDATE_2 = "blogsEntry.displayDate < ?";
3952            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
3953                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
3954                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_S",
3955                            new String[] {
3956                                    Long.class.getName(), Integer.class.getName(),
3957                                    
3958                            Integer.class.getName(), Integer.class.getName(),
3959                                    OrderByComparator.class.getName()
3960                            });
3961            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
3962                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
3963                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_S",
3964                            new String[] { Long.class.getName(), Integer.class.getName() },
3965                            BlogsEntryModelImpl.GROUPID_COLUMN_BITMASK |
3966                            BlogsEntryModelImpl.STATUS_COLUMN_BITMASK |
3967                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
3968                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
3969            public static final FinderPath FINDER_PATH_COUNT_BY_G_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
3970                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
3971                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_S",
3972                            new String[] { Long.class.getName(), Integer.class.getName() });
3973    
3974            /**
3975             * Returns all the blogs entries where groupId = &#63; and status = &#63;.
3976             *
3977             * @param groupId the group ID
3978             * @param status the status
3979             * @return the matching blogs entries
3980             */
3981            @Override
3982            public List<BlogsEntry> findByG_S(long groupId, int status) {
3983                    return findByG_S(groupId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
3984                            null);
3985            }
3986    
3987            /**
3988             * Returns a range of all the blogs entries where groupId = &#63; and status = &#63;.
3989             *
3990             * <p>
3991             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3992             * </p>
3993             *
3994             * @param groupId the group ID
3995             * @param status the status
3996             * @param start the lower bound of the range of blogs entries
3997             * @param end the upper bound of the range of blogs entries (not inclusive)
3998             * @return the range of matching blogs entries
3999             */
4000            @Override
4001            public List<BlogsEntry> findByG_S(long groupId, int status, int start,
4002                    int end) {
4003                    return findByG_S(groupId, status, start, end, null);
4004            }
4005    
4006            /**
4007             * Returns an ordered range of all the blogs entries where groupId = &#63; and status = &#63;.
4008             *
4009             * <p>
4010             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4011             * </p>
4012             *
4013             * @param groupId the group ID
4014             * @param status the status
4015             * @param start the lower bound of the range of blogs entries
4016             * @param end the upper bound of the range of blogs entries (not inclusive)
4017             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4018             * @return the ordered range of matching blogs entries
4019             */
4020            @Override
4021            public List<BlogsEntry> findByG_S(long groupId, int status, int start,
4022                    int end, OrderByComparator<BlogsEntry> orderByComparator) {
4023                    boolean pagination = true;
4024                    FinderPath finderPath = null;
4025                    Object[] finderArgs = null;
4026    
4027                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4028                                    (orderByComparator == null)) {
4029                            pagination = false;
4030                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S;
4031                            finderArgs = new Object[] { groupId, status };
4032                    }
4033                    else {
4034                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S;
4035                            finderArgs = new Object[] {
4036                                            groupId, status,
4037                                            
4038                                            start, end, orderByComparator
4039                                    };
4040                    }
4041    
4042                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
4043                                    finderArgs, this);
4044    
4045                    if ((list != null) && !list.isEmpty()) {
4046                            for (BlogsEntry blogsEntry : list) {
4047                                    if ((groupId != blogsEntry.getGroupId()) ||
4048                                                    (status != blogsEntry.getStatus())) {
4049                                            list = null;
4050    
4051                                            break;
4052                                    }
4053                            }
4054                    }
4055    
4056                    if (list == null) {
4057                            StringBundler query = null;
4058    
4059                            if (orderByComparator != null) {
4060                                    query = new StringBundler(4 +
4061                                                    (orderByComparator.getOrderByFields().length * 3));
4062                            }
4063                            else {
4064                                    query = new StringBundler(4);
4065                            }
4066    
4067                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
4068    
4069                            query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4070    
4071                            query.append(_FINDER_COLUMN_G_S_STATUS_2);
4072    
4073                            if (orderByComparator != null) {
4074                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4075                                            orderByComparator);
4076                            }
4077                            else
4078                             if (pagination) {
4079                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
4080                            }
4081    
4082                            String sql = query.toString();
4083    
4084                            Session session = null;
4085    
4086                            try {
4087                                    session = openSession();
4088    
4089                                    Query q = session.createQuery(sql);
4090    
4091                                    QueryPos qPos = QueryPos.getInstance(q);
4092    
4093                                    qPos.add(groupId);
4094    
4095                                    qPos.add(status);
4096    
4097                                    if (!pagination) {
4098                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
4099                                                            start, end, false);
4100    
4101                                            Collections.sort(list);
4102    
4103                                            list = Collections.unmodifiableList(list);
4104                                    }
4105                                    else {
4106                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
4107                                                            start, end);
4108                                    }
4109    
4110                                    cacheResult(list);
4111    
4112                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
4113                            }
4114                            catch (Exception e) {
4115                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4116    
4117                                    throw processException(e);
4118                            }
4119                            finally {
4120                                    closeSession(session);
4121                            }
4122                    }
4123    
4124                    return list;
4125            }
4126    
4127            /**
4128             * Returns the first blogs entry in the ordered set where groupId = &#63; and status = &#63;.
4129             *
4130             * @param groupId the group ID
4131             * @param status the status
4132             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4133             * @return the first matching blogs entry
4134             * @throws NoSuchEntryException if a matching blogs entry could not be found
4135             */
4136            @Override
4137            public BlogsEntry findByG_S_First(long groupId, int status,
4138                    OrderByComparator<BlogsEntry> orderByComparator)
4139                    throws NoSuchEntryException {
4140                    BlogsEntry blogsEntry = fetchByG_S_First(groupId, status,
4141                                    orderByComparator);
4142    
4143                    if (blogsEntry != null) {
4144                            return blogsEntry;
4145                    }
4146    
4147                    StringBundler msg = new StringBundler(6);
4148    
4149                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4150    
4151                    msg.append("groupId=");
4152                    msg.append(groupId);
4153    
4154                    msg.append(", status=");
4155                    msg.append(status);
4156    
4157                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4158    
4159                    throw new NoSuchEntryException(msg.toString());
4160            }
4161    
4162            /**
4163             * Returns the first blogs entry in the ordered set where groupId = &#63; and status = &#63;.
4164             *
4165             * @param groupId the group ID
4166             * @param status the status
4167             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4168             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
4169             */
4170            @Override
4171            public BlogsEntry fetchByG_S_First(long groupId, int status,
4172                    OrderByComparator<BlogsEntry> orderByComparator) {
4173                    List<BlogsEntry> list = findByG_S(groupId, status, 0, 1,
4174                                    orderByComparator);
4175    
4176                    if (!list.isEmpty()) {
4177                            return list.get(0);
4178                    }
4179    
4180                    return null;
4181            }
4182    
4183            /**
4184             * Returns the last blogs entry in the ordered set where groupId = &#63; and status = &#63;.
4185             *
4186             * @param groupId the group ID
4187             * @param status the status
4188             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4189             * @return the last matching blogs entry
4190             * @throws NoSuchEntryException if a matching blogs entry could not be found
4191             */
4192            @Override
4193            public BlogsEntry findByG_S_Last(long groupId, int status,
4194                    OrderByComparator<BlogsEntry> orderByComparator)
4195                    throws NoSuchEntryException {
4196                    BlogsEntry blogsEntry = fetchByG_S_Last(groupId, status,
4197                                    orderByComparator);
4198    
4199                    if (blogsEntry != null) {
4200                            return blogsEntry;
4201                    }
4202    
4203                    StringBundler msg = new StringBundler(6);
4204    
4205                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4206    
4207                    msg.append("groupId=");
4208                    msg.append(groupId);
4209    
4210                    msg.append(", status=");
4211                    msg.append(status);
4212    
4213                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4214    
4215                    throw new NoSuchEntryException(msg.toString());
4216            }
4217    
4218            /**
4219             * Returns the last blogs entry in the ordered set where groupId = &#63; and status = &#63;.
4220             *
4221             * @param groupId the group ID
4222             * @param status the status
4223             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4224             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
4225             */
4226            @Override
4227            public BlogsEntry fetchByG_S_Last(long groupId, int status,
4228                    OrderByComparator<BlogsEntry> orderByComparator) {
4229                    int count = countByG_S(groupId, status);
4230    
4231                    if (count == 0) {
4232                            return null;
4233                    }
4234    
4235                    List<BlogsEntry> list = findByG_S(groupId, status, count - 1, count,
4236                                    orderByComparator);
4237    
4238                    if (!list.isEmpty()) {
4239                            return list.get(0);
4240                    }
4241    
4242                    return null;
4243            }
4244    
4245            /**
4246             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63; and status = &#63;.
4247             *
4248             * @param entryId the primary key of the current blogs entry
4249             * @param groupId the group ID
4250             * @param status the status
4251             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4252             * @return the previous, current, and next blogs entry
4253             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
4254             */
4255            @Override
4256            public BlogsEntry[] findByG_S_PrevAndNext(long entryId, long groupId,
4257                    int status, OrderByComparator<BlogsEntry> orderByComparator)
4258                    throws NoSuchEntryException {
4259                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
4260    
4261                    Session session = null;
4262    
4263                    try {
4264                            session = openSession();
4265    
4266                            BlogsEntry[] array = new BlogsEntryImpl[3];
4267    
4268                            array[0] = getByG_S_PrevAndNext(session, blogsEntry, groupId,
4269                                            status, orderByComparator, true);
4270    
4271                            array[1] = blogsEntry;
4272    
4273                            array[2] = getByG_S_PrevAndNext(session, blogsEntry, groupId,
4274                                            status, orderByComparator, false);
4275    
4276                            return array;
4277                    }
4278                    catch (Exception e) {
4279                            throw processException(e);
4280                    }
4281                    finally {
4282                            closeSession(session);
4283                    }
4284            }
4285    
4286            protected BlogsEntry getByG_S_PrevAndNext(Session session,
4287                    BlogsEntry blogsEntry, long groupId, int status,
4288                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
4289                    StringBundler query = null;
4290    
4291                    if (orderByComparator != null) {
4292                            query = new StringBundler(6 +
4293                                            (orderByComparator.getOrderByFields().length * 6));
4294                    }
4295                    else {
4296                            query = new StringBundler(3);
4297                    }
4298    
4299                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
4300    
4301                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4302    
4303                    query.append(_FINDER_COLUMN_G_S_STATUS_2);
4304    
4305                    if (orderByComparator != null) {
4306                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4307    
4308                            if (orderByConditionFields.length > 0) {
4309                                    query.append(WHERE_AND);
4310                            }
4311    
4312                            for (int i = 0; i < orderByConditionFields.length; i++) {
4313                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4314                                    query.append(orderByConditionFields[i]);
4315    
4316                                    if ((i + 1) < orderByConditionFields.length) {
4317                                            if (orderByComparator.isAscending() ^ previous) {
4318                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4319                                            }
4320                                            else {
4321                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4322                                            }
4323                                    }
4324                                    else {
4325                                            if (orderByComparator.isAscending() ^ previous) {
4326                                                    query.append(WHERE_GREATER_THAN);
4327                                            }
4328                                            else {
4329                                                    query.append(WHERE_LESSER_THAN);
4330                                            }
4331                                    }
4332                            }
4333    
4334                            query.append(ORDER_BY_CLAUSE);
4335    
4336                            String[] orderByFields = orderByComparator.getOrderByFields();
4337    
4338                            for (int i = 0; i < orderByFields.length; i++) {
4339                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4340                                    query.append(orderByFields[i]);
4341    
4342                                    if ((i + 1) < orderByFields.length) {
4343                                            if (orderByComparator.isAscending() ^ previous) {
4344                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4345                                            }
4346                                            else {
4347                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4348                                            }
4349                                    }
4350                                    else {
4351                                            if (orderByComparator.isAscending() ^ previous) {
4352                                                    query.append(ORDER_BY_ASC);
4353                                            }
4354                                            else {
4355                                                    query.append(ORDER_BY_DESC);
4356                                            }
4357                                    }
4358                            }
4359                    }
4360                    else {
4361                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
4362                    }
4363    
4364                    String sql = query.toString();
4365    
4366                    Query q = session.createQuery(sql);
4367    
4368                    q.setFirstResult(0);
4369                    q.setMaxResults(2);
4370    
4371                    QueryPos qPos = QueryPos.getInstance(q);
4372    
4373                    qPos.add(groupId);
4374    
4375                    qPos.add(status);
4376    
4377                    if (orderByComparator != null) {
4378                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
4379    
4380                            for (Object value : values) {
4381                                    qPos.add(value);
4382                            }
4383                    }
4384    
4385                    List<BlogsEntry> list = q.list();
4386    
4387                    if (list.size() == 2) {
4388                            return list.get(1);
4389                    }
4390                    else {
4391                            return null;
4392                    }
4393            }
4394    
4395            /**
4396             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and status = &#63;.
4397             *
4398             * @param groupId the group ID
4399             * @param status the status
4400             * @return the matching blogs entries that the user has permission to view
4401             */
4402            @Override
4403            public List<BlogsEntry> filterFindByG_S(long groupId, int status) {
4404                    return filterFindByG_S(groupId, status, QueryUtil.ALL_POS,
4405                            QueryUtil.ALL_POS, null);
4406            }
4407    
4408            /**
4409             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63; and status = &#63;.
4410             *
4411             * <p>
4412             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4413             * </p>
4414             *
4415             * @param groupId the group ID
4416             * @param status the status
4417             * @param start the lower bound of the range of blogs entries
4418             * @param end the upper bound of the range of blogs entries (not inclusive)
4419             * @return the range of matching blogs entries that the user has permission to view
4420             */
4421            @Override
4422            public List<BlogsEntry> filterFindByG_S(long groupId, int status,
4423                    int start, int end) {
4424                    return filterFindByG_S(groupId, status, start, end, null);
4425            }
4426    
4427            /**
4428             * Returns an ordered range of all the blogs entries that the user has permissions to view where groupId = &#63; and status = &#63;.
4429             *
4430             * <p>
4431             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4432             * </p>
4433             *
4434             * @param groupId the group ID
4435             * @param status the status
4436             * @param start the lower bound of the range of blogs entries
4437             * @param end the upper bound of the range of blogs entries (not inclusive)
4438             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4439             * @return the ordered range of matching blogs entries that the user has permission to view
4440             */
4441            @Override
4442            public List<BlogsEntry> filterFindByG_S(long groupId, int status,
4443                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator) {
4444                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4445                            return findByG_S(groupId, status, start, end, orderByComparator);
4446                    }
4447    
4448                    StringBundler query = null;
4449    
4450                    if (orderByComparator != null) {
4451                            query = new StringBundler(4 +
4452                                            (orderByComparator.getOrderByFields().length * 3));
4453                    }
4454                    else {
4455                            query = new StringBundler(4);
4456                    }
4457    
4458                    if (getDB().isSupportsInlineDistinct()) {
4459                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
4460                    }
4461                    else {
4462                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
4463                    }
4464    
4465                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4466    
4467                    query.append(_FINDER_COLUMN_G_S_STATUS_2);
4468    
4469                    if (!getDB().isSupportsInlineDistinct()) {
4470                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
4471                    }
4472    
4473                    if (orderByComparator != null) {
4474                            if (getDB().isSupportsInlineDistinct()) {
4475                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4476                                            orderByComparator, true);
4477                            }
4478                            else {
4479                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
4480                                            orderByComparator, true);
4481                            }
4482                    }
4483                    else {
4484                            if (getDB().isSupportsInlineDistinct()) {
4485                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
4486                            }
4487                            else {
4488                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
4489                            }
4490                    }
4491    
4492                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4493                                    BlogsEntry.class.getName(),
4494                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4495    
4496                    Session session = null;
4497    
4498                    try {
4499                            session = openSession();
4500    
4501                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
4502    
4503                            if (getDB().isSupportsInlineDistinct()) {
4504                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
4505                            }
4506                            else {
4507                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
4508                            }
4509    
4510                            QueryPos qPos = QueryPos.getInstance(q);
4511    
4512                            qPos.add(groupId);
4513    
4514                            qPos.add(status);
4515    
4516                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
4517                    }
4518                    catch (Exception e) {
4519                            throw processException(e);
4520                    }
4521                    finally {
4522                            closeSession(session);
4523                    }
4524            }
4525    
4526            /**
4527             * 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;.
4528             *
4529             * @param entryId the primary key of the current blogs entry
4530             * @param groupId the group ID
4531             * @param status the status
4532             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4533             * @return the previous, current, and next blogs entry
4534             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
4535             */
4536            @Override
4537            public BlogsEntry[] filterFindByG_S_PrevAndNext(long entryId, long groupId,
4538                    int status, OrderByComparator<BlogsEntry> orderByComparator)
4539                    throws NoSuchEntryException {
4540                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4541                            return findByG_S_PrevAndNext(entryId, groupId, status,
4542                                    orderByComparator);
4543                    }
4544    
4545                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
4546    
4547                    Session session = null;
4548    
4549                    try {
4550                            session = openSession();
4551    
4552                            BlogsEntry[] array = new BlogsEntryImpl[3];
4553    
4554                            array[0] = filterGetByG_S_PrevAndNext(session, blogsEntry, groupId,
4555                                            status, orderByComparator, true);
4556    
4557                            array[1] = blogsEntry;
4558    
4559                            array[2] = filterGetByG_S_PrevAndNext(session, blogsEntry, groupId,
4560                                            status, orderByComparator, false);
4561    
4562                            return array;
4563                    }
4564                    catch (Exception e) {
4565                            throw processException(e);
4566                    }
4567                    finally {
4568                            closeSession(session);
4569                    }
4570            }
4571    
4572            protected BlogsEntry filterGetByG_S_PrevAndNext(Session session,
4573                    BlogsEntry blogsEntry, long groupId, int status,
4574                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
4575                    StringBundler query = null;
4576    
4577                    if (orderByComparator != null) {
4578                            query = new StringBundler(6 +
4579                                            (orderByComparator.getOrderByFields().length * 6));
4580                    }
4581                    else {
4582                            query = new StringBundler(3);
4583                    }
4584    
4585                    if (getDB().isSupportsInlineDistinct()) {
4586                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
4587                    }
4588                    else {
4589                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
4590                    }
4591    
4592                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4593    
4594                    query.append(_FINDER_COLUMN_G_S_STATUS_2);
4595    
4596                    if (!getDB().isSupportsInlineDistinct()) {
4597                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
4598                    }
4599    
4600                    if (orderByComparator != null) {
4601                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4602    
4603                            if (orderByConditionFields.length > 0) {
4604                                    query.append(WHERE_AND);
4605                            }
4606    
4607                            for (int i = 0; i < orderByConditionFields.length; i++) {
4608                                    if (getDB().isSupportsInlineDistinct()) {
4609                                            query.append(_ORDER_BY_ENTITY_ALIAS);
4610                                    }
4611                                    else {
4612                                            query.append(_ORDER_BY_ENTITY_TABLE);
4613                                    }
4614    
4615                                    query.append(orderByConditionFields[i]);
4616    
4617                                    if ((i + 1) < orderByConditionFields.length) {
4618                                            if (orderByComparator.isAscending() ^ previous) {
4619                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4620                                            }
4621                                            else {
4622                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4623                                            }
4624                                    }
4625                                    else {
4626                                            if (orderByComparator.isAscending() ^ previous) {
4627                                                    query.append(WHERE_GREATER_THAN);
4628                                            }
4629                                            else {
4630                                                    query.append(WHERE_LESSER_THAN);
4631                                            }
4632                                    }
4633                            }
4634    
4635                            query.append(ORDER_BY_CLAUSE);
4636    
4637                            String[] orderByFields = orderByComparator.getOrderByFields();
4638    
4639                            for (int i = 0; i < orderByFields.length; i++) {
4640                                    if (getDB().isSupportsInlineDistinct()) {
4641                                            query.append(_ORDER_BY_ENTITY_ALIAS);
4642                                    }
4643                                    else {
4644                                            query.append(_ORDER_BY_ENTITY_TABLE);
4645                                    }
4646    
4647                                    query.append(orderByFields[i]);
4648    
4649                                    if ((i + 1) < orderByFields.length) {
4650                                            if (orderByComparator.isAscending() ^ previous) {
4651                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4652                                            }
4653                                            else {
4654                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4655                                            }
4656                                    }
4657                                    else {
4658                                            if (orderByComparator.isAscending() ^ previous) {
4659                                                    query.append(ORDER_BY_ASC);
4660                                            }
4661                                            else {
4662                                                    query.append(ORDER_BY_DESC);
4663                                            }
4664                                    }
4665                            }
4666                    }
4667                    else {
4668                            if (getDB().isSupportsInlineDistinct()) {
4669                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
4670                            }
4671                            else {
4672                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
4673                            }
4674                    }
4675    
4676                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4677                                    BlogsEntry.class.getName(),
4678                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4679    
4680                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
4681    
4682                    q.setFirstResult(0);
4683                    q.setMaxResults(2);
4684    
4685                    if (getDB().isSupportsInlineDistinct()) {
4686                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
4687                    }
4688                    else {
4689                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
4690                    }
4691    
4692                    QueryPos qPos = QueryPos.getInstance(q);
4693    
4694                    qPos.add(groupId);
4695    
4696                    qPos.add(status);
4697    
4698                    if (orderByComparator != null) {
4699                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
4700    
4701                            for (Object value : values) {
4702                                    qPos.add(value);
4703                            }
4704                    }
4705    
4706                    List<BlogsEntry> list = q.list();
4707    
4708                    if (list.size() == 2) {
4709                            return list.get(1);
4710                    }
4711                    else {
4712                            return null;
4713                    }
4714            }
4715    
4716            /**
4717             * Removes all the blogs entries where groupId = &#63; and status = &#63; from the database.
4718             *
4719             * @param groupId the group ID
4720             * @param status the status
4721             */
4722            @Override
4723            public void removeByG_S(long groupId, int status) {
4724                    for (BlogsEntry blogsEntry : findByG_S(groupId, status,
4725                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
4726                            remove(blogsEntry);
4727                    }
4728            }
4729    
4730            /**
4731             * Returns the number of blogs entries where groupId = &#63; and status = &#63;.
4732             *
4733             * @param groupId the group ID
4734             * @param status the status
4735             * @return the number of matching blogs entries
4736             */
4737            @Override
4738            public int countByG_S(long groupId, int status) {
4739                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_S;
4740    
4741                    Object[] finderArgs = new Object[] { groupId, status };
4742    
4743                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
4744                                    this);
4745    
4746                    if (count == null) {
4747                            StringBundler query = new StringBundler(3);
4748    
4749                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
4750    
4751                            query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4752    
4753                            query.append(_FINDER_COLUMN_G_S_STATUS_2);
4754    
4755                            String sql = query.toString();
4756    
4757                            Session session = null;
4758    
4759                            try {
4760                                    session = openSession();
4761    
4762                                    Query q = session.createQuery(sql);
4763    
4764                                    QueryPos qPos = QueryPos.getInstance(q);
4765    
4766                                    qPos.add(groupId);
4767    
4768                                    qPos.add(status);
4769    
4770                                    count = (Long)q.uniqueResult();
4771    
4772                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
4773                            }
4774                            catch (Exception e) {
4775                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4776    
4777                                    throw processException(e);
4778                            }
4779                            finally {
4780                                    closeSession(session);
4781                            }
4782                    }
4783    
4784                    return count.intValue();
4785            }
4786    
4787            /**
4788             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and status = &#63;.
4789             *
4790             * @param groupId the group ID
4791             * @param status the status
4792             * @return the number of matching blogs entries that the user has permission to view
4793             */
4794            @Override
4795            public int filterCountByG_S(long groupId, int status) {
4796                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4797                            return countByG_S(groupId, status);
4798                    }
4799    
4800                    StringBundler query = new StringBundler(3);
4801    
4802                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
4803    
4804                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4805    
4806                    query.append(_FINDER_COLUMN_G_S_STATUS_2);
4807    
4808                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4809                                    BlogsEntry.class.getName(),
4810                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4811    
4812                    Session session = null;
4813    
4814                    try {
4815                            session = openSession();
4816    
4817                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
4818    
4819                            q.addScalar(COUNT_COLUMN_NAME,
4820                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
4821    
4822                            QueryPos qPos = QueryPos.getInstance(q);
4823    
4824                            qPos.add(groupId);
4825    
4826                            qPos.add(status);
4827    
4828                            Long count = (Long)q.uniqueResult();
4829    
4830                            return count.intValue();
4831                    }
4832                    catch (Exception e) {
4833                            throw processException(e);
4834                    }
4835                    finally {
4836                            closeSession(session);
4837                    }
4838            }
4839    
4840            private static final String _FINDER_COLUMN_G_S_GROUPID_2 = "blogsEntry.groupId = ? AND ";
4841            private static final String _FINDER_COLUMN_G_S_STATUS_2 = "blogsEntry.status = ?";
4842            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_NOTS = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
4843                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
4844                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_NotS",
4845                            new String[] {
4846                                    Long.class.getName(), Integer.class.getName(),
4847                                    
4848                            Integer.class.getName(), Integer.class.getName(),
4849                                    OrderByComparator.class.getName()
4850                            });
4851            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_NOTS = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
4852                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
4853                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_NotS",
4854                            new String[] { Long.class.getName(), Integer.class.getName() });
4855    
4856            /**
4857             * Returns all the blogs entries where groupId = &#63; and status &ne; &#63;.
4858             *
4859             * @param groupId the group ID
4860             * @param status the status
4861             * @return the matching blogs entries
4862             */
4863            @Override
4864            public List<BlogsEntry> findByG_NotS(long groupId, int status) {
4865                    return findByG_NotS(groupId, status, QueryUtil.ALL_POS,
4866                            QueryUtil.ALL_POS, null);
4867            }
4868    
4869            /**
4870             * Returns a range of all the blogs entries where groupId = &#63; and status &ne; &#63;.
4871             *
4872             * <p>
4873             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4874             * </p>
4875             *
4876             * @param groupId the group ID
4877             * @param status the status
4878             * @param start the lower bound of the range of blogs entries
4879             * @param end the upper bound of the range of blogs entries (not inclusive)
4880             * @return the range of matching blogs entries
4881             */
4882            @Override
4883            public List<BlogsEntry> findByG_NotS(long groupId, int status, int start,
4884                    int end) {
4885                    return findByG_NotS(groupId, status, start, end, null);
4886            }
4887    
4888            /**
4889             * Returns an ordered range of all the blogs entries where groupId = &#63; and status &ne; &#63;.
4890             *
4891             * <p>
4892             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4893             * </p>
4894             *
4895             * @param groupId the group ID
4896             * @param status the status
4897             * @param start the lower bound of the range of blogs entries
4898             * @param end the upper bound of the range of blogs entries (not inclusive)
4899             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4900             * @return the ordered range of matching blogs entries
4901             */
4902            @Override
4903            public List<BlogsEntry> findByG_NotS(long groupId, int status, int start,
4904                    int end, OrderByComparator<BlogsEntry> orderByComparator) {
4905                    boolean pagination = true;
4906                    FinderPath finderPath = null;
4907                    Object[] finderArgs = null;
4908    
4909                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_NOTS;
4910                    finderArgs = new Object[] { groupId, status, start, end, orderByComparator };
4911    
4912                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
4913                                    finderArgs, this);
4914    
4915                    if ((list != null) && !list.isEmpty()) {
4916                            for (BlogsEntry blogsEntry : list) {
4917                                    if ((groupId != blogsEntry.getGroupId()) ||
4918                                                    (status == blogsEntry.getStatus())) {
4919                                            list = null;
4920    
4921                                            break;
4922                                    }
4923                            }
4924                    }
4925    
4926                    if (list == null) {
4927                            StringBundler query = null;
4928    
4929                            if (orderByComparator != null) {
4930                                    query = new StringBundler(4 +
4931                                                    (orderByComparator.getOrderByFields().length * 3));
4932                            }
4933                            else {
4934                                    query = new StringBundler(4);
4935                            }
4936    
4937                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
4938    
4939                            query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
4940    
4941                            query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
4942    
4943                            if (orderByComparator != null) {
4944                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4945                                            orderByComparator);
4946                            }
4947                            else
4948                             if (pagination) {
4949                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
4950                            }
4951    
4952                            String sql = query.toString();
4953    
4954                            Session session = null;
4955    
4956                            try {
4957                                    session = openSession();
4958    
4959                                    Query q = session.createQuery(sql);
4960    
4961                                    QueryPos qPos = QueryPos.getInstance(q);
4962    
4963                                    qPos.add(groupId);
4964    
4965                                    qPos.add(status);
4966    
4967                                    if (!pagination) {
4968                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
4969                                                            start, end, false);
4970    
4971                                            Collections.sort(list);
4972    
4973                                            list = Collections.unmodifiableList(list);
4974                                    }
4975                                    else {
4976                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
4977                                                            start, end);
4978                                    }
4979    
4980                                    cacheResult(list);
4981    
4982                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
4983                            }
4984                            catch (Exception e) {
4985                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4986    
4987                                    throw processException(e);
4988                            }
4989                            finally {
4990                                    closeSession(session);
4991                            }
4992                    }
4993    
4994                    return list;
4995            }
4996    
4997            /**
4998             * Returns the first blogs entry in the ordered set where groupId = &#63; and status &ne; &#63;.
4999             *
5000             * @param groupId the group ID
5001             * @param status the status
5002             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5003             * @return the first matching blogs entry
5004             * @throws NoSuchEntryException if a matching blogs entry could not be found
5005             */
5006            @Override
5007            public BlogsEntry findByG_NotS_First(long groupId, int status,
5008                    OrderByComparator<BlogsEntry> orderByComparator)
5009                    throws NoSuchEntryException {
5010                    BlogsEntry blogsEntry = fetchByG_NotS_First(groupId, status,
5011                                    orderByComparator);
5012    
5013                    if (blogsEntry != null) {
5014                            return blogsEntry;
5015                    }
5016    
5017                    StringBundler msg = new StringBundler(6);
5018    
5019                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5020    
5021                    msg.append("groupId=");
5022                    msg.append(groupId);
5023    
5024                    msg.append(", status=");
5025                    msg.append(status);
5026    
5027                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5028    
5029                    throw new NoSuchEntryException(msg.toString());
5030            }
5031    
5032            /**
5033             * Returns the first blogs entry in the ordered set where groupId = &#63; and status &ne; &#63;.
5034             *
5035             * @param groupId the group ID
5036             * @param status the status
5037             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5038             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
5039             */
5040            @Override
5041            public BlogsEntry fetchByG_NotS_First(long groupId, int status,
5042                    OrderByComparator<BlogsEntry> orderByComparator) {
5043                    List<BlogsEntry> list = findByG_NotS(groupId, status, 0, 1,
5044                                    orderByComparator);
5045    
5046                    if (!list.isEmpty()) {
5047                            return list.get(0);
5048                    }
5049    
5050                    return null;
5051            }
5052    
5053            /**
5054             * Returns the last blogs entry in the ordered set where groupId = &#63; and status &ne; &#63;.
5055             *
5056             * @param groupId the group ID
5057             * @param status the status
5058             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5059             * @return the last matching blogs entry
5060             * @throws NoSuchEntryException if a matching blogs entry could not be found
5061             */
5062            @Override
5063            public BlogsEntry findByG_NotS_Last(long groupId, int status,
5064                    OrderByComparator<BlogsEntry> orderByComparator)
5065                    throws NoSuchEntryException {
5066                    BlogsEntry blogsEntry = fetchByG_NotS_Last(groupId, status,
5067                                    orderByComparator);
5068    
5069                    if (blogsEntry != null) {
5070                            return blogsEntry;
5071                    }
5072    
5073                    StringBundler msg = new StringBundler(6);
5074    
5075                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5076    
5077                    msg.append("groupId=");
5078                    msg.append(groupId);
5079    
5080                    msg.append(", status=");
5081                    msg.append(status);
5082    
5083                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5084    
5085                    throw new NoSuchEntryException(msg.toString());
5086            }
5087    
5088            /**
5089             * Returns the last blogs entry in the ordered set where groupId = &#63; and status &ne; &#63;.
5090             *
5091             * @param groupId the group ID
5092             * @param status the status
5093             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5094             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
5095             */
5096            @Override
5097            public BlogsEntry fetchByG_NotS_Last(long groupId, int status,
5098                    OrderByComparator<BlogsEntry> orderByComparator) {
5099                    int count = countByG_NotS(groupId, status);
5100    
5101                    if (count == 0) {
5102                            return null;
5103                    }
5104    
5105                    List<BlogsEntry> list = findByG_NotS(groupId, status, count - 1, count,
5106                                    orderByComparator);
5107    
5108                    if (!list.isEmpty()) {
5109                            return list.get(0);
5110                    }
5111    
5112                    return null;
5113            }
5114    
5115            /**
5116             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63; and status &ne; &#63;.
5117             *
5118             * @param entryId the primary key of the current blogs entry
5119             * @param groupId the group ID
5120             * @param status the status
5121             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5122             * @return the previous, current, and next blogs entry
5123             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
5124             */
5125            @Override
5126            public BlogsEntry[] findByG_NotS_PrevAndNext(long entryId, long groupId,
5127                    int status, OrderByComparator<BlogsEntry> orderByComparator)
5128                    throws NoSuchEntryException {
5129                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
5130    
5131                    Session session = null;
5132    
5133                    try {
5134                            session = openSession();
5135    
5136                            BlogsEntry[] array = new BlogsEntryImpl[3];
5137    
5138                            array[0] = getByG_NotS_PrevAndNext(session, blogsEntry, groupId,
5139                                            status, orderByComparator, true);
5140    
5141                            array[1] = blogsEntry;
5142    
5143                            array[2] = getByG_NotS_PrevAndNext(session, blogsEntry, groupId,
5144                                            status, orderByComparator, false);
5145    
5146                            return array;
5147                    }
5148                    catch (Exception e) {
5149                            throw processException(e);
5150                    }
5151                    finally {
5152                            closeSession(session);
5153                    }
5154            }
5155    
5156            protected BlogsEntry getByG_NotS_PrevAndNext(Session session,
5157                    BlogsEntry blogsEntry, long groupId, int status,
5158                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
5159                    StringBundler query = null;
5160    
5161                    if (orderByComparator != null) {
5162                            query = new StringBundler(6 +
5163                                            (orderByComparator.getOrderByFields().length * 6));
5164                    }
5165                    else {
5166                            query = new StringBundler(3);
5167                    }
5168    
5169                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
5170    
5171                    query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
5172    
5173                    query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
5174    
5175                    if (orderByComparator != null) {
5176                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5177    
5178                            if (orderByConditionFields.length > 0) {
5179                                    query.append(WHERE_AND);
5180                            }
5181    
5182                            for (int i = 0; i < orderByConditionFields.length; i++) {
5183                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5184                                    query.append(orderByConditionFields[i]);
5185    
5186                                    if ((i + 1) < orderByConditionFields.length) {
5187                                            if (orderByComparator.isAscending() ^ previous) {
5188                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5189                                            }
5190                                            else {
5191                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5192                                            }
5193                                    }
5194                                    else {
5195                                            if (orderByComparator.isAscending() ^ previous) {
5196                                                    query.append(WHERE_GREATER_THAN);
5197                                            }
5198                                            else {
5199                                                    query.append(WHERE_LESSER_THAN);
5200                                            }
5201                                    }
5202                            }
5203    
5204                            query.append(ORDER_BY_CLAUSE);
5205    
5206                            String[] orderByFields = orderByComparator.getOrderByFields();
5207    
5208                            for (int i = 0; i < orderByFields.length; i++) {
5209                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5210                                    query.append(orderByFields[i]);
5211    
5212                                    if ((i + 1) < orderByFields.length) {
5213                                            if (orderByComparator.isAscending() ^ previous) {
5214                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5215                                            }
5216                                            else {
5217                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5218                                            }
5219                                    }
5220                                    else {
5221                                            if (orderByComparator.isAscending() ^ previous) {
5222                                                    query.append(ORDER_BY_ASC);
5223                                            }
5224                                            else {
5225                                                    query.append(ORDER_BY_DESC);
5226                                            }
5227                                    }
5228                            }
5229                    }
5230                    else {
5231                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
5232                    }
5233    
5234                    String sql = query.toString();
5235    
5236                    Query q = session.createQuery(sql);
5237    
5238                    q.setFirstResult(0);
5239                    q.setMaxResults(2);
5240    
5241                    QueryPos qPos = QueryPos.getInstance(q);
5242    
5243                    qPos.add(groupId);
5244    
5245                    qPos.add(status);
5246    
5247                    if (orderByComparator != null) {
5248                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
5249    
5250                            for (Object value : values) {
5251                                    qPos.add(value);
5252                            }
5253                    }
5254    
5255                    List<BlogsEntry> list = q.list();
5256    
5257                    if (list.size() == 2) {
5258                            return list.get(1);
5259                    }
5260                    else {
5261                            return null;
5262                    }
5263            }
5264    
5265            /**
5266             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and status &ne; &#63;.
5267             *
5268             * @param groupId the group ID
5269             * @param status the status
5270             * @return the matching blogs entries that the user has permission to view
5271             */
5272            @Override
5273            public List<BlogsEntry> filterFindByG_NotS(long groupId, int status) {
5274                    return filterFindByG_NotS(groupId, status, QueryUtil.ALL_POS,
5275                            QueryUtil.ALL_POS, null);
5276            }
5277    
5278            /**
5279             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63; and status &ne; &#63;.
5280             *
5281             * <p>
5282             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5283             * </p>
5284             *
5285             * @param groupId the group ID
5286             * @param status the status
5287             * @param start the lower bound of the range of blogs entries
5288             * @param end the upper bound of the range of blogs entries (not inclusive)
5289             * @return the range of matching blogs entries that the user has permission to view
5290             */
5291            @Override
5292            public List<BlogsEntry> filterFindByG_NotS(long groupId, int status,
5293                    int start, int end) {
5294                    return filterFindByG_NotS(groupId, status, start, end, null);
5295            }
5296    
5297            /**
5298             * Returns an ordered range of all the blogs entries that the user has permissions to view where groupId = &#63; and status &ne; &#63;.
5299             *
5300             * <p>
5301             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5302             * </p>
5303             *
5304             * @param groupId the group ID
5305             * @param status the status
5306             * @param start the lower bound of the range of blogs entries
5307             * @param end the upper bound of the range of blogs entries (not inclusive)
5308             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5309             * @return the ordered range of matching blogs entries that the user has permission to view
5310             */
5311            @Override
5312            public List<BlogsEntry> filterFindByG_NotS(long groupId, int status,
5313                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator) {
5314                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5315                            return findByG_NotS(groupId, status, start, end, orderByComparator);
5316                    }
5317    
5318                    StringBundler query = null;
5319    
5320                    if (orderByComparator != null) {
5321                            query = new StringBundler(4 +
5322                                            (orderByComparator.getOrderByFields().length * 3));
5323                    }
5324                    else {
5325                            query = new StringBundler(4);
5326                    }
5327    
5328                    if (getDB().isSupportsInlineDistinct()) {
5329                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
5330                    }
5331                    else {
5332                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
5333                    }
5334    
5335                    query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
5336    
5337                    query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
5338    
5339                    if (!getDB().isSupportsInlineDistinct()) {
5340                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
5341                    }
5342    
5343                    if (orderByComparator != null) {
5344                            if (getDB().isSupportsInlineDistinct()) {
5345                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5346                                            orderByComparator, true);
5347                            }
5348                            else {
5349                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
5350                                            orderByComparator, true);
5351                            }
5352                    }
5353                    else {
5354                            if (getDB().isSupportsInlineDistinct()) {
5355                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
5356                            }
5357                            else {
5358                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
5359                            }
5360                    }
5361    
5362                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5363                                    BlogsEntry.class.getName(),
5364                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5365    
5366                    Session session = null;
5367    
5368                    try {
5369                            session = openSession();
5370    
5371                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
5372    
5373                            if (getDB().isSupportsInlineDistinct()) {
5374                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
5375                            }
5376                            else {
5377                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
5378                            }
5379    
5380                            QueryPos qPos = QueryPos.getInstance(q);
5381    
5382                            qPos.add(groupId);
5383    
5384                            qPos.add(status);
5385    
5386                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
5387                    }
5388                    catch (Exception e) {
5389                            throw processException(e);
5390                    }
5391                    finally {
5392                            closeSession(session);
5393                    }
5394            }
5395    
5396            /**
5397             * 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;.
5398             *
5399             * @param entryId the primary key of the current blogs entry
5400             * @param groupId the group ID
5401             * @param status the status
5402             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5403             * @return the previous, current, and next blogs entry
5404             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
5405             */
5406            @Override
5407            public BlogsEntry[] filterFindByG_NotS_PrevAndNext(long entryId,
5408                    long groupId, int status,
5409                    OrderByComparator<BlogsEntry> orderByComparator)
5410                    throws NoSuchEntryException {
5411                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5412                            return findByG_NotS_PrevAndNext(entryId, groupId, status,
5413                                    orderByComparator);
5414                    }
5415    
5416                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
5417    
5418                    Session session = null;
5419    
5420                    try {
5421                            session = openSession();
5422    
5423                            BlogsEntry[] array = new BlogsEntryImpl[3];
5424    
5425                            array[0] = filterGetByG_NotS_PrevAndNext(session, blogsEntry,
5426                                            groupId, status, orderByComparator, true);
5427    
5428                            array[1] = blogsEntry;
5429    
5430                            array[2] = filterGetByG_NotS_PrevAndNext(session, blogsEntry,
5431                                            groupId, status, orderByComparator, false);
5432    
5433                            return array;
5434                    }
5435                    catch (Exception e) {
5436                            throw processException(e);
5437                    }
5438                    finally {
5439                            closeSession(session);
5440                    }
5441            }
5442    
5443            protected BlogsEntry filterGetByG_NotS_PrevAndNext(Session session,
5444                    BlogsEntry blogsEntry, long groupId, int status,
5445                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
5446                    StringBundler query = null;
5447    
5448                    if (orderByComparator != null) {
5449                            query = new StringBundler(6 +
5450                                            (orderByComparator.getOrderByFields().length * 6));
5451                    }
5452                    else {
5453                            query = new StringBundler(3);
5454                    }
5455    
5456                    if (getDB().isSupportsInlineDistinct()) {
5457                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
5458                    }
5459                    else {
5460                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
5461                    }
5462    
5463                    query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
5464    
5465                    query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
5466    
5467                    if (!getDB().isSupportsInlineDistinct()) {
5468                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
5469                    }
5470    
5471                    if (orderByComparator != null) {
5472                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5473    
5474                            if (orderByConditionFields.length > 0) {
5475                                    query.append(WHERE_AND);
5476                            }
5477    
5478                            for (int i = 0; i < orderByConditionFields.length; i++) {
5479                                    if (getDB().isSupportsInlineDistinct()) {
5480                                            query.append(_ORDER_BY_ENTITY_ALIAS);
5481                                    }
5482                                    else {
5483                                            query.append(_ORDER_BY_ENTITY_TABLE);
5484                                    }
5485    
5486                                    query.append(orderByConditionFields[i]);
5487    
5488                                    if ((i + 1) < orderByConditionFields.length) {
5489                                            if (orderByComparator.isAscending() ^ previous) {
5490                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5491                                            }
5492                                            else {
5493                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5494                                            }
5495                                    }
5496                                    else {
5497                                            if (orderByComparator.isAscending() ^ previous) {
5498                                                    query.append(WHERE_GREATER_THAN);
5499                                            }
5500                                            else {
5501                                                    query.append(WHERE_LESSER_THAN);
5502                                            }
5503                                    }
5504                            }
5505    
5506                            query.append(ORDER_BY_CLAUSE);
5507    
5508                            String[] orderByFields = orderByComparator.getOrderByFields();
5509    
5510                            for (int i = 0; i < orderByFields.length; i++) {
5511                                    if (getDB().isSupportsInlineDistinct()) {
5512                                            query.append(_ORDER_BY_ENTITY_ALIAS);
5513                                    }
5514                                    else {
5515                                            query.append(_ORDER_BY_ENTITY_TABLE);
5516                                    }
5517    
5518                                    query.append(orderByFields[i]);
5519    
5520                                    if ((i + 1) < orderByFields.length) {
5521                                            if (orderByComparator.isAscending() ^ previous) {
5522                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5523                                            }
5524                                            else {
5525                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5526                                            }
5527                                    }
5528                                    else {
5529                                            if (orderByComparator.isAscending() ^ previous) {
5530                                                    query.append(ORDER_BY_ASC);
5531                                            }
5532                                            else {
5533                                                    query.append(ORDER_BY_DESC);
5534                                            }
5535                                    }
5536                            }
5537                    }
5538                    else {
5539                            if (getDB().isSupportsInlineDistinct()) {
5540                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
5541                            }
5542                            else {
5543                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
5544                            }
5545                    }
5546    
5547                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5548                                    BlogsEntry.class.getName(),
5549                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5550    
5551                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
5552    
5553                    q.setFirstResult(0);
5554                    q.setMaxResults(2);
5555    
5556                    if (getDB().isSupportsInlineDistinct()) {
5557                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
5558                    }
5559                    else {
5560                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
5561                    }
5562    
5563                    QueryPos qPos = QueryPos.getInstance(q);
5564    
5565                    qPos.add(groupId);
5566    
5567                    qPos.add(status);
5568    
5569                    if (orderByComparator != null) {
5570                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
5571    
5572                            for (Object value : values) {
5573                                    qPos.add(value);
5574                            }
5575                    }
5576    
5577                    List<BlogsEntry> list = q.list();
5578    
5579                    if (list.size() == 2) {
5580                            return list.get(1);
5581                    }
5582                    else {
5583                            return null;
5584                    }
5585            }
5586    
5587            /**
5588             * Removes all the blogs entries where groupId = &#63; and status &ne; &#63; from the database.
5589             *
5590             * @param groupId the group ID
5591             * @param status the status
5592             */
5593            @Override
5594            public void removeByG_NotS(long groupId, int status) {
5595                    for (BlogsEntry blogsEntry : findByG_NotS(groupId, status,
5596                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
5597                            remove(blogsEntry);
5598                    }
5599            }
5600    
5601            /**
5602             * Returns the number of blogs entries where groupId = &#63; and status &ne; &#63;.
5603             *
5604             * @param groupId the group ID
5605             * @param status the status
5606             * @return the number of matching blogs entries
5607             */
5608            @Override
5609            public int countByG_NotS(long groupId, int status) {
5610                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_NOTS;
5611    
5612                    Object[] finderArgs = new Object[] { groupId, status };
5613    
5614                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
5615                                    this);
5616    
5617                    if (count == null) {
5618                            StringBundler query = new StringBundler(3);
5619    
5620                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
5621    
5622                            query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
5623    
5624                            query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
5625    
5626                            String sql = query.toString();
5627    
5628                            Session session = null;
5629    
5630                            try {
5631                                    session = openSession();
5632    
5633                                    Query q = session.createQuery(sql);
5634    
5635                                    QueryPos qPos = QueryPos.getInstance(q);
5636    
5637                                    qPos.add(groupId);
5638    
5639                                    qPos.add(status);
5640    
5641                                    count = (Long)q.uniqueResult();
5642    
5643                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
5644                            }
5645                            catch (Exception e) {
5646                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5647    
5648                                    throw processException(e);
5649                            }
5650                            finally {
5651                                    closeSession(session);
5652                            }
5653                    }
5654    
5655                    return count.intValue();
5656            }
5657    
5658            /**
5659             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and status &ne; &#63;.
5660             *
5661             * @param groupId the group ID
5662             * @param status the status
5663             * @return the number of matching blogs entries that the user has permission to view
5664             */
5665            @Override
5666            public int filterCountByG_NotS(long groupId, int status) {
5667                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5668                            return countByG_NotS(groupId, status);
5669                    }
5670    
5671                    StringBundler query = new StringBundler(3);
5672    
5673                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
5674    
5675                    query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
5676    
5677                    query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
5678    
5679                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5680                                    BlogsEntry.class.getName(),
5681                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5682    
5683                    Session session = null;
5684    
5685                    try {
5686                            session = openSession();
5687    
5688                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
5689    
5690                            q.addScalar(COUNT_COLUMN_NAME,
5691                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
5692    
5693                            QueryPos qPos = QueryPos.getInstance(q);
5694    
5695                            qPos.add(groupId);
5696    
5697                            qPos.add(status);
5698    
5699                            Long count = (Long)q.uniqueResult();
5700    
5701                            return count.intValue();
5702                    }
5703                    catch (Exception e) {
5704                            throw processException(e);
5705                    }
5706                    finally {
5707                            closeSession(session);
5708                    }
5709            }
5710    
5711            private static final String _FINDER_COLUMN_G_NOTS_GROUPID_2 = "blogsEntry.groupId = ? AND ";
5712            private static final String _FINDER_COLUMN_G_NOTS_STATUS_2 = "blogsEntry.status != ?";
5713            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
5714                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
5715                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_U",
5716                            new String[] {
5717                                    Long.class.getName(), Long.class.getName(),
5718                                    
5719                            Integer.class.getName(), Integer.class.getName(),
5720                                    OrderByComparator.class.getName()
5721                            });
5722            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
5723                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
5724                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_U",
5725                            new String[] { Long.class.getName(), Long.class.getName() },
5726                            BlogsEntryModelImpl.COMPANYID_COLUMN_BITMASK |
5727                            BlogsEntryModelImpl.USERID_COLUMN_BITMASK |
5728                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
5729                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
5730            public static final FinderPath FINDER_PATH_COUNT_BY_C_U = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
5731                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
5732                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_U",
5733                            new String[] { Long.class.getName(), Long.class.getName() });
5734    
5735            /**
5736             * Returns all the blogs entries where companyId = &#63; and userId = &#63;.
5737             *
5738             * @param companyId the company ID
5739             * @param userId the user ID
5740             * @return the matching blogs entries
5741             */
5742            @Override
5743            public List<BlogsEntry> findByC_U(long companyId, long userId) {
5744                    return findByC_U(companyId, userId, QueryUtil.ALL_POS,
5745                            QueryUtil.ALL_POS, null);
5746            }
5747    
5748            /**
5749             * Returns a range of all the blogs entries where companyId = &#63; and userId = &#63;.
5750             *
5751             * <p>
5752             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5753             * </p>
5754             *
5755             * @param companyId the company ID
5756             * @param userId the user ID
5757             * @param start the lower bound of the range of blogs entries
5758             * @param end the upper bound of the range of blogs entries (not inclusive)
5759             * @return the range of matching blogs entries
5760             */
5761            @Override
5762            public List<BlogsEntry> findByC_U(long companyId, long userId, int start,
5763                    int end) {
5764                    return findByC_U(companyId, userId, start, end, null);
5765            }
5766    
5767            /**
5768             * Returns an ordered range of all the blogs entries where companyId = &#63; and userId = &#63;.
5769             *
5770             * <p>
5771             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5772             * </p>
5773             *
5774             * @param companyId the company ID
5775             * @param userId the user ID
5776             * @param start the lower bound of the range of blogs entries
5777             * @param end the upper bound of the range of blogs entries (not inclusive)
5778             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5779             * @return the ordered range of matching blogs entries
5780             */
5781            @Override
5782            public List<BlogsEntry> findByC_U(long companyId, long userId, int start,
5783                    int end, OrderByComparator<BlogsEntry> orderByComparator) {
5784                    boolean pagination = true;
5785                    FinderPath finderPath = null;
5786                    Object[] finderArgs = null;
5787    
5788                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5789                                    (orderByComparator == null)) {
5790                            pagination = false;
5791                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U;
5792                            finderArgs = new Object[] { companyId, userId };
5793                    }
5794                    else {
5795                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U;
5796                            finderArgs = new Object[] {
5797                                            companyId, userId,
5798                                            
5799                                            start, end, orderByComparator
5800                                    };
5801                    }
5802    
5803                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
5804                                    finderArgs, this);
5805    
5806                    if ((list != null) && !list.isEmpty()) {
5807                            for (BlogsEntry blogsEntry : list) {
5808                                    if ((companyId != blogsEntry.getCompanyId()) ||
5809                                                    (userId != blogsEntry.getUserId())) {
5810                                            list = null;
5811    
5812                                            break;
5813                                    }
5814                            }
5815                    }
5816    
5817                    if (list == null) {
5818                            StringBundler query = null;
5819    
5820                            if (orderByComparator != null) {
5821                                    query = new StringBundler(4 +
5822                                                    (orderByComparator.getOrderByFields().length * 3));
5823                            }
5824                            else {
5825                                    query = new StringBundler(4);
5826                            }
5827    
5828                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
5829    
5830                            query.append(_FINDER_COLUMN_C_U_COMPANYID_2);
5831    
5832                            query.append(_FINDER_COLUMN_C_U_USERID_2);
5833    
5834                            if (orderByComparator != null) {
5835                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5836                                            orderByComparator);
5837                            }
5838                            else
5839                             if (pagination) {
5840                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
5841                            }
5842    
5843                            String sql = query.toString();
5844    
5845                            Session session = null;
5846    
5847                            try {
5848                                    session = openSession();
5849    
5850                                    Query q = session.createQuery(sql);
5851    
5852                                    QueryPos qPos = QueryPos.getInstance(q);
5853    
5854                                    qPos.add(companyId);
5855    
5856                                    qPos.add(userId);
5857    
5858                                    if (!pagination) {
5859                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
5860                                                            start, end, false);
5861    
5862                                            Collections.sort(list);
5863    
5864                                            list = Collections.unmodifiableList(list);
5865                                    }
5866                                    else {
5867                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
5868                                                            start, end);
5869                                    }
5870    
5871                                    cacheResult(list);
5872    
5873                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
5874                            }
5875                            catch (Exception e) {
5876                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5877    
5878                                    throw processException(e);
5879                            }
5880                            finally {
5881                                    closeSession(session);
5882                            }
5883                    }
5884    
5885                    return list;
5886            }
5887    
5888            /**
5889             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63;.
5890             *
5891             * @param companyId the company ID
5892             * @param userId the user ID
5893             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5894             * @return the first matching blogs entry
5895             * @throws NoSuchEntryException if a matching blogs entry could not be found
5896             */
5897            @Override
5898            public BlogsEntry findByC_U_First(long companyId, long userId,
5899                    OrderByComparator<BlogsEntry> orderByComparator)
5900                    throws NoSuchEntryException {
5901                    BlogsEntry blogsEntry = fetchByC_U_First(companyId, userId,
5902                                    orderByComparator);
5903    
5904                    if (blogsEntry != null) {
5905                            return blogsEntry;
5906                    }
5907    
5908                    StringBundler msg = new StringBundler(6);
5909    
5910                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5911    
5912                    msg.append("companyId=");
5913                    msg.append(companyId);
5914    
5915                    msg.append(", userId=");
5916                    msg.append(userId);
5917    
5918                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5919    
5920                    throw new NoSuchEntryException(msg.toString());
5921            }
5922    
5923            /**
5924             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63;.
5925             *
5926             * @param companyId the company ID
5927             * @param userId the user ID
5928             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5929             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
5930             */
5931            @Override
5932            public BlogsEntry fetchByC_U_First(long companyId, long userId,
5933                    OrderByComparator<BlogsEntry> orderByComparator) {
5934                    List<BlogsEntry> list = findByC_U(companyId, userId, 0, 1,
5935                                    orderByComparator);
5936    
5937                    if (!list.isEmpty()) {
5938                            return list.get(0);
5939                    }
5940    
5941                    return null;
5942            }
5943    
5944            /**
5945             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63;.
5946             *
5947             * @param companyId the company ID
5948             * @param userId the user ID
5949             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5950             * @return the last matching blogs entry
5951             * @throws NoSuchEntryException if a matching blogs entry could not be found
5952             */
5953            @Override
5954            public BlogsEntry findByC_U_Last(long companyId, long userId,
5955                    OrderByComparator<BlogsEntry> orderByComparator)
5956                    throws NoSuchEntryException {
5957                    BlogsEntry blogsEntry = fetchByC_U_Last(companyId, userId,
5958                                    orderByComparator);
5959    
5960                    if (blogsEntry != null) {
5961                            return blogsEntry;
5962                    }
5963    
5964                    StringBundler msg = new StringBundler(6);
5965    
5966                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5967    
5968                    msg.append("companyId=");
5969                    msg.append(companyId);
5970    
5971                    msg.append(", userId=");
5972                    msg.append(userId);
5973    
5974                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5975    
5976                    throw new NoSuchEntryException(msg.toString());
5977            }
5978    
5979            /**
5980             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63;.
5981             *
5982             * @param companyId the company ID
5983             * @param userId the user ID
5984             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5985             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
5986             */
5987            @Override
5988            public BlogsEntry fetchByC_U_Last(long companyId, long userId,
5989                    OrderByComparator<BlogsEntry> orderByComparator) {
5990                    int count = countByC_U(companyId, userId);
5991    
5992                    if (count == 0) {
5993                            return null;
5994                    }
5995    
5996                    List<BlogsEntry> list = findByC_U(companyId, userId, count - 1, count,
5997                                    orderByComparator);
5998    
5999                    if (!list.isEmpty()) {
6000                            return list.get(0);
6001                    }
6002    
6003                    return null;
6004            }
6005    
6006            /**
6007             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63; and userId = &#63;.
6008             *
6009             * @param entryId the primary key of the current blogs entry
6010             * @param companyId the company ID
6011             * @param userId the user ID
6012             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6013             * @return the previous, current, and next blogs entry
6014             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
6015             */
6016            @Override
6017            public BlogsEntry[] findByC_U_PrevAndNext(long entryId, long companyId,
6018                    long userId, OrderByComparator<BlogsEntry> orderByComparator)
6019                    throws NoSuchEntryException {
6020                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
6021    
6022                    Session session = null;
6023    
6024                    try {
6025                            session = openSession();
6026    
6027                            BlogsEntry[] array = new BlogsEntryImpl[3];
6028    
6029                            array[0] = getByC_U_PrevAndNext(session, blogsEntry, companyId,
6030                                            userId, orderByComparator, true);
6031    
6032                            array[1] = blogsEntry;
6033    
6034                            array[2] = getByC_U_PrevAndNext(session, blogsEntry, companyId,
6035                                            userId, orderByComparator, false);
6036    
6037                            return array;
6038                    }
6039                    catch (Exception e) {
6040                            throw processException(e);
6041                    }
6042                    finally {
6043                            closeSession(session);
6044                    }
6045            }
6046    
6047            protected BlogsEntry getByC_U_PrevAndNext(Session session,
6048                    BlogsEntry blogsEntry, long companyId, long userId,
6049                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
6050                    StringBundler query = null;
6051    
6052                    if (orderByComparator != null) {
6053                            query = new StringBundler(6 +
6054                                            (orderByComparator.getOrderByFields().length * 6));
6055                    }
6056                    else {
6057                            query = new StringBundler(3);
6058                    }
6059    
6060                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
6061    
6062                    query.append(_FINDER_COLUMN_C_U_COMPANYID_2);
6063    
6064                    query.append(_FINDER_COLUMN_C_U_USERID_2);
6065    
6066                    if (orderByComparator != null) {
6067                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6068    
6069                            if (orderByConditionFields.length > 0) {
6070                                    query.append(WHERE_AND);
6071                            }
6072    
6073                            for (int i = 0; i < orderByConditionFields.length; i++) {
6074                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6075                                    query.append(orderByConditionFields[i]);
6076    
6077                                    if ((i + 1) < orderByConditionFields.length) {
6078                                            if (orderByComparator.isAscending() ^ previous) {
6079                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6080                                            }
6081                                            else {
6082                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6083                                            }
6084                                    }
6085                                    else {
6086                                            if (orderByComparator.isAscending() ^ previous) {
6087                                                    query.append(WHERE_GREATER_THAN);
6088                                            }
6089                                            else {
6090                                                    query.append(WHERE_LESSER_THAN);
6091                                            }
6092                                    }
6093                            }
6094    
6095                            query.append(ORDER_BY_CLAUSE);
6096    
6097                            String[] orderByFields = orderByComparator.getOrderByFields();
6098    
6099                            for (int i = 0; i < orderByFields.length; i++) {
6100                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6101                                    query.append(orderByFields[i]);
6102    
6103                                    if ((i + 1) < orderByFields.length) {
6104                                            if (orderByComparator.isAscending() ^ previous) {
6105                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6106                                            }
6107                                            else {
6108                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6109                                            }
6110                                    }
6111                                    else {
6112                                            if (orderByComparator.isAscending() ^ previous) {
6113                                                    query.append(ORDER_BY_ASC);
6114                                            }
6115                                            else {
6116                                                    query.append(ORDER_BY_DESC);
6117                                            }
6118                                    }
6119                            }
6120                    }
6121                    else {
6122                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
6123                    }
6124    
6125                    String sql = query.toString();
6126    
6127                    Query q = session.createQuery(sql);
6128    
6129                    q.setFirstResult(0);
6130                    q.setMaxResults(2);
6131    
6132                    QueryPos qPos = QueryPos.getInstance(q);
6133    
6134                    qPos.add(companyId);
6135    
6136                    qPos.add(userId);
6137    
6138                    if (orderByComparator != null) {
6139                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
6140    
6141                            for (Object value : values) {
6142                                    qPos.add(value);
6143                            }
6144                    }
6145    
6146                    List<BlogsEntry> list = q.list();
6147    
6148                    if (list.size() == 2) {
6149                            return list.get(1);
6150                    }
6151                    else {
6152                            return null;
6153                    }
6154            }
6155    
6156            /**
6157             * Removes all the blogs entries where companyId = &#63; and userId = &#63; from the database.
6158             *
6159             * @param companyId the company ID
6160             * @param userId the user ID
6161             */
6162            @Override
6163            public void removeByC_U(long companyId, long userId) {
6164                    for (BlogsEntry blogsEntry : findByC_U(companyId, userId,
6165                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
6166                            remove(blogsEntry);
6167                    }
6168            }
6169    
6170            /**
6171             * Returns the number of blogs entries where companyId = &#63; and userId = &#63;.
6172             *
6173             * @param companyId the company ID
6174             * @param userId the user ID
6175             * @return the number of matching blogs entries
6176             */
6177            @Override
6178            public int countByC_U(long companyId, long userId) {
6179                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_U;
6180    
6181                    Object[] finderArgs = new Object[] { companyId, userId };
6182    
6183                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
6184                                    this);
6185    
6186                    if (count == null) {
6187                            StringBundler query = new StringBundler(3);
6188    
6189                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
6190    
6191                            query.append(_FINDER_COLUMN_C_U_COMPANYID_2);
6192    
6193                            query.append(_FINDER_COLUMN_C_U_USERID_2);
6194    
6195                            String sql = query.toString();
6196    
6197                            Session session = null;
6198    
6199                            try {
6200                                    session = openSession();
6201    
6202                                    Query q = session.createQuery(sql);
6203    
6204                                    QueryPos qPos = QueryPos.getInstance(q);
6205    
6206                                    qPos.add(companyId);
6207    
6208                                    qPos.add(userId);
6209    
6210                                    count = (Long)q.uniqueResult();
6211    
6212                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
6213                            }
6214                            catch (Exception e) {
6215                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6216    
6217                                    throw processException(e);
6218                            }
6219                            finally {
6220                                    closeSession(session);
6221                            }
6222                    }
6223    
6224                    return count.intValue();
6225            }
6226    
6227            private static final String _FINDER_COLUMN_C_U_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
6228            private static final String _FINDER_COLUMN_C_U_USERID_2 = "blogsEntry.userId = ?";
6229            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
6230                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
6231                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_LtD",
6232                            new String[] {
6233                                    Long.class.getName(), Date.class.getName(),
6234                                    
6235                            Integer.class.getName(), Integer.class.getName(),
6236                                    OrderByComparator.class.getName()
6237                            });
6238            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
6239                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
6240                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_LtD",
6241                            new String[] { Long.class.getName(), Date.class.getName() });
6242    
6243            /**
6244             * Returns all the blogs entries where companyId = &#63; and displayDate &lt; &#63;.
6245             *
6246             * @param companyId the company ID
6247             * @param displayDate the display date
6248             * @return the matching blogs entries
6249             */
6250            @Override
6251            public List<BlogsEntry> findByC_LtD(long companyId, Date displayDate) {
6252                    return findByC_LtD(companyId, displayDate, QueryUtil.ALL_POS,
6253                            QueryUtil.ALL_POS, null);
6254            }
6255    
6256            /**
6257             * Returns a range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63;.
6258             *
6259             * <p>
6260             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6261             * </p>
6262             *
6263             * @param companyId the company ID
6264             * @param displayDate the display date
6265             * @param start the lower bound of the range of blogs entries
6266             * @param end the upper bound of the range of blogs entries (not inclusive)
6267             * @return the range of matching blogs entries
6268             */
6269            @Override
6270            public List<BlogsEntry> findByC_LtD(long companyId, Date displayDate,
6271                    int start, int end) {
6272                    return findByC_LtD(companyId, displayDate, start, end, null);
6273            }
6274    
6275            /**
6276             * Returns an ordered range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63;.
6277             *
6278             * <p>
6279             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6280             * </p>
6281             *
6282             * @param companyId the company ID
6283             * @param displayDate the display date
6284             * @param start the lower bound of the range of blogs entries
6285             * @param end the upper bound of the range of blogs entries (not inclusive)
6286             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6287             * @return the ordered range of matching blogs entries
6288             */
6289            @Override
6290            public List<BlogsEntry> findByC_LtD(long companyId, Date displayDate,
6291                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator) {
6292                    boolean pagination = true;
6293                    FinderPath finderPath = null;
6294                    Object[] finderArgs = null;
6295    
6296                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD;
6297                    finderArgs = new Object[] {
6298                                    companyId, displayDate,
6299                                    
6300                                    start, end, orderByComparator
6301                            };
6302    
6303                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
6304                                    finderArgs, this);
6305    
6306                    if ((list != null) && !list.isEmpty()) {
6307                            for (BlogsEntry blogsEntry : list) {
6308                                    if ((companyId != blogsEntry.getCompanyId()) ||
6309                                                    (displayDate.getTime() <= blogsEntry.getDisplayDate()
6310                                                                                                                                    .getTime())) {
6311                                            list = null;
6312    
6313                                            break;
6314                                    }
6315                            }
6316                    }
6317    
6318                    if (list == null) {
6319                            StringBundler query = null;
6320    
6321                            if (orderByComparator != null) {
6322                                    query = new StringBundler(4 +
6323                                                    (orderByComparator.getOrderByFields().length * 3));
6324                            }
6325                            else {
6326                                    query = new StringBundler(4);
6327                            }
6328    
6329                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
6330    
6331                            query.append(_FINDER_COLUMN_C_LTD_COMPANYID_2);
6332    
6333                            boolean bindDisplayDate = false;
6334    
6335                            if (displayDate == null) {
6336                                    query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_1);
6337                            }
6338                            else {
6339                                    bindDisplayDate = true;
6340    
6341                                    query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_2);
6342                            }
6343    
6344                            if (orderByComparator != null) {
6345                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6346                                            orderByComparator);
6347                            }
6348                            else
6349                             if (pagination) {
6350                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
6351                            }
6352    
6353                            String sql = query.toString();
6354    
6355                            Session session = null;
6356    
6357                            try {
6358                                    session = openSession();
6359    
6360                                    Query q = session.createQuery(sql);
6361    
6362                                    QueryPos qPos = QueryPos.getInstance(q);
6363    
6364                                    qPos.add(companyId);
6365    
6366                                    if (bindDisplayDate) {
6367                                            qPos.add(new Timestamp(displayDate.getTime()));
6368                                    }
6369    
6370                                    if (!pagination) {
6371                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
6372                                                            start, end, false);
6373    
6374                                            Collections.sort(list);
6375    
6376                                            list = Collections.unmodifiableList(list);
6377                                    }
6378                                    else {
6379                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
6380                                                            start, end);
6381                                    }
6382    
6383                                    cacheResult(list);
6384    
6385                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
6386                            }
6387                            catch (Exception e) {
6388                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6389    
6390                                    throw processException(e);
6391                            }
6392                            finally {
6393                                    closeSession(session);
6394                            }
6395                    }
6396    
6397                    return list;
6398            }
6399    
6400            /**
6401             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63;.
6402             *
6403             * @param companyId the company ID
6404             * @param displayDate the display date
6405             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6406             * @return the first matching blogs entry
6407             * @throws NoSuchEntryException if a matching blogs entry could not be found
6408             */
6409            @Override
6410            public BlogsEntry findByC_LtD_First(long companyId, Date displayDate,
6411                    OrderByComparator<BlogsEntry> orderByComparator)
6412                    throws NoSuchEntryException {
6413                    BlogsEntry blogsEntry = fetchByC_LtD_First(companyId, displayDate,
6414                                    orderByComparator);
6415    
6416                    if (blogsEntry != null) {
6417                            return blogsEntry;
6418                    }
6419    
6420                    StringBundler msg = new StringBundler(6);
6421    
6422                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6423    
6424                    msg.append("companyId=");
6425                    msg.append(companyId);
6426    
6427                    msg.append(", displayDate=");
6428                    msg.append(displayDate);
6429    
6430                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6431    
6432                    throw new NoSuchEntryException(msg.toString());
6433            }
6434    
6435            /**
6436             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63;.
6437             *
6438             * @param companyId the company ID
6439             * @param displayDate the display date
6440             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6441             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
6442             */
6443            @Override
6444            public BlogsEntry fetchByC_LtD_First(long companyId, Date displayDate,
6445                    OrderByComparator<BlogsEntry> orderByComparator) {
6446                    List<BlogsEntry> list = findByC_LtD(companyId, displayDate, 0, 1,
6447                                    orderByComparator);
6448    
6449                    if (!list.isEmpty()) {
6450                            return list.get(0);
6451                    }
6452    
6453                    return null;
6454            }
6455    
6456            /**
6457             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63;.
6458             *
6459             * @param companyId the company ID
6460             * @param displayDate the display date
6461             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6462             * @return the last matching blogs entry
6463             * @throws NoSuchEntryException if a matching blogs entry could not be found
6464             */
6465            @Override
6466            public BlogsEntry findByC_LtD_Last(long companyId, Date displayDate,
6467                    OrderByComparator<BlogsEntry> orderByComparator)
6468                    throws NoSuchEntryException {
6469                    BlogsEntry blogsEntry = fetchByC_LtD_Last(companyId, displayDate,
6470                                    orderByComparator);
6471    
6472                    if (blogsEntry != null) {
6473                            return blogsEntry;
6474                    }
6475    
6476                    StringBundler msg = new StringBundler(6);
6477    
6478                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6479    
6480                    msg.append("companyId=");
6481                    msg.append(companyId);
6482    
6483                    msg.append(", displayDate=");
6484                    msg.append(displayDate);
6485    
6486                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6487    
6488                    throw new NoSuchEntryException(msg.toString());
6489            }
6490    
6491            /**
6492             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63;.
6493             *
6494             * @param companyId the company ID
6495             * @param displayDate the display date
6496             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6497             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
6498             */
6499            @Override
6500            public BlogsEntry fetchByC_LtD_Last(long companyId, Date displayDate,
6501                    OrderByComparator<BlogsEntry> orderByComparator) {
6502                    int count = countByC_LtD(companyId, displayDate);
6503    
6504                    if (count == 0) {
6505                            return null;
6506                    }
6507    
6508                    List<BlogsEntry> list = findByC_LtD(companyId, displayDate, count - 1,
6509                                    count, orderByComparator);
6510    
6511                    if (!list.isEmpty()) {
6512                            return list.get(0);
6513                    }
6514    
6515                    return null;
6516            }
6517    
6518            /**
6519             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63;.
6520             *
6521             * @param entryId the primary key of the current blogs entry
6522             * @param companyId the company ID
6523             * @param displayDate the display date
6524             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6525             * @return the previous, current, and next blogs entry
6526             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
6527             */
6528            @Override
6529            public BlogsEntry[] findByC_LtD_PrevAndNext(long entryId, long companyId,
6530                    Date displayDate, OrderByComparator<BlogsEntry> orderByComparator)
6531                    throws NoSuchEntryException {
6532                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
6533    
6534                    Session session = null;
6535    
6536                    try {
6537                            session = openSession();
6538    
6539                            BlogsEntry[] array = new BlogsEntryImpl[3];
6540    
6541                            array[0] = getByC_LtD_PrevAndNext(session, blogsEntry, companyId,
6542                                            displayDate, orderByComparator, true);
6543    
6544                            array[1] = blogsEntry;
6545    
6546                            array[2] = getByC_LtD_PrevAndNext(session, blogsEntry, companyId,
6547                                            displayDate, orderByComparator, false);
6548    
6549                            return array;
6550                    }
6551                    catch (Exception e) {
6552                            throw processException(e);
6553                    }
6554                    finally {
6555                            closeSession(session);
6556                    }
6557            }
6558    
6559            protected BlogsEntry getByC_LtD_PrevAndNext(Session session,
6560                    BlogsEntry blogsEntry, long companyId, Date displayDate,
6561                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
6562                    StringBundler query = null;
6563    
6564                    if (orderByComparator != null) {
6565                            query = new StringBundler(6 +
6566                                            (orderByComparator.getOrderByFields().length * 6));
6567                    }
6568                    else {
6569                            query = new StringBundler(3);
6570                    }
6571    
6572                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
6573    
6574                    query.append(_FINDER_COLUMN_C_LTD_COMPANYID_2);
6575    
6576                    boolean bindDisplayDate = false;
6577    
6578                    if (displayDate == null) {
6579                            query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_1);
6580                    }
6581                    else {
6582                            bindDisplayDate = true;
6583    
6584                            query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_2);
6585                    }
6586    
6587                    if (orderByComparator != null) {
6588                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6589    
6590                            if (orderByConditionFields.length > 0) {
6591                                    query.append(WHERE_AND);
6592                            }
6593    
6594                            for (int i = 0; i < orderByConditionFields.length; i++) {
6595                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6596                                    query.append(orderByConditionFields[i]);
6597    
6598                                    if ((i + 1) < orderByConditionFields.length) {
6599                                            if (orderByComparator.isAscending() ^ previous) {
6600                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6601                                            }
6602                                            else {
6603                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6604                                            }
6605                                    }
6606                                    else {
6607                                            if (orderByComparator.isAscending() ^ previous) {
6608                                                    query.append(WHERE_GREATER_THAN);
6609                                            }
6610                                            else {
6611                                                    query.append(WHERE_LESSER_THAN);
6612                                            }
6613                                    }
6614                            }
6615    
6616                            query.append(ORDER_BY_CLAUSE);
6617    
6618                            String[] orderByFields = orderByComparator.getOrderByFields();
6619    
6620                            for (int i = 0; i < orderByFields.length; i++) {
6621                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6622                                    query.append(orderByFields[i]);
6623    
6624                                    if ((i + 1) < orderByFields.length) {
6625                                            if (orderByComparator.isAscending() ^ previous) {
6626                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6627                                            }
6628                                            else {
6629                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6630                                            }
6631                                    }
6632                                    else {
6633                                            if (orderByComparator.isAscending() ^ previous) {
6634                                                    query.append(ORDER_BY_ASC);
6635                                            }
6636                                            else {
6637                                                    query.append(ORDER_BY_DESC);
6638                                            }
6639                                    }
6640                            }
6641                    }
6642                    else {
6643                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
6644                    }
6645    
6646                    String sql = query.toString();
6647    
6648                    Query q = session.createQuery(sql);
6649    
6650                    q.setFirstResult(0);
6651                    q.setMaxResults(2);
6652    
6653                    QueryPos qPos = QueryPos.getInstance(q);
6654    
6655                    qPos.add(companyId);
6656    
6657                    if (bindDisplayDate) {
6658                            qPos.add(new Timestamp(displayDate.getTime()));
6659                    }
6660    
6661                    if (orderByComparator != null) {
6662                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
6663    
6664                            for (Object value : values) {
6665                                    qPos.add(value);
6666                            }
6667                    }
6668    
6669                    List<BlogsEntry> list = q.list();
6670    
6671                    if (list.size() == 2) {
6672                            return list.get(1);
6673                    }
6674                    else {
6675                            return null;
6676                    }
6677            }
6678    
6679            /**
6680             * Removes all the blogs entries where companyId = &#63; and displayDate &lt; &#63; from the database.
6681             *
6682             * @param companyId the company ID
6683             * @param displayDate the display date
6684             */
6685            @Override
6686            public void removeByC_LtD(long companyId, Date displayDate) {
6687                    for (BlogsEntry blogsEntry : findByC_LtD(companyId, displayDate,
6688                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
6689                            remove(blogsEntry);
6690                    }
6691            }
6692    
6693            /**
6694             * Returns the number of blogs entries where companyId = &#63; and displayDate &lt; &#63;.
6695             *
6696             * @param companyId the company ID
6697             * @param displayDate the display date
6698             * @return the number of matching blogs entries
6699             */
6700            @Override
6701            public int countByC_LtD(long companyId, Date displayDate) {
6702                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD;
6703    
6704                    Object[] finderArgs = new Object[] { companyId, displayDate };
6705    
6706                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
6707                                    this);
6708    
6709                    if (count == null) {
6710                            StringBundler query = new StringBundler(3);
6711    
6712                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
6713    
6714                            query.append(_FINDER_COLUMN_C_LTD_COMPANYID_2);
6715    
6716                            boolean bindDisplayDate = false;
6717    
6718                            if (displayDate == null) {
6719                                    query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_1);
6720                            }
6721                            else {
6722                                    bindDisplayDate = true;
6723    
6724                                    query.append(_FINDER_COLUMN_C_LTD_DISPLAYDATE_2);
6725                            }
6726    
6727                            String sql = query.toString();
6728    
6729                            Session session = null;
6730    
6731                            try {
6732                                    session = openSession();
6733    
6734                                    Query q = session.createQuery(sql);
6735    
6736                                    QueryPos qPos = QueryPos.getInstance(q);
6737    
6738                                    qPos.add(companyId);
6739    
6740                                    if (bindDisplayDate) {
6741                                            qPos.add(new Timestamp(displayDate.getTime()));
6742                                    }
6743    
6744                                    count = (Long)q.uniqueResult();
6745    
6746                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
6747                            }
6748                            catch (Exception e) {
6749                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6750    
6751                                    throw processException(e);
6752                            }
6753                            finally {
6754                                    closeSession(session);
6755                            }
6756                    }
6757    
6758                    return count.intValue();
6759            }
6760    
6761            private static final String _FINDER_COLUMN_C_LTD_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
6762            private static final String _FINDER_COLUMN_C_LTD_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL";
6763            private static final String _FINDER_COLUMN_C_LTD_DISPLAYDATE_2 = "blogsEntry.displayDate < ?";
6764            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
6765                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
6766                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_S",
6767                            new String[] {
6768                                    Long.class.getName(), Integer.class.getName(),
6769                                    
6770                            Integer.class.getName(), Integer.class.getName(),
6771                                    OrderByComparator.class.getName()
6772                            });
6773            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
6774                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
6775                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_S",
6776                            new String[] { Long.class.getName(), Integer.class.getName() },
6777                            BlogsEntryModelImpl.COMPANYID_COLUMN_BITMASK |
6778                            BlogsEntryModelImpl.STATUS_COLUMN_BITMASK |
6779                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
6780                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
6781            public static final FinderPath FINDER_PATH_COUNT_BY_C_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
6782                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
6783                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_S",
6784                            new String[] { Long.class.getName(), Integer.class.getName() });
6785    
6786            /**
6787             * Returns all the blogs entries where companyId = &#63; and status = &#63;.
6788             *
6789             * @param companyId the company ID
6790             * @param status the status
6791             * @return the matching blogs entries
6792             */
6793            @Override
6794            public List<BlogsEntry> findByC_S(long companyId, int status) {
6795                    return findByC_S(companyId, status, QueryUtil.ALL_POS,
6796                            QueryUtil.ALL_POS, null);
6797            }
6798    
6799            /**
6800             * Returns a range of all the blogs entries where companyId = &#63; and status = &#63;.
6801             *
6802             * <p>
6803             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6804             * </p>
6805             *
6806             * @param companyId the company ID
6807             * @param status the status
6808             * @param start the lower bound of the range of blogs entries
6809             * @param end the upper bound of the range of blogs entries (not inclusive)
6810             * @return the range of matching blogs entries
6811             */
6812            @Override
6813            public List<BlogsEntry> findByC_S(long companyId, int status, int start,
6814                    int end) {
6815                    return findByC_S(companyId, status, start, end, null);
6816            }
6817    
6818            /**
6819             * Returns an ordered range of all the blogs entries where companyId = &#63; and status = &#63;.
6820             *
6821             * <p>
6822             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6823             * </p>
6824             *
6825             * @param companyId the company ID
6826             * @param status the status
6827             * @param start the lower bound of the range of blogs entries
6828             * @param end the upper bound of the range of blogs entries (not inclusive)
6829             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6830             * @return the ordered range of matching blogs entries
6831             */
6832            @Override
6833            public List<BlogsEntry> findByC_S(long companyId, int status, int start,
6834                    int end, OrderByComparator<BlogsEntry> orderByComparator) {
6835                    boolean pagination = true;
6836                    FinderPath finderPath = null;
6837                    Object[] finderArgs = null;
6838    
6839                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6840                                    (orderByComparator == null)) {
6841                            pagination = false;
6842                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S;
6843                            finderArgs = new Object[] { companyId, status };
6844                    }
6845                    else {
6846                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_S;
6847                            finderArgs = new Object[] {
6848                                            companyId, status,
6849                                            
6850                                            start, end, orderByComparator
6851                                    };
6852                    }
6853    
6854                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
6855                                    finderArgs, this);
6856    
6857                    if ((list != null) && !list.isEmpty()) {
6858                            for (BlogsEntry blogsEntry : list) {
6859                                    if ((companyId != blogsEntry.getCompanyId()) ||
6860                                                    (status != blogsEntry.getStatus())) {
6861                                            list = null;
6862    
6863                                            break;
6864                                    }
6865                            }
6866                    }
6867    
6868                    if (list == null) {
6869                            StringBundler query = null;
6870    
6871                            if (orderByComparator != null) {
6872                                    query = new StringBundler(4 +
6873                                                    (orderByComparator.getOrderByFields().length * 3));
6874                            }
6875                            else {
6876                                    query = new StringBundler(4);
6877                            }
6878    
6879                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
6880    
6881                            query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
6882    
6883                            query.append(_FINDER_COLUMN_C_S_STATUS_2);
6884    
6885                            if (orderByComparator != null) {
6886                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6887                                            orderByComparator);
6888                            }
6889                            else
6890                             if (pagination) {
6891                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
6892                            }
6893    
6894                            String sql = query.toString();
6895    
6896                            Session session = null;
6897    
6898                            try {
6899                                    session = openSession();
6900    
6901                                    Query q = session.createQuery(sql);
6902    
6903                                    QueryPos qPos = QueryPos.getInstance(q);
6904    
6905                                    qPos.add(companyId);
6906    
6907                                    qPos.add(status);
6908    
6909                                    if (!pagination) {
6910                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
6911                                                            start, end, false);
6912    
6913                                            Collections.sort(list);
6914    
6915                                            list = Collections.unmodifiableList(list);
6916                                    }
6917                                    else {
6918                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
6919                                                            start, end);
6920                                    }
6921    
6922                                    cacheResult(list);
6923    
6924                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
6925                            }
6926                            catch (Exception e) {
6927                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6928    
6929                                    throw processException(e);
6930                            }
6931                            finally {
6932                                    closeSession(session);
6933                            }
6934                    }
6935    
6936                    return list;
6937            }
6938    
6939            /**
6940             * Returns the first blogs entry in the ordered set where companyId = &#63; and status = &#63;.
6941             *
6942             * @param companyId the company ID
6943             * @param status the status
6944             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6945             * @return the first matching blogs entry
6946             * @throws NoSuchEntryException if a matching blogs entry could not be found
6947             */
6948            @Override
6949            public BlogsEntry findByC_S_First(long companyId, int status,
6950                    OrderByComparator<BlogsEntry> orderByComparator)
6951                    throws NoSuchEntryException {
6952                    BlogsEntry blogsEntry = fetchByC_S_First(companyId, status,
6953                                    orderByComparator);
6954    
6955                    if (blogsEntry != null) {
6956                            return blogsEntry;
6957                    }
6958    
6959                    StringBundler msg = new StringBundler(6);
6960    
6961                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6962    
6963                    msg.append("companyId=");
6964                    msg.append(companyId);
6965    
6966                    msg.append(", status=");
6967                    msg.append(status);
6968    
6969                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6970    
6971                    throw new NoSuchEntryException(msg.toString());
6972            }
6973    
6974            /**
6975             * Returns the first blogs entry in the ordered set where companyId = &#63; and status = &#63;.
6976             *
6977             * @param companyId the company ID
6978             * @param status the status
6979             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6980             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
6981             */
6982            @Override
6983            public BlogsEntry fetchByC_S_First(long companyId, int status,
6984                    OrderByComparator<BlogsEntry> orderByComparator) {
6985                    List<BlogsEntry> list = findByC_S(companyId, status, 0, 1,
6986                                    orderByComparator);
6987    
6988                    if (!list.isEmpty()) {
6989                            return list.get(0);
6990                    }
6991    
6992                    return null;
6993            }
6994    
6995            /**
6996             * Returns the last blogs entry in the ordered set where companyId = &#63; and status = &#63;.
6997             *
6998             * @param companyId the company ID
6999             * @param status the status
7000             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7001             * @return the last matching blogs entry
7002             * @throws NoSuchEntryException if a matching blogs entry could not be found
7003             */
7004            @Override
7005            public BlogsEntry findByC_S_Last(long companyId, int status,
7006                    OrderByComparator<BlogsEntry> orderByComparator)
7007                    throws NoSuchEntryException {
7008                    BlogsEntry blogsEntry = fetchByC_S_Last(companyId, status,
7009                                    orderByComparator);
7010    
7011                    if (blogsEntry != null) {
7012                            return blogsEntry;
7013                    }
7014    
7015                    StringBundler msg = new StringBundler(6);
7016    
7017                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7018    
7019                    msg.append("companyId=");
7020                    msg.append(companyId);
7021    
7022                    msg.append(", status=");
7023                    msg.append(status);
7024    
7025                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7026    
7027                    throw new NoSuchEntryException(msg.toString());
7028            }
7029    
7030            /**
7031             * Returns the last blogs entry in the ordered set where companyId = &#63; and status = &#63;.
7032             *
7033             * @param companyId the company ID
7034             * @param status the status
7035             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7036             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
7037             */
7038            @Override
7039            public BlogsEntry fetchByC_S_Last(long companyId, int status,
7040                    OrderByComparator<BlogsEntry> orderByComparator) {
7041                    int count = countByC_S(companyId, status);
7042    
7043                    if (count == 0) {
7044                            return null;
7045                    }
7046    
7047                    List<BlogsEntry> list = findByC_S(companyId, status, count - 1, count,
7048                                    orderByComparator);
7049    
7050                    if (!list.isEmpty()) {
7051                            return list.get(0);
7052                    }
7053    
7054                    return null;
7055            }
7056    
7057            /**
7058             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63; and status = &#63;.
7059             *
7060             * @param entryId the primary key of the current blogs entry
7061             * @param companyId the company ID
7062             * @param status the status
7063             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7064             * @return the previous, current, and next blogs entry
7065             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
7066             */
7067            @Override
7068            public BlogsEntry[] findByC_S_PrevAndNext(long entryId, long companyId,
7069                    int status, OrderByComparator<BlogsEntry> orderByComparator)
7070                    throws NoSuchEntryException {
7071                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
7072    
7073                    Session session = null;
7074    
7075                    try {
7076                            session = openSession();
7077    
7078                            BlogsEntry[] array = new BlogsEntryImpl[3];
7079    
7080                            array[0] = getByC_S_PrevAndNext(session, blogsEntry, companyId,
7081                                            status, orderByComparator, true);
7082    
7083                            array[1] = blogsEntry;
7084    
7085                            array[2] = getByC_S_PrevAndNext(session, blogsEntry, companyId,
7086                                            status, orderByComparator, false);
7087    
7088                            return array;
7089                    }
7090                    catch (Exception e) {
7091                            throw processException(e);
7092                    }
7093                    finally {
7094                            closeSession(session);
7095                    }
7096            }
7097    
7098            protected BlogsEntry getByC_S_PrevAndNext(Session session,
7099                    BlogsEntry blogsEntry, long companyId, int status,
7100                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
7101                    StringBundler query = null;
7102    
7103                    if (orderByComparator != null) {
7104                            query = new StringBundler(6 +
7105                                            (orderByComparator.getOrderByFields().length * 6));
7106                    }
7107                    else {
7108                            query = new StringBundler(3);
7109                    }
7110    
7111                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
7112    
7113                    query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
7114    
7115                    query.append(_FINDER_COLUMN_C_S_STATUS_2);
7116    
7117                    if (orderByComparator != null) {
7118                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7119    
7120                            if (orderByConditionFields.length > 0) {
7121                                    query.append(WHERE_AND);
7122                            }
7123    
7124                            for (int i = 0; i < orderByConditionFields.length; i++) {
7125                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7126                                    query.append(orderByConditionFields[i]);
7127    
7128                                    if ((i + 1) < orderByConditionFields.length) {
7129                                            if (orderByComparator.isAscending() ^ previous) {
7130                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7131                                            }
7132                                            else {
7133                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7134                                            }
7135                                    }
7136                                    else {
7137                                            if (orderByComparator.isAscending() ^ previous) {
7138                                                    query.append(WHERE_GREATER_THAN);
7139                                            }
7140                                            else {
7141                                                    query.append(WHERE_LESSER_THAN);
7142                                            }
7143                                    }
7144                            }
7145    
7146                            query.append(ORDER_BY_CLAUSE);
7147    
7148                            String[] orderByFields = orderByComparator.getOrderByFields();
7149    
7150                            for (int i = 0; i < orderByFields.length; i++) {
7151                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7152                                    query.append(orderByFields[i]);
7153    
7154                                    if ((i + 1) < orderByFields.length) {
7155                                            if (orderByComparator.isAscending() ^ previous) {
7156                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7157                                            }
7158                                            else {
7159                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7160                                            }
7161                                    }
7162                                    else {
7163                                            if (orderByComparator.isAscending() ^ previous) {
7164                                                    query.append(ORDER_BY_ASC);
7165                                            }
7166                                            else {
7167                                                    query.append(ORDER_BY_DESC);
7168                                            }
7169                                    }
7170                            }
7171                    }
7172                    else {
7173                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
7174                    }
7175    
7176                    String sql = query.toString();
7177    
7178                    Query q = session.createQuery(sql);
7179    
7180                    q.setFirstResult(0);
7181                    q.setMaxResults(2);
7182    
7183                    QueryPos qPos = QueryPos.getInstance(q);
7184    
7185                    qPos.add(companyId);
7186    
7187                    qPos.add(status);
7188    
7189                    if (orderByComparator != null) {
7190                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
7191    
7192                            for (Object value : values) {
7193                                    qPos.add(value);
7194                            }
7195                    }
7196    
7197                    List<BlogsEntry> list = q.list();
7198    
7199                    if (list.size() == 2) {
7200                            return list.get(1);
7201                    }
7202                    else {
7203                            return null;
7204                    }
7205            }
7206    
7207            /**
7208             * Removes all the blogs entries where companyId = &#63; and status = &#63; from the database.
7209             *
7210             * @param companyId the company ID
7211             * @param status the status
7212             */
7213            @Override
7214            public void removeByC_S(long companyId, int status) {
7215                    for (BlogsEntry blogsEntry : findByC_S(companyId, status,
7216                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
7217                            remove(blogsEntry);
7218                    }
7219            }
7220    
7221            /**
7222             * Returns the number of blogs entries where companyId = &#63; and status = &#63;.
7223             *
7224             * @param companyId the company ID
7225             * @param status the status
7226             * @return the number of matching blogs entries
7227             */
7228            @Override
7229            public int countByC_S(long companyId, int status) {
7230                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_S;
7231    
7232                    Object[] finderArgs = new Object[] { companyId, status };
7233    
7234                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
7235                                    this);
7236    
7237                    if (count == null) {
7238                            StringBundler query = new StringBundler(3);
7239    
7240                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
7241    
7242                            query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
7243    
7244                            query.append(_FINDER_COLUMN_C_S_STATUS_2);
7245    
7246                            String sql = query.toString();
7247    
7248                            Session session = null;
7249    
7250                            try {
7251                                    session = openSession();
7252    
7253                                    Query q = session.createQuery(sql);
7254    
7255                                    QueryPos qPos = QueryPos.getInstance(q);
7256    
7257                                    qPos.add(companyId);
7258    
7259                                    qPos.add(status);
7260    
7261                                    count = (Long)q.uniqueResult();
7262    
7263                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
7264                            }
7265                            catch (Exception e) {
7266                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
7267    
7268                                    throw processException(e);
7269                            }
7270                            finally {
7271                                    closeSession(session);
7272                            }
7273                    }
7274    
7275                    return count.intValue();
7276            }
7277    
7278            private static final String _FINDER_COLUMN_C_S_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
7279            private static final String _FINDER_COLUMN_C_S_STATUS_2 = "blogsEntry.status = ?";
7280            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_NOTS = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
7281                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
7282                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_NotS",
7283                            new String[] {
7284                                    Long.class.getName(), Integer.class.getName(),
7285                                    
7286                            Integer.class.getName(), Integer.class.getName(),
7287                                    OrderByComparator.class.getName()
7288                            });
7289            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_NOTS = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
7290                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
7291                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_NotS",
7292                            new String[] { Long.class.getName(), Integer.class.getName() });
7293    
7294            /**
7295             * Returns all the blogs entries where companyId = &#63; and status &ne; &#63;.
7296             *
7297             * @param companyId the company ID
7298             * @param status the status
7299             * @return the matching blogs entries
7300             */
7301            @Override
7302            public List<BlogsEntry> findByC_NotS(long companyId, int status) {
7303                    return findByC_NotS(companyId, status, QueryUtil.ALL_POS,
7304                            QueryUtil.ALL_POS, null);
7305            }
7306    
7307            /**
7308             * Returns a range of all the blogs entries where companyId = &#63; and status &ne; &#63;.
7309             *
7310             * <p>
7311             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7312             * </p>
7313             *
7314             * @param companyId the company ID
7315             * @param status the status
7316             * @param start the lower bound of the range of blogs entries
7317             * @param end the upper bound of the range of blogs entries (not inclusive)
7318             * @return the range of matching blogs entries
7319             */
7320            @Override
7321            public List<BlogsEntry> findByC_NotS(long companyId, int status, int start,
7322                    int end) {
7323                    return findByC_NotS(companyId, status, start, end, null);
7324            }
7325    
7326            /**
7327             * Returns an ordered range of all the blogs entries where companyId = &#63; and status &ne; &#63;.
7328             *
7329             * <p>
7330             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7331             * </p>
7332             *
7333             * @param companyId the company ID
7334             * @param status the status
7335             * @param start the lower bound of the range of blogs entries
7336             * @param end the upper bound of the range of blogs entries (not inclusive)
7337             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7338             * @return the ordered range of matching blogs entries
7339             */
7340            @Override
7341            public List<BlogsEntry> findByC_NotS(long companyId, int status, int start,
7342                    int end, OrderByComparator<BlogsEntry> orderByComparator) {
7343                    boolean pagination = true;
7344                    FinderPath finderPath = null;
7345                    Object[] finderArgs = null;
7346    
7347                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_NOTS;
7348                    finderArgs = new Object[] {
7349                                    companyId, status,
7350                                    
7351                                    start, end, orderByComparator
7352                            };
7353    
7354                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
7355                                    finderArgs, this);
7356    
7357                    if ((list != null) && !list.isEmpty()) {
7358                            for (BlogsEntry blogsEntry : list) {
7359                                    if ((companyId != blogsEntry.getCompanyId()) ||
7360                                                    (status == blogsEntry.getStatus())) {
7361                                            list = null;
7362    
7363                                            break;
7364                                    }
7365                            }
7366                    }
7367    
7368                    if (list == null) {
7369                            StringBundler query = null;
7370    
7371                            if (orderByComparator != null) {
7372                                    query = new StringBundler(4 +
7373                                                    (orderByComparator.getOrderByFields().length * 3));
7374                            }
7375                            else {
7376                                    query = new StringBundler(4);
7377                            }
7378    
7379                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
7380    
7381                            query.append(_FINDER_COLUMN_C_NOTS_COMPANYID_2);
7382    
7383                            query.append(_FINDER_COLUMN_C_NOTS_STATUS_2);
7384    
7385                            if (orderByComparator != null) {
7386                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7387                                            orderByComparator);
7388                            }
7389                            else
7390                             if (pagination) {
7391                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
7392                            }
7393    
7394                            String sql = query.toString();
7395    
7396                            Session session = null;
7397    
7398                            try {
7399                                    session = openSession();
7400    
7401                                    Query q = session.createQuery(sql);
7402    
7403                                    QueryPos qPos = QueryPos.getInstance(q);
7404    
7405                                    qPos.add(companyId);
7406    
7407                                    qPos.add(status);
7408    
7409                                    if (!pagination) {
7410                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
7411                                                            start, end, false);
7412    
7413                                            Collections.sort(list);
7414    
7415                                            list = Collections.unmodifiableList(list);
7416                                    }
7417                                    else {
7418                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
7419                                                            start, end);
7420                                    }
7421    
7422                                    cacheResult(list);
7423    
7424                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
7425                            }
7426                            catch (Exception e) {
7427                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
7428    
7429                                    throw processException(e);
7430                            }
7431                            finally {
7432                                    closeSession(session);
7433                            }
7434                    }
7435    
7436                    return list;
7437            }
7438    
7439            /**
7440             * Returns the first blogs entry in the ordered set where companyId = &#63; and status &ne; &#63;.
7441             *
7442             * @param companyId the company ID
7443             * @param status the status
7444             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7445             * @return the first matching blogs entry
7446             * @throws NoSuchEntryException if a matching blogs entry could not be found
7447             */
7448            @Override
7449            public BlogsEntry findByC_NotS_First(long companyId, int status,
7450                    OrderByComparator<BlogsEntry> orderByComparator)
7451                    throws NoSuchEntryException {
7452                    BlogsEntry blogsEntry = fetchByC_NotS_First(companyId, status,
7453                                    orderByComparator);
7454    
7455                    if (blogsEntry != null) {
7456                            return blogsEntry;
7457                    }
7458    
7459                    StringBundler msg = new StringBundler(6);
7460    
7461                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7462    
7463                    msg.append("companyId=");
7464                    msg.append(companyId);
7465    
7466                    msg.append(", status=");
7467                    msg.append(status);
7468    
7469                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7470    
7471                    throw new NoSuchEntryException(msg.toString());
7472            }
7473    
7474            /**
7475             * Returns the first blogs entry in the ordered set where companyId = &#63; and status &ne; &#63;.
7476             *
7477             * @param companyId the company ID
7478             * @param status the status
7479             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7480             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
7481             */
7482            @Override
7483            public BlogsEntry fetchByC_NotS_First(long companyId, int status,
7484                    OrderByComparator<BlogsEntry> orderByComparator) {
7485                    List<BlogsEntry> list = findByC_NotS(companyId, status, 0, 1,
7486                                    orderByComparator);
7487    
7488                    if (!list.isEmpty()) {
7489                            return list.get(0);
7490                    }
7491    
7492                    return null;
7493            }
7494    
7495            /**
7496             * Returns the last blogs entry in the ordered set where companyId = &#63; and status &ne; &#63;.
7497             *
7498             * @param companyId the company ID
7499             * @param status the status
7500             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7501             * @return the last matching blogs entry
7502             * @throws NoSuchEntryException if a matching blogs entry could not be found
7503             */
7504            @Override
7505            public BlogsEntry findByC_NotS_Last(long companyId, int status,
7506                    OrderByComparator<BlogsEntry> orderByComparator)
7507                    throws NoSuchEntryException {
7508                    BlogsEntry blogsEntry = fetchByC_NotS_Last(companyId, status,
7509                                    orderByComparator);
7510    
7511                    if (blogsEntry != null) {
7512                            return blogsEntry;
7513                    }
7514    
7515                    StringBundler msg = new StringBundler(6);
7516    
7517                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7518    
7519                    msg.append("companyId=");
7520                    msg.append(companyId);
7521    
7522                    msg.append(", status=");
7523                    msg.append(status);
7524    
7525                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7526    
7527                    throw new NoSuchEntryException(msg.toString());
7528            }
7529    
7530            /**
7531             * Returns the last blogs entry in the ordered set where companyId = &#63; and status &ne; &#63;.
7532             *
7533             * @param companyId the company ID
7534             * @param status the status
7535             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7536             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
7537             */
7538            @Override
7539            public BlogsEntry fetchByC_NotS_Last(long companyId, int status,
7540                    OrderByComparator<BlogsEntry> orderByComparator) {
7541                    int count = countByC_NotS(companyId, status);
7542    
7543                    if (count == 0) {
7544                            return null;
7545                    }
7546    
7547                    List<BlogsEntry> list = findByC_NotS(companyId, status, count - 1,
7548                                    count, orderByComparator);
7549    
7550                    if (!list.isEmpty()) {
7551                            return list.get(0);
7552                    }
7553    
7554                    return null;
7555            }
7556    
7557            /**
7558             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63; and status &ne; &#63;.
7559             *
7560             * @param entryId the primary key of the current blogs entry
7561             * @param companyId the company ID
7562             * @param status the status
7563             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7564             * @return the previous, current, and next blogs entry
7565             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
7566             */
7567            @Override
7568            public BlogsEntry[] findByC_NotS_PrevAndNext(long entryId, long companyId,
7569                    int status, OrderByComparator<BlogsEntry> orderByComparator)
7570                    throws NoSuchEntryException {
7571                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
7572    
7573                    Session session = null;
7574    
7575                    try {
7576                            session = openSession();
7577    
7578                            BlogsEntry[] array = new BlogsEntryImpl[3];
7579    
7580                            array[0] = getByC_NotS_PrevAndNext(session, blogsEntry, companyId,
7581                                            status, orderByComparator, true);
7582    
7583                            array[1] = blogsEntry;
7584    
7585                            array[2] = getByC_NotS_PrevAndNext(session, blogsEntry, companyId,
7586                                            status, orderByComparator, false);
7587    
7588                            return array;
7589                    }
7590                    catch (Exception e) {
7591                            throw processException(e);
7592                    }
7593                    finally {
7594                            closeSession(session);
7595                    }
7596            }
7597    
7598            protected BlogsEntry getByC_NotS_PrevAndNext(Session session,
7599                    BlogsEntry blogsEntry, long companyId, int status,
7600                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
7601                    StringBundler query = null;
7602    
7603                    if (orderByComparator != null) {
7604                            query = new StringBundler(6 +
7605                                            (orderByComparator.getOrderByFields().length * 6));
7606                    }
7607                    else {
7608                            query = new StringBundler(3);
7609                    }
7610    
7611                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
7612    
7613                    query.append(_FINDER_COLUMN_C_NOTS_COMPANYID_2);
7614    
7615                    query.append(_FINDER_COLUMN_C_NOTS_STATUS_2);
7616    
7617                    if (orderByComparator != null) {
7618                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7619    
7620                            if (orderByConditionFields.length > 0) {
7621                                    query.append(WHERE_AND);
7622                            }
7623    
7624                            for (int i = 0; i < orderByConditionFields.length; i++) {
7625                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7626                                    query.append(orderByConditionFields[i]);
7627    
7628                                    if ((i + 1) < orderByConditionFields.length) {
7629                                            if (orderByComparator.isAscending() ^ previous) {
7630                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7631                                            }
7632                                            else {
7633                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7634                                            }
7635                                    }
7636                                    else {
7637                                            if (orderByComparator.isAscending() ^ previous) {
7638                                                    query.append(WHERE_GREATER_THAN);
7639                                            }
7640                                            else {
7641                                                    query.append(WHERE_LESSER_THAN);
7642                                            }
7643                                    }
7644                            }
7645    
7646                            query.append(ORDER_BY_CLAUSE);
7647    
7648                            String[] orderByFields = orderByComparator.getOrderByFields();
7649    
7650                            for (int i = 0; i < orderByFields.length; i++) {
7651                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7652                                    query.append(orderByFields[i]);
7653    
7654                                    if ((i + 1) < orderByFields.length) {
7655                                            if (orderByComparator.isAscending() ^ previous) {
7656                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7657                                            }
7658                                            else {
7659                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7660                                            }
7661                                    }
7662                                    else {
7663                                            if (orderByComparator.isAscending() ^ previous) {
7664                                                    query.append(ORDER_BY_ASC);
7665                                            }
7666                                            else {
7667                                                    query.append(ORDER_BY_DESC);
7668                                            }
7669                                    }
7670                            }
7671                    }
7672                    else {
7673                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
7674                    }
7675    
7676                    String sql = query.toString();
7677    
7678                    Query q = session.createQuery(sql);
7679    
7680                    q.setFirstResult(0);
7681                    q.setMaxResults(2);
7682    
7683                    QueryPos qPos = QueryPos.getInstance(q);
7684    
7685                    qPos.add(companyId);
7686    
7687                    qPos.add(status);
7688    
7689                    if (orderByComparator != null) {
7690                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
7691    
7692                            for (Object value : values) {
7693                                    qPos.add(value);
7694                            }
7695                    }
7696    
7697                    List<BlogsEntry> list = q.list();
7698    
7699                    if (list.size() == 2) {
7700                            return list.get(1);
7701                    }
7702                    else {
7703                            return null;
7704                    }
7705            }
7706    
7707            /**
7708             * Removes all the blogs entries where companyId = &#63; and status &ne; &#63; from the database.
7709             *
7710             * @param companyId the company ID
7711             * @param status the status
7712             */
7713            @Override
7714            public void removeByC_NotS(long companyId, int status) {
7715                    for (BlogsEntry blogsEntry : findByC_NotS(companyId, status,
7716                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
7717                            remove(blogsEntry);
7718                    }
7719            }
7720    
7721            /**
7722             * Returns the number of blogs entries where companyId = &#63; and status &ne; &#63;.
7723             *
7724             * @param companyId the company ID
7725             * @param status the status
7726             * @return the number of matching blogs entries
7727             */
7728            @Override
7729            public int countByC_NotS(long companyId, int status) {
7730                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_NOTS;
7731    
7732                    Object[] finderArgs = new Object[] { companyId, status };
7733    
7734                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
7735                                    this);
7736    
7737                    if (count == null) {
7738                            StringBundler query = new StringBundler(3);
7739    
7740                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
7741    
7742                            query.append(_FINDER_COLUMN_C_NOTS_COMPANYID_2);
7743    
7744                            query.append(_FINDER_COLUMN_C_NOTS_STATUS_2);
7745    
7746                            String sql = query.toString();
7747    
7748                            Session session = null;
7749    
7750                            try {
7751                                    session = openSession();
7752    
7753                                    Query q = session.createQuery(sql);
7754    
7755                                    QueryPos qPos = QueryPos.getInstance(q);
7756    
7757                                    qPos.add(companyId);
7758    
7759                                    qPos.add(status);
7760    
7761                                    count = (Long)q.uniqueResult();
7762    
7763                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
7764                            }
7765                            catch (Exception e) {
7766                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
7767    
7768                                    throw processException(e);
7769                            }
7770                            finally {
7771                                    closeSession(session);
7772                            }
7773                    }
7774    
7775                    return count.intValue();
7776            }
7777    
7778            private static final String _FINDER_COLUMN_C_NOTS_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
7779            private static final String _FINDER_COLUMN_C_NOTS_STATUS_2 = "blogsEntry.status != ?";
7780            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
7781                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
7782                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByLtD_S",
7783                            new String[] {
7784                                    Date.class.getName(), Integer.class.getName(),
7785                                    
7786                            Integer.class.getName(), Integer.class.getName(),
7787                                    OrderByComparator.class.getName()
7788                            });
7789            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
7790                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
7791                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByLtD_S",
7792                            new String[] { Date.class.getName(), Integer.class.getName() });
7793    
7794            /**
7795             * Returns all the blogs entries where displayDate &lt; &#63; and status = &#63;.
7796             *
7797             * @param displayDate the display date
7798             * @param status the status
7799             * @return the matching blogs entries
7800             */
7801            @Override
7802            public List<BlogsEntry> findByLtD_S(Date displayDate, int status) {
7803                    return findByLtD_S(displayDate, status, QueryUtil.ALL_POS,
7804                            QueryUtil.ALL_POS, null);
7805            }
7806    
7807            /**
7808             * Returns a range of all the blogs entries where displayDate &lt; &#63; and status = &#63;.
7809             *
7810             * <p>
7811             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7812             * </p>
7813             *
7814             * @param displayDate the display date
7815             * @param status the status
7816             * @param start the lower bound of the range of blogs entries
7817             * @param end the upper bound of the range of blogs entries (not inclusive)
7818             * @return the range of matching blogs entries
7819             */
7820            @Override
7821            public List<BlogsEntry> findByLtD_S(Date displayDate, int status,
7822                    int start, int end) {
7823                    return findByLtD_S(displayDate, status, start, end, null);
7824            }
7825    
7826            /**
7827             * Returns an ordered range of all the blogs entries where displayDate &lt; &#63; and status = &#63;.
7828             *
7829             * <p>
7830             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7831             * </p>
7832             *
7833             * @param displayDate the display date
7834             * @param status the status
7835             * @param start the lower bound of the range of blogs entries
7836             * @param end the upper bound of the range of blogs entries (not inclusive)
7837             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7838             * @return the ordered range of matching blogs entries
7839             */
7840            @Override
7841            public List<BlogsEntry> findByLtD_S(Date displayDate, int status,
7842                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator) {
7843                    boolean pagination = true;
7844                    FinderPath finderPath = null;
7845                    Object[] finderArgs = null;
7846    
7847                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_LTD_S;
7848                    finderArgs = new Object[] {
7849                                    displayDate, status,
7850                                    
7851                                    start, end, orderByComparator
7852                            };
7853    
7854                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
7855                                    finderArgs, this);
7856    
7857                    if ((list != null) && !list.isEmpty()) {
7858                            for (BlogsEntry blogsEntry : list) {
7859                                    if ((displayDate.getTime() <= blogsEntry.getDisplayDate()
7860                                                                                                                            .getTime()) ||
7861                                                    (status != blogsEntry.getStatus())) {
7862                                            list = null;
7863    
7864                                            break;
7865                                    }
7866                            }
7867                    }
7868    
7869                    if (list == null) {
7870                            StringBundler query = null;
7871    
7872                            if (orderByComparator != null) {
7873                                    query = new StringBundler(4 +
7874                                                    (orderByComparator.getOrderByFields().length * 3));
7875                            }
7876                            else {
7877                                    query = new StringBundler(4);
7878                            }
7879    
7880                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
7881    
7882                            boolean bindDisplayDate = false;
7883    
7884                            if (displayDate == null) {
7885                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_1);
7886                            }
7887                            else {
7888                                    bindDisplayDate = true;
7889    
7890                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_2);
7891                            }
7892    
7893                            query.append(_FINDER_COLUMN_LTD_S_STATUS_2);
7894    
7895                            if (orderByComparator != null) {
7896                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7897                                            orderByComparator);
7898                            }
7899                            else
7900                             if (pagination) {
7901                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
7902                            }
7903    
7904                            String sql = query.toString();
7905    
7906                            Session session = null;
7907    
7908                            try {
7909                                    session = openSession();
7910    
7911                                    Query q = session.createQuery(sql);
7912    
7913                                    QueryPos qPos = QueryPos.getInstance(q);
7914    
7915                                    if (bindDisplayDate) {
7916                                            qPos.add(new Timestamp(displayDate.getTime()));
7917                                    }
7918    
7919                                    qPos.add(status);
7920    
7921                                    if (!pagination) {
7922                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
7923                                                            start, end, false);
7924    
7925                                            Collections.sort(list);
7926    
7927                                            list = Collections.unmodifiableList(list);
7928                                    }
7929                                    else {
7930                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
7931                                                            start, end);
7932                                    }
7933    
7934                                    cacheResult(list);
7935    
7936                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
7937                            }
7938                            catch (Exception e) {
7939                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
7940    
7941                                    throw processException(e);
7942                            }
7943                            finally {
7944                                    closeSession(session);
7945                            }
7946                    }
7947    
7948                    return list;
7949            }
7950    
7951            /**
7952             * Returns the first blogs entry in the ordered set where displayDate &lt; &#63; and status = &#63;.
7953             *
7954             * @param displayDate the display date
7955             * @param status the status
7956             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7957             * @return the first matching blogs entry
7958             * @throws NoSuchEntryException if a matching blogs entry could not be found
7959             */
7960            @Override
7961            public BlogsEntry findByLtD_S_First(Date displayDate, int status,
7962                    OrderByComparator<BlogsEntry> orderByComparator)
7963                    throws NoSuchEntryException {
7964                    BlogsEntry blogsEntry = fetchByLtD_S_First(displayDate, status,
7965                                    orderByComparator);
7966    
7967                    if (blogsEntry != null) {
7968                            return blogsEntry;
7969                    }
7970    
7971                    StringBundler msg = new StringBundler(6);
7972    
7973                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7974    
7975                    msg.append("displayDate=");
7976                    msg.append(displayDate);
7977    
7978                    msg.append(", status=");
7979                    msg.append(status);
7980    
7981                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7982    
7983                    throw new NoSuchEntryException(msg.toString());
7984            }
7985    
7986            /**
7987             * Returns the first blogs entry in the ordered set where displayDate &lt; &#63; and status = &#63;.
7988             *
7989             * @param displayDate the display date
7990             * @param status the status
7991             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7992             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
7993             */
7994            @Override
7995            public BlogsEntry fetchByLtD_S_First(Date displayDate, int status,
7996                    OrderByComparator<BlogsEntry> orderByComparator) {
7997                    List<BlogsEntry> list = findByLtD_S(displayDate, status, 0, 1,
7998                                    orderByComparator);
7999    
8000                    if (!list.isEmpty()) {
8001                            return list.get(0);
8002                    }
8003    
8004                    return null;
8005            }
8006    
8007            /**
8008             * Returns the last blogs entry in the ordered set where displayDate &lt; &#63; and status = &#63;.
8009             *
8010             * @param displayDate the display date
8011             * @param status the status
8012             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8013             * @return the last matching blogs entry
8014             * @throws NoSuchEntryException if a matching blogs entry could not be found
8015             */
8016            @Override
8017            public BlogsEntry findByLtD_S_Last(Date displayDate, int status,
8018                    OrderByComparator<BlogsEntry> orderByComparator)
8019                    throws NoSuchEntryException {
8020                    BlogsEntry blogsEntry = fetchByLtD_S_Last(displayDate, status,
8021                                    orderByComparator);
8022    
8023                    if (blogsEntry != null) {
8024                            return blogsEntry;
8025                    }
8026    
8027                    StringBundler msg = new StringBundler(6);
8028    
8029                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8030    
8031                    msg.append("displayDate=");
8032                    msg.append(displayDate);
8033    
8034                    msg.append(", status=");
8035                    msg.append(status);
8036    
8037                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8038    
8039                    throw new NoSuchEntryException(msg.toString());
8040            }
8041    
8042            /**
8043             * Returns the last blogs entry in the ordered set where displayDate &lt; &#63; and status = &#63;.
8044             *
8045             * @param displayDate the display date
8046             * @param status the status
8047             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8048             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
8049             */
8050            @Override
8051            public BlogsEntry fetchByLtD_S_Last(Date displayDate, int status,
8052                    OrderByComparator<BlogsEntry> orderByComparator) {
8053                    int count = countByLtD_S(displayDate, status);
8054    
8055                    if (count == 0) {
8056                            return null;
8057                    }
8058    
8059                    List<BlogsEntry> list = findByLtD_S(displayDate, status, count - 1,
8060                                    count, orderByComparator);
8061    
8062                    if (!list.isEmpty()) {
8063                            return list.get(0);
8064                    }
8065    
8066                    return null;
8067            }
8068    
8069            /**
8070             * Returns the blogs entries before and after the current blogs entry in the ordered set where displayDate &lt; &#63; and status = &#63;.
8071             *
8072             * @param entryId the primary key of the current blogs entry
8073             * @param displayDate the display date
8074             * @param status the status
8075             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8076             * @return the previous, current, and next blogs entry
8077             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
8078             */
8079            @Override
8080            public BlogsEntry[] findByLtD_S_PrevAndNext(long entryId, Date displayDate,
8081                    int status, OrderByComparator<BlogsEntry> orderByComparator)
8082                    throws NoSuchEntryException {
8083                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
8084    
8085                    Session session = null;
8086    
8087                    try {
8088                            session = openSession();
8089    
8090                            BlogsEntry[] array = new BlogsEntryImpl[3];
8091    
8092                            array[0] = getByLtD_S_PrevAndNext(session, blogsEntry, displayDate,
8093                                            status, orderByComparator, true);
8094    
8095                            array[1] = blogsEntry;
8096    
8097                            array[2] = getByLtD_S_PrevAndNext(session, blogsEntry, displayDate,
8098                                            status, orderByComparator, false);
8099    
8100                            return array;
8101                    }
8102                    catch (Exception e) {
8103                            throw processException(e);
8104                    }
8105                    finally {
8106                            closeSession(session);
8107                    }
8108            }
8109    
8110            protected BlogsEntry getByLtD_S_PrevAndNext(Session session,
8111                    BlogsEntry blogsEntry, Date displayDate, int status,
8112                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
8113                    StringBundler query = null;
8114    
8115                    if (orderByComparator != null) {
8116                            query = new StringBundler(6 +
8117                                            (orderByComparator.getOrderByFields().length * 6));
8118                    }
8119                    else {
8120                            query = new StringBundler(3);
8121                    }
8122    
8123                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
8124    
8125                    boolean bindDisplayDate = false;
8126    
8127                    if (displayDate == null) {
8128                            query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_1);
8129                    }
8130                    else {
8131                            bindDisplayDate = true;
8132    
8133                            query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_2);
8134                    }
8135    
8136                    query.append(_FINDER_COLUMN_LTD_S_STATUS_2);
8137    
8138                    if (orderByComparator != null) {
8139                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8140    
8141                            if (orderByConditionFields.length > 0) {
8142                                    query.append(WHERE_AND);
8143                            }
8144    
8145                            for (int i = 0; i < orderByConditionFields.length; i++) {
8146                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8147                                    query.append(orderByConditionFields[i]);
8148    
8149                                    if ((i + 1) < orderByConditionFields.length) {
8150                                            if (orderByComparator.isAscending() ^ previous) {
8151                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8152                                            }
8153                                            else {
8154                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8155                                            }
8156                                    }
8157                                    else {
8158                                            if (orderByComparator.isAscending() ^ previous) {
8159                                                    query.append(WHERE_GREATER_THAN);
8160                                            }
8161                                            else {
8162                                                    query.append(WHERE_LESSER_THAN);
8163                                            }
8164                                    }
8165                            }
8166    
8167                            query.append(ORDER_BY_CLAUSE);
8168    
8169                            String[] orderByFields = orderByComparator.getOrderByFields();
8170    
8171                            for (int i = 0; i < orderByFields.length; i++) {
8172                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8173                                    query.append(orderByFields[i]);
8174    
8175                                    if ((i + 1) < orderByFields.length) {
8176                                            if (orderByComparator.isAscending() ^ previous) {
8177                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8178                                            }
8179                                            else {
8180                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8181                                            }
8182                                    }
8183                                    else {
8184                                            if (orderByComparator.isAscending() ^ previous) {
8185                                                    query.append(ORDER_BY_ASC);
8186                                            }
8187                                            else {
8188                                                    query.append(ORDER_BY_DESC);
8189                                            }
8190                                    }
8191                            }
8192                    }
8193                    else {
8194                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
8195                    }
8196    
8197                    String sql = query.toString();
8198    
8199                    Query q = session.createQuery(sql);
8200    
8201                    q.setFirstResult(0);
8202                    q.setMaxResults(2);
8203    
8204                    QueryPos qPos = QueryPos.getInstance(q);
8205    
8206                    if (bindDisplayDate) {
8207                            qPos.add(new Timestamp(displayDate.getTime()));
8208                    }
8209    
8210                    qPos.add(status);
8211    
8212                    if (orderByComparator != null) {
8213                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
8214    
8215                            for (Object value : values) {
8216                                    qPos.add(value);
8217                            }
8218                    }
8219    
8220                    List<BlogsEntry> list = q.list();
8221    
8222                    if (list.size() == 2) {
8223                            return list.get(1);
8224                    }
8225                    else {
8226                            return null;
8227                    }
8228            }
8229    
8230            /**
8231             * Removes all the blogs entries where displayDate &lt; &#63; and status = &#63; from the database.
8232             *
8233             * @param displayDate the display date
8234             * @param status the status
8235             */
8236            @Override
8237            public void removeByLtD_S(Date displayDate, int status) {
8238                    for (BlogsEntry blogsEntry : findByLtD_S(displayDate, status,
8239                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
8240                            remove(blogsEntry);
8241                    }
8242            }
8243    
8244            /**
8245             * Returns the number of blogs entries where displayDate &lt; &#63; and status = &#63;.
8246             *
8247             * @param displayDate the display date
8248             * @param status the status
8249             * @return the number of matching blogs entries
8250             */
8251            @Override
8252            public int countByLtD_S(Date displayDate, int status) {
8253                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_LTD_S;
8254    
8255                    Object[] finderArgs = new Object[] { displayDate, status };
8256    
8257                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
8258                                    this);
8259    
8260                    if (count == null) {
8261                            StringBundler query = new StringBundler(3);
8262    
8263                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
8264    
8265                            boolean bindDisplayDate = false;
8266    
8267                            if (displayDate == null) {
8268                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_1);
8269                            }
8270                            else {
8271                                    bindDisplayDate = true;
8272    
8273                                    query.append(_FINDER_COLUMN_LTD_S_DISPLAYDATE_2);
8274                            }
8275    
8276                            query.append(_FINDER_COLUMN_LTD_S_STATUS_2);
8277    
8278                            String sql = query.toString();
8279    
8280                            Session session = null;
8281    
8282                            try {
8283                                    session = openSession();
8284    
8285                                    Query q = session.createQuery(sql);
8286    
8287                                    QueryPos qPos = QueryPos.getInstance(q);
8288    
8289                                    if (bindDisplayDate) {
8290                                            qPos.add(new Timestamp(displayDate.getTime()));
8291                                    }
8292    
8293                                    qPos.add(status);
8294    
8295                                    count = (Long)q.uniqueResult();
8296    
8297                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
8298                            }
8299                            catch (Exception e) {
8300                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
8301    
8302                                    throw processException(e);
8303                            }
8304                            finally {
8305                                    closeSession(session);
8306                            }
8307                    }
8308    
8309                    return count.intValue();
8310            }
8311    
8312            private static final String _FINDER_COLUMN_LTD_S_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL AND ";
8313            private static final String _FINDER_COLUMN_LTD_S_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
8314            private static final String _FINDER_COLUMN_LTD_S_STATUS_2 = "blogsEntry.status = ?";
8315            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
8316                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
8317                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_LtD",
8318                            new String[] {
8319                                    Long.class.getName(), Long.class.getName(), Date.class.getName(),
8320                                    
8321                            Integer.class.getName(), Integer.class.getName(),
8322                                    OrderByComparator.class.getName()
8323                            });
8324            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
8325                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
8326                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_U_LtD",
8327                            new String[] {
8328                                    Long.class.getName(), Long.class.getName(), Date.class.getName()
8329                            });
8330    
8331            /**
8332             * Returns all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
8333             *
8334             * @param groupId the group ID
8335             * @param userId the user ID
8336             * @param displayDate the display date
8337             * @return the matching blogs entries
8338             */
8339            @Override
8340            public List<BlogsEntry> findByG_U_LtD(long groupId, long userId,
8341                    Date displayDate) {
8342                    return findByG_U_LtD(groupId, userId, displayDate, QueryUtil.ALL_POS,
8343                            QueryUtil.ALL_POS, null);
8344            }
8345    
8346            /**
8347             * Returns a range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
8348             *
8349             * <p>
8350             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8351             * </p>
8352             *
8353             * @param groupId the group ID
8354             * @param userId the user ID
8355             * @param displayDate the display date
8356             * @param start the lower bound of the range of blogs entries
8357             * @param end the upper bound of the range of blogs entries (not inclusive)
8358             * @return the range of matching blogs entries
8359             */
8360            @Override
8361            public List<BlogsEntry> findByG_U_LtD(long groupId, long userId,
8362                    Date displayDate, int start, int end) {
8363                    return findByG_U_LtD(groupId, userId, displayDate, start, end, null);
8364            }
8365    
8366            /**
8367             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
8368             *
8369             * <p>
8370             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8371             * </p>
8372             *
8373             * @param groupId the group ID
8374             * @param userId the user ID
8375             * @param displayDate the display date
8376             * @param start the lower bound of the range of blogs entries
8377             * @param end the upper bound of the range of blogs entries (not inclusive)
8378             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8379             * @return the ordered range of matching blogs entries
8380             */
8381            @Override
8382            public List<BlogsEntry> findByG_U_LtD(long groupId, long userId,
8383                    Date displayDate, int start, int end,
8384                    OrderByComparator<BlogsEntry> orderByComparator) {
8385                    boolean pagination = true;
8386                    FinderPath finderPath = null;
8387                    Object[] finderArgs = null;
8388    
8389                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD;
8390                    finderArgs = new Object[] {
8391                                    groupId, userId, displayDate,
8392                                    
8393                                    start, end, orderByComparator
8394                            };
8395    
8396                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
8397                                    finderArgs, this);
8398    
8399                    if ((list != null) && !list.isEmpty()) {
8400                            for (BlogsEntry blogsEntry : list) {
8401                                    if ((groupId != blogsEntry.getGroupId()) ||
8402                                                    (userId != blogsEntry.getUserId()) ||
8403                                                    (displayDate.getTime() <= blogsEntry.getDisplayDate()
8404                                                                                                                                    .getTime())) {
8405                                            list = null;
8406    
8407                                            break;
8408                                    }
8409                            }
8410                    }
8411    
8412                    if (list == null) {
8413                            StringBundler query = null;
8414    
8415                            if (orderByComparator != null) {
8416                                    query = new StringBundler(5 +
8417                                                    (orderByComparator.getOrderByFields().length * 3));
8418                            }
8419                            else {
8420                                    query = new StringBundler(5);
8421                            }
8422    
8423                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
8424    
8425                            query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
8426    
8427                            query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
8428    
8429                            boolean bindDisplayDate = false;
8430    
8431                            if (displayDate == null) {
8432                                    query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
8433                            }
8434                            else {
8435                                    bindDisplayDate = true;
8436    
8437                                    query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
8438                            }
8439    
8440                            if (orderByComparator != null) {
8441                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8442                                            orderByComparator);
8443                            }
8444                            else
8445                             if (pagination) {
8446                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
8447                            }
8448    
8449                            String sql = query.toString();
8450    
8451                            Session session = null;
8452    
8453                            try {
8454                                    session = openSession();
8455    
8456                                    Query q = session.createQuery(sql);
8457    
8458                                    QueryPos qPos = QueryPos.getInstance(q);
8459    
8460                                    qPos.add(groupId);
8461    
8462                                    qPos.add(userId);
8463    
8464                                    if (bindDisplayDate) {
8465                                            qPos.add(new Timestamp(displayDate.getTime()));
8466                                    }
8467    
8468                                    if (!pagination) {
8469                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
8470                                                            start, end, false);
8471    
8472                                            Collections.sort(list);
8473    
8474                                            list = Collections.unmodifiableList(list);
8475                                    }
8476                                    else {
8477                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
8478                                                            start, end);
8479                                    }
8480    
8481                                    cacheResult(list);
8482    
8483                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
8484                            }
8485                            catch (Exception e) {
8486                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
8487    
8488                                    throw processException(e);
8489                            }
8490                            finally {
8491                                    closeSession(session);
8492                            }
8493                    }
8494    
8495                    return list;
8496            }
8497    
8498            /**
8499             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
8500             *
8501             * @param groupId the group ID
8502             * @param userId the user ID
8503             * @param displayDate the display date
8504             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8505             * @return the first matching blogs entry
8506             * @throws NoSuchEntryException if a matching blogs entry could not be found
8507             */
8508            @Override
8509            public BlogsEntry findByG_U_LtD_First(long groupId, long userId,
8510                    Date displayDate, OrderByComparator<BlogsEntry> orderByComparator)
8511                    throws NoSuchEntryException {
8512                    BlogsEntry blogsEntry = fetchByG_U_LtD_First(groupId, userId,
8513                                    displayDate, orderByComparator);
8514    
8515                    if (blogsEntry != null) {
8516                            return blogsEntry;
8517                    }
8518    
8519                    StringBundler msg = new StringBundler(8);
8520    
8521                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8522    
8523                    msg.append("groupId=");
8524                    msg.append(groupId);
8525    
8526                    msg.append(", userId=");
8527                    msg.append(userId);
8528    
8529                    msg.append(", displayDate=");
8530                    msg.append(displayDate);
8531    
8532                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8533    
8534                    throw new NoSuchEntryException(msg.toString());
8535            }
8536    
8537            /**
8538             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
8539             *
8540             * @param groupId the group ID
8541             * @param userId the user ID
8542             * @param displayDate the display date
8543             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8544             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
8545             */
8546            @Override
8547            public BlogsEntry fetchByG_U_LtD_First(long groupId, long userId,
8548                    Date displayDate, OrderByComparator<BlogsEntry> orderByComparator) {
8549                    List<BlogsEntry> list = findByG_U_LtD(groupId, userId, displayDate, 0,
8550                                    1, orderByComparator);
8551    
8552                    if (!list.isEmpty()) {
8553                            return list.get(0);
8554                    }
8555    
8556                    return null;
8557            }
8558    
8559            /**
8560             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
8561             *
8562             * @param groupId the group ID
8563             * @param userId the user ID
8564             * @param displayDate the display date
8565             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8566             * @return the last matching blogs entry
8567             * @throws NoSuchEntryException if a matching blogs entry could not be found
8568             */
8569            @Override
8570            public BlogsEntry findByG_U_LtD_Last(long groupId, long userId,
8571                    Date displayDate, OrderByComparator<BlogsEntry> orderByComparator)
8572                    throws NoSuchEntryException {
8573                    BlogsEntry blogsEntry = fetchByG_U_LtD_Last(groupId, userId,
8574                                    displayDate, orderByComparator);
8575    
8576                    if (blogsEntry != null) {
8577                            return blogsEntry;
8578                    }
8579    
8580                    StringBundler msg = new StringBundler(8);
8581    
8582                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8583    
8584                    msg.append("groupId=");
8585                    msg.append(groupId);
8586    
8587                    msg.append(", userId=");
8588                    msg.append(userId);
8589    
8590                    msg.append(", displayDate=");
8591                    msg.append(displayDate);
8592    
8593                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8594    
8595                    throw new NoSuchEntryException(msg.toString());
8596            }
8597    
8598            /**
8599             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
8600             *
8601             * @param groupId the group ID
8602             * @param userId the user ID
8603             * @param displayDate the display date
8604             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8605             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
8606             */
8607            @Override
8608            public BlogsEntry fetchByG_U_LtD_Last(long groupId, long userId,
8609                    Date displayDate, OrderByComparator<BlogsEntry> orderByComparator) {
8610                    int count = countByG_U_LtD(groupId, userId, displayDate);
8611    
8612                    if (count == 0) {
8613                            return null;
8614                    }
8615    
8616                    List<BlogsEntry> list = findByG_U_LtD(groupId, userId, displayDate,
8617                                    count - 1, count, orderByComparator);
8618    
8619                    if (!list.isEmpty()) {
8620                            return list.get(0);
8621                    }
8622    
8623                    return null;
8624            }
8625    
8626            /**
8627             * 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;.
8628             *
8629             * @param entryId the primary key of the current blogs entry
8630             * @param groupId the group ID
8631             * @param userId the user ID
8632             * @param displayDate the display date
8633             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8634             * @return the previous, current, and next blogs entry
8635             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
8636             */
8637            @Override
8638            public BlogsEntry[] findByG_U_LtD_PrevAndNext(long entryId, long groupId,
8639                    long userId, Date displayDate,
8640                    OrderByComparator<BlogsEntry> orderByComparator)
8641                    throws NoSuchEntryException {
8642                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
8643    
8644                    Session session = null;
8645    
8646                    try {
8647                            session = openSession();
8648    
8649                            BlogsEntry[] array = new BlogsEntryImpl[3];
8650    
8651                            array[0] = getByG_U_LtD_PrevAndNext(session, blogsEntry, groupId,
8652                                            userId, displayDate, orderByComparator, true);
8653    
8654                            array[1] = blogsEntry;
8655    
8656                            array[2] = getByG_U_LtD_PrevAndNext(session, blogsEntry, groupId,
8657                                            userId, displayDate, orderByComparator, false);
8658    
8659                            return array;
8660                    }
8661                    catch (Exception e) {
8662                            throw processException(e);
8663                    }
8664                    finally {
8665                            closeSession(session);
8666                    }
8667            }
8668    
8669            protected BlogsEntry getByG_U_LtD_PrevAndNext(Session session,
8670                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
8671                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
8672                    StringBundler query = null;
8673    
8674                    if (orderByComparator != null) {
8675                            query = new StringBundler(6 +
8676                                            (orderByComparator.getOrderByFields().length * 6));
8677                    }
8678                    else {
8679                            query = new StringBundler(3);
8680                    }
8681    
8682                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
8683    
8684                    query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
8685    
8686                    query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
8687    
8688                    boolean bindDisplayDate = false;
8689    
8690                    if (displayDate == null) {
8691                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
8692                    }
8693                    else {
8694                            bindDisplayDate = true;
8695    
8696                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
8697                    }
8698    
8699                    if (orderByComparator != null) {
8700                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8701    
8702                            if (orderByConditionFields.length > 0) {
8703                                    query.append(WHERE_AND);
8704                            }
8705    
8706                            for (int i = 0; i < orderByConditionFields.length; i++) {
8707                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8708                                    query.append(orderByConditionFields[i]);
8709    
8710                                    if ((i + 1) < orderByConditionFields.length) {
8711                                            if (orderByComparator.isAscending() ^ previous) {
8712                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8713                                            }
8714                                            else {
8715                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8716                                            }
8717                                    }
8718                                    else {
8719                                            if (orderByComparator.isAscending() ^ previous) {
8720                                                    query.append(WHERE_GREATER_THAN);
8721                                            }
8722                                            else {
8723                                                    query.append(WHERE_LESSER_THAN);
8724                                            }
8725                                    }
8726                            }
8727    
8728                            query.append(ORDER_BY_CLAUSE);
8729    
8730                            String[] orderByFields = orderByComparator.getOrderByFields();
8731    
8732                            for (int i = 0; i < orderByFields.length; i++) {
8733                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8734                                    query.append(orderByFields[i]);
8735    
8736                                    if ((i + 1) < orderByFields.length) {
8737                                            if (orderByComparator.isAscending() ^ previous) {
8738                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8739                                            }
8740                                            else {
8741                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8742                                            }
8743                                    }
8744                                    else {
8745                                            if (orderByComparator.isAscending() ^ previous) {
8746                                                    query.append(ORDER_BY_ASC);
8747                                            }
8748                                            else {
8749                                                    query.append(ORDER_BY_DESC);
8750                                            }
8751                                    }
8752                            }
8753                    }
8754                    else {
8755                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
8756                    }
8757    
8758                    String sql = query.toString();
8759    
8760                    Query q = session.createQuery(sql);
8761    
8762                    q.setFirstResult(0);
8763                    q.setMaxResults(2);
8764    
8765                    QueryPos qPos = QueryPos.getInstance(q);
8766    
8767                    qPos.add(groupId);
8768    
8769                    qPos.add(userId);
8770    
8771                    if (bindDisplayDate) {
8772                            qPos.add(new Timestamp(displayDate.getTime()));
8773                    }
8774    
8775                    if (orderByComparator != null) {
8776                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
8777    
8778                            for (Object value : values) {
8779                                    qPos.add(value);
8780                            }
8781                    }
8782    
8783                    List<BlogsEntry> list = q.list();
8784    
8785                    if (list.size() == 2) {
8786                            return list.get(1);
8787                    }
8788                    else {
8789                            return null;
8790                    }
8791            }
8792    
8793            /**
8794             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
8795             *
8796             * @param groupId the group ID
8797             * @param userId the user ID
8798             * @param displayDate the display date
8799             * @return the matching blogs entries that the user has permission to view
8800             */
8801            @Override
8802            public List<BlogsEntry> filterFindByG_U_LtD(long groupId, long userId,
8803                    Date displayDate) {
8804                    return filterFindByG_U_LtD(groupId, userId, displayDate,
8805                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
8806            }
8807    
8808            /**
8809             * 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;.
8810             *
8811             * <p>
8812             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8813             * </p>
8814             *
8815             * @param groupId the group ID
8816             * @param userId the user ID
8817             * @param displayDate the display date
8818             * @param start the lower bound of the range of blogs entries
8819             * @param end the upper bound of the range of blogs entries (not inclusive)
8820             * @return the range of matching blogs entries that the user has permission to view
8821             */
8822            @Override
8823            public List<BlogsEntry> filterFindByG_U_LtD(long groupId, long userId,
8824                    Date displayDate, int start, int end) {
8825                    return filterFindByG_U_LtD(groupId, userId, displayDate, start, end,
8826                            null);
8827            }
8828    
8829            /**
8830             * 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;.
8831             *
8832             * <p>
8833             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8834             * </p>
8835             *
8836             * @param groupId the group ID
8837             * @param userId the user ID
8838             * @param displayDate the display date
8839             * @param start the lower bound of the range of blogs entries
8840             * @param end the upper bound of the range of blogs entries (not inclusive)
8841             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8842             * @return the ordered range of matching blogs entries that the user has permission to view
8843             */
8844            @Override
8845            public List<BlogsEntry> filterFindByG_U_LtD(long groupId, long userId,
8846                    Date displayDate, int start, int end,
8847                    OrderByComparator<BlogsEntry> orderByComparator) {
8848                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8849                            return findByG_U_LtD(groupId, userId, displayDate, start, end,
8850                                    orderByComparator);
8851                    }
8852    
8853                    StringBundler query = null;
8854    
8855                    if (orderByComparator != null) {
8856                            query = new StringBundler(5 +
8857                                            (orderByComparator.getOrderByFields().length * 3));
8858                    }
8859                    else {
8860                            query = new StringBundler(5);
8861                    }
8862    
8863                    if (getDB().isSupportsInlineDistinct()) {
8864                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
8865                    }
8866                    else {
8867                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
8868                    }
8869    
8870                    query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
8871    
8872                    query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
8873    
8874                    boolean bindDisplayDate = false;
8875    
8876                    if (displayDate == null) {
8877                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
8878                    }
8879                    else {
8880                            bindDisplayDate = true;
8881    
8882                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
8883                    }
8884    
8885                    if (!getDB().isSupportsInlineDistinct()) {
8886                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
8887                    }
8888    
8889                    if (orderByComparator != null) {
8890                            if (getDB().isSupportsInlineDistinct()) {
8891                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8892                                            orderByComparator, true);
8893                            }
8894                            else {
8895                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
8896                                            orderByComparator, true);
8897                            }
8898                    }
8899                    else {
8900                            if (getDB().isSupportsInlineDistinct()) {
8901                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
8902                            }
8903                            else {
8904                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
8905                            }
8906                    }
8907    
8908                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8909                                    BlogsEntry.class.getName(),
8910                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8911    
8912                    Session session = null;
8913    
8914                    try {
8915                            session = openSession();
8916    
8917                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
8918    
8919                            if (getDB().isSupportsInlineDistinct()) {
8920                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
8921                            }
8922                            else {
8923                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
8924                            }
8925    
8926                            QueryPos qPos = QueryPos.getInstance(q);
8927    
8928                            qPos.add(groupId);
8929    
8930                            qPos.add(userId);
8931    
8932                            if (bindDisplayDate) {
8933                                    qPos.add(new Timestamp(displayDate.getTime()));
8934                            }
8935    
8936                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
8937                    }
8938                    catch (Exception e) {
8939                            throw processException(e);
8940                    }
8941                    finally {
8942                            closeSession(session);
8943                    }
8944            }
8945    
8946            /**
8947             * 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;.
8948             *
8949             * @param entryId the primary key of the current blogs entry
8950             * @param groupId the group ID
8951             * @param userId the user ID
8952             * @param displayDate the display date
8953             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8954             * @return the previous, current, and next blogs entry
8955             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
8956             */
8957            @Override
8958            public BlogsEntry[] filterFindByG_U_LtD_PrevAndNext(long entryId,
8959                    long groupId, long userId, Date displayDate,
8960                    OrderByComparator<BlogsEntry> orderByComparator)
8961                    throws NoSuchEntryException {
8962                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8963                            return findByG_U_LtD_PrevAndNext(entryId, groupId, userId,
8964                                    displayDate, orderByComparator);
8965                    }
8966    
8967                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
8968    
8969                    Session session = null;
8970    
8971                    try {
8972                            session = openSession();
8973    
8974                            BlogsEntry[] array = new BlogsEntryImpl[3];
8975    
8976                            array[0] = filterGetByG_U_LtD_PrevAndNext(session, blogsEntry,
8977                                            groupId, userId, displayDate, orderByComparator, true);
8978    
8979                            array[1] = blogsEntry;
8980    
8981                            array[2] = filterGetByG_U_LtD_PrevAndNext(session, blogsEntry,
8982                                            groupId, userId, displayDate, orderByComparator, false);
8983    
8984                            return array;
8985                    }
8986                    catch (Exception e) {
8987                            throw processException(e);
8988                    }
8989                    finally {
8990                            closeSession(session);
8991                    }
8992            }
8993    
8994            protected BlogsEntry filterGetByG_U_LtD_PrevAndNext(Session session,
8995                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
8996                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
8997                    StringBundler query = null;
8998    
8999                    if (orderByComparator != null) {
9000                            query = new StringBundler(6 +
9001                                            (orderByComparator.getOrderByFields().length * 6));
9002                    }
9003                    else {
9004                            query = new StringBundler(3);
9005                    }
9006    
9007                    if (getDB().isSupportsInlineDistinct()) {
9008                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
9009                    }
9010                    else {
9011                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
9012                    }
9013    
9014                    query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
9015    
9016                    query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
9017    
9018                    boolean bindDisplayDate = false;
9019    
9020                    if (displayDate == null) {
9021                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
9022                    }
9023                    else {
9024                            bindDisplayDate = true;
9025    
9026                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
9027                    }
9028    
9029                    if (!getDB().isSupportsInlineDistinct()) {
9030                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
9031                    }
9032    
9033                    if (orderByComparator != null) {
9034                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9035    
9036                            if (orderByConditionFields.length > 0) {
9037                                    query.append(WHERE_AND);
9038                            }
9039    
9040                            for (int i = 0; i < orderByConditionFields.length; i++) {
9041                                    if (getDB().isSupportsInlineDistinct()) {
9042                                            query.append(_ORDER_BY_ENTITY_ALIAS);
9043                                    }
9044                                    else {
9045                                            query.append(_ORDER_BY_ENTITY_TABLE);
9046                                    }
9047    
9048                                    query.append(orderByConditionFields[i]);
9049    
9050                                    if ((i + 1) < orderByConditionFields.length) {
9051                                            if (orderByComparator.isAscending() ^ previous) {
9052                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9053                                            }
9054                                            else {
9055                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
9056                                            }
9057                                    }
9058                                    else {
9059                                            if (orderByComparator.isAscending() ^ previous) {
9060                                                    query.append(WHERE_GREATER_THAN);
9061                                            }
9062                                            else {
9063                                                    query.append(WHERE_LESSER_THAN);
9064                                            }
9065                                    }
9066                            }
9067    
9068                            query.append(ORDER_BY_CLAUSE);
9069    
9070                            String[] orderByFields = orderByComparator.getOrderByFields();
9071    
9072                            for (int i = 0; i < orderByFields.length; i++) {
9073                                    if (getDB().isSupportsInlineDistinct()) {
9074                                            query.append(_ORDER_BY_ENTITY_ALIAS);
9075                                    }
9076                                    else {
9077                                            query.append(_ORDER_BY_ENTITY_TABLE);
9078                                    }
9079    
9080                                    query.append(orderByFields[i]);
9081    
9082                                    if ((i + 1) < orderByFields.length) {
9083                                            if (orderByComparator.isAscending() ^ previous) {
9084                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
9085                                            }
9086                                            else {
9087                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
9088                                            }
9089                                    }
9090                                    else {
9091                                            if (orderByComparator.isAscending() ^ previous) {
9092                                                    query.append(ORDER_BY_ASC);
9093                                            }
9094                                            else {
9095                                                    query.append(ORDER_BY_DESC);
9096                                            }
9097                                    }
9098                            }
9099                    }
9100                    else {
9101                            if (getDB().isSupportsInlineDistinct()) {
9102                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
9103                            }
9104                            else {
9105                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
9106                            }
9107                    }
9108    
9109                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9110                                    BlogsEntry.class.getName(),
9111                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9112    
9113                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
9114    
9115                    q.setFirstResult(0);
9116                    q.setMaxResults(2);
9117    
9118                    if (getDB().isSupportsInlineDistinct()) {
9119                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
9120                    }
9121                    else {
9122                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
9123                    }
9124    
9125                    QueryPos qPos = QueryPos.getInstance(q);
9126    
9127                    qPos.add(groupId);
9128    
9129                    qPos.add(userId);
9130    
9131                    if (bindDisplayDate) {
9132                            qPos.add(new Timestamp(displayDate.getTime()));
9133                    }
9134    
9135                    if (orderByComparator != null) {
9136                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
9137    
9138                            for (Object value : values) {
9139                                    qPos.add(value);
9140                            }
9141                    }
9142    
9143                    List<BlogsEntry> list = q.list();
9144    
9145                    if (list.size() == 2) {
9146                            return list.get(1);
9147                    }
9148                    else {
9149                            return null;
9150                    }
9151            }
9152    
9153            /**
9154             * Removes all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; from the database.
9155             *
9156             * @param groupId the group ID
9157             * @param userId the user ID
9158             * @param displayDate the display date
9159             */
9160            @Override
9161            public void removeByG_U_LtD(long groupId, long userId, Date displayDate) {
9162                    for (BlogsEntry blogsEntry : findByG_U_LtD(groupId, userId,
9163                                    displayDate, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
9164                            remove(blogsEntry);
9165                    }
9166            }
9167    
9168            /**
9169             * Returns the number of blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
9170             *
9171             * @param groupId the group ID
9172             * @param userId the user ID
9173             * @param displayDate the display date
9174             * @return the number of matching blogs entries
9175             */
9176            @Override
9177            public int countByG_U_LtD(long groupId, long userId, Date displayDate) {
9178                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD;
9179    
9180                    Object[] finderArgs = new Object[] { groupId, userId, displayDate };
9181    
9182                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
9183                                    this);
9184    
9185                    if (count == null) {
9186                            StringBundler query = new StringBundler(4);
9187    
9188                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
9189    
9190                            query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
9191    
9192                            query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
9193    
9194                            boolean bindDisplayDate = false;
9195    
9196                            if (displayDate == null) {
9197                                    query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
9198                            }
9199                            else {
9200                                    bindDisplayDate = true;
9201    
9202                                    query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
9203                            }
9204    
9205                            String sql = query.toString();
9206    
9207                            Session session = null;
9208    
9209                            try {
9210                                    session = openSession();
9211    
9212                                    Query q = session.createQuery(sql);
9213    
9214                                    QueryPos qPos = QueryPos.getInstance(q);
9215    
9216                                    qPos.add(groupId);
9217    
9218                                    qPos.add(userId);
9219    
9220                                    if (bindDisplayDate) {
9221                                            qPos.add(new Timestamp(displayDate.getTime()));
9222                                    }
9223    
9224                                    count = (Long)q.uniqueResult();
9225    
9226                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
9227                            }
9228                            catch (Exception e) {
9229                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
9230    
9231                                    throw processException(e);
9232                            }
9233                            finally {
9234                                    closeSession(session);
9235                            }
9236                    }
9237    
9238                    return count.intValue();
9239            }
9240    
9241            /**
9242             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and displayDate &lt; &#63;.
9243             *
9244             * @param groupId the group ID
9245             * @param userId the user ID
9246             * @param displayDate the display date
9247             * @return the number of matching blogs entries that the user has permission to view
9248             */
9249            @Override
9250            public int filterCountByG_U_LtD(long groupId, long userId, Date displayDate) {
9251                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9252                            return countByG_U_LtD(groupId, userId, displayDate);
9253                    }
9254    
9255                    StringBundler query = new StringBundler(4);
9256    
9257                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
9258    
9259                    query.append(_FINDER_COLUMN_G_U_LTD_GROUPID_2);
9260    
9261                    query.append(_FINDER_COLUMN_G_U_LTD_USERID_2);
9262    
9263                    boolean bindDisplayDate = false;
9264    
9265                    if (displayDate == null) {
9266                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1);
9267                    }
9268                    else {
9269                            bindDisplayDate = true;
9270    
9271                            query.append(_FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2);
9272                    }
9273    
9274                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9275                                    BlogsEntry.class.getName(),
9276                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9277    
9278                    Session session = null;
9279    
9280                    try {
9281                            session = openSession();
9282    
9283                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
9284    
9285                            q.addScalar(COUNT_COLUMN_NAME,
9286                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
9287    
9288                            QueryPos qPos = QueryPos.getInstance(q);
9289    
9290                            qPos.add(groupId);
9291    
9292                            qPos.add(userId);
9293    
9294                            if (bindDisplayDate) {
9295                                    qPos.add(new Timestamp(displayDate.getTime()));
9296                            }
9297    
9298                            Long count = (Long)q.uniqueResult();
9299    
9300                            return count.intValue();
9301                    }
9302                    catch (Exception e) {
9303                            throw processException(e);
9304                    }
9305                    finally {
9306                            closeSession(session);
9307                    }
9308            }
9309    
9310            private static final String _FINDER_COLUMN_G_U_LTD_GROUPID_2 = "blogsEntry.groupId = ? AND ";
9311            private static final String _FINDER_COLUMN_G_U_LTD_USERID_2 = "blogsEntry.userId = ? AND ";
9312            private static final String _FINDER_COLUMN_G_U_LTD_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL";
9313            private static final String _FINDER_COLUMN_G_U_LTD_DISPLAYDATE_2 = "blogsEntry.displayDate < ?";
9314            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
9315                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
9316                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_S",
9317                            new String[] {
9318                                    Long.class.getName(), Long.class.getName(),
9319                                    Integer.class.getName(),
9320                                    
9321                            Integer.class.getName(), Integer.class.getName(),
9322                                    OrderByComparator.class.getName()
9323                            });
9324            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
9325                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
9326                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U_S",
9327                            new String[] {
9328                                    Long.class.getName(), Long.class.getName(),
9329                                    Integer.class.getName()
9330                            },
9331                            BlogsEntryModelImpl.GROUPID_COLUMN_BITMASK |
9332                            BlogsEntryModelImpl.USERID_COLUMN_BITMASK |
9333                            BlogsEntryModelImpl.STATUS_COLUMN_BITMASK |
9334                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
9335                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
9336            public static final FinderPath FINDER_PATH_COUNT_BY_G_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
9337                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
9338                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U_S",
9339                            new String[] {
9340                                    Long.class.getName(), Long.class.getName(),
9341                                    Integer.class.getName()
9342                            });
9343    
9344            /**
9345             * Returns all the blogs entries where groupId = &#63; and userId = &#63; and status = &#63;.
9346             *
9347             * @param groupId the group ID
9348             * @param userId the user ID
9349             * @param status the status
9350             * @return the matching blogs entries
9351             */
9352            @Override
9353            public List<BlogsEntry> findByG_U_S(long groupId, long userId, int status) {
9354                    return findByG_U_S(groupId, userId, status, QueryUtil.ALL_POS,
9355                            QueryUtil.ALL_POS, null);
9356            }
9357    
9358            /**
9359             * Returns a range of all the blogs entries where groupId = &#63; and userId = &#63; and status = &#63;.
9360             *
9361             * <p>
9362             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9363             * </p>
9364             *
9365             * @param groupId the group ID
9366             * @param userId the user ID
9367             * @param status the status
9368             * @param start the lower bound of the range of blogs entries
9369             * @param end the upper bound of the range of blogs entries (not inclusive)
9370             * @return the range of matching blogs entries
9371             */
9372            @Override
9373            public List<BlogsEntry> findByG_U_S(long groupId, long userId, int status,
9374                    int start, int end) {
9375                    return findByG_U_S(groupId, userId, status, start, end, null);
9376            }
9377    
9378            /**
9379             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and status = &#63;.
9380             *
9381             * <p>
9382             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9383             * </p>
9384             *
9385             * @param groupId the group ID
9386             * @param userId the user ID
9387             * @param status the status
9388             * @param start the lower bound of the range of blogs entries
9389             * @param end the upper bound of the range of blogs entries (not inclusive)
9390             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9391             * @return the ordered range of matching blogs entries
9392             */
9393            @Override
9394            public List<BlogsEntry> findByG_U_S(long groupId, long userId, int status,
9395                    int start, int end, OrderByComparator<BlogsEntry> orderByComparator) {
9396                    boolean pagination = true;
9397                    FinderPath finderPath = null;
9398                    Object[] finderArgs = null;
9399    
9400                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
9401                                    (orderByComparator == null)) {
9402                            pagination = false;
9403                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S;
9404                            finderArgs = new Object[] { groupId, userId, status };
9405                    }
9406                    else {
9407                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_S;
9408                            finderArgs = new Object[] {
9409                                            groupId, userId, status,
9410                                            
9411                                            start, end, orderByComparator
9412                                    };
9413                    }
9414    
9415                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
9416                                    finderArgs, this);
9417    
9418                    if ((list != null) && !list.isEmpty()) {
9419                            for (BlogsEntry blogsEntry : list) {
9420                                    if ((groupId != blogsEntry.getGroupId()) ||
9421                                                    (userId != blogsEntry.getUserId()) ||
9422                                                    (status != blogsEntry.getStatus())) {
9423                                            list = null;
9424    
9425                                            break;
9426                                    }
9427                            }
9428                    }
9429    
9430                    if (list == null) {
9431                            StringBundler query = null;
9432    
9433                            if (orderByComparator != null) {
9434                                    query = new StringBundler(5 +
9435                                                    (orderByComparator.getOrderByFields().length * 3));
9436                            }
9437                            else {
9438                                    query = new StringBundler(5);
9439                            }
9440    
9441                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
9442    
9443                            query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
9444    
9445                            query.append(_FINDER_COLUMN_G_U_S_USERID_2);
9446    
9447                            query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
9448    
9449                            if (orderByComparator != null) {
9450                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9451                                            orderByComparator);
9452                            }
9453                            else
9454                             if (pagination) {
9455                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
9456                            }
9457    
9458                            String sql = query.toString();
9459    
9460                            Session session = null;
9461    
9462                            try {
9463                                    session = openSession();
9464    
9465                                    Query q = session.createQuery(sql);
9466    
9467                                    QueryPos qPos = QueryPos.getInstance(q);
9468    
9469                                    qPos.add(groupId);
9470    
9471                                    qPos.add(userId);
9472    
9473                                    qPos.add(status);
9474    
9475                                    if (!pagination) {
9476                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
9477                                                            start, end, false);
9478    
9479                                            Collections.sort(list);
9480    
9481                                            list = Collections.unmodifiableList(list);
9482                                    }
9483                                    else {
9484                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
9485                                                            start, end);
9486                                    }
9487    
9488                                    cacheResult(list);
9489    
9490                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
9491                            }
9492                            catch (Exception e) {
9493                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
9494    
9495                                    throw processException(e);
9496                            }
9497                            finally {
9498                                    closeSession(session);
9499                            }
9500                    }
9501    
9502                    return list;
9503            }
9504    
9505            /**
9506             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
9507             *
9508             * @param groupId the group ID
9509             * @param userId the user ID
9510             * @param status the status
9511             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9512             * @return the first matching blogs entry
9513             * @throws NoSuchEntryException if a matching blogs entry could not be found
9514             */
9515            @Override
9516            public BlogsEntry findByG_U_S_First(long groupId, long userId, int status,
9517                    OrderByComparator<BlogsEntry> orderByComparator)
9518                    throws NoSuchEntryException {
9519                    BlogsEntry blogsEntry = fetchByG_U_S_First(groupId, userId, status,
9520                                    orderByComparator);
9521    
9522                    if (blogsEntry != null) {
9523                            return blogsEntry;
9524                    }
9525    
9526                    StringBundler msg = new StringBundler(8);
9527    
9528                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9529    
9530                    msg.append("groupId=");
9531                    msg.append(groupId);
9532    
9533                    msg.append(", userId=");
9534                    msg.append(userId);
9535    
9536                    msg.append(", status=");
9537                    msg.append(status);
9538    
9539                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9540    
9541                    throw new NoSuchEntryException(msg.toString());
9542            }
9543    
9544            /**
9545             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
9546             *
9547             * @param groupId the group ID
9548             * @param userId the user ID
9549             * @param status the status
9550             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9551             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
9552             */
9553            @Override
9554            public BlogsEntry fetchByG_U_S_First(long groupId, long userId, int status,
9555                    OrderByComparator<BlogsEntry> orderByComparator) {
9556                    List<BlogsEntry> list = findByG_U_S(groupId, userId, status, 0, 1,
9557                                    orderByComparator);
9558    
9559                    if (!list.isEmpty()) {
9560                            return list.get(0);
9561                    }
9562    
9563                    return null;
9564            }
9565    
9566            /**
9567             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
9568             *
9569             * @param groupId the group ID
9570             * @param userId the user ID
9571             * @param status the status
9572             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9573             * @return the last matching blogs entry
9574             * @throws NoSuchEntryException if a matching blogs entry could not be found
9575             */
9576            @Override
9577            public BlogsEntry findByG_U_S_Last(long groupId, long userId, int status,
9578                    OrderByComparator<BlogsEntry> orderByComparator)
9579                    throws NoSuchEntryException {
9580                    BlogsEntry blogsEntry = fetchByG_U_S_Last(groupId, userId, status,
9581                                    orderByComparator);
9582    
9583                    if (blogsEntry != null) {
9584                            return blogsEntry;
9585                    }
9586    
9587                    StringBundler msg = new StringBundler(8);
9588    
9589                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9590    
9591                    msg.append("groupId=");
9592                    msg.append(groupId);
9593    
9594                    msg.append(", userId=");
9595                    msg.append(userId);
9596    
9597                    msg.append(", status=");
9598                    msg.append(status);
9599    
9600                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9601    
9602                    throw new NoSuchEntryException(msg.toString());
9603            }
9604    
9605            /**
9606             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
9607             *
9608             * @param groupId the group ID
9609             * @param userId the user ID
9610             * @param status the status
9611             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9612             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
9613             */
9614            @Override
9615            public BlogsEntry fetchByG_U_S_Last(long groupId, long userId, int status,
9616                    OrderByComparator<BlogsEntry> orderByComparator) {
9617                    int count = countByG_U_S(groupId, userId, status);
9618    
9619                    if (count == 0) {
9620                            return null;
9621                    }
9622    
9623                    List<BlogsEntry> list = findByG_U_S(groupId, userId, status, count - 1,
9624                                    count, orderByComparator);
9625    
9626                    if (!list.isEmpty()) {
9627                            return list.get(0);
9628                    }
9629    
9630                    return null;
9631            }
9632    
9633            /**
9634             * Returns the blogs entries before and after the current blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
9635             *
9636             * @param entryId the primary key of the current blogs entry
9637             * @param groupId the group ID
9638             * @param userId the user ID
9639             * @param status the status
9640             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9641             * @return the previous, current, and next blogs entry
9642             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
9643             */
9644            @Override
9645            public BlogsEntry[] findByG_U_S_PrevAndNext(long entryId, long groupId,
9646                    long userId, int status, OrderByComparator<BlogsEntry> orderByComparator)
9647                    throws NoSuchEntryException {
9648                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
9649    
9650                    Session session = null;
9651    
9652                    try {
9653                            session = openSession();
9654    
9655                            BlogsEntry[] array = new BlogsEntryImpl[3];
9656    
9657                            array[0] = getByG_U_S_PrevAndNext(session, blogsEntry, groupId,
9658                                            userId, status, orderByComparator, true);
9659    
9660                            array[1] = blogsEntry;
9661    
9662                            array[2] = getByG_U_S_PrevAndNext(session, blogsEntry, groupId,
9663                                            userId, status, orderByComparator, false);
9664    
9665                            return array;
9666                    }
9667                    catch (Exception e) {
9668                            throw processException(e);
9669                    }
9670                    finally {
9671                            closeSession(session);
9672                    }
9673            }
9674    
9675            protected BlogsEntry getByG_U_S_PrevAndNext(Session session,
9676                    BlogsEntry blogsEntry, long groupId, long userId, int status,
9677                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
9678                    StringBundler query = null;
9679    
9680                    if (orderByComparator != null) {
9681                            query = new StringBundler(6 +
9682                                            (orderByComparator.getOrderByFields().length * 6));
9683                    }
9684                    else {
9685                            query = new StringBundler(3);
9686                    }
9687    
9688                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
9689    
9690                    query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
9691    
9692                    query.append(_FINDER_COLUMN_G_U_S_USERID_2);
9693    
9694                    query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
9695    
9696                    if (orderByComparator != null) {
9697                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9698    
9699                            if (orderByConditionFields.length > 0) {
9700                                    query.append(WHERE_AND);
9701                            }
9702    
9703                            for (int i = 0; i < orderByConditionFields.length; i++) {
9704                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9705                                    query.append(orderByConditionFields[i]);
9706    
9707                                    if ((i + 1) < orderByConditionFields.length) {
9708                                            if (orderByComparator.isAscending() ^ previous) {
9709                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9710                                            }
9711                                            else {
9712                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
9713                                            }
9714                                    }
9715                                    else {
9716                                            if (orderByComparator.isAscending() ^ previous) {
9717                                                    query.append(WHERE_GREATER_THAN);
9718                                            }
9719                                            else {
9720                                                    query.append(WHERE_LESSER_THAN);
9721                                            }
9722                                    }
9723                            }
9724    
9725                            query.append(ORDER_BY_CLAUSE);
9726    
9727                            String[] orderByFields = orderByComparator.getOrderByFields();
9728    
9729                            for (int i = 0; i < orderByFields.length; i++) {
9730                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9731                                    query.append(orderByFields[i]);
9732    
9733                                    if ((i + 1) < orderByFields.length) {
9734                                            if (orderByComparator.isAscending() ^ previous) {
9735                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
9736                                            }
9737                                            else {
9738                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
9739                                            }
9740                                    }
9741                                    else {
9742                                            if (orderByComparator.isAscending() ^ previous) {
9743                                                    query.append(ORDER_BY_ASC);
9744                                            }
9745                                            else {
9746                                                    query.append(ORDER_BY_DESC);
9747                                            }
9748                                    }
9749                            }
9750                    }
9751                    else {
9752                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
9753                    }
9754    
9755                    String sql = query.toString();
9756    
9757                    Query q = session.createQuery(sql);
9758    
9759                    q.setFirstResult(0);
9760                    q.setMaxResults(2);
9761    
9762                    QueryPos qPos = QueryPos.getInstance(q);
9763    
9764                    qPos.add(groupId);
9765    
9766                    qPos.add(userId);
9767    
9768                    qPos.add(status);
9769    
9770                    if (orderByComparator != null) {
9771                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
9772    
9773                            for (Object value : values) {
9774                                    qPos.add(value);
9775                            }
9776                    }
9777    
9778                    List<BlogsEntry> list = q.list();
9779    
9780                    if (list.size() == 2) {
9781                            return list.get(1);
9782                    }
9783                    else {
9784                            return null;
9785                    }
9786            }
9787    
9788            /**
9789             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status = &#63;.
9790             *
9791             * @param groupId the group ID
9792             * @param userId the user ID
9793             * @param status the status
9794             * @return the matching blogs entries that the user has permission to view
9795             */
9796            @Override
9797            public List<BlogsEntry> filterFindByG_U_S(long groupId, long userId,
9798                    int status) {
9799                    return filterFindByG_U_S(groupId, userId, status, QueryUtil.ALL_POS,
9800                            QueryUtil.ALL_POS, null);
9801            }
9802    
9803            /**
9804             * Returns a range of all the blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status = &#63;.
9805             *
9806             * <p>
9807             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9808             * </p>
9809             *
9810             * @param groupId the group ID
9811             * @param userId the user ID
9812             * @param status the status
9813             * @param start the lower bound of the range of blogs entries
9814             * @param end the upper bound of the range of blogs entries (not inclusive)
9815             * @return the range of matching blogs entries that the user has permission to view
9816             */
9817            @Override
9818            public List<BlogsEntry> filterFindByG_U_S(long groupId, long userId,
9819                    int status, int start, int end) {
9820                    return filterFindByG_U_S(groupId, userId, status, start, end, null);
9821            }
9822    
9823            /**
9824             * 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;.
9825             *
9826             * <p>
9827             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9828             * </p>
9829             *
9830             * @param groupId the group ID
9831             * @param userId the user ID
9832             * @param status the status
9833             * @param start the lower bound of the range of blogs entries
9834             * @param end the upper bound of the range of blogs entries (not inclusive)
9835             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9836             * @return the ordered range of matching blogs entries that the user has permission to view
9837             */
9838            @Override
9839            public List<BlogsEntry> filterFindByG_U_S(long groupId, long userId,
9840                    int status, int start, int end,
9841                    OrderByComparator<BlogsEntry> orderByComparator) {
9842                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9843                            return findByG_U_S(groupId, userId, status, start, end,
9844                                    orderByComparator);
9845                    }
9846    
9847                    StringBundler query = null;
9848    
9849                    if (orderByComparator != null) {
9850                            query = new StringBundler(5 +
9851                                            (orderByComparator.getOrderByFields().length * 3));
9852                    }
9853                    else {
9854                            query = new StringBundler(5);
9855                    }
9856    
9857                    if (getDB().isSupportsInlineDistinct()) {
9858                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
9859                    }
9860                    else {
9861                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
9862                    }
9863    
9864                    query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
9865    
9866                    query.append(_FINDER_COLUMN_G_U_S_USERID_2);
9867    
9868                    query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
9869    
9870                    if (!getDB().isSupportsInlineDistinct()) {
9871                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
9872                    }
9873    
9874                    if (orderByComparator != null) {
9875                            if (getDB().isSupportsInlineDistinct()) {
9876                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9877                                            orderByComparator, true);
9878                            }
9879                            else {
9880                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
9881                                            orderByComparator, true);
9882                            }
9883                    }
9884                    else {
9885                            if (getDB().isSupportsInlineDistinct()) {
9886                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
9887                            }
9888                            else {
9889                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
9890                            }
9891                    }
9892    
9893                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9894                                    BlogsEntry.class.getName(),
9895                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9896    
9897                    Session session = null;
9898    
9899                    try {
9900                            session = openSession();
9901    
9902                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
9903    
9904                            if (getDB().isSupportsInlineDistinct()) {
9905                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
9906                            }
9907                            else {
9908                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
9909                            }
9910    
9911                            QueryPos qPos = QueryPos.getInstance(q);
9912    
9913                            qPos.add(groupId);
9914    
9915                            qPos.add(userId);
9916    
9917                            qPos.add(status);
9918    
9919                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
9920                    }
9921                    catch (Exception e) {
9922                            throw processException(e);
9923                    }
9924                    finally {
9925                            closeSession(session);
9926                    }
9927            }
9928    
9929            /**
9930             * 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;.
9931             *
9932             * @param entryId the primary key of the current blogs entry
9933             * @param groupId the group ID
9934             * @param userId the user ID
9935             * @param status the status
9936             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9937             * @return the previous, current, and next blogs entry
9938             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
9939             */
9940            @Override
9941            public BlogsEntry[] filterFindByG_U_S_PrevAndNext(long entryId,
9942                    long groupId, long userId, int status,
9943                    OrderByComparator<BlogsEntry> orderByComparator)
9944                    throws NoSuchEntryException {
9945                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9946                            return findByG_U_S_PrevAndNext(entryId, groupId, userId, status,
9947                                    orderByComparator);
9948                    }
9949    
9950                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
9951    
9952                    Session session = null;
9953    
9954                    try {
9955                            session = openSession();
9956    
9957                            BlogsEntry[] array = new BlogsEntryImpl[3];
9958    
9959                            array[0] = filterGetByG_U_S_PrevAndNext(session, blogsEntry,
9960                                            groupId, userId, status, orderByComparator, true);
9961    
9962                            array[1] = blogsEntry;
9963    
9964                            array[2] = filterGetByG_U_S_PrevAndNext(session, blogsEntry,
9965                                            groupId, userId, status, orderByComparator, false);
9966    
9967                            return array;
9968                    }
9969                    catch (Exception e) {
9970                            throw processException(e);
9971                    }
9972                    finally {
9973                            closeSession(session);
9974                    }
9975            }
9976    
9977            protected BlogsEntry filterGetByG_U_S_PrevAndNext(Session session,
9978                    BlogsEntry blogsEntry, long groupId, long userId, int status,
9979                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
9980                    StringBundler query = null;
9981    
9982                    if (orderByComparator != null) {
9983                            query = new StringBundler(6 +
9984                                            (orderByComparator.getOrderByFields().length * 6));
9985                    }
9986                    else {
9987                            query = new StringBundler(3);
9988                    }
9989    
9990                    if (getDB().isSupportsInlineDistinct()) {
9991                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
9992                    }
9993                    else {
9994                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
9995                    }
9996    
9997                    query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
9998    
9999                    query.append(_FINDER_COLUMN_G_U_S_USERID_2);
10000    
10001                    query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
10002    
10003                    if (!getDB().isSupportsInlineDistinct()) {
10004                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
10005                    }
10006    
10007                    if (orderByComparator != null) {
10008                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10009    
10010                            if (orderByConditionFields.length > 0) {
10011                                    query.append(WHERE_AND);
10012                            }
10013    
10014                            for (int i = 0; i < orderByConditionFields.length; i++) {
10015                                    if (getDB().isSupportsInlineDistinct()) {
10016                                            query.append(_ORDER_BY_ENTITY_ALIAS);
10017                                    }
10018                                    else {
10019                                            query.append(_ORDER_BY_ENTITY_TABLE);
10020                                    }
10021    
10022                                    query.append(orderByConditionFields[i]);
10023    
10024                                    if ((i + 1) < orderByConditionFields.length) {
10025                                            if (orderByComparator.isAscending() ^ previous) {
10026                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10027                                            }
10028                                            else {
10029                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10030                                            }
10031                                    }
10032                                    else {
10033                                            if (orderByComparator.isAscending() ^ previous) {
10034                                                    query.append(WHERE_GREATER_THAN);
10035                                            }
10036                                            else {
10037                                                    query.append(WHERE_LESSER_THAN);
10038                                            }
10039                                    }
10040                            }
10041    
10042                            query.append(ORDER_BY_CLAUSE);
10043    
10044                            String[] orderByFields = orderByComparator.getOrderByFields();
10045    
10046                            for (int i = 0; i < orderByFields.length; i++) {
10047                                    if (getDB().isSupportsInlineDistinct()) {
10048                                            query.append(_ORDER_BY_ENTITY_ALIAS);
10049                                    }
10050                                    else {
10051                                            query.append(_ORDER_BY_ENTITY_TABLE);
10052                                    }
10053    
10054                                    query.append(orderByFields[i]);
10055    
10056                                    if ((i + 1) < orderByFields.length) {
10057                                            if (orderByComparator.isAscending() ^ previous) {
10058                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10059                                            }
10060                                            else {
10061                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10062                                            }
10063                                    }
10064                                    else {
10065                                            if (orderByComparator.isAscending() ^ previous) {
10066                                                    query.append(ORDER_BY_ASC);
10067                                            }
10068                                            else {
10069                                                    query.append(ORDER_BY_DESC);
10070                                            }
10071                                    }
10072                            }
10073                    }
10074                    else {
10075                            if (getDB().isSupportsInlineDistinct()) {
10076                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
10077                            }
10078                            else {
10079                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
10080                            }
10081                    }
10082    
10083                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10084                                    BlogsEntry.class.getName(),
10085                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10086    
10087                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
10088    
10089                    q.setFirstResult(0);
10090                    q.setMaxResults(2);
10091    
10092                    if (getDB().isSupportsInlineDistinct()) {
10093                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
10094                    }
10095                    else {
10096                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
10097                    }
10098    
10099                    QueryPos qPos = QueryPos.getInstance(q);
10100    
10101                    qPos.add(groupId);
10102    
10103                    qPos.add(userId);
10104    
10105                    qPos.add(status);
10106    
10107                    if (orderByComparator != null) {
10108                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
10109    
10110                            for (Object value : values) {
10111                                    qPos.add(value);
10112                            }
10113                    }
10114    
10115                    List<BlogsEntry> list = q.list();
10116    
10117                    if (list.size() == 2) {
10118                            return list.get(1);
10119                    }
10120                    else {
10121                            return null;
10122                    }
10123            }
10124    
10125            /**
10126             * Removes all the blogs entries where groupId = &#63; and userId = &#63; and status = &#63; from the database.
10127             *
10128             * @param groupId the group ID
10129             * @param userId the user ID
10130             * @param status the status
10131             */
10132            @Override
10133            public void removeByG_U_S(long groupId, long userId, int status) {
10134                    for (BlogsEntry blogsEntry : findByG_U_S(groupId, userId, status,
10135                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
10136                            remove(blogsEntry);
10137                    }
10138            }
10139    
10140            /**
10141             * Returns the number of blogs entries where groupId = &#63; and userId = &#63; and status = &#63;.
10142             *
10143             * @param groupId the group ID
10144             * @param userId the user ID
10145             * @param status the status
10146             * @return the number of matching blogs entries
10147             */
10148            @Override
10149            public int countByG_U_S(long groupId, long userId, int status) {
10150                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_U_S;
10151    
10152                    Object[] finderArgs = new Object[] { groupId, userId, status };
10153    
10154                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
10155                                    this);
10156    
10157                    if (count == null) {
10158                            StringBundler query = new StringBundler(4);
10159    
10160                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
10161    
10162                            query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
10163    
10164                            query.append(_FINDER_COLUMN_G_U_S_USERID_2);
10165    
10166                            query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
10167    
10168                            String sql = query.toString();
10169    
10170                            Session session = null;
10171    
10172                            try {
10173                                    session = openSession();
10174    
10175                                    Query q = session.createQuery(sql);
10176    
10177                                    QueryPos qPos = QueryPos.getInstance(q);
10178    
10179                                    qPos.add(groupId);
10180    
10181                                    qPos.add(userId);
10182    
10183                                    qPos.add(status);
10184    
10185                                    count = (Long)q.uniqueResult();
10186    
10187                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
10188                            }
10189                            catch (Exception e) {
10190                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
10191    
10192                                    throw processException(e);
10193                            }
10194                            finally {
10195                                    closeSession(session);
10196                            }
10197                    }
10198    
10199                    return count.intValue();
10200            }
10201    
10202            /**
10203             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status = &#63;.
10204             *
10205             * @param groupId the group ID
10206             * @param userId the user ID
10207             * @param status the status
10208             * @return the number of matching blogs entries that the user has permission to view
10209             */
10210            @Override
10211            public int filterCountByG_U_S(long groupId, long userId, int status) {
10212                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10213                            return countByG_U_S(groupId, userId, status);
10214                    }
10215    
10216                    StringBundler query = new StringBundler(4);
10217    
10218                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
10219    
10220                    query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
10221    
10222                    query.append(_FINDER_COLUMN_G_U_S_USERID_2);
10223    
10224                    query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
10225    
10226                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10227                                    BlogsEntry.class.getName(),
10228                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10229    
10230                    Session session = null;
10231    
10232                    try {
10233                            session = openSession();
10234    
10235                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
10236    
10237                            q.addScalar(COUNT_COLUMN_NAME,
10238                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
10239    
10240                            QueryPos qPos = QueryPos.getInstance(q);
10241    
10242                            qPos.add(groupId);
10243    
10244                            qPos.add(userId);
10245    
10246                            qPos.add(status);
10247    
10248                            Long count = (Long)q.uniqueResult();
10249    
10250                            return count.intValue();
10251                    }
10252                    catch (Exception e) {
10253                            throw processException(e);
10254                    }
10255                    finally {
10256                            closeSession(session);
10257                    }
10258            }
10259    
10260            private static final String _FINDER_COLUMN_G_U_S_GROUPID_2 = "blogsEntry.groupId = ? AND ";
10261            private static final String _FINDER_COLUMN_G_U_S_USERID_2 = "blogsEntry.userId = ? AND ";
10262            private static final String _FINDER_COLUMN_G_U_S_STATUS_2 = "blogsEntry.status = ?";
10263            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_NOTS = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
10264                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
10265                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_NotS",
10266                            new String[] {
10267                                    Long.class.getName(), Long.class.getName(),
10268                                    Integer.class.getName(),
10269                                    
10270                            Integer.class.getName(), Integer.class.getName(),
10271                                    OrderByComparator.class.getName()
10272                            });
10273            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_NOTS =
10274                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
10275                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
10276                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_U_NotS",
10277                            new String[] {
10278                                    Long.class.getName(), Long.class.getName(),
10279                                    Integer.class.getName()
10280                            });
10281    
10282            /**
10283             * Returns all the blogs entries where groupId = &#63; and userId = &#63; and status &ne; &#63;.
10284             *
10285             * @param groupId the group ID
10286             * @param userId the user ID
10287             * @param status the status
10288             * @return the matching blogs entries
10289             */
10290            @Override
10291            public List<BlogsEntry> findByG_U_NotS(long groupId, long userId, int status) {
10292                    return findByG_U_NotS(groupId, userId, status, QueryUtil.ALL_POS,
10293                            QueryUtil.ALL_POS, null);
10294            }
10295    
10296            /**
10297             * Returns a range of all the blogs entries where groupId = &#63; and userId = &#63; and status &ne; &#63;.
10298             *
10299             * <p>
10300             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10301             * </p>
10302             *
10303             * @param groupId the group ID
10304             * @param userId the user ID
10305             * @param status the status
10306             * @param start the lower bound of the range of blogs entries
10307             * @param end the upper bound of the range of blogs entries (not inclusive)
10308             * @return the range of matching blogs entries
10309             */
10310            @Override
10311            public List<BlogsEntry> findByG_U_NotS(long groupId, long userId,
10312                    int status, int start, int end) {
10313                    return findByG_U_NotS(groupId, userId, status, start, end, null);
10314            }
10315    
10316            /**
10317             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and status &ne; &#63;.
10318             *
10319             * <p>
10320             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10321             * </p>
10322             *
10323             * @param groupId the group ID
10324             * @param userId the user ID
10325             * @param status the status
10326             * @param start the lower bound of the range of blogs entries
10327             * @param end the upper bound of the range of blogs entries (not inclusive)
10328             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10329             * @return the ordered range of matching blogs entries
10330             */
10331            @Override
10332            public List<BlogsEntry> findByG_U_NotS(long groupId, long userId,
10333                    int status, int start, int end,
10334                    OrderByComparator<BlogsEntry> orderByComparator) {
10335                    boolean pagination = true;
10336                    FinderPath finderPath = null;
10337                    Object[] finderArgs = null;
10338    
10339                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_NOTS;
10340                    finderArgs = new Object[] {
10341                                    groupId, userId, status,
10342                                    
10343                                    start, end, orderByComparator
10344                            };
10345    
10346                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
10347                                    finderArgs, this);
10348    
10349                    if ((list != null) && !list.isEmpty()) {
10350                            for (BlogsEntry blogsEntry : list) {
10351                                    if ((groupId != blogsEntry.getGroupId()) ||
10352                                                    (userId != blogsEntry.getUserId()) ||
10353                                                    (status == blogsEntry.getStatus())) {
10354                                            list = null;
10355    
10356                                            break;
10357                                    }
10358                            }
10359                    }
10360    
10361                    if (list == null) {
10362                            StringBundler query = null;
10363    
10364                            if (orderByComparator != null) {
10365                                    query = new StringBundler(5 +
10366                                                    (orderByComparator.getOrderByFields().length * 3));
10367                            }
10368                            else {
10369                                    query = new StringBundler(5);
10370                            }
10371    
10372                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
10373    
10374                            query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
10375    
10376                            query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
10377    
10378                            query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
10379    
10380                            if (orderByComparator != null) {
10381                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10382                                            orderByComparator);
10383                            }
10384                            else
10385                             if (pagination) {
10386                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
10387                            }
10388    
10389                            String sql = query.toString();
10390    
10391                            Session session = null;
10392    
10393                            try {
10394                                    session = openSession();
10395    
10396                                    Query q = session.createQuery(sql);
10397    
10398                                    QueryPos qPos = QueryPos.getInstance(q);
10399    
10400                                    qPos.add(groupId);
10401    
10402                                    qPos.add(userId);
10403    
10404                                    qPos.add(status);
10405    
10406                                    if (!pagination) {
10407                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
10408                                                            start, end, false);
10409    
10410                                            Collections.sort(list);
10411    
10412                                            list = Collections.unmodifiableList(list);
10413                                    }
10414                                    else {
10415                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
10416                                                            start, end);
10417                                    }
10418    
10419                                    cacheResult(list);
10420    
10421                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
10422                            }
10423                            catch (Exception e) {
10424                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
10425    
10426                                    throw processException(e);
10427                            }
10428                            finally {
10429                                    closeSession(session);
10430                            }
10431                    }
10432    
10433                    return list;
10434            }
10435    
10436            /**
10437             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status &ne; &#63;.
10438             *
10439             * @param groupId the group ID
10440             * @param userId the user ID
10441             * @param status the status
10442             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10443             * @return the first matching blogs entry
10444             * @throws NoSuchEntryException if a matching blogs entry could not be found
10445             */
10446            @Override
10447            public BlogsEntry findByG_U_NotS_First(long groupId, long userId,
10448                    int status, OrderByComparator<BlogsEntry> orderByComparator)
10449                    throws NoSuchEntryException {
10450                    BlogsEntry blogsEntry = fetchByG_U_NotS_First(groupId, userId, status,
10451                                    orderByComparator);
10452    
10453                    if (blogsEntry != null) {
10454                            return blogsEntry;
10455                    }
10456    
10457                    StringBundler msg = new StringBundler(8);
10458    
10459                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10460    
10461                    msg.append("groupId=");
10462                    msg.append(groupId);
10463    
10464                    msg.append(", userId=");
10465                    msg.append(userId);
10466    
10467                    msg.append(", status=");
10468                    msg.append(status);
10469    
10470                    msg.append(StringPool.CLOSE_CURLY_BRACE);
10471    
10472                    throw new NoSuchEntryException(msg.toString());
10473            }
10474    
10475            /**
10476             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status &ne; &#63;.
10477             *
10478             * @param groupId the group ID
10479             * @param userId the user ID
10480             * @param status the status
10481             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10482             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
10483             */
10484            @Override
10485            public BlogsEntry fetchByG_U_NotS_First(long groupId, long userId,
10486                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
10487                    List<BlogsEntry> list = findByG_U_NotS(groupId, userId, status, 0, 1,
10488                                    orderByComparator);
10489    
10490                    if (!list.isEmpty()) {
10491                            return list.get(0);
10492                    }
10493    
10494                    return null;
10495            }
10496    
10497            /**
10498             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status &ne; &#63;.
10499             *
10500             * @param groupId the group ID
10501             * @param userId the user ID
10502             * @param status the status
10503             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10504             * @return the last matching blogs entry
10505             * @throws NoSuchEntryException if a matching blogs entry could not be found
10506             */
10507            @Override
10508            public BlogsEntry findByG_U_NotS_Last(long groupId, long userId,
10509                    int status, OrderByComparator<BlogsEntry> orderByComparator)
10510                    throws NoSuchEntryException {
10511                    BlogsEntry blogsEntry = fetchByG_U_NotS_Last(groupId, userId, status,
10512                                    orderByComparator);
10513    
10514                    if (blogsEntry != null) {
10515                            return blogsEntry;
10516                    }
10517    
10518                    StringBundler msg = new StringBundler(8);
10519    
10520                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10521    
10522                    msg.append("groupId=");
10523                    msg.append(groupId);
10524    
10525                    msg.append(", userId=");
10526                    msg.append(userId);
10527    
10528                    msg.append(", status=");
10529                    msg.append(status);
10530    
10531                    msg.append(StringPool.CLOSE_CURLY_BRACE);
10532    
10533                    throw new NoSuchEntryException(msg.toString());
10534            }
10535    
10536            /**
10537             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and status &ne; &#63;.
10538             *
10539             * @param groupId the group ID
10540             * @param userId the user ID
10541             * @param status the status
10542             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10543             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
10544             */
10545            @Override
10546            public BlogsEntry fetchByG_U_NotS_Last(long groupId, long userId,
10547                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
10548                    int count = countByG_U_NotS(groupId, userId, status);
10549    
10550                    if (count == 0) {
10551                            return null;
10552                    }
10553    
10554                    List<BlogsEntry> list = findByG_U_NotS(groupId, userId, status,
10555                                    count - 1, count, orderByComparator);
10556    
10557                    if (!list.isEmpty()) {
10558                            return list.get(0);
10559                    }
10560    
10561                    return null;
10562            }
10563    
10564            /**
10565             * 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;.
10566             *
10567             * @param entryId the primary key of the current blogs entry
10568             * @param groupId the group ID
10569             * @param userId the user ID
10570             * @param status the status
10571             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10572             * @return the previous, current, and next blogs entry
10573             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
10574             */
10575            @Override
10576            public BlogsEntry[] findByG_U_NotS_PrevAndNext(long entryId, long groupId,
10577                    long userId, int status, OrderByComparator<BlogsEntry> orderByComparator)
10578                    throws NoSuchEntryException {
10579                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
10580    
10581                    Session session = null;
10582    
10583                    try {
10584                            session = openSession();
10585    
10586                            BlogsEntry[] array = new BlogsEntryImpl[3];
10587    
10588                            array[0] = getByG_U_NotS_PrevAndNext(session, blogsEntry, groupId,
10589                                            userId, status, orderByComparator, true);
10590    
10591                            array[1] = blogsEntry;
10592    
10593                            array[2] = getByG_U_NotS_PrevAndNext(session, blogsEntry, groupId,
10594                                            userId, status, orderByComparator, false);
10595    
10596                            return array;
10597                    }
10598                    catch (Exception e) {
10599                            throw processException(e);
10600                    }
10601                    finally {
10602                            closeSession(session);
10603                    }
10604            }
10605    
10606            protected BlogsEntry getByG_U_NotS_PrevAndNext(Session session,
10607                    BlogsEntry blogsEntry, long groupId, long userId, int status,
10608                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
10609                    StringBundler query = null;
10610    
10611                    if (orderByComparator != null) {
10612                            query = new StringBundler(6 +
10613                                            (orderByComparator.getOrderByFields().length * 6));
10614                    }
10615                    else {
10616                            query = new StringBundler(3);
10617                    }
10618    
10619                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
10620    
10621                    query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
10622    
10623                    query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
10624    
10625                    query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
10626    
10627                    if (orderByComparator != null) {
10628                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10629    
10630                            if (orderByConditionFields.length > 0) {
10631                                    query.append(WHERE_AND);
10632                            }
10633    
10634                            for (int i = 0; i < orderByConditionFields.length; i++) {
10635                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10636                                    query.append(orderByConditionFields[i]);
10637    
10638                                    if ((i + 1) < orderByConditionFields.length) {
10639                                            if (orderByComparator.isAscending() ^ previous) {
10640                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10641                                            }
10642                                            else {
10643                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10644                                            }
10645                                    }
10646                                    else {
10647                                            if (orderByComparator.isAscending() ^ previous) {
10648                                                    query.append(WHERE_GREATER_THAN);
10649                                            }
10650                                            else {
10651                                                    query.append(WHERE_LESSER_THAN);
10652                                            }
10653                                    }
10654                            }
10655    
10656                            query.append(ORDER_BY_CLAUSE);
10657    
10658                            String[] orderByFields = orderByComparator.getOrderByFields();
10659    
10660                            for (int i = 0; i < orderByFields.length; i++) {
10661                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10662                                    query.append(orderByFields[i]);
10663    
10664                                    if ((i + 1) < orderByFields.length) {
10665                                            if (orderByComparator.isAscending() ^ previous) {
10666                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10667                                            }
10668                                            else {
10669                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10670                                            }
10671                                    }
10672                                    else {
10673                                            if (orderByComparator.isAscending() ^ previous) {
10674                                                    query.append(ORDER_BY_ASC);
10675                                            }
10676                                            else {
10677                                                    query.append(ORDER_BY_DESC);
10678                                            }
10679                                    }
10680                            }
10681                    }
10682                    else {
10683                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
10684                    }
10685    
10686                    String sql = query.toString();
10687    
10688                    Query q = session.createQuery(sql);
10689    
10690                    q.setFirstResult(0);
10691                    q.setMaxResults(2);
10692    
10693                    QueryPos qPos = QueryPos.getInstance(q);
10694    
10695                    qPos.add(groupId);
10696    
10697                    qPos.add(userId);
10698    
10699                    qPos.add(status);
10700    
10701                    if (orderByComparator != null) {
10702                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
10703    
10704                            for (Object value : values) {
10705                                    qPos.add(value);
10706                            }
10707                    }
10708    
10709                    List<BlogsEntry> list = q.list();
10710    
10711                    if (list.size() == 2) {
10712                            return list.get(1);
10713                    }
10714                    else {
10715                            return null;
10716                    }
10717            }
10718    
10719            /**
10720             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status &ne; &#63;.
10721             *
10722             * @param groupId the group ID
10723             * @param userId the user ID
10724             * @param status the status
10725             * @return the matching blogs entries that the user has permission to view
10726             */
10727            @Override
10728            public List<BlogsEntry> filterFindByG_U_NotS(long groupId, long userId,
10729                    int status) {
10730                    return filterFindByG_U_NotS(groupId, userId, status, QueryUtil.ALL_POS,
10731                            QueryUtil.ALL_POS, null);
10732            }
10733    
10734            /**
10735             * 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;.
10736             *
10737             * <p>
10738             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10739             * </p>
10740             *
10741             * @param groupId the group ID
10742             * @param userId the user ID
10743             * @param status the status
10744             * @param start the lower bound of the range of blogs entries
10745             * @param end the upper bound of the range of blogs entries (not inclusive)
10746             * @return the range of matching blogs entries that the user has permission to view
10747             */
10748            @Override
10749            public List<BlogsEntry> filterFindByG_U_NotS(long groupId, long userId,
10750                    int status, int start, int end) {
10751                    return filterFindByG_U_NotS(groupId, userId, status, start, end, null);
10752            }
10753    
10754            /**
10755             * 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;.
10756             *
10757             * <p>
10758             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10759             * </p>
10760             *
10761             * @param groupId the group ID
10762             * @param userId the user ID
10763             * @param status the status
10764             * @param start the lower bound of the range of blogs entries
10765             * @param end the upper bound of the range of blogs entries (not inclusive)
10766             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10767             * @return the ordered range of matching blogs entries that the user has permission to view
10768             */
10769            @Override
10770            public List<BlogsEntry> filterFindByG_U_NotS(long groupId, long userId,
10771                    int status, int start, int end,
10772                    OrderByComparator<BlogsEntry> orderByComparator) {
10773                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10774                            return findByG_U_NotS(groupId, userId, status, start, end,
10775                                    orderByComparator);
10776                    }
10777    
10778                    StringBundler query = null;
10779    
10780                    if (orderByComparator != null) {
10781                            query = new StringBundler(5 +
10782                                            (orderByComparator.getOrderByFields().length * 3));
10783                    }
10784                    else {
10785                            query = new StringBundler(5);
10786                    }
10787    
10788                    if (getDB().isSupportsInlineDistinct()) {
10789                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
10790                    }
10791                    else {
10792                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
10793                    }
10794    
10795                    query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
10796    
10797                    query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
10798    
10799                    query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
10800    
10801                    if (!getDB().isSupportsInlineDistinct()) {
10802                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
10803                    }
10804    
10805                    if (orderByComparator != null) {
10806                            if (getDB().isSupportsInlineDistinct()) {
10807                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10808                                            orderByComparator, true);
10809                            }
10810                            else {
10811                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
10812                                            orderByComparator, true);
10813                            }
10814                    }
10815                    else {
10816                            if (getDB().isSupportsInlineDistinct()) {
10817                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
10818                            }
10819                            else {
10820                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
10821                            }
10822                    }
10823    
10824                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10825                                    BlogsEntry.class.getName(),
10826                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10827    
10828                    Session session = null;
10829    
10830                    try {
10831                            session = openSession();
10832    
10833                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
10834    
10835                            if (getDB().isSupportsInlineDistinct()) {
10836                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
10837                            }
10838                            else {
10839                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
10840                            }
10841    
10842                            QueryPos qPos = QueryPos.getInstance(q);
10843    
10844                            qPos.add(groupId);
10845    
10846                            qPos.add(userId);
10847    
10848                            qPos.add(status);
10849    
10850                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
10851                    }
10852                    catch (Exception e) {
10853                            throw processException(e);
10854                    }
10855                    finally {
10856                            closeSession(session);
10857                    }
10858            }
10859    
10860            /**
10861             * 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;.
10862             *
10863             * @param entryId the primary key of the current blogs entry
10864             * @param groupId the group ID
10865             * @param userId the user ID
10866             * @param status the status
10867             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10868             * @return the previous, current, and next blogs entry
10869             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
10870             */
10871            @Override
10872            public BlogsEntry[] filterFindByG_U_NotS_PrevAndNext(long entryId,
10873                    long groupId, long userId, int status,
10874                    OrderByComparator<BlogsEntry> orderByComparator)
10875                    throws NoSuchEntryException {
10876                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10877                            return findByG_U_NotS_PrevAndNext(entryId, groupId, userId, status,
10878                                    orderByComparator);
10879                    }
10880    
10881                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
10882    
10883                    Session session = null;
10884    
10885                    try {
10886                            session = openSession();
10887    
10888                            BlogsEntry[] array = new BlogsEntryImpl[3];
10889    
10890                            array[0] = filterGetByG_U_NotS_PrevAndNext(session, blogsEntry,
10891                                            groupId, userId, status, orderByComparator, true);
10892    
10893                            array[1] = blogsEntry;
10894    
10895                            array[2] = filterGetByG_U_NotS_PrevAndNext(session, blogsEntry,
10896                                            groupId, userId, status, orderByComparator, false);
10897    
10898                            return array;
10899                    }
10900                    catch (Exception e) {
10901                            throw processException(e);
10902                    }
10903                    finally {
10904                            closeSession(session);
10905                    }
10906            }
10907    
10908            protected BlogsEntry filterGetByG_U_NotS_PrevAndNext(Session session,
10909                    BlogsEntry blogsEntry, long groupId, long userId, int status,
10910                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
10911                    StringBundler query = null;
10912    
10913                    if (orderByComparator != null) {
10914                            query = new StringBundler(6 +
10915                                            (orderByComparator.getOrderByFields().length * 6));
10916                    }
10917                    else {
10918                            query = new StringBundler(3);
10919                    }
10920    
10921                    if (getDB().isSupportsInlineDistinct()) {
10922                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
10923                    }
10924                    else {
10925                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
10926                    }
10927    
10928                    query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
10929    
10930                    query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
10931    
10932                    query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
10933    
10934                    if (!getDB().isSupportsInlineDistinct()) {
10935                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
10936                    }
10937    
10938                    if (orderByComparator != null) {
10939                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10940    
10941                            if (orderByConditionFields.length > 0) {
10942                                    query.append(WHERE_AND);
10943                            }
10944    
10945                            for (int i = 0; i < orderByConditionFields.length; i++) {
10946                                    if (getDB().isSupportsInlineDistinct()) {
10947                                            query.append(_ORDER_BY_ENTITY_ALIAS);
10948                                    }
10949                                    else {
10950                                            query.append(_ORDER_BY_ENTITY_TABLE);
10951                                    }
10952    
10953                                    query.append(orderByConditionFields[i]);
10954    
10955                                    if ((i + 1) < orderByConditionFields.length) {
10956                                            if (orderByComparator.isAscending() ^ previous) {
10957                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10958                                            }
10959                                            else {
10960                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10961                                            }
10962                                    }
10963                                    else {
10964                                            if (orderByComparator.isAscending() ^ previous) {
10965                                                    query.append(WHERE_GREATER_THAN);
10966                                            }
10967                                            else {
10968                                                    query.append(WHERE_LESSER_THAN);
10969                                            }
10970                                    }
10971                            }
10972    
10973                            query.append(ORDER_BY_CLAUSE);
10974    
10975                            String[] orderByFields = orderByComparator.getOrderByFields();
10976    
10977                            for (int i = 0; i < orderByFields.length; i++) {
10978                                    if (getDB().isSupportsInlineDistinct()) {
10979                                            query.append(_ORDER_BY_ENTITY_ALIAS);
10980                                    }
10981                                    else {
10982                                            query.append(_ORDER_BY_ENTITY_TABLE);
10983                                    }
10984    
10985                                    query.append(orderByFields[i]);
10986    
10987                                    if ((i + 1) < orderByFields.length) {
10988                                            if (orderByComparator.isAscending() ^ previous) {
10989                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10990                                            }
10991                                            else {
10992                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10993                                            }
10994                                    }
10995                                    else {
10996                                            if (orderByComparator.isAscending() ^ previous) {
10997                                                    query.append(ORDER_BY_ASC);
10998                                            }
10999                                            else {
11000                                                    query.append(ORDER_BY_DESC);
11001                                            }
11002                                    }
11003                            }
11004                    }
11005                    else {
11006                            if (getDB().isSupportsInlineDistinct()) {
11007                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
11008                            }
11009                            else {
11010                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
11011                            }
11012                    }
11013    
11014                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11015                                    BlogsEntry.class.getName(),
11016                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11017    
11018                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
11019    
11020                    q.setFirstResult(0);
11021                    q.setMaxResults(2);
11022    
11023                    if (getDB().isSupportsInlineDistinct()) {
11024                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
11025                    }
11026                    else {
11027                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
11028                    }
11029    
11030                    QueryPos qPos = QueryPos.getInstance(q);
11031    
11032                    qPos.add(groupId);
11033    
11034                    qPos.add(userId);
11035    
11036                    qPos.add(status);
11037    
11038                    if (orderByComparator != null) {
11039                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
11040    
11041                            for (Object value : values) {
11042                                    qPos.add(value);
11043                            }
11044                    }
11045    
11046                    List<BlogsEntry> list = q.list();
11047    
11048                    if (list.size() == 2) {
11049                            return list.get(1);
11050                    }
11051                    else {
11052                            return null;
11053                    }
11054            }
11055    
11056            /**
11057             * Removes all the blogs entries where groupId = &#63; and userId = &#63; and status &ne; &#63; from the database.
11058             *
11059             * @param groupId the group ID
11060             * @param userId the user ID
11061             * @param status the status
11062             */
11063            @Override
11064            public void removeByG_U_NotS(long groupId, long userId, int status) {
11065                    for (BlogsEntry blogsEntry : findByG_U_NotS(groupId, userId, status,
11066                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
11067                            remove(blogsEntry);
11068                    }
11069            }
11070    
11071            /**
11072             * Returns the number of blogs entries where groupId = &#63; and userId = &#63; and status &ne; &#63;.
11073             *
11074             * @param groupId the group ID
11075             * @param userId the user ID
11076             * @param status the status
11077             * @return the number of matching blogs entries
11078             */
11079            @Override
11080            public int countByG_U_NotS(long groupId, long userId, int status) {
11081                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_NOTS;
11082    
11083                    Object[] finderArgs = new Object[] { groupId, userId, status };
11084    
11085                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
11086                                    this);
11087    
11088                    if (count == null) {
11089                            StringBundler query = new StringBundler(4);
11090    
11091                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
11092    
11093                            query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
11094    
11095                            query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
11096    
11097                            query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
11098    
11099                            String sql = query.toString();
11100    
11101                            Session session = null;
11102    
11103                            try {
11104                                    session = openSession();
11105    
11106                                    Query q = session.createQuery(sql);
11107    
11108                                    QueryPos qPos = QueryPos.getInstance(q);
11109    
11110                                    qPos.add(groupId);
11111    
11112                                    qPos.add(userId);
11113    
11114                                    qPos.add(status);
11115    
11116                                    count = (Long)q.uniqueResult();
11117    
11118                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
11119                            }
11120                            catch (Exception e) {
11121                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
11122    
11123                                    throw processException(e);
11124                            }
11125                            finally {
11126                                    closeSession(session);
11127                            }
11128                    }
11129    
11130                    return count.intValue();
11131            }
11132    
11133            /**
11134             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and userId = &#63; and status &ne; &#63;.
11135             *
11136             * @param groupId the group ID
11137             * @param userId the user ID
11138             * @param status the status
11139             * @return the number of matching blogs entries that the user has permission to view
11140             */
11141            @Override
11142            public int filterCountByG_U_NotS(long groupId, long userId, int status) {
11143                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11144                            return countByG_U_NotS(groupId, userId, status);
11145                    }
11146    
11147                    StringBundler query = new StringBundler(4);
11148    
11149                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
11150    
11151                    query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
11152    
11153                    query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
11154    
11155                    query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
11156    
11157                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11158                                    BlogsEntry.class.getName(),
11159                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11160    
11161                    Session session = null;
11162    
11163                    try {
11164                            session = openSession();
11165    
11166                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
11167    
11168                            q.addScalar(COUNT_COLUMN_NAME,
11169                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
11170    
11171                            QueryPos qPos = QueryPos.getInstance(q);
11172    
11173                            qPos.add(groupId);
11174    
11175                            qPos.add(userId);
11176    
11177                            qPos.add(status);
11178    
11179                            Long count = (Long)q.uniqueResult();
11180    
11181                            return count.intValue();
11182                    }
11183                    catch (Exception e) {
11184                            throw processException(e);
11185                    }
11186                    finally {
11187                            closeSession(session);
11188                    }
11189            }
11190    
11191            private static final String _FINDER_COLUMN_G_U_NOTS_GROUPID_2 = "blogsEntry.groupId = ? AND ";
11192            private static final String _FINDER_COLUMN_G_U_NOTS_USERID_2 = "blogsEntry.userId = ? AND ";
11193            private static final String _FINDER_COLUMN_G_U_NOTS_STATUS_2 = "blogsEntry.status != ?";
11194            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
11195                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
11196                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_LtD_S",
11197                            new String[] {
11198                                    Long.class.getName(), Date.class.getName(),
11199                                    Integer.class.getName(),
11200                                    
11201                            Integer.class.getName(), Integer.class.getName(),
11202                                    OrderByComparator.class.getName()
11203                            });
11204            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
11205                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
11206                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_LtD_S",
11207                            new String[] {
11208                                    Long.class.getName(), Date.class.getName(),
11209                                    Integer.class.getName()
11210                            });
11211    
11212            /**
11213             * Returns all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
11214             *
11215             * @param groupId the group ID
11216             * @param displayDate the display date
11217             * @param status the status
11218             * @return the matching blogs entries
11219             */
11220            @Override
11221            public List<BlogsEntry> findByG_LtD_S(long groupId, Date displayDate,
11222                    int status) {
11223                    return findByG_LtD_S(groupId, displayDate, status, QueryUtil.ALL_POS,
11224                            QueryUtil.ALL_POS, null);
11225            }
11226    
11227            /**
11228             * Returns a range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
11229             *
11230             * <p>
11231             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11232             * </p>
11233             *
11234             * @param groupId the group ID
11235             * @param displayDate the display date
11236             * @param status the status
11237             * @param start the lower bound of the range of blogs entries
11238             * @param end the upper bound of the range of blogs entries (not inclusive)
11239             * @return the range of matching blogs entries
11240             */
11241            @Override
11242            public List<BlogsEntry> findByG_LtD_S(long groupId, Date displayDate,
11243                    int status, int start, int end) {
11244                    return findByG_LtD_S(groupId, displayDate, status, start, end, null);
11245            }
11246    
11247            /**
11248             * Returns an ordered range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
11249             *
11250             * <p>
11251             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11252             * </p>
11253             *
11254             * @param groupId the group ID
11255             * @param displayDate the display date
11256             * @param status the status
11257             * @param start the lower bound of the range of blogs entries
11258             * @param end the upper bound of the range of blogs entries (not inclusive)
11259             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11260             * @return the ordered range of matching blogs entries
11261             */
11262            @Override
11263            public List<BlogsEntry> findByG_LtD_S(long groupId, Date displayDate,
11264                    int status, int start, int end,
11265                    OrderByComparator<BlogsEntry> orderByComparator) {
11266                    boolean pagination = true;
11267                    FinderPath finderPath = null;
11268                    Object[] finderArgs = null;
11269    
11270                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD_S;
11271                    finderArgs = new Object[] {
11272                                    groupId, displayDate, status,
11273                                    
11274                                    start, end, orderByComparator
11275                            };
11276    
11277                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
11278                                    finderArgs, this);
11279    
11280                    if ((list != null) && !list.isEmpty()) {
11281                            for (BlogsEntry blogsEntry : list) {
11282                                    if ((groupId != blogsEntry.getGroupId()) ||
11283                                                    (displayDate.getTime() <= blogsEntry.getDisplayDate()
11284                                                                                                                                    .getTime()) ||
11285                                                    (status != blogsEntry.getStatus())) {
11286                                            list = null;
11287    
11288                                            break;
11289                                    }
11290                            }
11291                    }
11292    
11293                    if (list == null) {
11294                            StringBundler query = null;
11295    
11296                            if (orderByComparator != null) {
11297                                    query = new StringBundler(5 +
11298                                                    (orderByComparator.getOrderByFields().length * 3));
11299                            }
11300                            else {
11301                                    query = new StringBundler(5);
11302                            }
11303    
11304                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
11305    
11306                            query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
11307    
11308                            boolean bindDisplayDate = false;
11309    
11310                            if (displayDate == null) {
11311                                    query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
11312                            }
11313                            else {
11314                                    bindDisplayDate = true;
11315    
11316                                    query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
11317                            }
11318    
11319                            query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
11320    
11321                            if (orderByComparator != null) {
11322                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11323                                            orderByComparator);
11324                            }
11325                            else
11326                             if (pagination) {
11327                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
11328                            }
11329    
11330                            String sql = query.toString();
11331    
11332                            Session session = null;
11333    
11334                            try {
11335                                    session = openSession();
11336    
11337                                    Query q = session.createQuery(sql);
11338    
11339                                    QueryPos qPos = QueryPos.getInstance(q);
11340    
11341                                    qPos.add(groupId);
11342    
11343                                    if (bindDisplayDate) {
11344                                            qPos.add(new Timestamp(displayDate.getTime()));
11345                                    }
11346    
11347                                    qPos.add(status);
11348    
11349                                    if (!pagination) {
11350                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
11351                                                            start, end, false);
11352    
11353                                            Collections.sort(list);
11354    
11355                                            list = Collections.unmodifiableList(list);
11356                                    }
11357                                    else {
11358                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
11359                                                            start, end);
11360                                    }
11361    
11362                                    cacheResult(list);
11363    
11364                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
11365                            }
11366                            catch (Exception e) {
11367                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
11368    
11369                                    throw processException(e);
11370                            }
11371                            finally {
11372                                    closeSession(session);
11373                            }
11374                    }
11375    
11376                    return list;
11377            }
11378    
11379            /**
11380             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
11381             *
11382             * @param groupId the group ID
11383             * @param displayDate the display date
11384             * @param status the status
11385             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11386             * @return the first matching blogs entry
11387             * @throws NoSuchEntryException if a matching blogs entry could not be found
11388             */
11389            @Override
11390            public BlogsEntry findByG_LtD_S_First(long groupId, Date displayDate,
11391                    int status, OrderByComparator<BlogsEntry> orderByComparator)
11392                    throws NoSuchEntryException {
11393                    BlogsEntry blogsEntry = fetchByG_LtD_S_First(groupId, displayDate,
11394                                    status, orderByComparator);
11395    
11396                    if (blogsEntry != null) {
11397                            return blogsEntry;
11398                    }
11399    
11400                    StringBundler msg = new StringBundler(8);
11401    
11402                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11403    
11404                    msg.append("groupId=");
11405                    msg.append(groupId);
11406    
11407                    msg.append(", displayDate=");
11408                    msg.append(displayDate);
11409    
11410                    msg.append(", status=");
11411                    msg.append(status);
11412    
11413                    msg.append(StringPool.CLOSE_CURLY_BRACE);
11414    
11415                    throw new NoSuchEntryException(msg.toString());
11416            }
11417    
11418            /**
11419             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
11420             *
11421             * @param groupId the group ID
11422             * @param displayDate the display date
11423             * @param status the status
11424             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11425             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
11426             */
11427            @Override
11428            public BlogsEntry fetchByG_LtD_S_First(long groupId, Date displayDate,
11429                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
11430                    List<BlogsEntry> list = findByG_LtD_S(groupId, displayDate, status, 0,
11431                                    1, orderByComparator);
11432    
11433                    if (!list.isEmpty()) {
11434                            return list.get(0);
11435                    }
11436    
11437                    return null;
11438            }
11439    
11440            /**
11441             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
11442             *
11443             * @param groupId the group ID
11444             * @param displayDate the display date
11445             * @param status the status
11446             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11447             * @return the last matching blogs entry
11448             * @throws NoSuchEntryException if a matching blogs entry could not be found
11449             */
11450            @Override
11451            public BlogsEntry findByG_LtD_S_Last(long groupId, Date displayDate,
11452                    int status, OrderByComparator<BlogsEntry> orderByComparator)
11453                    throws NoSuchEntryException {
11454                    BlogsEntry blogsEntry = fetchByG_LtD_S_Last(groupId, displayDate,
11455                                    status, orderByComparator);
11456    
11457                    if (blogsEntry != null) {
11458                            return blogsEntry;
11459                    }
11460    
11461                    StringBundler msg = new StringBundler(8);
11462    
11463                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11464    
11465                    msg.append("groupId=");
11466                    msg.append(groupId);
11467    
11468                    msg.append(", displayDate=");
11469                    msg.append(displayDate);
11470    
11471                    msg.append(", status=");
11472                    msg.append(status);
11473    
11474                    msg.append(StringPool.CLOSE_CURLY_BRACE);
11475    
11476                    throw new NoSuchEntryException(msg.toString());
11477            }
11478    
11479            /**
11480             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
11481             *
11482             * @param groupId the group ID
11483             * @param displayDate the display date
11484             * @param status the status
11485             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11486             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
11487             */
11488            @Override
11489            public BlogsEntry fetchByG_LtD_S_Last(long groupId, Date displayDate,
11490                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
11491                    int count = countByG_LtD_S(groupId, displayDate, status);
11492    
11493                    if (count == 0) {
11494                            return null;
11495                    }
11496    
11497                    List<BlogsEntry> list = findByG_LtD_S(groupId, displayDate, status,
11498                                    count - 1, count, orderByComparator);
11499    
11500                    if (!list.isEmpty()) {
11501                            return list.get(0);
11502                    }
11503    
11504                    return null;
11505            }
11506    
11507            /**
11508             * 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;.
11509             *
11510             * @param entryId the primary key of the current blogs entry
11511             * @param groupId the group ID
11512             * @param displayDate the display date
11513             * @param status the status
11514             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11515             * @return the previous, current, and next blogs entry
11516             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
11517             */
11518            @Override
11519            public BlogsEntry[] findByG_LtD_S_PrevAndNext(long entryId, long groupId,
11520                    Date displayDate, int status,
11521                    OrderByComparator<BlogsEntry> orderByComparator)
11522                    throws NoSuchEntryException {
11523                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
11524    
11525                    Session session = null;
11526    
11527                    try {
11528                            session = openSession();
11529    
11530                            BlogsEntry[] array = new BlogsEntryImpl[3];
11531    
11532                            array[0] = getByG_LtD_S_PrevAndNext(session, blogsEntry, groupId,
11533                                            displayDate, status, orderByComparator, true);
11534    
11535                            array[1] = blogsEntry;
11536    
11537                            array[2] = getByG_LtD_S_PrevAndNext(session, blogsEntry, groupId,
11538                                            displayDate, status, orderByComparator, false);
11539    
11540                            return array;
11541                    }
11542                    catch (Exception e) {
11543                            throw processException(e);
11544                    }
11545                    finally {
11546                            closeSession(session);
11547                    }
11548            }
11549    
11550            protected BlogsEntry getByG_LtD_S_PrevAndNext(Session session,
11551                    BlogsEntry blogsEntry, long groupId, Date displayDate, int status,
11552                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
11553                    StringBundler query = null;
11554    
11555                    if (orderByComparator != null) {
11556                            query = new StringBundler(6 +
11557                                            (orderByComparator.getOrderByFields().length * 6));
11558                    }
11559                    else {
11560                            query = new StringBundler(3);
11561                    }
11562    
11563                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
11564    
11565                    query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
11566    
11567                    boolean bindDisplayDate = false;
11568    
11569                    if (displayDate == null) {
11570                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
11571                    }
11572                    else {
11573                            bindDisplayDate = true;
11574    
11575                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
11576                    }
11577    
11578                    query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
11579    
11580                    if (orderByComparator != null) {
11581                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11582    
11583                            if (orderByConditionFields.length > 0) {
11584                                    query.append(WHERE_AND);
11585                            }
11586    
11587                            for (int i = 0; i < orderByConditionFields.length; i++) {
11588                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11589                                    query.append(orderByConditionFields[i]);
11590    
11591                                    if ((i + 1) < orderByConditionFields.length) {
11592                                            if (orderByComparator.isAscending() ^ previous) {
11593                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
11594                                            }
11595                                            else {
11596                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
11597                                            }
11598                                    }
11599                                    else {
11600                                            if (orderByComparator.isAscending() ^ previous) {
11601                                                    query.append(WHERE_GREATER_THAN);
11602                                            }
11603                                            else {
11604                                                    query.append(WHERE_LESSER_THAN);
11605                                            }
11606                                    }
11607                            }
11608    
11609                            query.append(ORDER_BY_CLAUSE);
11610    
11611                            String[] orderByFields = orderByComparator.getOrderByFields();
11612    
11613                            for (int i = 0; i < orderByFields.length; i++) {
11614                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11615                                    query.append(orderByFields[i]);
11616    
11617                                    if ((i + 1) < orderByFields.length) {
11618                                            if (orderByComparator.isAscending() ^ previous) {
11619                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
11620                                            }
11621                                            else {
11622                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
11623                                            }
11624                                    }
11625                                    else {
11626                                            if (orderByComparator.isAscending() ^ previous) {
11627                                                    query.append(ORDER_BY_ASC);
11628                                            }
11629                                            else {
11630                                                    query.append(ORDER_BY_DESC);
11631                                            }
11632                                    }
11633                            }
11634                    }
11635                    else {
11636                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
11637                    }
11638    
11639                    String sql = query.toString();
11640    
11641                    Query q = session.createQuery(sql);
11642    
11643                    q.setFirstResult(0);
11644                    q.setMaxResults(2);
11645    
11646                    QueryPos qPos = QueryPos.getInstance(q);
11647    
11648                    qPos.add(groupId);
11649    
11650                    if (bindDisplayDate) {
11651                            qPos.add(new Timestamp(displayDate.getTime()));
11652                    }
11653    
11654                    qPos.add(status);
11655    
11656                    if (orderByComparator != null) {
11657                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
11658    
11659                            for (Object value : values) {
11660                                    qPos.add(value);
11661                            }
11662                    }
11663    
11664                    List<BlogsEntry> list = q.list();
11665    
11666                    if (list.size() == 2) {
11667                            return list.get(1);
11668                    }
11669                    else {
11670                            return null;
11671                    }
11672            }
11673    
11674            /**
11675             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
11676             *
11677             * @param groupId the group ID
11678             * @param displayDate the display date
11679             * @param status the status
11680             * @return the matching blogs entries that the user has permission to view
11681             */
11682            @Override
11683            public List<BlogsEntry> filterFindByG_LtD_S(long groupId, Date displayDate,
11684                    int status) {
11685                    return filterFindByG_LtD_S(groupId, displayDate, status,
11686                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
11687            }
11688    
11689            /**
11690             * 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;.
11691             *
11692             * <p>
11693             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11694             * </p>
11695             *
11696             * @param groupId the group ID
11697             * @param displayDate the display date
11698             * @param status the status
11699             * @param start the lower bound of the range of blogs entries
11700             * @param end the upper bound of the range of blogs entries (not inclusive)
11701             * @return the range of matching blogs entries that the user has permission to view
11702             */
11703            @Override
11704            public List<BlogsEntry> filterFindByG_LtD_S(long groupId, Date displayDate,
11705                    int status, int start, int end) {
11706                    return filterFindByG_LtD_S(groupId, displayDate, status, start, end,
11707                            null);
11708            }
11709    
11710            /**
11711             * 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;.
11712             *
11713             * <p>
11714             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11715             * </p>
11716             *
11717             * @param groupId the group ID
11718             * @param displayDate the display date
11719             * @param status the status
11720             * @param start the lower bound of the range of blogs entries
11721             * @param end the upper bound of the range of blogs entries (not inclusive)
11722             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11723             * @return the ordered range of matching blogs entries that the user has permission to view
11724             */
11725            @Override
11726            public List<BlogsEntry> filterFindByG_LtD_S(long groupId, Date displayDate,
11727                    int status, int start, int end,
11728                    OrderByComparator<BlogsEntry> orderByComparator) {
11729                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11730                            return findByG_LtD_S(groupId, displayDate, status, start, end,
11731                                    orderByComparator);
11732                    }
11733    
11734                    StringBundler query = null;
11735    
11736                    if (orderByComparator != null) {
11737                            query = new StringBundler(5 +
11738                                            (orderByComparator.getOrderByFields().length * 3));
11739                    }
11740                    else {
11741                            query = new StringBundler(5);
11742                    }
11743    
11744                    if (getDB().isSupportsInlineDistinct()) {
11745                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
11746                    }
11747                    else {
11748                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
11749                    }
11750    
11751                    query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
11752    
11753                    boolean bindDisplayDate = false;
11754    
11755                    if (displayDate == null) {
11756                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
11757                    }
11758                    else {
11759                            bindDisplayDate = true;
11760    
11761                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
11762                    }
11763    
11764                    query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
11765    
11766                    if (!getDB().isSupportsInlineDistinct()) {
11767                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
11768                    }
11769    
11770                    if (orderByComparator != null) {
11771                            if (getDB().isSupportsInlineDistinct()) {
11772                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11773                                            orderByComparator, true);
11774                            }
11775                            else {
11776                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
11777                                            orderByComparator, true);
11778                            }
11779                    }
11780                    else {
11781                            if (getDB().isSupportsInlineDistinct()) {
11782                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
11783                            }
11784                            else {
11785                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
11786                            }
11787                    }
11788    
11789                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11790                                    BlogsEntry.class.getName(),
11791                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11792    
11793                    Session session = null;
11794    
11795                    try {
11796                            session = openSession();
11797    
11798                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
11799    
11800                            if (getDB().isSupportsInlineDistinct()) {
11801                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
11802                            }
11803                            else {
11804                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
11805                            }
11806    
11807                            QueryPos qPos = QueryPos.getInstance(q);
11808    
11809                            qPos.add(groupId);
11810    
11811                            if (bindDisplayDate) {
11812                                    qPos.add(new Timestamp(displayDate.getTime()));
11813                            }
11814    
11815                            qPos.add(status);
11816    
11817                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
11818                    }
11819                    catch (Exception e) {
11820                            throw processException(e);
11821                    }
11822                    finally {
11823                            closeSession(session);
11824                    }
11825            }
11826    
11827            /**
11828             * 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;.
11829             *
11830             * @param entryId the primary key of the current blogs entry
11831             * @param groupId the group ID
11832             * @param displayDate the display date
11833             * @param status the status
11834             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11835             * @return the previous, current, and next blogs entry
11836             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
11837             */
11838            @Override
11839            public BlogsEntry[] filterFindByG_LtD_S_PrevAndNext(long entryId,
11840                    long groupId, Date displayDate, int status,
11841                    OrderByComparator<BlogsEntry> orderByComparator)
11842                    throws NoSuchEntryException {
11843                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11844                            return findByG_LtD_S_PrevAndNext(entryId, groupId, displayDate,
11845                                    status, orderByComparator);
11846                    }
11847    
11848                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
11849    
11850                    Session session = null;
11851    
11852                    try {
11853                            session = openSession();
11854    
11855                            BlogsEntry[] array = new BlogsEntryImpl[3];
11856    
11857                            array[0] = filterGetByG_LtD_S_PrevAndNext(session, blogsEntry,
11858                                            groupId, displayDate, status, orderByComparator, true);
11859    
11860                            array[1] = blogsEntry;
11861    
11862                            array[2] = filterGetByG_LtD_S_PrevAndNext(session, blogsEntry,
11863                                            groupId, displayDate, status, orderByComparator, false);
11864    
11865                            return array;
11866                    }
11867                    catch (Exception e) {
11868                            throw processException(e);
11869                    }
11870                    finally {
11871                            closeSession(session);
11872                    }
11873            }
11874    
11875            protected BlogsEntry filterGetByG_LtD_S_PrevAndNext(Session session,
11876                    BlogsEntry blogsEntry, long groupId, Date displayDate, int status,
11877                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
11878                    StringBundler query = null;
11879    
11880                    if (orderByComparator != null) {
11881                            query = new StringBundler(6 +
11882                                            (orderByComparator.getOrderByFields().length * 6));
11883                    }
11884                    else {
11885                            query = new StringBundler(3);
11886                    }
11887    
11888                    if (getDB().isSupportsInlineDistinct()) {
11889                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
11890                    }
11891                    else {
11892                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
11893                    }
11894    
11895                    query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
11896    
11897                    boolean bindDisplayDate = false;
11898    
11899                    if (displayDate == null) {
11900                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
11901                    }
11902                    else {
11903                            bindDisplayDate = true;
11904    
11905                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
11906                    }
11907    
11908                    query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
11909    
11910                    if (!getDB().isSupportsInlineDistinct()) {
11911                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
11912                    }
11913    
11914                    if (orderByComparator != null) {
11915                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11916    
11917                            if (orderByConditionFields.length > 0) {
11918                                    query.append(WHERE_AND);
11919                            }
11920    
11921                            for (int i = 0; i < orderByConditionFields.length; i++) {
11922                                    if (getDB().isSupportsInlineDistinct()) {
11923                                            query.append(_ORDER_BY_ENTITY_ALIAS);
11924                                    }
11925                                    else {
11926                                            query.append(_ORDER_BY_ENTITY_TABLE);
11927                                    }
11928    
11929                                    query.append(orderByConditionFields[i]);
11930    
11931                                    if ((i + 1) < orderByConditionFields.length) {
11932                                            if (orderByComparator.isAscending() ^ previous) {
11933                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
11934                                            }
11935                                            else {
11936                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
11937                                            }
11938                                    }
11939                                    else {
11940                                            if (orderByComparator.isAscending() ^ previous) {
11941                                                    query.append(WHERE_GREATER_THAN);
11942                                            }
11943                                            else {
11944                                                    query.append(WHERE_LESSER_THAN);
11945                                            }
11946                                    }
11947                            }
11948    
11949                            query.append(ORDER_BY_CLAUSE);
11950    
11951                            String[] orderByFields = orderByComparator.getOrderByFields();
11952    
11953                            for (int i = 0; i < orderByFields.length; i++) {
11954                                    if (getDB().isSupportsInlineDistinct()) {
11955                                            query.append(_ORDER_BY_ENTITY_ALIAS);
11956                                    }
11957                                    else {
11958                                            query.append(_ORDER_BY_ENTITY_TABLE);
11959                                    }
11960    
11961                                    query.append(orderByFields[i]);
11962    
11963                                    if ((i + 1) < orderByFields.length) {
11964                                            if (orderByComparator.isAscending() ^ previous) {
11965                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
11966                                            }
11967                                            else {
11968                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
11969                                            }
11970                                    }
11971                                    else {
11972                                            if (orderByComparator.isAscending() ^ previous) {
11973                                                    query.append(ORDER_BY_ASC);
11974                                            }
11975                                            else {
11976                                                    query.append(ORDER_BY_DESC);
11977                                            }
11978                                    }
11979                            }
11980                    }
11981                    else {
11982                            if (getDB().isSupportsInlineDistinct()) {
11983                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
11984                            }
11985                            else {
11986                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
11987                            }
11988                    }
11989    
11990                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11991                                    BlogsEntry.class.getName(),
11992                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
11993    
11994                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
11995    
11996                    q.setFirstResult(0);
11997                    q.setMaxResults(2);
11998    
11999                    if (getDB().isSupportsInlineDistinct()) {
12000                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
12001                    }
12002                    else {
12003                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
12004                    }
12005    
12006                    QueryPos qPos = QueryPos.getInstance(q);
12007    
12008                    qPos.add(groupId);
12009    
12010                    if (bindDisplayDate) {
12011                            qPos.add(new Timestamp(displayDate.getTime()));
12012                    }
12013    
12014                    qPos.add(status);
12015    
12016                    if (orderByComparator != null) {
12017                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
12018    
12019                            for (Object value : values) {
12020                                    qPos.add(value);
12021                            }
12022                    }
12023    
12024                    List<BlogsEntry> list = q.list();
12025    
12026                    if (list.size() == 2) {
12027                            return list.get(1);
12028                    }
12029                    else {
12030                            return null;
12031                    }
12032            }
12033    
12034            /**
12035             * Removes all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63; from the database.
12036             *
12037             * @param groupId the group ID
12038             * @param displayDate the display date
12039             * @param status the status
12040             */
12041            @Override
12042            public void removeByG_LtD_S(long groupId, Date displayDate, int status) {
12043                    for (BlogsEntry blogsEntry : findByG_LtD_S(groupId, displayDate,
12044                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
12045                            remove(blogsEntry);
12046                    }
12047            }
12048    
12049            /**
12050             * Returns the number of blogs entries where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
12051             *
12052             * @param groupId the group ID
12053             * @param displayDate the display date
12054             * @param status the status
12055             * @return the number of matching blogs entries
12056             */
12057            @Override
12058            public int countByG_LtD_S(long groupId, Date displayDate, int status) {
12059                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD_S;
12060    
12061                    Object[] finderArgs = new Object[] { groupId, displayDate, status };
12062    
12063                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
12064                                    this);
12065    
12066                    if (count == null) {
12067                            StringBundler query = new StringBundler(4);
12068    
12069                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
12070    
12071                            query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
12072    
12073                            boolean bindDisplayDate = false;
12074    
12075                            if (displayDate == null) {
12076                                    query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
12077                            }
12078                            else {
12079                                    bindDisplayDate = true;
12080    
12081                                    query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
12082                            }
12083    
12084                            query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
12085    
12086                            String sql = query.toString();
12087    
12088                            Session session = null;
12089    
12090                            try {
12091                                    session = openSession();
12092    
12093                                    Query q = session.createQuery(sql);
12094    
12095                                    QueryPos qPos = QueryPos.getInstance(q);
12096    
12097                                    qPos.add(groupId);
12098    
12099                                    if (bindDisplayDate) {
12100                                            qPos.add(new Timestamp(displayDate.getTime()));
12101                                    }
12102    
12103                                    qPos.add(status);
12104    
12105                                    count = (Long)q.uniqueResult();
12106    
12107                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
12108                            }
12109                            catch (Exception e) {
12110                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
12111    
12112                                    throw processException(e);
12113                            }
12114                            finally {
12115                                    closeSession(session);
12116                            }
12117                    }
12118    
12119                    return count.intValue();
12120            }
12121    
12122            /**
12123             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63; and status = &#63;.
12124             *
12125             * @param groupId the group ID
12126             * @param displayDate the display date
12127             * @param status the status
12128             * @return the number of matching blogs entries that the user has permission to view
12129             */
12130            @Override
12131            public int filterCountByG_LtD_S(long groupId, Date displayDate, int status) {
12132                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12133                            return countByG_LtD_S(groupId, displayDate, status);
12134                    }
12135    
12136                    StringBundler query = new StringBundler(4);
12137    
12138                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
12139    
12140                    query.append(_FINDER_COLUMN_G_LTD_S_GROUPID_2);
12141    
12142                    boolean bindDisplayDate = false;
12143    
12144                    if (displayDate == null) {
12145                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1);
12146                    }
12147                    else {
12148                            bindDisplayDate = true;
12149    
12150                            query.append(_FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2);
12151                    }
12152    
12153                    query.append(_FINDER_COLUMN_G_LTD_S_STATUS_2);
12154    
12155                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12156                                    BlogsEntry.class.getName(),
12157                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12158    
12159                    Session session = null;
12160    
12161                    try {
12162                            session = openSession();
12163    
12164                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
12165    
12166                            q.addScalar(COUNT_COLUMN_NAME,
12167                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
12168    
12169                            QueryPos qPos = QueryPos.getInstance(q);
12170    
12171                            qPos.add(groupId);
12172    
12173                            if (bindDisplayDate) {
12174                                    qPos.add(new Timestamp(displayDate.getTime()));
12175                            }
12176    
12177                            qPos.add(status);
12178    
12179                            Long count = (Long)q.uniqueResult();
12180    
12181                            return count.intValue();
12182                    }
12183                    catch (Exception e) {
12184                            throw processException(e);
12185                    }
12186                    finally {
12187                            closeSession(session);
12188                    }
12189            }
12190    
12191            private static final String _FINDER_COLUMN_G_LTD_S_GROUPID_2 = "blogsEntry.groupId = ? AND ";
12192            private static final String _FINDER_COLUMN_G_LTD_S_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL AND ";
12193            private static final String _FINDER_COLUMN_G_LTD_S_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
12194            private static final String _FINDER_COLUMN_G_LTD_S_STATUS_2 = "blogsEntry.status = ?";
12195            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD_NOTS =
12196                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
12197                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
12198                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_LtD_NotS",
12199                            new String[] {
12200                                    Long.class.getName(), Date.class.getName(),
12201                                    Integer.class.getName(),
12202                                    
12203                            Integer.class.getName(), Integer.class.getName(),
12204                                    OrderByComparator.class.getName()
12205                            });
12206            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD_NOTS =
12207                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
12208                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
12209                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_LtD_NotS",
12210                            new String[] {
12211                                    Long.class.getName(), Date.class.getName(),
12212                                    Integer.class.getName()
12213                            });
12214    
12215            /**
12216             * Returns all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
12217             *
12218             * @param groupId the group ID
12219             * @param displayDate the display date
12220             * @param status the status
12221             * @return the matching blogs entries
12222             */
12223            @Override
12224            public List<BlogsEntry> findByG_LtD_NotS(long groupId, Date displayDate,
12225                    int status) {
12226                    return findByG_LtD_NotS(groupId, displayDate, status,
12227                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
12228            }
12229    
12230            /**
12231             * Returns a range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
12232             *
12233             * <p>
12234             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
12235             * </p>
12236             *
12237             * @param groupId the group ID
12238             * @param displayDate the display date
12239             * @param status the status
12240             * @param start the lower bound of the range of blogs entries
12241             * @param end the upper bound of the range of blogs entries (not inclusive)
12242             * @return the range of matching blogs entries
12243             */
12244            @Override
12245            public List<BlogsEntry> findByG_LtD_NotS(long groupId, Date displayDate,
12246                    int status, int start, int end) {
12247                    return findByG_LtD_NotS(groupId, displayDate, status, start, end, null);
12248            }
12249    
12250            /**
12251             * Returns an ordered range of all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
12252             *
12253             * <p>
12254             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
12255             * </p>
12256             *
12257             * @param groupId the group ID
12258             * @param displayDate the display date
12259             * @param status the status
12260             * @param start the lower bound of the range of blogs entries
12261             * @param end the upper bound of the range of blogs entries (not inclusive)
12262             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12263             * @return the ordered range of matching blogs entries
12264             */
12265            @Override
12266            public List<BlogsEntry> findByG_LtD_NotS(long groupId, Date displayDate,
12267                    int status, int start, int end,
12268                    OrderByComparator<BlogsEntry> orderByComparator) {
12269                    boolean pagination = true;
12270                    FinderPath finderPath = null;
12271                    Object[] finderArgs = null;
12272    
12273                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LTD_NOTS;
12274                    finderArgs = new Object[] {
12275                                    groupId, displayDate, status,
12276                                    
12277                                    start, end, orderByComparator
12278                            };
12279    
12280                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
12281                                    finderArgs, this);
12282    
12283                    if ((list != null) && !list.isEmpty()) {
12284                            for (BlogsEntry blogsEntry : list) {
12285                                    if ((groupId != blogsEntry.getGroupId()) ||
12286                                                    (displayDate.getTime() <= blogsEntry.getDisplayDate()
12287                                                                                                                                    .getTime()) ||
12288                                                    (status == blogsEntry.getStatus())) {
12289                                            list = null;
12290    
12291                                            break;
12292                                    }
12293                            }
12294                    }
12295    
12296                    if (list == null) {
12297                            StringBundler query = null;
12298    
12299                            if (orderByComparator != null) {
12300                                    query = new StringBundler(5 +
12301                                                    (orderByComparator.getOrderByFields().length * 3));
12302                            }
12303                            else {
12304                                    query = new StringBundler(5);
12305                            }
12306    
12307                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
12308    
12309                            query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
12310    
12311                            boolean bindDisplayDate = false;
12312    
12313                            if (displayDate == null) {
12314                                    query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
12315                            }
12316                            else {
12317                                    bindDisplayDate = true;
12318    
12319                                    query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
12320                            }
12321    
12322                            query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
12323    
12324                            if (orderByComparator != null) {
12325                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12326                                            orderByComparator);
12327                            }
12328                            else
12329                             if (pagination) {
12330                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
12331                            }
12332    
12333                            String sql = query.toString();
12334    
12335                            Session session = null;
12336    
12337                            try {
12338                                    session = openSession();
12339    
12340                                    Query q = session.createQuery(sql);
12341    
12342                                    QueryPos qPos = QueryPos.getInstance(q);
12343    
12344                                    qPos.add(groupId);
12345    
12346                                    if (bindDisplayDate) {
12347                                            qPos.add(new Timestamp(displayDate.getTime()));
12348                                    }
12349    
12350                                    qPos.add(status);
12351    
12352                                    if (!pagination) {
12353                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
12354                                                            start, end, false);
12355    
12356                                            Collections.sort(list);
12357    
12358                                            list = Collections.unmodifiableList(list);
12359                                    }
12360                                    else {
12361                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
12362                                                            start, end);
12363                                    }
12364    
12365                                    cacheResult(list);
12366    
12367                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
12368                            }
12369                            catch (Exception e) {
12370                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
12371    
12372                                    throw processException(e);
12373                            }
12374                            finally {
12375                                    closeSession(session);
12376                            }
12377                    }
12378    
12379                    return list;
12380            }
12381    
12382            /**
12383             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
12384             *
12385             * @param groupId the group ID
12386             * @param displayDate the display date
12387             * @param status the status
12388             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12389             * @return the first matching blogs entry
12390             * @throws NoSuchEntryException if a matching blogs entry could not be found
12391             */
12392            @Override
12393            public BlogsEntry findByG_LtD_NotS_First(long groupId, Date displayDate,
12394                    int status, OrderByComparator<BlogsEntry> orderByComparator)
12395                    throws NoSuchEntryException {
12396                    BlogsEntry blogsEntry = fetchByG_LtD_NotS_First(groupId, displayDate,
12397                                    status, orderByComparator);
12398    
12399                    if (blogsEntry != null) {
12400                            return blogsEntry;
12401                    }
12402    
12403                    StringBundler msg = new StringBundler(8);
12404    
12405                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12406    
12407                    msg.append("groupId=");
12408                    msg.append(groupId);
12409    
12410                    msg.append(", displayDate=");
12411                    msg.append(displayDate);
12412    
12413                    msg.append(", status=");
12414                    msg.append(status);
12415    
12416                    msg.append(StringPool.CLOSE_CURLY_BRACE);
12417    
12418                    throw new NoSuchEntryException(msg.toString());
12419            }
12420    
12421            /**
12422             * Returns the first blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
12423             *
12424             * @param groupId the group ID
12425             * @param displayDate the display date
12426             * @param status the status
12427             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12428             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
12429             */
12430            @Override
12431            public BlogsEntry fetchByG_LtD_NotS_First(long groupId, Date displayDate,
12432                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
12433                    List<BlogsEntry> list = findByG_LtD_NotS(groupId, displayDate, status,
12434                                    0, 1, orderByComparator);
12435    
12436                    if (!list.isEmpty()) {
12437                            return list.get(0);
12438                    }
12439    
12440                    return null;
12441            }
12442    
12443            /**
12444             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
12445             *
12446             * @param groupId the group ID
12447             * @param displayDate the display date
12448             * @param status the status
12449             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12450             * @return the last matching blogs entry
12451             * @throws NoSuchEntryException if a matching blogs entry could not be found
12452             */
12453            @Override
12454            public BlogsEntry findByG_LtD_NotS_Last(long groupId, Date displayDate,
12455                    int status, OrderByComparator<BlogsEntry> orderByComparator)
12456                    throws NoSuchEntryException {
12457                    BlogsEntry blogsEntry = fetchByG_LtD_NotS_Last(groupId, displayDate,
12458                                    status, orderByComparator);
12459    
12460                    if (blogsEntry != null) {
12461                            return blogsEntry;
12462                    }
12463    
12464                    StringBundler msg = new StringBundler(8);
12465    
12466                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
12467    
12468                    msg.append("groupId=");
12469                    msg.append(groupId);
12470    
12471                    msg.append(", displayDate=");
12472                    msg.append(displayDate);
12473    
12474                    msg.append(", status=");
12475                    msg.append(status);
12476    
12477                    msg.append(StringPool.CLOSE_CURLY_BRACE);
12478    
12479                    throw new NoSuchEntryException(msg.toString());
12480            }
12481    
12482            /**
12483             * Returns the last blogs entry in the ordered set where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
12484             *
12485             * @param groupId the group ID
12486             * @param displayDate the display date
12487             * @param status the status
12488             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12489             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
12490             */
12491            @Override
12492            public BlogsEntry fetchByG_LtD_NotS_Last(long groupId, Date displayDate,
12493                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
12494                    int count = countByG_LtD_NotS(groupId, displayDate, status);
12495    
12496                    if (count == 0) {
12497                            return null;
12498                    }
12499    
12500                    List<BlogsEntry> list = findByG_LtD_NotS(groupId, displayDate, status,
12501                                    count - 1, count, orderByComparator);
12502    
12503                    if (!list.isEmpty()) {
12504                            return list.get(0);
12505                    }
12506    
12507                    return null;
12508            }
12509    
12510            /**
12511             * 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;.
12512             *
12513             * @param entryId the primary key of the current blogs entry
12514             * @param groupId the group ID
12515             * @param displayDate the display date
12516             * @param status the status
12517             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12518             * @return the previous, current, and next blogs entry
12519             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
12520             */
12521            @Override
12522            public BlogsEntry[] findByG_LtD_NotS_PrevAndNext(long entryId,
12523                    long groupId, Date displayDate, int status,
12524                    OrderByComparator<BlogsEntry> orderByComparator)
12525                    throws NoSuchEntryException {
12526                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
12527    
12528                    Session session = null;
12529    
12530                    try {
12531                            session = openSession();
12532    
12533                            BlogsEntry[] array = new BlogsEntryImpl[3];
12534    
12535                            array[0] = getByG_LtD_NotS_PrevAndNext(session, blogsEntry,
12536                                            groupId, displayDate, status, orderByComparator, true);
12537    
12538                            array[1] = blogsEntry;
12539    
12540                            array[2] = getByG_LtD_NotS_PrevAndNext(session, blogsEntry,
12541                                            groupId, displayDate, status, orderByComparator, false);
12542    
12543                            return array;
12544                    }
12545                    catch (Exception e) {
12546                            throw processException(e);
12547                    }
12548                    finally {
12549                            closeSession(session);
12550                    }
12551            }
12552    
12553            protected BlogsEntry getByG_LtD_NotS_PrevAndNext(Session session,
12554                    BlogsEntry blogsEntry, long groupId, Date displayDate, int status,
12555                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
12556                    StringBundler query = null;
12557    
12558                    if (orderByComparator != null) {
12559                            query = new StringBundler(6 +
12560                                            (orderByComparator.getOrderByFields().length * 6));
12561                    }
12562                    else {
12563                            query = new StringBundler(3);
12564                    }
12565    
12566                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
12567    
12568                    query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
12569    
12570                    boolean bindDisplayDate = false;
12571    
12572                    if (displayDate == null) {
12573                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
12574                    }
12575                    else {
12576                            bindDisplayDate = true;
12577    
12578                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
12579                    }
12580    
12581                    query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
12582    
12583                    if (orderByComparator != null) {
12584                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
12585    
12586                            if (orderByConditionFields.length > 0) {
12587                                    query.append(WHERE_AND);
12588                            }
12589    
12590                            for (int i = 0; i < orderByConditionFields.length; i++) {
12591                                    query.append(_ORDER_BY_ENTITY_ALIAS);
12592                                    query.append(orderByConditionFields[i]);
12593    
12594                                    if ((i + 1) < orderByConditionFields.length) {
12595                                            if (orderByComparator.isAscending() ^ previous) {
12596                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
12597                                            }
12598                                            else {
12599                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
12600                                            }
12601                                    }
12602                                    else {
12603                                            if (orderByComparator.isAscending() ^ previous) {
12604                                                    query.append(WHERE_GREATER_THAN);
12605                                            }
12606                                            else {
12607                                                    query.append(WHERE_LESSER_THAN);
12608                                            }
12609                                    }
12610                            }
12611    
12612                            query.append(ORDER_BY_CLAUSE);
12613    
12614                            String[] orderByFields = orderByComparator.getOrderByFields();
12615    
12616                            for (int i = 0; i < orderByFields.length; i++) {
12617                                    query.append(_ORDER_BY_ENTITY_ALIAS);
12618                                    query.append(orderByFields[i]);
12619    
12620                                    if ((i + 1) < orderByFields.length) {
12621                                            if (orderByComparator.isAscending() ^ previous) {
12622                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
12623                                            }
12624                                            else {
12625                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
12626                                            }
12627                                    }
12628                                    else {
12629                                            if (orderByComparator.isAscending() ^ previous) {
12630                                                    query.append(ORDER_BY_ASC);
12631                                            }
12632                                            else {
12633                                                    query.append(ORDER_BY_DESC);
12634                                            }
12635                                    }
12636                            }
12637                    }
12638                    else {
12639                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
12640                    }
12641    
12642                    String sql = query.toString();
12643    
12644                    Query q = session.createQuery(sql);
12645    
12646                    q.setFirstResult(0);
12647                    q.setMaxResults(2);
12648    
12649                    QueryPos qPos = QueryPos.getInstance(q);
12650    
12651                    qPos.add(groupId);
12652    
12653                    if (bindDisplayDate) {
12654                            qPos.add(new Timestamp(displayDate.getTime()));
12655                    }
12656    
12657                    qPos.add(status);
12658    
12659                    if (orderByComparator != null) {
12660                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
12661    
12662                            for (Object value : values) {
12663                                    qPos.add(value);
12664                            }
12665                    }
12666    
12667                    List<BlogsEntry> list = q.list();
12668    
12669                    if (list.size() == 2) {
12670                            return list.get(1);
12671                    }
12672                    else {
12673                            return null;
12674                    }
12675            }
12676    
12677            /**
12678             * Returns all the blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
12679             *
12680             * @param groupId the group ID
12681             * @param displayDate the display date
12682             * @param status the status
12683             * @return the matching blogs entries that the user has permission to view
12684             */
12685            @Override
12686            public List<BlogsEntry> filterFindByG_LtD_NotS(long groupId,
12687                    Date displayDate, int status) {
12688                    return filterFindByG_LtD_NotS(groupId, displayDate, status,
12689                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
12690            }
12691    
12692            /**
12693             * 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;.
12694             *
12695             * <p>
12696             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
12697             * </p>
12698             *
12699             * @param groupId the group ID
12700             * @param displayDate the display date
12701             * @param status the status
12702             * @param start the lower bound of the range of blogs entries
12703             * @param end the upper bound of the range of blogs entries (not inclusive)
12704             * @return the range of matching blogs entries that the user has permission to view
12705             */
12706            @Override
12707            public List<BlogsEntry> filterFindByG_LtD_NotS(long groupId,
12708                    Date displayDate, int status, int start, int end) {
12709                    return filterFindByG_LtD_NotS(groupId, displayDate, status, start, end,
12710                            null);
12711            }
12712    
12713            /**
12714             * 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;.
12715             *
12716             * <p>
12717             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
12718             * </p>
12719             *
12720             * @param groupId the group ID
12721             * @param displayDate the display date
12722             * @param status the status
12723             * @param start the lower bound of the range of blogs entries
12724             * @param end the upper bound of the range of blogs entries (not inclusive)
12725             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12726             * @return the ordered range of matching blogs entries that the user has permission to view
12727             */
12728            @Override
12729            public List<BlogsEntry> filterFindByG_LtD_NotS(long groupId,
12730                    Date displayDate, int status, int start, int end,
12731                    OrderByComparator<BlogsEntry> orderByComparator) {
12732                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12733                            return findByG_LtD_NotS(groupId, displayDate, status, start, end,
12734                                    orderByComparator);
12735                    }
12736    
12737                    StringBundler query = null;
12738    
12739                    if (orderByComparator != null) {
12740                            query = new StringBundler(5 +
12741                                            (orderByComparator.getOrderByFields().length * 3));
12742                    }
12743                    else {
12744                            query = new StringBundler(5);
12745                    }
12746    
12747                    if (getDB().isSupportsInlineDistinct()) {
12748                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
12749                    }
12750                    else {
12751                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
12752                    }
12753    
12754                    query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
12755    
12756                    boolean bindDisplayDate = false;
12757    
12758                    if (displayDate == null) {
12759                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
12760                    }
12761                    else {
12762                            bindDisplayDate = true;
12763    
12764                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
12765                    }
12766    
12767                    query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
12768    
12769                    if (!getDB().isSupportsInlineDistinct()) {
12770                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
12771                    }
12772    
12773                    if (orderByComparator != null) {
12774                            if (getDB().isSupportsInlineDistinct()) {
12775                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12776                                            orderByComparator, true);
12777                            }
12778                            else {
12779                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
12780                                            orderByComparator, true);
12781                            }
12782                    }
12783                    else {
12784                            if (getDB().isSupportsInlineDistinct()) {
12785                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
12786                            }
12787                            else {
12788                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
12789                            }
12790                    }
12791    
12792                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12793                                    BlogsEntry.class.getName(),
12794                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12795    
12796                    Session session = null;
12797    
12798                    try {
12799                            session = openSession();
12800    
12801                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
12802    
12803                            if (getDB().isSupportsInlineDistinct()) {
12804                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
12805                            }
12806                            else {
12807                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
12808                            }
12809    
12810                            QueryPos qPos = QueryPos.getInstance(q);
12811    
12812                            qPos.add(groupId);
12813    
12814                            if (bindDisplayDate) {
12815                                    qPos.add(new Timestamp(displayDate.getTime()));
12816                            }
12817    
12818                            qPos.add(status);
12819    
12820                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
12821                    }
12822                    catch (Exception e) {
12823                            throw processException(e);
12824                    }
12825                    finally {
12826                            closeSession(session);
12827                    }
12828            }
12829    
12830            /**
12831             * 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;.
12832             *
12833             * @param entryId the primary key of the current blogs entry
12834             * @param groupId the group ID
12835             * @param displayDate the display date
12836             * @param status the status
12837             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
12838             * @return the previous, current, and next blogs entry
12839             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
12840             */
12841            @Override
12842            public BlogsEntry[] filterFindByG_LtD_NotS_PrevAndNext(long entryId,
12843                    long groupId, Date displayDate, int status,
12844                    OrderByComparator<BlogsEntry> orderByComparator)
12845                    throws NoSuchEntryException {
12846                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12847                            return findByG_LtD_NotS_PrevAndNext(entryId, groupId, displayDate,
12848                                    status, orderByComparator);
12849                    }
12850    
12851                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
12852    
12853                    Session session = null;
12854    
12855                    try {
12856                            session = openSession();
12857    
12858                            BlogsEntry[] array = new BlogsEntryImpl[3];
12859    
12860                            array[0] = filterGetByG_LtD_NotS_PrevAndNext(session, blogsEntry,
12861                                            groupId, displayDate, status, orderByComparator, true);
12862    
12863                            array[1] = blogsEntry;
12864    
12865                            array[2] = filterGetByG_LtD_NotS_PrevAndNext(session, blogsEntry,
12866                                            groupId, displayDate, status, orderByComparator, false);
12867    
12868                            return array;
12869                    }
12870                    catch (Exception e) {
12871                            throw processException(e);
12872                    }
12873                    finally {
12874                            closeSession(session);
12875                    }
12876            }
12877    
12878            protected BlogsEntry filterGetByG_LtD_NotS_PrevAndNext(Session session,
12879                    BlogsEntry blogsEntry, long groupId, Date displayDate, int status,
12880                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
12881                    StringBundler query = null;
12882    
12883                    if (orderByComparator != null) {
12884                            query = new StringBundler(6 +
12885                                            (orderByComparator.getOrderByFields().length * 6));
12886                    }
12887                    else {
12888                            query = new StringBundler(3);
12889                    }
12890    
12891                    if (getDB().isSupportsInlineDistinct()) {
12892                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
12893                    }
12894                    else {
12895                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
12896                    }
12897    
12898                    query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
12899    
12900                    boolean bindDisplayDate = false;
12901    
12902                    if (displayDate == null) {
12903                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
12904                    }
12905                    else {
12906                            bindDisplayDate = true;
12907    
12908                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
12909                    }
12910    
12911                    query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
12912    
12913                    if (!getDB().isSupportsInlineDistinct()) {
12914                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
12915                    }
12916    
12917                    if (orderByComparator != null) {
12918                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
12919    
12920                            if (orderByConditionFields.length > 0) {
12921                                    query.append(WHERE_AND);
12922                            }
12923    
12924                            for (int i = 0; i < orderByConditionFields.length; i++) {
12925                                    if (getDB().isSupportsInlineDistinct()) {
12926                                            query.append(_ORDER_BY_ENTITY_ALIAS);
12927                                    }
12928                                    else {
12929                                            query.append(_ORDER_BY_ENTITY_TABLE);
12930                                    }
12931    
12932                                    query.append(orderByConditionFields[i]);
12933    
12934                                    if ((i + 1) < orderByConditionFields.length) {
12935                                            if (orderByComparator.isAscending() ^ previous) {
12936                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
12937                                            }
12938                                            else {
12939                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
12940                                            }
12941                                    }
12942                                    else {
12943                                            if (orderByComparator.isAscending() ^ previous) {
12944                                                    query.append(WHERE_GREATER_THAN);
12945                                            }
12946                                            else {
12947                                                    query.append(WHERE_LESSER_THAN);
12948                                            }
12949                                    }
12950                            }
12951    
12952                            query.append(ORDER_BY_CLAUSE);
12953    
12954                            String[] orderByFields = orderByComparator.getOrderByFields();
12955    
12956                            for (int i = 0; i < orderByFields.length; i++) {
12957                                    if (getDB().isSupportsInlineDistinct()) {
12958                                            query.append(_ORDER_BY_ENTITY_ALIAS);
12959                                    }
12960                                    else {
12961                                            query.append(_ORDER_BY_ENTITY_TABLE);
12962                                    }
12963    
12964                                    query.append(orderByFields[i]);
12965    
12966                                    if ((i + 1) < orderByFields.length) {
12967                                            if (orderByComparator.isAscending() ^ previous) {
12968                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
12969                                            }
12970                                            else {
12971                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
12972                                            }
12973                                    }
12974                                    else {
12975                                            if (orderByComparator.isAscending() ^ previous) {
12976                                                    query.append(ORDER_BY_ASC);
12977                                            }
12978                                            else {
12979                                                    query.append(ORDER_BY_DESC);
12980                                            }
12981                                    }
12982                            }
12983                    }
12984                    else {
12985                            if (getDB().isSupportsInlineDistinct()) {
12986                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
12987                            }
12988                            else {
12989                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
12990                            }
12991                    }
12992    
12993                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12994                                    BlogsEntry.class.getName(),
12995                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
12996    
12997                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
12998    
12999                    q.setFirstResult(0);
13000                    q.setMaxResults(2);
13001    
13002                    if (getDB().isSupportsInlineDistinct()) {
13003                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
13004                    }
13005                    else {
13006                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
13007                    }
13008    
13009                    QueryPos qPos = QueryPos.getInstance(q);
13010    
13011                    qPos.add(groupId);
13012    
13013                    if (bindDisplayDate) {
13014                            qPos.add(new Timestamp(displayDate.getTime()));
13015                    }
13016    
13017                    qPos.add(status);
13018    
13019                    if (orderByComparator != null) {
13020                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
13021    
13022                            for (Object value : values) {
13023                                    qPos.add(value);
13024                            }
13025                    }
13026    
13027                    List<BlogsEntry> list = q.list();
13028    
13029                    if (list.size() == 2) {
13030                            return list.get(1);
13031                    }
13032                    else {
13033                            return null;
13034                    }
13035            }
13036    
13037            /**
13038             * Removes all the blogs entries where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63; from the database.
13039             *
13040             * @param groupId the group ID
13041             * @param displayDate the display date
13042             * @param status the status
13043             */
13044            @Override
13045            public void removeByG_LtD_NotS(long groupId, Date displayDate, int status) {
13046                    for (BlogsEntry blogsEntry : findByG_LtD_NotS(groupId, displayDate,
13047                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
13048                            remove(blogsEntry);
13049                    }
13050            }
13051    
13052            /**
13053             * Returns the number of blogs entries where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13054             *
13055             * @param groupId the group ID
13056             * @param displayDate the display date
13057             * @param status the status
13058             * @return the number of matching blogs entries
13059             */
13060            @Override
13061            public int countByG_LtD_NotS(long groupId, Date displayDate, int status) {
13062                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LTD_NOTS;
13063    
13064                    Object[] finderArgs = new Object[] { groupId, displayDate, status };
13065    
13066                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
13067                                    this);
13068    
13069                    if (count == null) {
13070                            StringBundler query = new StringBundler(4);
13071    
13072                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
13073    
13074                            query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
13075    
13076                            boolean bindDisplayDate = false;
13077    
13078                            if (displayDate == null) {
13079                                    query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
13080                            }
13081                            else {
13082                                    bindDisplayDate = true;
13083    
13084                                    query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
13085                            }
13086    
13087                            query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
13088    
13089                            String sql = query.toString();
13090    
13091                            Session session = null;
13092    
13093                            try {
13094                                    session = openSession();
13095    
13096                                    Query q = session.createQuery(sql);
13097    
13098                                    QueryPos qPos = QueryPos.getInstance(q);
13099    
13100                                    qPos.add(groupId);
13101    
13102                                    if (bindDisplayDate) {
13103                                            qPos.add(new Timestamp(displayDate.getTime()));
13104                                    }
13105    
13106                                    qPos.add(status);
13107    
13108                                    count = (Long)q.uniqueResult();
13109    
13110                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
13111                            }
13112                            catch (Exception e) {
13113                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
13114    
13115                                    throw processException(e);
13116                            }
13117                            finally {
13118                                    closeSession(session);
13119                            }
13120                    }
13121    
13122                    return count.intValue();
13123            }
13124    
13125            /**
13126             * Returns the number of blogs entries that the user has permission to view where groupId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
13127             *
13128             * @param groupId the group ID
13129             * @param displayDate the display date
13130             * @param status the status
13131             * @return the number of matching blogs entries that the user has permission to view
13132             */
13133            @Override
13134            public int filterCountByG_LtD_NotS(long groupId, Date displayDate,
13135                    int status) {
13136                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
13137                            return countByG_LtD_NotS(groupId, displayDate, status);
13138                    }
13139    
13140                    StringBundler query = new StringBundler(4);
13141    
13142                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
13143    
13144                    query.append(_FINDER_COLUMN_G_LTD_NOTS_GROUPID_2);
13145    
13146                    boolean bindDisplayDate = false;
13147    
13148                    if (displayDate == null) {
13149                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1);
13150                    }
13151                    else {
13152                            bindDisplayDate = true;
13153    
13154                            query.append(_FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2);
13155                    }
13156    
13157                    query.append(_FINDER_COLUMN_G_LTD_NOTS_STATUS_2);
13158    
13159                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
13160                                    BlogsEntry.class.getName(),
13161                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
13162    
13163                    Session session = null;
13164    
13165                    try {
13166                            session = openSession();
13167    
13168                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
13169    
13170                            q.addScalar(COUNT_COLUMN_NAME,
13171                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
13172    
13173                            QueryPos qPos = QueryPos.getInstance(q);
13174    
13175                            qPos.add(groupId);
13176    
13177                            if (bindDisplayDate) {
13178                                    qPos.add(new Timestamp(displayDate.getTime()));
13179                            }
13180    
13181                            qPos.add(status);
13182    
13183                            Long count = (Long)q.uniqueResult();
13184    
13185                            return count.intValue();
13186                    }
13187                    catch (Exception e) {
13188                            throw processException(e);
13189                    }
13190                    finally {
13191                            closeSession(session);
13192                    }
13193            }
13194    
13195            private static final String _FINDER_COLUMN_G_LTD_NOTS_GROUPID_2 = "blogsEntry.groupId = ? AND ";
13196            private static final String _FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL AND ";
13197            private static final String _FINDER_COLUMN_G_LTD_NOTS_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
13198            private static final String _FINDER_COLUMN_G_LTD_NOTS_STATUS_2 = "blogsEntry.status != ?";
13199            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
13200                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
13201                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_U_S",
13202                            new String[] {
13203                                    Long.class.getName(), Long.class.getName(),
13204                                    Integer.class.getName(),
13205                                    
13206                            Integer.class.getName(), Integer.class.getName(),
13207                                    OrderByComparator.class.getName()
13208                            });
13209            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
13210                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
13211                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_U_S",
13212                            new String[] {
13213                                    Long.class.getName(), Long.class.getName(),
13214                                    Integer.class.getName()
13215                            },
13216                            BlogsEntryModelImpl.COMPANYID_COLUMN_BITMASK |
13217                            BlogsEntryModelImpl.USERID_COLUMN_BITMASK |
13218                            BlogsEntryModelImpl.STATUS_COLUMN_BITMASK |
13219                            BlogsEntryModelImpl.DISPLAYDATE_COLUMN_BITMASK |
13220                            BlogsEntryModelImpl.CREATEDATE_COLUMN_BITMASK);
13221            public static final FinderPath FINDER_PATH_COUNT_BY_C_U_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
13222                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
13223                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_U_S",
13224                            new String[] {
13225                                    Long.class.getName(), Long.class.getName(),
13226                                    Integer.class.getName()
13227                            });
13228    
13229            /**
13230             * Returns all the blogs entries where companyId = &#63; and userId = &#63; and status = &#63;.
13231             *
13232             * @param companyId the company ID
13233             * @param userId the user ID
13234             * @param status the status
13235             * @return the matching blogs entries
13236             */
13237            @Override
13238            public List<BlogsEntry> findByC_U_S(long companyId, long userId, int status) {
13239                    return findByC_U_S(companyId, userId, status, QueryUtil.ALL_POS,
13240                            QueryUtil.ALL_POS, null);
13241            }
13242    
13243            /**
13244             * Returns a range of all the blogs entries where companyId = &#63; and userId = &#63; and status = &#63;.
13245             *
13246             * <p>
13247             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
13248             * </p>
13249             *
13250             * @param companyId the company ID
13251             * @param userId the user ID
13252             * @param status the status
13253             * @param start the lower bound of the range of blogs entries
13254             * @param end the upper bound of the range of blogs entries (not inclusive)
13255             * @return the range of matching blogs entries
13256             */
13257            @Override
13258            public List<BlogsEntry> findByC_U_S(long companyId, long userId,
13259                    int status, int start, int end) {
13260                    return findByC_U_S(companyId, userId, status, start, end, null);
13261            }
13262    
13263            /**
13264             * Returns an ordered range of all the blogs entries where companyId = &#63; and userId = &#63; and status = &#63;.
13265             *
13266             * <p>
13267             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
13268             * </p>
13269             *
13270             * @param companyId the company ID
13271             * @param userId the user ID
13272             * @param status the status
13273             * @param start the lower bound of the range of blogs entries
13274             * @param end the upper bound of the range of blogs entries (not inclusive)
13275             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13276             * @return the ordered range of matching blogs entries
13277             */
13278            @Override
13279            public List<BlogsEntry> findByC_U_S(long companyId, long userId,
13280                    int status, int start, int end,
13281                    OrderByComparator<BlogsEntry> orderByComparator) {
13282                    boolean pagination = true;
13283                    FinderPath finderPath = null;
13284                    Object[] finderArgs = null;
13285    
13286                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
13287                                    (orderByComparator == null)) {
13288                            pagination = false;
13289                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U_S;
13290                            finderArgs = new Object[] { companyId, userId, status };
13291                    }
13292                    else {
13293                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U_S;
13294                            finderArgs = new Object[] {
13295                                            companyId, userId, status,
13296                                            
13297                                            start, end, orderByComparator
13298                                    };
13299                    }
13300    
13301                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
13302                                    finderArgs, this);
13303    
13304                    if ((list != null) && !list.isEmpty()) {
13305                            for (BlogsEntry blogsEntry : list) {
13306                                    if ((companyId != blogsEntry.getCompanyId()) ||
13307                                                    (userId != blogsEntry.getUserId()) ||
13308                                                    (status != blogsEntry.getStatus())) {
13309                                            list = null;
13310    
13311                                            break;
13312                                    }
13313                            }
13314                    }
13315    
13316                    if (list == null) {
13317                            StringBundler query = null;
13318    
13319                            if (orderByComparator != null) {
13320                                    query = new StringBundler(5 +
13321                                                    (orderByComparator.getOrderByFields().length * 3));
13322                            }
13323                            else {
13324                                    query = new StringBundler(5);
13325                            }
13326    
13327                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
13328    
13329                            query.append(_FINDER_COLUMN_C_U_S_COMPANYID_2);
13330    
13331                            query.append(_FINDER_COLUMN_C_U_S_USERID_2);
13332    
13333                            query.append(_FINDER_COLUMN_C_U_S_STATUS_2);
13334    
13335                            if (orderByComparator != null) {
13336                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13337                                            orderByComparator);
13338                            }
13339                            else
13340                             if (pagination) {
13341                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
13342                            }
13343    
13344                            String sql = query.toString();
13345    
13346                            Session session = null;
13347    
13348                            try {
13349                                    session = openSession();
13350    
13351                                    Query q = session.createQuery(sql);
13352    
13353                                    QueryPos qPos = QueryPos.getInstance(q);
13354    
13355                                    qPos.add(companyId);
13356    
13357                                    qPos.add(userId);
13358    
13359                                    qPos.add(status);
13360    
13361                                    if (!pagination) {
13362                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
13363                                                            start, end, false);
13364    
13365                                            Collections.sort(list);
13366    
13367                                            list = Collections.unmodifiableList(list);
13368                                    }
13369                                    else {
13370                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
13371                                                            start, end);
13372                                    }
13373    
13374                                    cacheResult(list);
13375    
13376                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
13377                            }
13378                            catch (Exception e) {
13379                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
13380    
13381                                    throw processException(e);
13382                            }
13383                            finally {
13384                                    closeSession(session);
13385                            }
13386                    }
13387    
13388                    return list;
13389            }
13390    
13391            /**
13392             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status = &#63;.
13393             *
13394             * @param companyId the company ID
13395             * @param userId the user ID
13396             * @param status the status
13397             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13398             * @return the first matching blogs entry
13399             * @throws NoSuchEntryException if a matching blogs entry could not be found
13400             */
13401            @Override
13402            public BlogsEntry findByC_U_S_First(long companyId, long userId,
13403                    int status, OrderByComparator<BlogsEntry> orderByComparator)
13404                    throws NoSuchEntryException {
13405                    BlogsEntry blogsEntry = fetchByC_U_S_First(companyId, userId, status,
13406                                    orderByComparator);
13407    
13408                    if (blogsEntry != null) {
13409                            return blogsEntry;
13410                    }
13411    
13412                    StringBundler msg = new StringBundler(8);
13413    
13414                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13415    
13416                    msg.append("companyId=");
13417                    msg.append(companyId);
13418    
13419                    msg.append(", userId=");
13420                    msg.append(userId);
13421    
13422                    msg.append(", status=");
13423                    msg.append(status);
13424    
13425                    msg.append(StringPool.CLOSE_CURLY_BRACE);
13426    
13427                    throw new NoSuchEntryException(msg.toString());
13428            }
13429    
13430            /**
13431             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status = &#63;.
13432             *
13433             * @param companyId the company ID
13434             * @param userId the user ID
13435             * @param status the status
13436             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13437             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
13438             */
13439            @Override
13440            public BlogsEntry fetchByC_U_S_First(long companyId, long userId,
13441                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
13442                    List<BlogsEntry> list = findByC_U_S(companyId, userId, status, 0, 1,
13443                                    orderByComparator);
13444    
13445                    if (!list.isEmpty()) {
13446                            return list.get(0);
13447                    }
13448    
13449                    return null;
13450            }
13451    
13452            /**
13453             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status = &#63;.
13454             *
13455             * @param companyId the company ID
13456             * @param userId the user ID
13457             * @param status the status
13458             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13459             * @return the last matching blogs entry
13460             * @throws NoSuchEntryException if a matching blogs entry could not be found
13461             */
13462            @Override
13463            public BlogsEntry findByC_U_S_Last(long companyId, long userId, int status,
13464                    OrderByComparator<BlogsEntry> orderByComparator)
13465                    throws NoSuchEntryException {
13466                    BlogsEntry blogsEntry = fetchByC_U_S_Last(companyId, userId, status,
13467                                    orderByComparator);
13468    
13469                    if (blogsEntry != null) {
13470                            return blogsEntry;
13471                    }
13472    
13473                    StringBundler msg = new StringBundler(8);
13474    
13475                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13476    
13477                    msg.append("companyId=");
13478                    msg.append(companyId);
13479    
13480                    msg.append(", userId=");
13481                    msg.append(userId);
13482    
13483                    msg.append(", status=");
13484                    msg.append(status);
13485    
13486                    msg.append(StringPool.CLOSE_CURLY_BRACE);
13487    
13488                    throw new NoSuchEntryException(msg.toString());
13489            }
13490    
13491            /**
13492             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status = &#63;.
13493             *
13494             * @param companyId the company ID
13495             * @param userId the user ID
13496             * @param status the status
13497             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13498             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
13499             */
13500            @Override
13501            public BlogsEntry fetchByC_U_S_Last(long companyId, long userId,
13502                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
13503                    int count = countByC_U_S(companyId, userId, status);
13504    
13505                    if (count == 0) {
13506                            return null;
13507                    }
13508    
13509                    List<BlogsEntry> list = findByC_U_S(companyId, userId, status,
13510                                    count - 1, count, orderByComparator);
13511    
13512                    if (!list.isEmpty()) {
13513                            return list.get(0);
13514                    }
13515    
13516                    return null;
13517            }
13518    
13519            /**
13520             * Returns the blogs entries before and after the current blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status = &#63;.
13521             *
13522             * @param entryId the primary key of the current blogs entry
13523             * @param companyId the company ID
13524             * @param userId the user ID
13525             * @param status the status
13526             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13527             * @return the previous, current, and next blogs entry
13528             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
13529             */
13530            @Override
13531            public BlogsEntry[] findByC_U_S_PrevAndNext(long entryId, long companyId,
13532                    long userId, int status, OrderByComparator<BlogsEntry> orderByComparator)
13533                    throws NoSuchEntryException {
13534                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
13535    
13536                    Session session = null;
13537    
13538                    try {
13539                            session = openSession();
13540    
13541                            BlogsEntry[] array = new BlogsEntryImpl[3];
13542    
13543                            array[0] = getByC_U_S_PrevAndNext(session, blogsEntry, companyId,
13544                                            userId, status, orderByComparator, true);
13545    
13546                            array[1] = blogsEntry;
13547    
13548                            array[2] = getByC_U_S_PrevAndNext(session, blogsEntry, companyId,
13549                                            userId, status, orderByComparator, false);
13550    
13551                            return array;
13552                    }
13553                    catch (Exception e) {
13554                            throw processException(e);
13555                    }
13556                    finally {
13557                            closeSession(session);
13558                    }
13559            }
13560    
13561            protected BlogsEntry getByC_U_S_PrevAndNext(Session session,
13562                    BlogsEntry blogsEntry, long companyId, long userId, int status,
13563                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
13564                    StringBundler query = null;
13565    
13566                    if (orderByComparator != null) {
13567                            query = new StringBundler(6 +
13568                                            (orderByComparator.getOrderByFields().length * 6));
13569                    }
13570                    else {
13571                            query = new StringBundler(3);
13572                    }
13573    
13574                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
13575    
13576                    query.append(_FINDER_COLUMN_C_U_S_COMPANYID_2);
13577    
13578                    query.append(_FINDER_COLUMN_C_U_S_USERID_2);
13579    
13580                    query.append(_FINDER_COLUMN_C_U_S_STATUS_2);
13581    
13582                    if (orderByComparator != null) {
13583                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
13584    
13585                            if (orderByConditionFields.length > 0) {
13586                                    query.append(WHERE_AND);
13587                            }
13588    
13589                            for (int i = 0; i < orderByConditionFields.length; i++) {
13590                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13591                                    query.append(orderByConditionFields[i]);
13592    
13593                                    if ((i + 1) < orderByConditionFields.length) {
13594                                            if (orderByComparator.isAscending() ^ previous) {
13595                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
13596                                            }
13597                                            else {
13598                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
13599                                            }
13600                                    }
13601                                    else {
13602                                            if (orderByComparator.isAscending() ^ previous) {
13603                                                    query.append(WHERE_GREATER_THAN);
13604                                            }
13605                                            else {
13606                                                    query.append(WHERE_LESSER_THAN);
13607                                            }
13608                                    }
13609                            }
13610    
13611                            query.append(ORDER_BY_CLAUSE);
13612    
13613                            String[] orderByFields = orderByComparator.getOrderByFields();
13614    
13615                            for (int i = 0; i < orderByFields.length; i++) {
13616                                    query.append(_ORDER_BY_ENTITY_ALIAS);
13617                                    query.append(orderByFields[i]);
13618    
13619                                    if ((i + 1) < orderByFields.length) {
13620                                            if (orderByComparator.isAscending() ^ previous) {
13621                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
13622                                            }
13623                                            else {
13624                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
13625                                            }
13626                                    }
13627                                    else {
13628                                            if (orderByComparator.isAscending() ^ previous) {
13629                                                    query.append(ORDER_BY_ASC);
13630                                            }
13631                                            else {
13632                                                    query.append(ORDER_BY_DESC);
13633                                            }
13634                                    }
13635                            }
13636                    }
13637                    else {
13638                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
13639                    }
13640    
13641                    String sql = query.toString();
13642    
13643                    Query q = session.createQuery(sql);
13644    
13645                    q.setFirstResult(0);
13646                    q.setMaxResults(2);
13647    
13648                    QueryPos qPos = QueryPos.getInstance(q);
13649    
13650                    qPos.add(companyId);
13651    
13652                    qPos.add(userId);
13653    
13654                    qPos.add(status);
13655    
13656                    if (orderByComparator != null) {
13657                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
13658    
13659                            for (Object value : values) {
13660                                    qPos.add(value);
13661                            }
13662                    }
13663    
13664                    List<BlogsEntry> list = q.list();
13665    
13666                    if (list.size() == 2) {
13667                            return list.get(1);
13668                    }
13669                    else {
13670                            return null;
13671                    }
13672            }
13673    
13674            /**
13675             * Removes all the blogs entries where companyId = &#63; and userId = &#63; and status = &#63; from the database.
13676             *
13677             * @param companyId the company ID
13678             * @param userId the user ID
13679             * @param status the status
13680             */
13681            @Override
13682            public void removeByC_U_S(long companyId, long userId, int status) {
13683                    for (BlogsEntry blogsEntry : findByC_U_S(companyId, userId, status,
13684                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
13685                            remove(blogsEntry);
13686                    }
13687            }
13688    
13689            /**
13690             * Returns the number of blogs entries where companyId = &#63; and userId = &#63; and status = &#63;.
13691             *
13692             * @param companyId the company ID
13693             * @param userId the user ID
13694             * @param status the status
13695             * @return the number of matching blogs entries
13696             */
13697            @Override
13698            public int countByC_U_S(long companyId, long userId, int status) {
13699                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_U_S;
13700    
13701                    Object[] finderArgs = new Object[] { companyId, userId, status };
13702    
13703                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
13704                                    this);
13705    
13706                    if (count == null) {
13707                            StringBundler query = new StringBundler(4);
13708    
13709                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
13710    
13711                            query.append(_FINDER_COLUMN_C_U_S_COMPANYID_2);
13712    
13713                            query.append(_FINDER_COLUMN_C_U_S_USERID_2);
13714    
13715                            query.append(_FINDER_COLUMN_C_U_S_STATUS_2);
13716    
13717                            String sql = query.toString();
13718    
13719                            Session session = null;
13720    
13721                            try {
13722                                    session = openSession();
13723    
13724                                    Query q = session.createQuery(sql);
13725    
13726                                    QueryPos qPos = QueryPos.getInstance(q);
13727    
13728                                    qPos.add(companyId);
13729    
13730                                    qPos.add(userId);
13731    
13732                                    qPos.add(status);
13733    
13734                                    count = (Long)q.uniqueResult();
13735    
13736                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
13737                            }
13738                            catch (Exception e) {
13739                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
13740    
13741                                    throw processException(e);
13742                            }
13743                            finally {
13744                                    closeSession(session);
13745                            }
13746                    }
13747    
13748                    return count.intValue();
13749            }
13750    
13751            private static final String _FINDER_COLUMN_C_U_S_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
13752            private static final String _FINDER_COLUMN_C_U_S_USERID_2 = "blogsEntry.userId = ? AND ";
13753            private static final String _FINDER_COLUMN_C_U_S_STATUS_2 = "blogsEntry.status = ?";
13754            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U_NOTS = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
13755                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
13756                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_U_NotS",
13757                            new String[] {
13758                                    Long.class.getName(), Long.class.getName(),
13759                                    Integer.class.getName(),
13760                                    
13761                            Integer.class.getName(), Integer.class.getName(),
13762                                    OrderByComparator.class.getName()
13763                            });
13764            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_U_NOTS =
13765                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
13766                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
13767                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_U_NotS",
13768                            new String[] {
13769                                    Long.class.getName(), Long.class.getName(),
13770                                    Integer.class.getName()
13771                            });
13772    
13773            /**
13774             * Returns all the blogs entries where companyId = &#63; and userId = &#63; and status &ne; &#63;.
13775             *
13776             * @param companyId the company ID
13777             * @param userId the user ID
13778             * @param status the status
13779             * @return the matching blogs entries
13780             */
13781            @Override
13782            public List<BlogsEntry> findByC_U_NotS(long companyId, long userId,
13783                    int status) {
13784                    return findByC_U_NotS(companyId, userId, status, QueryUtil.ALL_POS,
13785                            QueryUtil.ALL_POS, null);
13786            }
13787    
13788            /**
13789             * Returns a range of all the blogs entries where companyId = &#63; and userId = &#63; and status &ne; &#63;.
13790             *
13791             * <p>
13792             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
13793             * </p>
13794             *
13795             * @param companyId the company ID
13796             * @param userId the user ID
13797             * @param status the status
13798             * @param start the lower bound of the range of blogs entries
13799             * @param end the upper bound of the range of blogs entries (not inclusive)
13800             * @return the range of matching blogs entries
13801             */
13802            @Override
13803            public List<BlogsEntry> findByC_U_NotS(long companyId, long userId,
13804                    int status, int start, int end) {
13805                    return findByC_U_NotS(companyId, userId, status, start, end, null);
13806            }
13807    
13808            /**
13809             * Returns an ordered range of all the blogs entries where companyId = &#63; and userId = &#63; and status &ne; &#63;.
13810             *
13811             * <p>
13812             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
13813             * </p>
13814             *
13815             * @param companyId the company ID
13816             * @param userId the user ID
13817             * @param status the status
13818             * @param start the lower bound of the range of blogs entries
13819             * @param end the upper bound of the range of blogs entries (not inclusive)
13820             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
13821             * @return the ordered range of matching blogs entries
13822             */
13823            @Override
13824            public List<BlogsEntry> findByC_U_NotS(long companyId, long userId,
13825                    int status, int start, int end,
13826                    OrderByComparator<BlogsEntry> orderByComparator) {
13827                    boolean pagination = true;
13828                    FinderPath finderPath = null;
13829                    Object[] finderArgs = null;
13830    
13831                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_U_NOTS;
13832                    finderArgs = new Object[] {
13833                                    companyId, userId, status,
13834                                    
13835                                    start, end, orderByComparator
13836                            };
13837    
13838                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
13839                                    finderArgs, this);
13840    
13841                    if ((list != null) && !list.isEmpty()) {
13842                            for (BlogsEntry blogsEntry : list) {
13843                                    if ((companyId != blogsEntry.getCompanyId()) ||
13844                                                    (userId != blogsEntry.getUserId()) ||
13845                                                    (status == blogsEntry.getStatus())) {
13846                                            list = null;
13847    
13848                                            break;
13849                                    }
13850                            }
13851                    }
13852    
13853                    if (list == null) {
13854                            StringBundler query = null;
13855    
13856                            if (orderByComparator != null) {
13857                                    query = new StringBundler(5 +
13858                                                    (orderByComparator.getOrderByFields().length * 3));
13859                            }
13860                            else {
13861                                    query = new StringBundler(5);
13862                            }
13863    
13864                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
13865    
13866                            query.append(_FINDER_COLUMN_C_U_NOTS_COMPANYID_2);
13867    
13868                            query.append(_FINDER_COLUMN_C_U_NOTS_USERID_2);
13869    
13870                            query.append(_FINDER_COLUMN_C_U_NOTS_STATUS_2);
13871    
13872                            if (orderByComparator != null) {
13873                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13874                                            orderByComparator);
13875                            }
13876                            else
13877                             if (pagination) {
13878                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
13879                            }
13880    
13881                            String sql = query.toString();
13882    
13883                            Session session = null;
13884    
13885                            try {
13886                                    session = openSession();
13887    
13888                                    Query q = session.createQuery(sql);
13889    
13890                                    QueryPos qPos = QueryPos.getInstance(q);
13891    
13892                                    qPos.add(companyId);
13893    
13894                                    qPos.add(userId);
13895    
13896                                    qPos.add(status);
13897    
13898                                    if (!pagination) {
13899                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
13900                                                            start, end, false);
13901    
13902                                            Collections.sort(list);
13903    
13904                                            list = Collections.unmodifiableList(list);
13905                                    }
13906                                    else {
13907                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
13908                                                            start, end);
13909                                    }
13910    
13911                                    cacheResult(list);
13912    
13913                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
13914                            }
13915                            catch (Exception e) {
13916                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
13917    
13918                                    throw processException(e);
13919                            }
13920                            finally {
13921                                    closeSession(session);
13922                            }
13923                    }
13924    
13925                    return list;
13926            }
13927    
13928            /**
13929             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status &ne; &#63;.
13930             *
13931             * @param companyId the company ID
13932             * @param userId the user ID
13933             * @param status the status
13934             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13935             * @return the first matching blogs entry
13936             * @throws NoSuchEntryException if a matching blogs entry could not be found
13937             */
13938            @Override
13939            public BlogsEntry findByC_U_NotS_First(long companyId, long userId,
13940                    int status, OrderByComparator<BlogsEntry> orderByComparator)
13941                    throws NoSuchEntryException {
13942                    BlogsEntry blogsEntry = fetchByC_U_NotS_First(companyId, userId,
13943                                    status, orderByComparator);
13944    
13945                    if (blogsEntry != null) {
13946                            return blogsEntry;
13947                    }
13948    
13949                    StringBundler msg = new StringBundler(8);
13950    
13951                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
13952    
13953                    msg.append("companyId=");
13954                    msg.append(companyId);
13955    
13956                    msg.append(", userId=");
13957                    msg.append(userId);
13958    
13959                    msg.append(", status=");
13960                    msg.append(status);
13961    
13962                    msg.append(StringPool.CLOSE_CURLY_BRACE);
13963    
13964                    throw new NoSuchEntryException(msg.toString());
13965            }
13966    
13967            /**
13968             * Returns the first blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status &ne; &#63;.
13969             *
13970             * @param companyId the company ID
13971             * @param userId the user ID
13972             * @param status the status
13973             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13974             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
13975             */
13976            @Override
13977            public BlogsEntry fetchByC_U_NotS_First(long companyId, long userId,
13978                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
13979                    List<BlogsEntry> list = findByC_U_NotS(companyId, userId, status, 0, 1,
13980                                    orderByComparator);
13981    
13982                    if (!list.isEmpty()) {
13983                            return list.get(0);
13984                    }
13985    
13986                    return null;
13987            }
13988    
13989            /**
13990             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status &ne; &#63;.
13991             *
13992             * @param companyId the company ID
13993             * @param userId the user ID
13994             * @param status the status
13995             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
13996             * @return the last matching blogs entry
13997             * @throws NoSuchEntryException if a matching blogs entry could not be found
13998             */
13999            @Override
14000            public BlogsEntry findByC_U_NotS_Last(long companyId, long userId,
14001                    int status, OrderByComparator<BlogsEntry> orderByComparator)
14002                    throws NoSuchEntryException {
14003                    BlogsEntry blogsEntry = fetchByC_U_NotS_Last(companyId, userId, status,
14004                                    orderByComparator);
14005    
14006                    if (blogsEntry != null) {
14007                            return blogsEntry;
14008                    }
14009    
14010                    StringBundler msg = new StringBundler(8);
14011    
14012                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
14013    
14014                    msg.append("companyId=");
14015                    msg.append(companyId);
14016    
14017                    msg.append(", userId=");
14018                    msg.append(userId);
14019    
14020                    msg.append(", status=");
14021                    msg.append(status);
14022    
14023                    msg.append(StringPool.CLOSE_CURLY_BRACE);
14024    
14025                    throw new NoSuchEntryException(msg.toString());
14026            }
14027    
14028            /**
14029             * Returns the last blogs entry in the ordered set where companyId = &#63; and userId = &#63; and status &ne; &#63;.
14030             *
14031             * @param companyId the company ID
14032             * @param userId the user ID
14033             * @param status the status
14034             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14035             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
14036             */
14037            @Override
14038            public BlogsEntry fetchByC_U_NotS_Last(long companyId, long userId,
14039                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
14040                    int count = countByC_U_NotS(companyId, userId, status);
14041    
14042                    if (count == 0) {
14043                            return null;
14044                    }
14045    
14046                    List<BlogsEntry> list = findByC_U_NotS(companyId, userId, status,
14047                                    count - 1, count, orderByComparator);
14048    
14049                    if (!list.isEmpty()) {
14050                            return list.get(0);
14051                    }
14052    
14053                    return null;
14054            }
14055    
14056            /**
14057             * 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;.
14058             *
14059             * @param entryId the primary key of the current blogs entry
14060             * @param companyId the company ID
14061             * @param userId the user ID
14062             * @param status the status
14063             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14064             * @return the previous, current, and next blogs entry
14065             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
14066             */
14067            @Override
14068            public BlogsEntry[] findByC_U_NotS_PrevAndNext(long entryId,
14069                    long companyId, long userId, int status,
14070                    OrderByComparator<BlogsEntry> orderByComparator)
14071                    throws NoSuchEntryException {
14072                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
14073    
14074                    Session session = null;
14075    
14076                    try {
14077                            session = openSession();
14078    
14079                            BlogsEntry[] array = new BlogsEntryImpl[3];
14080    
14081                            array[0] = getByC_U_NotS_PrevAndNext(session, blogsEntry,
14082                                            companyId, userId, status, orderByComparator, true);
14083    
14084                            array[1] = blogsEntry;
14085    
14086                            array[2] = getByC_U_NotS_PrevAndNext(session, blogsEntry,
14087                                            companyId, userId, status, orderByComparator, false);
14088    
14089                            return array;
14090                    }
14091                    catch (Exception e) {
14092                            throw processException(e);
14093                    }
14094                    finally {
14095                            closeSession(session);
14096                    }
14097            }
14098    
14099            protected BlogsEntry getByC_U_NotS_PrevAndNext(Session session,
14100                    BlogsEntry blogsEntry, long companyId, long userId, int status,
14101                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
14102                    StringBundler query = null;
14103    
14104                    if (orderByComparator != null) {
14105                            query = new StringBundler(6 +
14106                                            (orderByComparator.getOrderByFields().length * 6));
14107                    }
14108                    else {
14109                            query = new StringBundler(3);
14110                    }
14111    
14112                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
14113    
14114                    query.append(_FINDER_COLUMN_C_U_NOTS_COMPANYID_2);
14115    
14116                    query.append(_FINDER_COLUMN_C_U_NOTS_USERID_2);
14117    
14118                    query.append(_FINDER_COLUMN_C_U_NOTS_STATUS_2);
14119    
14120                    if (orderByComparator != null) {
14121                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
14122    
14123                            if (orderByConditionFields.length > 0) {
14124                                    query.append(WHERE_AND);
14125                            }
14126    
14127                            for (int i = 0; i < orderByConditionFields.length; i++) {
14128                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14129                                    query.append(orderByConditionFields[i]);
14130    
14131                                    if ((i + 1) < orderByConditionFields.length) {
14132                                            if (orderByComparator.isAscending() ^ previous) {
14133                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
14134                                            }
14135                                            else {
14136                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
14137                                            }
14138                                    }
14139                                    else {
14140                                            if (orderByComparator.isAscending() ^ previous) {
14141                                                    query.append(WHERE_GREATER_THAN);
14142                                            }
14143                                            else {
14144                                                    query.append(WHERE_LESSER_THAN);
14145                                            }
14146                                    }
14147                            }
14148    
14149                            query.append(ORDER_BY_CLAUSE);
14150    
14151                            String[] orderByFields = orderByComparator.getOrderByFields();
14152    
14153                            for (int i = 0; i < orderByFields.length; i++) {
14154                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14155                                    query.append(orderByFields[i]);
14156    
14157                                    if ((i + 1) < orderByFields.length) {
14158                                            if (orderByComparator.isAscending() ^ previous) {
14159                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
14160                                            }
14161                                            else {
14162                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
14163                                            }
14164                                    }
14165                                    else {
14166                                            if (orderByComparator.isAscending() ^ previous) {
14167                                                    query.append(ORDER_BY_ASC);
14168                                            }
14169                                            else {
14170                                                    query.append(ORDER_BY_DESC);
14171                                            }
14172                                    }
14173                            }
14174                    }
14175                    else {
14176                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
14177                    }
14178    
14179                    String sql = query.toString();
14180    
14181                    Query q = session.createQuery(sql);
14182    
14183                    q.setFirstResult(0);
14184                    q.setMaxResults(2);
14185    
14186                    QueryPos qPos = QueryPos.getInstance(q);
14187    
14188                    qPos.add(companyId);
14189    
14190                    qPos.add(userId);
14191    
14192                    qPos.add(status);
14193    
14194                    if (orderByComparator != null) {
14195                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
14196    
14197                            for (Object value : values) {
14198                                    qPos.add(value);
14199                            }
14200                    }
14201    
14202                    List<BlogsEntry> list = q.list();
14203    
14204                    if (list.size() == 2) {
14205                            return list.get(1);
14206                    }
14207                    else {
14208                            return null;
14209                    }
14210            }
14211    
14212            /**
14213             * Removes all the blogs entries where companyId = &#63; and userId = &#63; and status &ne; &#63; from the database.
14214             *
14215             * @param companyId the company ID
14216             * @param userId the user ID
14217             * @param status the status
14218             */
14219            @Override
14220            public void removeByC_U_NotS(long companyId, long userId, int status) {
14221                    for (BlogsEntry blogsEntry : findByC_U_NotS(companyId, userId, status,
14222                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
14223                            remove(blogsEntry);
14224                    }
14225            }
14226    
14227            /**
14228             * Returns the number of blogs entries where companyId = &#63; and userId = &#63; and status &ne; &#63;.
14229             *
14230             * @param companyId the company ID
14231             * @param userId the user ID
14232             * @param status the status
14233             * @return the number of matching blogs entries
14234             */
14235            @Override
14236            public int countByC_U_NotS(long companyId, long userId, int status) {
14237                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_U_NOTS;
14238    
14239                    Object[] finderArgs = new Object[] { companyId, userId, status };
14240    
14241                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
14242                                    this);
14243    
14244                    if (count == null) {
14245                            StringBundler query = new StringBundler(4);
14246    
14247                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
14248    
14249                            query.append(_FINDER_COLUMN_C_U_NOTS_COMPANYID_2);
14250    
14251                            query.append(_FINDER_COLUMN_C_U_NOTS_USERID_2);
14252    
14253                            query.append(_FINDER_COLUMN_C_U_NOTS_STATUS_2);
14254    
14255                            String sql = query.toString();
14256    
14257                            Session session = null;
14258    
14259                            try {
14260                                    session = openSession();
14261    
14262                                    Query q = session.createQuery(sql);
14263    
14264                                    QueryPos qPos = QueryPos.getInstance(q);
14265    
14266                                    qPos.add(companyId);
14267    
14268                                    qPos.add(userId);
14269    
14270                                    qPos.add(status);
14271    
14272                                    count = (Long)q.uniqueResult();
14273    
14274                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
14275                            }
14276                            catch (Exception e) {
14277                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
14278    
14279                                    throw processException(e);
14280                            }
14281                            finally {
14282                                    closeSession(session);
14283                            }
14284                    }
14285    
14286                    return count.intValue();
14287            }
14288    
14289            private static final String _FINDER_COLUMN_C_U_NOTS_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
14290            private static final String _FINDER_COLUMN_C_U_NOTS_USERID_2 = "blogsEntry.userId = ? AND ";
14291            private static final String _FINDER_COLUMN_C_U_NOTS_STATUS_2 = "blogsEntry.status != ?";
14292            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
14293                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
14294                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_LtD_S",
14295                            new String[] {
14296                                    Long.class.getName(), Date.class.getName(),
14297                                    Integer.class.getName(),
14298                                    
14299                            Integer.class.getName(), Integer.class.getName(),
14300                                    OrderByComparator.class.getName()
14301                            });
14302            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD_S = new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
14303                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
14304                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_LtD_S",
14305                            new String[] {
14306                                    Long.class.getName(), Date.class.getName(),
14307                                    Integer.class.getName()
14308                            });
14309    
14310            /**
14311             * Returns all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
14312             *
14313             * @param companyId the company ID
14314             * @param displayDate the display date
14315             * @param status the status
14316             * @return the matching blogs entries
14317             */
14318            @Override
14319            public List<BlogsEntry> findByC_LtD_S(long companyId, Date displayDate,
14320                    int status) {
14321                    return findByC_LtD_S(companyId, displayDate, status, QueryUtil.ALL_POS,
14322                            QueryUtil.ALL_POS, null);
14323            }
14324    
14325            /**
14326             * Returns a range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
14327             *
14328             * <p>
14329             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
14330             * </p>
14331             *
14332             * @param companyId the company ID
14333             * @param displayDate the display date
14334             * @param status the status
14335             * @param start the lower bound of the range of blogs entries
14336             * @param end the upper bound of the range of blogs entries (not inclusive)
14337             * @return the range of matching blogs entries
14338             */
14339            @Override
14340            public List<BlogsEntry> findByC_LtD_S(long companyId, Date displayDate,
14341                    int status, int start, int end) {
14342                    return findByC_LtD_S(companyId, displayDate, status, start, end, null);
14343            }
14344    
14345            /**
14346             * Returns an ordered range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
14347             *
14348             * <p>
14349             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
14350             * </p>
14351             *
14352             * @param companyId the company ID
14353             * @param displayDate the display date
14354             * @param status the status
14355             * @param start the lower bound of the range of blogs entries
14356             * @param end the upper bound of the range of blogs entries (not inclusive)
14357             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14358             * @return the ordered range of matching blogs entries
14359             */
14360            @Override
14361            public List<BlogsEntry> findByC_LtD_S(long companyId, Date displayDate,
14362                    int status, int start, int end,
14363                    OrderByComparator<BlogsEntry> orderByComparator) {
14364                    boolean pagination = true;
14365                    FinderPath finderPath = null;
14366                    Object[] finderArgs = null;
14367    
14368                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD_S;
14369                    finderArgs = new Object[] {
14370                                    companyId, displayDate, status,
14371                                    
14372                                    start, end, orderByComparator
14373                            };
14374    
14375                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
14376                                    finderArgs, this);
14377    
14378                    if ((list != null) && !list.isEmpty()) {
14379                            for (BlogsEntry blogsEntry : list) {
14380                                    if ((companyId != blogsEntry.getCompanyId()) ||
14381                                                    (displayDate.getTime() <= blogsEntry.getDisplayDate()
14382                                                                                                                                    .getTime()) ||
14383                                                    (status != blogsEntry.getStatus())) {
14384                                            list = null;
14385    
14386                                            break;
14387                                    }
14388                            }
14389                    }
14390    
14391                    if (list == null) {
14392                            StringBundler query = null;
14393    
14394                            if (orderByComparator != null) {
14395                                    query = new StringBundler(5 +
14396                                                    (orderByComparator.getOrderByFields().length * 3));
14397                            }
14398                            else {
14399                                    query = new StringBundler(5);
14400                            }
14401    
14402                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
14403    
14404                            query.append(_FINDER_COLUMN_C_LTD_S_COMPANYID_2);
14405    
14406                            boolean bindDisplayDate = false;
14407    
14408                            if (displayDate == null) {
14409                                    query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_1);
14410                            }
14411                            else {
14412                                    bindDisplayDate = true;
14413    
14414                                    query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_2);
14415                            }
14416    
14417                            query.append(_FINDER_COLUMN_C_LTD_S_STATUS_2);
14418    
14419                            if (orderByComparator != null) {
14420                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
14421                                            orderByComparator);
14422                            }
14423                            else
14424                             if (pagination) {
14425                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
14426                            }
14427    
14428                            String sql = query.toString();
14429    
14430                            Session session = null;
14431    
14432                            try {
14433                                    session = openSession();
14434    
14435                                    Query q = session.createQuery(sql);
14436    
14437                                    QueryPos qPos = QueryPos.getInstance(q);
14438    
14439                                    qPos.add(companyId);
14440    
14441                                    if (bindDisplayDate) {
14442                                            qPos.add(new Timestamp(displayDate.getTime()));
14443                                    }
14444    
14445                                    qPos.add(status);
14446    
14447                                    if (!pagination) {
14448                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
14449                                                            start, end, false);
14450    
14451                                            Collections.sort(list);
14452    
14453                                            list = Collections.unmodifiableList(list);
14454                                    }
14455                                    else {
14456                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
14457                                                            start, end);
14458                                    }
14459    
14460                                    cacheResult(list);
14461    
14462                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
14463                            }
14464                            catch (Exception e) {
14465                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
14466    
14467                                    throw processException(e);
14468                            }
14469                            finally {
14470                                    closeSession(session);
14471                            }
14472                    }
14473    
14474                    return list;
14475            }
14476    
14477            /**
14478             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
14479             *
14480             * @param companyId the company ID
14481             * @param displayDate the display date
14482             * @param status the status
14483             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14484             * @return the first matching blogs entry
14485             * @throws NoSuchEntryException if a matching blogs entry could not be found
14486             */
14487            @Override
14488            public BlogsEntry findByC_LtD_S_First(long companyId, Date displayDate,
14489                    int status, OrderByComparator<BlogsEntry> orderByComparator)
14490                    throws NoSuchEntryException {
14491                    BlogsEntry blogsEntry = fetchByC_LtD_S_First(companyId, displayDate,
14492                                    status, orderByComparator);
14493    
14494                    if (blogsEntry != null) {
14495                            return blogsEntry;
14496                    }
14497    
14498                    StringBundler msg = new StringBundler(8);
14499    
14500                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
14501    
14502                    msg.append("companyId=");
14503                    msg.append(companyId);
14504    
14505                    msg.append(", displayDate=");
14506                    msg.append(displayDate);
14507    
14508                    msg.append(", status=");
14509                    msg.append(status);
14510    
14511                    msg.append(StringPool.CLOSE_CURLY_BRACE);
14512    
14513                    throw new NoSuchEntryException(msg.toString());
14514            }
14515    
14516            /**
14517             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
14518             *
14519             * @param companyId the company ID
14520             * @param displayDate the display date
14521             * @param status the status
14522             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14523             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
14524             */
14525            @Override
14526            public BlogsEntry fetchByC_LtD_S_First(long companyId, Date displayDate,
14527                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
14528                    List<BlogsEntry> list = findByC_LtD_S(companyId, displayDate, status,
14529                                    0, 1, orderByComparator);
14530    
14531                    if (!list.isEmpty()) {
14532                            return list.get(0);
14533                    }
14534    
14535                    return null;
14536            }
14537    
14538            /**
14539             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
14540             *
14541             * @param companyId the company ID
14542             * @param displayDate the display date
14543             * @param status the status
14544             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14545             * @return the last matching blogs entry
14546             * @throws NoSuchEntryException if a matching blogs entry could not be found
14547             */
14548            @Override
14549            public BlogsEntry findByC_LtD_S_Last(long companyId, Date displayDate,
14550                    int status, OrderByComparator<BlogsEntry> orderByComparator)
14551                    throws NoSuchEntryException {
14552                    BlogsEntry blogsEntry = fetchByC_LtD_S_Last(companyId, displayDate,
14553                                    status, orderByComparator);
14554    
14555                    if (blogsEntry != null) {
14556                            return blogsEntry;
14557                    }
14558    
14559                    StringBundler msg = new StringBundler(8);
14560    
14561                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
14562    
14563                    msg.append("companyId=");
14564                    msg.append(companyId);
14565    
14566                    msg.append(", displayDate=");
14567                    msg.append(displayDate);
14568    
14569                    msg.append(", status=");
14570                    msg.append(status);
14571    
14572                    msg.append(StringPool.CLOSE_CURLY_BRACE);
14573    
14574                    throw new NoSuchEntryException(msg.toString());
14575            }
14576    
14577            /**
14578             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
14579             *
14580             * @param companyId the company ID
14581             * @param displayDate the display date
14582             * @param status the status
14583             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14584             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
14585             */
14586            @Override
14587            public BlogsEntry fetchByC_LtD_S_Last(long companyId, Date displayDate,
14588                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
14589                    int count = countByC_LtD_S(companyId, displayDate, status);
14590    
14591                    if (count == 0) {
14592                            return null;
14593                    }
14594    
14595                    List<BlogsEntry> list = findByC_LtD_S(companyId, displayDate, status,
14596                                    count - 1, count, orderByComparator);
14597    
14598                    if (!list.isEmpty()) {
14599                            return list.get(0);
14600                    }
14601    
14602                    return null;
14603            }
14604    
14605            /**
14606             * 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;.
14607             *
14608             * @param entryId the primary key of the current blogs entry
14609             * @param companyId the company ID
14610             * @param displayDate the display date
14611             * @param status the status
14612             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
14613             * @return the previous, current, and next blogs entry
14614             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
14615             */
14616            @Override
14617            public BlogsEntry[] findByC_LtD_S_PrevAndNext(long entryId, long companyId,
14618                    Date displayDate, int status,
14619                    OrderByComparator<BlogsEntry> orderByComparator)
14620                    throws NoSuchEntryException {
14621                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
14622    
14623                    Session session = null;
14624    
14625                    try {
14626                            session = openSession();
14627    
14628                            BlogsEntry[] array = new BlogsEntryImpl[3];
14629    
14630                            array[0] = getByC_LtD_S_PrevAndNext(session, blogsEntry, companyId,
14631                                            displayDate, status, orderByComparator, true);
14632    
14633                            array[1] = blogsEntry;
14634    
14635                            array[2] = getByC_LtD_S_PrevAndNext(session, blogsEntry, companyId,
14636                                            displayDate, status, orderByComparator, false);
14637    
14638                            return array;
14639                    }
14640                    catch (Exception e) {
14641                            throw processException(e);
14642                    }
14643                    finally {
14644                            closeSession(session);
14645                    }
14646            }
14647    
14648            protected BlogsEntry getByC_LtD_S_PrevAndNext(Session session,
14649                    BlogsEntry blogsEntry, long companyId, Date displayDate, int status,
14650                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
14651                    StringBundler query = null;
14652    
14653                    if (orderByComparator != null) {
14654                            query = new StringBundler(6 +
14655                                            (orderByComparator.getOrderByFields().length * 6));
14656                    }
14657                    else {
14658                            query = new StringBundler(3);
14659                    }
14660    
14661                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
14662    
14663                    query.append(_FINDER_COLUMN_C_LTD_S_COMPANYID_2);
14664    
14665                    boolean bindDisplayDate = false;
14666    
14667                    if (displayDate == null) {
14668                            query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_1);
14669                    }
14670                    else {
14671                            bindDisplayDate = true;
14672    
14673                            query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_2);
14674                    }
14675    
14676                    query.append(_FINDER_COLUMN_C_LTD_S_STATUS_2);
14677    
14678                    if (orderByComparator != null) {
14679                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
14680    
14681                            if (orderByConditionFields.length > 0) {
14682                                    query.append(WHERE_AND);
14683                            }
14684    
14685                            for (int i = 0; i < orderByConditionFields.length; i++) {
14686                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14687                                    query.append(orderByConditionFields[i]);
14688    
14689                                    if ((i + 1) < orderByConditionFields.length) {
14690                                            if (orderByComparator.isAscending() ^ previous) {
14691                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
14692                                            }
14693                                            else {
14694                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
14695                                            }
14696                                    }
14697                                    else {
14698                                            if (orderByComparator.isAscending() ^ previous) {
14699                                                    query.append(WHERE_GREATER_THAN);
14700                                            }
14701                                            else {
14702                                                    query.append(WHERE_LESSER_THAN);
14703                                            }
14704                                    }
14705                            }
14706    
14707                            query.append(ORDER_BY_CLAUSE);
14708    
14709                            String[] orderByFields = orderByComparator.getOrderByFields();
14710    
14711                            for (int i = 0; i < orderByFields.length; i++) {
14712                                    query.append(_ORDER_BY_ENTITY_ALIAS);
14713                                    query.append(orderByFields[i]);
14714    
14715                                    if ((i + 1) < orderByFields.length) {
14716                                            if (orderByComparator.isAscending() ^ previous) {
14717                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
14718                                            }
14719                                            else {
14720                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
14721                                            }
14722                                    }
14723                                    else {
14724                                            if (orderByComparator.isAscending() ^ previous) {
14725                                                    query.append(ORDER_BY_ASC);
14726                                            }
14727                                            else {
14728                                                    query.append(ORDER_BY_DESC);
14729                                            }
14730                                    }
14731                            }
14732                    }
14733                    else {
14734                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
14735                    }
14736    
14737                    String sql = query.toString();
14738    
14739                    Query q = session.createQuery(sql);
14740    
14741                    q.setFirstResult(0);
14742                    q.setMaxResults(2);
14743    
14744                    QueryPos qPos = QueryPos.getInstance(q);
14745    
14746                    qPos.add(companyId);
14747    
14748                    if (bindDisplayDate) {
14749                            qPos.add(new Timestamp(displayDate.getTime()));
14750                    }
14751    
14752                    qPos.add(status);
14753    
14754                    if (orderByComparator != null) {
14755                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
14756    
14757                            for (Object value : values) {
14758                                    qPos.add(value);
14759                            }
14760                    }
14761    
14762                    List<BlogsEntry> list = q.list();
14763    
14764                    if (list.size() == 2) {
14765                            return list.get(1);
14766                    }
14767                    else {
14768                            return null;
14769                    }
14770            }
14771    
14772            /**
14773             * Removes all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63; from the database.
14774             *
14775             * @param companyId the company ID
14776             * @param displayDate the display date
14777             * @param status the status
14778             */
14779            @Override
14780            public void removeByC_LtD_S(long companyId, Date displayDate, int status) {
14781                    for (BlogsEntry blogsEntry : findByC_LtD_S(companyId, displayDate,
14782                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
14783                            remove(blogsEntry);
14784                    }
14785            }
14786    
14787            /**
14788             * Returns the number of blogs entries where companyId = &#63; and displayDate &lt; &#63; and status = &#63;.
14789             *
14790             * @param companyId the company ID
14791             * @param displayDate the display date
14792             * @param status the status
14793             * @return the number of matching blogs entries
14794             */
14795            @Override
14796            public int countByC_LtD_S(long companyId, Date displayDate, int status) {
14797                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD_S;
14798    
14799                    Object[] finderArgs = new Object[] { companyId, displayDate, status };
14800    
14801                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
14802                                    this);
14803    
14804                    if (count == null) {
14805                            StringBundler query = new StringBundler(4);
14806    
14807                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
14808    
14809                            query.append(_FINDER_COLUMN_C_LTD_S_COMPANYID_2);
14810    
14811                            boolean bindDisplayDate = false;
14812    
14813                            if (displayDate == null) {
14814                                    query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_1);
14815                            }
14816                            else {
14817                                    bindDisplayDate = true;
14818    
14819                                    query.append(_FINDER_COLUMN_C_LTD_S_DISPLAYDATE_2);
14820                            }
14821    
14822                            query.append(_FINDER_COLUMN_C_LTD_S_STATUS_2);
14823    
14824                            String sql = query.toString();
14825    
14826                            Session session = null;
14827    
14828                            try {
14829                                    session = openSession();
14830    
14831                                    Query q = session.createQuery(sql);
14832    
14833                                    QueryPos qPos = QueryPos.getInstance(q);
14834    
14835                                    qPos.add(companyId);
14836    
14837                                    if (bindDisplayDate) {
14838                                            qPos.add(new Timestamp(displayDate.getTime()));
14839                                    }
14840    
14841                                    qPos.add(status);
14842    
14843                                    count = (Long)q.uniqueResult();
14844    
14845                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
14846                            }
14847                            catch (Exception e) {
14848                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
14849    
14850                                    throw processException(e);
14851                            }
14852                            finally {
14853                                    closeSession(session);
14854                            }
14855                    }
14856    
14857                    return count.intValue();
14858            }
14859    
14860            private static final String _FINDER_COLUMN_C_LTD_S_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
14861            private static final String _FINDER_COLUMN_C_LTD_S_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL AND ";
14862            private static final String _FINDER_COLUMN_C_LTD_S_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
14863            private static final String _FINDER_COLUMN_C_LTD_S_STATUS_2 = "blogsEntry.status = ?";
14864            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD_NOTS =
14865                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
14866                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
14867                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_LtD_NotS",
14868                            new String[] {
14869                                    Long.class.getName(), Date.class.getName(),
14870                                    Integer.class.getName(),
14871                                    
14872                            Integer.class.getName(), Integer.class.getName(),
14873                                    OrderByComparator.class.getName()
14874                            });
14875            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD_NOTS =
14876                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
14877                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
14878                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_LtD_NotS",
14879                            new String[] {
14880                                    Long.class.getName(), Date.class.getName(),
14881                                    Integer.class.getName()
14882                            });
14883    
14884            /**
14885             * Returns all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
14886             *
14887             * @param companyId the company ID
14888             * @param displayDate the display date
14889             * @param status the status
14890             * @return the matching blogs entries
14891             */
14892            @Override
14893            public List<BlogsEntry> findByC_LtD_NotS(long companyId, Date displayDate,
14894                    int status) {
14895                    return findByC_LtD_NotS(companyId, displayDate, status,
14896                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
14897            }
14898    
14899            /**
14900             * Returns a range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
14901             *
14902             * <p>
14903             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
14904             * </p>
14905             *
14906             * @param companyId the company ID
14907             * @param displayDate the display date
14908             * @param status the status
14909             * @param start the lower bound of the range of blogs entries
14910             * @param end the upper bound of the range of blogs entries (not inclusive)
14911             * @return the range of matching blogs entries
14912             */
14913            @Override
14914            public List<BlogsEntry> findByC_LtD_NotS(long companyId, Date displayDate,
14915                    int status, int start, int end) {
14916                    return findByC_LtD_NotS(companyId, displayDate, status, start, end, null);
14917            }
14918    
14919            /**
14920             * Returns an ordered range of all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
14921             *
14922             * <p>
14923             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
14924             * </p>
14925             *
14926             * @param companyId the company ID
14927             * @param displayDate the display date
14928             * @param status the status
14929             * @param start the lower bound of the range of blogs entries
14930             * @param end the upper bound of the range of blogs entries (not inclusive)
14931             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
14932             * @return the ordered range of matching blogs entries
14933             */
14934            @Override
14935            public List<BlogsEntry> findByC_LtD_NotS(long companyId, Date displayDate,
14936                    int status, int start, int end,
14937                    OrderByComparator<BlogsEntry> orderByComparator) {
14938                    boolean pagination = true;
14939                    FinderPath finderPath = null;
14940                    Object[] finderArgs = null;
14941    
14942                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_LTD_NOTS;
14943                    finderArgs = new Object[] {
14944                                    companyId, displayDate, status,
14945                                    
14946                                    start, end, orderByComparator
14947                            };
14948    
14949                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
14950                                    finderArgs, this);
14951    
14952                    if ((list != null) && !list.isEmpty()) {
14953                            for (BlogsEntry blogsEntry : list) {
14954                                    if ((companyId != blogsEntry.getCompanyId()) ||
14955                                                    (displayDate.getTime() <= blogsEntry.getDisplayDate()
14956                                                                                                                                    .getTime()) ||
14957                                                    (status == blogsEntry.getStatus())) {
14958                                            list = null;
14959    
14960                                            break;
14961                                    }
14962                            }
14963                    }
14964    
14965                    if (list == null) {
14966                            StringBundler query = null;
14967    
14968                            if (orderByComparator != null) {
14969                                    query = new StringBundler(5 +
14970                                                    (orderByComparator.getOrderByFields().length * 3));
14971                            }
14972                            else {
14973                                    query = new StringBundler(5);
14974                            }
14975    
14976                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
14977    
14978                            query.append(_FINDER_COLUMN_C_LTD_NOTS_COMPANYID_2);
14979    
14980                            boolean bindDisplayDate = false;
14981    
14982                            if (displayDate == null) {
14983                                    query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_1);
14984                            }
14985                            else {
14986                                    bindDisplayDate = true;
14987    
14988                                    query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_2);
14989                            }
14990    
14991                            query.append(_FINDER_COLUMN_C_LTD_NOTS_STATUS_2);
14992    
14993                            if (orderByComparator != null) {
14994                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
14995                                            orderByComparator);
14996                            }
14997                            else
14998                             if (pagination) {
14999                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
15000                            }
15001    
15002                            String sql = query.toString();
15003    
15004                            Session session = null;
15005    
15006                            try {
15007                                    session = openSession();
15008    
15009                                    Query q = session.createQuery(sql);
15010    
15011                                    QueryPos qPos = QueryPos.getInstance(q);
15012    
15013                                    qPos.add(companyId);
15014    
15015                                    if (bindDisplayDate) {
15016                                            qPos.add(new Timestamp(displayDate.getTime()));
15017                                    }
15018    
15019                                    qPos.add(status);
15020    
15021                                    if (!pagination) {
15022                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
15023                                                            start, end, false);
15024    
15025                                            Collections.sort(list);
15026    
15027                                            list = Collections.unmodifiableList(list);
15028                                    }
15029                                    else {
15030                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
15031                                                            start, end);
15032                                    }
15033    
15034                                    cacheResult(list);
15035    
15036                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
15037                            }
15038                            catch (Exception e) {
15039                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
15040    
15041                                    throw processException(e);
15042                            }
15043                            finally {
15044                                    closeSession(session);
15045                            }
15046                    }
15047    
15048                    return list;
15049            }
15050    
15051            /**
15052             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
15053             *
15054             * @param companyId the company ID
15055             * @param displayDate the display date
15056             * @param status the status
15057             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15058             * @return the first matching blogs entry
15059             * @throws NoSuchEntryException if a matching blogs entry could not be found
15060             */
15061            @Override
15062            public BlogsEntry findByC_LtD_NotS_First(long companyId, Date displayDate,
15063                    int status, OrderByComparator<BlogsEntry> orderByComparator)
15064                    throws NoSuchEntryException {
15065                    BlogsEntry blogsEntry = fetchByC_LtD_NotS_First(companyId, displayDate,
15066                                    status, orderByComparator);
15067    
15068                    if (blogsEntry != null) {
15069                            return blogsEntry;
15070                    }
15071    
15072                    StringBundler msg = new StringBundler(8);
15073    
15074                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15075    
15076                    msg.append("companyId=");
15077                    msg.append(companyId);
15078    
15079                    msg.append(", displayDate=");
15080                    msg.append(displayDate);
15081    
15082                    msg.append(", status=");
15083                    msg.append(status);
15084    
15085                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15086    
15087                    throw new NoSuchEntryException(msg.toString());
15088            }
15089    
15090            /**
15091             * Returns the first blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
15092             *
15093             * @param companyId the company ID
15094             * @param displayDate the display date
15095             * @param status the status
15096             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15097             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
15098             */
15099            @Override
15100            public BlogsEntry fetchByC_LtD_NotS_First(long companyId, Date displayDate,
15101                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
15102                    List<BlogsEntry> list = findByC_LtD_NotS(companyId, displayDate,
15103                                    status, 0, 1, orderByComparator);
15104    
15105                    if (!list.isEmpty()) {
15106                            return list.get(0);
15107                    }
15108    
15109                    return null;
15110            }
15111    
15112            /**
15113             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
15114             *
15115             * @param companyId the company ID
15116             * @param displayDate the display date
15117             * @param status the status
15118             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15119             * @return the last matching blogs entry
15120             * @throws NoSuchEntryException if a matching blogs entry could not be found
15121             */
15122            @Override
15123            public BlogsEntry findByC_LtD_NotS_Last(long companyId, Date displayDate,
15124                    int status, OrderByComparator<BlogsEntry> orderByComparator)
15125                    throws NoSuchEntryException {
15126                    BlogsEntry blogsEntry = fetchByC_LtD_NotS_Last(companyId, displayDate,
15127                                    status, orderByComparator);
15128    
15129                    if (blogsEntry != null) {
15130                            return blogsEntry;
15131                    }
15132    
15133                    StringBundler msg = new StringBundler(8);
15134    
15135                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15136    
15137                    msg.append("companyId=");
15138                    msg.append(companyId);
15139    
15140                    msg.append(", displayDate=");
15141                    msg.append(displayDate);
15142    
15143                    msg.append(", status=");
15144                    msg.append(status);
15145    
15146                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15147    
15148                    throw new NoSuchEntryException(msg.toString());
15149            }
15150    
15151            /**
15152             * Returns the last blogs entry in the ordered set where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
15153             *
15154             * @param companyId the company ID
15155             * @param displayDate the display date
15156             * @param status the status
15157             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15158             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
15159             */
15160            @Override
15161            public BlogsEntry fetchByC_LtD_NotS_Last(long companyId, Date displayDate,
15162                    int status, OrderByComparator<BlogsEntry> orderByComparator) {
15163                    int count = countByC_LtD_NotS(companyId, displayDate, status);
15164    
15165                    if (count == 0) {
15166                            return null;
15167                    }
15168    
15169                    List<BlogsEntry> list = findByC_LtD_NotS(companyId, displayDate,
15170                                    status, count - 1, count, orderByComparator);
15171    
15172                    if (!list.isEmpty()) {
15173                            return list.get(0);
15174                    }
15175    
15176                    return null;
15177            }
15178    
15179            /**
15180             * 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;.
15181             *
15182             * @param entryId the primary key of the current blogs entry
15183             * @param companyId the company ID
15184             * @param displayDate the display date
15185             * @param status the status
15186             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15187             * @return the previous, current, and next blogs entry
15188             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
15189             */
15190            @Override
15191            public BlogsEntry[] findByC_LtD_NotS_PrevAndNext(long entryId,
15192                    long companyId, Date displayDate, int status,
15193                    OrderByComparator<BlogsEntry> orderByComparator)
15194                    throws NoSuchEntryException {
15195                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
15196    
15197                    Session session = null;
15198    
15199                    try {
15200                            session = openSession();
15201    
15202                            BlogsEntry[] array = new BlogsEntryImpl[3];
15203    
15204                            array[0] = getByC_LtD_NotS_PrevAndNext(session, blogsEntry,
15205                                            companyId, displayDate, status, orderByComparator, true);
15206    
15207                            array[1] = blogsEntry;
15208    
15209                            array[2] = getByC_LtD_NotS_PrevAndNext(session, blogsEntry,
15210                                            companyId, displayDate, status, orderByComparator, false);
15211    
15212                            return array;
15213                    }
15214                    catch (Exception e) {
15215                            throw processException(e);
15216                    }
15217                    finally {
15218                            closeSession(session);
15219                    }
15220            }
15221    
15222            protected BlogsEntry getByC_LtD_NotS_PrevAndNext(Session session,
15223                    BlogsEntry blogsEntry, long companyId, Date displayDate, int status,
15224                    OrderByComparator<BlogsEntry> orderByComparator, boolean previous) {
15225                    StringBundler query = null;
15226    
15227                    if (orderByComparator != null) {
15228                            query = new StringBundler(6 +
15229                                            (orderByComparator.getOrderByFields().length * 6));
15230                    }
15231                    else {
15232                            query = new StringBundler(3);
15233                    }
15234    
15235                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
15236    
15237                    query.append(_FINDER_COLUMN_C_LTD_NOTS_COMPANYID_2);
15238    
15239                    boolean bindDisplayDate = false;
15240    
15241                    if (displayDate == null) {
15242                            query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_1);
15243                    }
15244                    else {
15245                            bindDisplayDate = true;
15246    
15247                            query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_2);
15248                    }
15249    
15250                    query.append(_FINDER_COLUMN_C_LTD_NOTS_STATUS_2);
15251    
15252                    if (orderByComparator != null) {
15253                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
15254    
15255                            if (orderByConditionFields.length > 0) {
15256                                    query.append(WHERE_AND);
15257                            }
15258    
15259                            for (int i = 0; i < orderByConditionFields.length; i++) {
15260                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15261                                    query.append(orderByConditionFields[i]);
15262    
15263                                    if ((i + 1) < orderByConditionFields.length) {
15264                                            if (orderByComparator.isAscending() ^ previous) {
15265                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
15266                                            }
15267                                            else {
15268                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
15269                                            }
15270                                    }
15271                                    else {
15272                                            if (orderByComparator.isAscending() ^ previous) {
15273                                                    query.append(WHERE_GREATER_THAN);
15274                                            }
15275                                            else {
15276                                                    query.append(WHERE_LESSER_THAN);
15277                                            }
15278                                    }
15279                            }
15280    
15281                            query.append(ORDER_BY_CLAUSE);
15282    
15283                            String[] orderByFields = orderByComparator.getOrderByFields();
15284    
15285                            for (int i = 0; i < orderByFields.length; i++) {
15286                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15287                                    query.append(orderByFields[i]);
15288    
15289                                    if ((i + 1) < orderByFields.length) {
15290                                            if (orderByComparator.isAscending() ^ previous) {
15291                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
15292                                            }
15293                                            else {
15294                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
15295                                            }
15296                                    }
15297                                    else {
15298                                            if (orderByComparator.isAscending() ^ previous) {
15299                                                    query.append(ORDER_BY_ASC);
15300                                            }
15301                                            else {
15302                                                    query.append(ORDER_BY_DESC);
15303                                            }
15304                                    }
15305                            }
15306                    }
15307                    else {
15308                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
15309                    }
15310    
15311                    String sql = query.toString();
15312    
15313                    Query q = session.createQuery(sql);
15314    
15315                    q.setFirstResult(0);
15316                    q.setMaxResults(2);
15317    
15318                    QueryPos qPos = QueryPos.getInstance(q);
15319    
15320                    qPos.add(companyId);
15321    
15322                    if (bindDisplayDate) {
15323                            qPos.add(new Timestamp(displayDate.getTime()));
15324                    }
15325    
15326                    qPos.add(status);
15327    
15328                    if (orderByComparator != null) {
15329                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
15330    
15331                            for (Object value : values) {
15332                                    qPos.add(value);
15333                            }
15334                    }
15335    
15336                    List<BlogsEntry> list = q.list();
15337    
15338                    if (list.size() == 2) {
15339                            return list.get(1);
15340                    }
15341                    else {
15342                            return null;
15343                    }
15344            }
15345    
15346            /**
15347             * Removes all the blogs entries where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63; from the database.
15348             *
15349             * @param companyId the company ID
15350             * @param displayDate the display date
15351             * @param status the status
15352             */
15353            @Override
15354            public void removeByC_LtD_NotS(long companyId, Date displayDate, int status) {
15355                    for (BlogsEntry blogsEntry : findByC_LtD_NotS(companyId, displayDate,
15356                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
15357                            remove(blogsEntry);
15358                    }
15359            }
15360    
15361            /**
15362             * Returns the number of blogs entries where companyId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
15363             *
15364             * @param companyId the company ID
15365             * @param displayDate the display date
15366             * @param status the status
15367             * @return the number of matching blogs entries
15368             */
15369            @Override
15370            public int countByC_LtD_NotS(long companyId, Date displayDate, int status) {
15371                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_LTD_NOTS;
15372    
15373                    Object[] finderArgs = new Object[] { companyId, displayDate, status };
15374    
15375                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
15376                                    this);
15377    
15378                    if (count == null) {
15379                            StringBundler query = new StringBundler(4);
15380    
15381                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
15382    
15383                            query.append(_FINDER_COLUMN_C_LTD_NOTS_COMPANYID_2);
15384    
15385                            boolean bindDisplayDate = false;
15386    
15387                            if (displayDate == null) {
15388                                    query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_1);
15389                            }
15390                            else {
15391                                    bindDisplayDate = true;
15392    
15393                                    query.append(_FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_2);
15394                            }
15395    
15396                            query.append(_FINDER_COLUMN_C_LTD_NOTS_STATUS_2);
15397    
15398                            String sql = query.toString();
15399    
15400                            Session session = null;
15401    
15402                            try {
15403                                    session = openSession();
15404    
15405                                    Query q = session.createQuery(sql);
15406    
15407                                    QueryPos qPos = QueryPos.getInstance(q);
15408    
15409                                    qPos.add(companyId);
15410    
15411                                    if (bindDisplayDate) {
15412                                            qPos.add(new Timestamp(displayDate.getTime()));
15413                                    }
15414    
15415                                    qPos.add(status);
15416    
15417                                    count = (Long)q.uniqueResult();
15418    
15419                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
15420                            }
15421                            catch (Exception e) {
15422                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
15423    
15424                                    throw processException(e);
15425                            }
15426                            finally {
15427                                    closeSession(session);
15428                            }
15429                    }
15430    
15431                    return count.intValue();
15432            }
15433    
15434            private static final String _FINDER_COLUMN_C_LTD_NOTS_COMPANYID_2 = "blogsEntry.companyId = ? AND ";
15435            private static final String _FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL AND ";
15436            private static final String _FINDER_COLUMN_C_LTD_NOTS_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
15437            private static final String _FINDER_COLUMN_C_LTD_NOTS_STATUS_2 = "blogsEntry.status != ?";
15438            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD_S =
15439                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
15440                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
15441                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_LtD_S",
15442                            new String[] {
15443                                    Long.class.getName(), Long.class.getName(), Date.class.getName(),
15444                                    Integer.class.getName(),
15445                                    
15446                            Integer.class.getName(), Integer.class.getName(),
15447                                    OrderByComparator.class.getName()
15448                            });
15449            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD_S =
15450                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
15451                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
15452                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_U_LtD_S",
15453                            new String[] {
15454                                    Long.class.getName(), Long.class.getName(), Date.class.getName(),
15455                                    Integer.class.getName()
15456                            });
15457    
15458            /**
15459             * Returns all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
15460             *
15461             * @param groupId the group ID
15462             * @param userId the user ID
15463             * @param displayDate the display date
15464             * @param status the status
15465             * @return the matching blogs entries
15466             */
15467            @Override
15468            public List<BlogsEntry> findByG_U_LtD_S(long groupId, long userId,
15469                    Date displayDate, int status) {
15470                    return findByG_U_LtD_S(groupId, userId, displayDate, status,
15471                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
15472            }
15473    
15474            /**
15475             * Returns a range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
15476             *
15477             * <p>
15478             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
15479             * </p>
15480             *
15481             * @param groupId the group ID
15482             * @param userId the user ID
15483             * @param displayDate the display date
15484             * @param status the status
15485             * @param start the lower bound of the range of blogs entries
15486             * @param end the upper bound of the range of blogs entries (not inclusive)
15487             * @return the range of matching blogs entries
15488             */
15489            @Override
15490            public List<BlogsEntry> findByG_U_LtD_S(long groupId, long userId,
15491                    Date displayDate, int status, int start, int end) {
15492                    return findByG_U_LtD_S(groupId, userId, displayDate, status, start,
15493                            end, null);
15494            }
15495    
15496            /**
15497             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
15498             *
15499             * <p>
15500             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
15501             * </p>
15502             *
15503             * @param groupId the group ID
15504             * @param userId the user ID
15505             * @param displayDate the display date
15506             * @param status the status
15507             * @param start the lower bound of the range of blogs entries
15508             * @param end the upper bound of the range of blogs entries (not inclusive)
15509             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
15510             * @return the ordered range of matching blogs entries
15511             */
15512            @Override
15513            public List<BlogsEntry> findByG_U_LtD_S(long groupId, long userId,
15514                    Date displayDate, int status, int start, int end,
15515                    OrderByComparator<BlogsEntry> orderByComparator) {
15516                    boolean pagination = true;
15517                    FinderPath finderPath = null;
15518                    Object[] finderArgs = null;
15519    
15520                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD_S;
15521                    finderArgs = new Object[] {
15522                                    groupId, userId, displayDate, status,
15523                                    
15524                                    start, end, orderByComparator
15525                            };
15526    
15527                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
15528                                    finderArgs, this);
15529    
15530                    if ((list != null) && !list.isEmpty()) {
15531                            for (BlogsEntry blogsEntry : list) {
15532                                    if ((groupId != blogsEntry.getGroupId()) ||
15533                                                    (userId != blogsEntry.getUserId()) ||
15534                                                    (displayDate.getTime() <= blogsEntry.getDisplayDate()
15535                                                                                                                                    .getTime()) ||
15536                                                    (status != blogsEntry.getStatus())) {
15537                                            list = null;
15538    
15539                                            break;
15540                                    }
15541                            }
15542                    }
15543    
15544                    if (list == null) {
15545                            StringBundler query = null;
15546    
15547                            if (orderByComparator != null) {
15548                                    query = new StringBundler(6 +
15549                                                    (orderByComparator.getOrderByFields().length * 3));
15550                            }
15551                            else {
15552                                    query = new StringBundler(6);
15553                            }
15554    
15555                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
15556    
15557                            query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
15558    
15559                            query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
15560    
15561                            boolean bindDisplayDate = false;
15562    
15563                            if (displayDate == null) {
15564                                    query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
15565                            }
15566                            else {
15567                                    bindDisplayDate = true;
15568    
15569                                    query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
15570                            }
15571    
15572                            query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
15573    
15574                            if (orderByComparator != null) {
15575                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
15576                                            orderByComparator);
15577                            }
15578                            else
15579                             if (pagination) {
15580                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
15581                            }
15582    
15583                            String sql = query.toString();
15584    
15585                            Session session = null;
15586    
15587                            try {
15588                                    session = openSession();
15589    
15590                                    Query q = session.createQuery(sql);
15591    
15592                                    QueryPos qPos = QueryPos.getInstance(q);
15593    
15594                                    qPos.add(groupId);
15595    
15596                                    qPos.add(userId);
15597    
15598                                    if (bindDisplayDate) {
15599                                            qPos.add(new Timestamp(displayDate.getTime()));
15600                                    }
15601    
15602                                    qPos.add(status);
15603    
15604                                    if (!pagination) {
15605                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
15606                                                            start, end, false);
15607    
15608                                            Collections.sort(list);
15609    
15610                                            list = Collections.unmodifiableList(list);
15611                                    }
15612                                    else {
15613                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
15614                                                            start, end);
15615                                    }
15616    
15617                                    cacheResult(list);
15618    
15619                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
15620                            }
15621                            catch (Exception e) {
15622                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
15623    
15624                                    throw processException(e);
15625                            }
15626                            finally {
15627                                    closeSession(session);
15628                            }
15629                    }
15630    
15631                    return list;
15632            }
15633    
15634            /**
15635             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
15636             *
15637             * @param groupId the group ID
15638             * @param userId the user ID
15639             * @param displayDate the display date
15640             * @param status the status
15641             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15642             * @return the first matching blogs entry
15643             * @throws NoSuchEntryException if a matching blogs entry could not be found
15644             */
15645            @Override
15646            public BlogsEntry findByG_U_LtD_S_First(long groupId, long userId,
15647                    Date displayDate, int status,
15648                    OrderByComparator<BlogsEntry> orderByComparator)
15649                    throws NoSuchEntryException {
15650                    BlogsEntry blogsEntry = fetchByG_U_LtD_S_First(groupId, userId,
15651                                    displayDate, status, orderByComparator);
15652    
15653                    if (blogsEntry != null) {
15654                            return blogsEntry;
15655                    }
15656    
15657                    StringBundler msg = new StringBundler(10);
15658    
15659                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15660    
15661                    msg.append("groupId=");
15662                    msg.append(groupId);
15663    
15664                    msg.append(", userId=");
15665                    msg.append(userId);
15666    
15667                    msg.append(", displayDate=");
15668                    msg.append(displayDate);
15669    
15670                    msg.append(", status=");
15671                    msg.append(status);
15672    
15673                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15674    
15675                    throw new NoSuchEntryException(msg.toString());
15676            }
15677    
15678            /**
15679             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
15680             *
15681             * @param groupId the group ID
15682             * @param userId the user ID
15683             * @param displayDate the display date
15684             * @param status the status
15685             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15686             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
15687             */
15688            @Override
15689            public BlogsEntry fetchByG_U_LtD_S_First(long groupId, long userId,
15690                    Date displayDate, int status,
15691                    OrderByComparator<BlogsEntry> orderByComparator) {
15692                    List<BlogsEntry> list = findByG_U_LtD_S(groupId, userId, displayDate,
15693                                    status, 0, 1, orderByComparator);
15694    
15695                    if (!list.isEmpty()) {
15696                            return list.get(0);
15697                    }
15698    
15699                    return null;
15700            }
15701    
15702            /**
15703             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
15704             *
15705             * @param groupId the group ID
15706             * @param userId the user ID
15707             * @param displayDate the display date
15708             * @param status the status
15709             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15710             * @return the last matching blogs entry
15711             * @throws NoSuchEntryException if a matching blogs entry could not be found
15712             */
15713            @Override
15714            public BlogsEntry findByG_U_LtD_S_Last(long groupId, long userId,
15715                    Date displayDate, int status,
15716                    OrderByComparator<BlogsEntry> orderByComparator)
15717                    throws NoSuchEntryException {
15718                    BlogsEntry blogsEntry = fetchByG_U_LtD_S_Last(groupId, userId,
15719                                    displayDate, status, orderByComparator);
15720    
15721                    if (blogsEntry != null) {
15722                            return blogsEntry;
15723                    }
15724    
15725                    StringBundler msg = new StringBundler(10);
15726    
15727                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
15728    
15729                    msg.append("groupId=");
15730                    msg.append(groupId);
15731    
15732                    msg.append(", userId=");
15733                    msg.append(userId);
15734    
15735                    msg.append(", displayDate=");
15736                    msg.append(displayDate);
15737    
15738                    msg.append(", status=");
15739                    msg.append(status);
15740    
15741                    msg.append(StringPool.CLOSE_CURLY_BRACE);
15742    
15743                    throw new NoSuchEntryException(msg.toString());
15744            }
15745    
15746            /**
15747             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
15748             *
15749             * @param groupId the group ID
15750             * @param userId the user ID
15751             * @param displayDate the display date
15752             * @param status the status
15753             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15754             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
15755             */
15756            @Override
15757            public BlogsEntry fetchByG_U_LtD_S_Last(long groupId, long userId,
15758                    Date displayDate, int status,
15759                    OrderByComparator<BlogsEntry> orderByComparator) {
15760                    int count = countByG_U_LtD_S(groupId, userId, displayDate, status);
15761    
15762                    if (count == 0) {
15763                            return null;
15764                    }
15765    
15766                    List<BlogsEntry> list = findByG_U_LtD_S(groupId, userId, displayDate,
15767                                    status, count - 1, count, orderByComparator);
15768    
15769                    if (!list.isEmpty()) {
15770                            return list.get(0);
15771                    }
15772    
15773                    return null;
15774            }
15775    
15776            /**
15777             * 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;.
15778             *
15779             * @param entryId the primary key of the current blogs entry
15780             * @param groupId the group ID
15781             * @param userId the user ID
15782             * @param displayDate the display date
15783             * @param status the status
15784             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
15785             * @return the previous, current, and next blogs entry
15786             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
15787             */
15788            @Override
15789            public BlogsEntry[] findByG_U_LtD_S_PrevAndNext(long entryId, long groupId,
15790                    long userId, Date displayDate, int status,
15791                    OrderByComparator<BlogsEntry> orderByComparator)
15792                    throws NoSuchEntryException {
15793                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
15794    
15795                    Session session = null;
15796    
15797                    try {
15798                            session = openSession();
15799    
15800                            BlogsEntry[] array = new BlogsEntryImpl[3];
15801    
15802                            array[0] = getByG_U_LtD_S_PrevAndNext(session, blogsEntry, groupId,
15803                                            userId, displayDate, status, orderByComparator, true);
15804    
15805                            array[1] = blogsEntry;
15806    
15807                            array[2] = getByG_U_LtD_S_PrevAndNext(session, blogsEntry, groupId,
15808                                            userId, displayDate, status, orderByComparator, false);
15809    
15810                            return array;
15811                    }
15812                    catch (Exception e) {
15813                            throw processException(e);
15814                    }
15815                    finally {
15816                            closeSession(session);
15817                    }
15818            }
15819    
15820            protected BlogsEntry getByG_U_LtD_S_PrevAndNext(Session session,
15821                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
15822                    int status, OrderByComparator<BlogsEntry> orderByComparator,
15823                    boolean previous) {
15824                    StringBundler query = null;
15825    
15826                    if (orderByComparator != null) {
15827                            query = new StringBundler(6 +
15828                                            (orderByComparator.getOrderByFields().length * 6));
15829                    }
15830                    else {
15831                            query = new StringBundler(3);
15832                    }
15833    
15834                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
15835    
15836                    query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
15837    
15838                    query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
15839    
15840                    boolean bindDisplayDate = false;
15841    
15842                    if (displayDate == null) {
15843                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
15844                    }
15845                    else {
15846                            bindDisplayDate = true;
15847    
15848                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
15849                    }
15850    
15851                    query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
15852    
15853                    if (orderByComparator != null) {
15854                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
15855    
15856                            if (orderByConditionFields.length > 0) {
15857                                    query.append(WHERE_AND);
15858                            }
15859    
15860                            for (int i = 0; i < orderByConditionFields.length; i++) {
15861                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15862                                    query.append(orderByConditionFields[i]);
15863    
15864                                    if ((i + 1) < orderByConditionFields.length) {
15865                                            if (orderByComparator.isAscending() ^ previous) {
15866                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
15867                                            }
15868                                            else {
15869                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
15870                                            }
15871                                    }
15872                                    else {
15873                                            if (orderByComparator.isAscending() ^ previous) {
15874                                                    query.append(WHERE_GREATER_THAN);
15875                                            }
15876                                            else {
15877                                                    query.append(WHERE_LESSER_THAN);
15878                                            }
15879                                    }
15880                            }
15881    
15882                            query.append(ORDER_BY_CLAUSE);
15883    
15884                            String[] orderByFields = orderByComparator.getOrderByFields();
15885    
15886                            for (int i = 0; i < orderByFields.length; i++) {
15887                                    query.append(_ORDER_BY_ENTITY_ALIAS);
15888                                    query.append(orderByFields[i]);
15889    
15890                                    if ((i + 1) < orderByFields.length) {
15891                                            if (orderByComparator.isAscending() ^ previous) {
15892                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
15893                                            }
15894                                            else {
15895                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
15896                                            }
15897                                    }
15898                                    else {
15899                                            if (orderByComparator.isAscending() ^ previous) {
15900                                                    query.append(ORDER_BY_ASC);
15901                                            }
15902                                            else {
15903                                                    query.append(ORDER_BY_DESC);
15904                                            }
15905                                    }
15906                            }
15907                    }
15908                    else {
15909                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
15910                    }
15911    
15912                    String sql = query.toString();
15913    
15914                    Query q = session.createQuery(sql);
15915    
15916                    q.setFirstResult(0);
15917                    q.setMaxResults(2);
15918    
15919                    QueryPos qPos = QueryPos.getInstance(q);
15920    
15921                    qPos.add(groupId);
15922    
15923                    qPos.add(userId);
15924    
15925                    if (bindDisplayDate) {
15926                            qPos.add(new Timestamp(displayDate.getTime()));
15927                    }
15928    
15929                    qPos.add(status);
15930    
15931                    if (orderByComparator != null) {
15932                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
15933    
15934                            for (Object value : values) {
15935                                    qPos.add(value);
15936                            }
15937                    }
15938    
15939                    List<BlogsEntry> list = q.list();
15940    
15941                    if (list.size() == 2) {
15942                            return list.get(1);
15943                    }
15944                    else {
15945                            return null;
15946                    }
15947            }
15948    
15949            /**
15950             * 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;.
15951             *
15952             * @param groupId the group ID
15953             * @param userId the user ID
15954             * @param displayDate the display date
15955             * @param status the status
15956             * @return the matching blogs entries that the user has permission to view
15957             */
15958            @Override
15959            public List<BlogsEntry> filterFindByG_U_LtD_S(long groupId, long userId,
15960                    Date displayDate, int status) {
15961                    return filterFindByG_U_LtD_S(groupId, userId, displayDate, status,
15962                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
15963            }
15964    
15965            /**
15966             * 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;.
15967             *
15968             * <p>
15969             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
15970             * </p>
15971             *
15972             * @param groupId the group ID
15973             * @param userId the user ID
15974             * @param displayDate the display date
15975             * @param status the status
15976             * @param start the lower bound of the range of blogs entries
15977             * @param end the upper bound of the range of blogs entries (not inclusive)
15978             * @return the range of matching blogs entries that the user has permission to view
15979             */
15980            @Override
15981            public List<BlogsEntry> filterFindByG_U_LtD_S(long groupId, long userId,
15982                    Date displayDate, int status, int start, int end) {
15983                    return filterFindByG_U_LtD_S(groupId, userId, displayDate, status,
15984                            start, end, null);
15985            }
15986    
15987            /**
15988             * 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;.
15989             *
15990             * <p>
15991             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
15992             * </p>
15993             *
15994             * @param groupId the group ID
15995             * @param userId the user ID
15996             * @param displayDate the display date
15997             * @param status the status
15998             * @param start the lower bound of the range of blogs entries
15999             * @param end the upper bound of the range of blogs entries (not inclusive)
16000             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
16001             * @return the ordered range of matching blogs entries that the user has permission to view
16002             */
16003            @Override
16004            public List<BlogsEntry> filterFindByG_U_LtD_S(long groupId, long userId,
16005                    Date displayDate, int status, int start, int end,
16006                    OrderByComparator<BlogsEntry> orderByComparator) {
16007                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16008                            return findByG_U_LtD_S(groupId, userId, displayDate, status, start,
16009                                    end, orderByComparator);
16010                    }
16011    
16012                    StringBundler query = null;
16013    
16014                    if (orderByComparator != null) {
16015                            query = new StringBundler(6 +
16016                                            (orderByComparator.getOrderByFields().length * 3));
16017                    }
16018                    else {
16019                            query = new StringBundler(6);
16020                    }
16021    
16022                    if (getDB().isSupportsInlineDistinct()) {
16023                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
16024                    }
16025                    else {
16026                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
16027                    }
16028    
16029                    query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
16030    
16031                    query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
16032    
16033                    boolean bindDisplayDate = false;
16034    
16035                    if (displayDate == null) {
16036                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
16037                    }
16038                    else {
16039                            bindDisplayDate = true;
16040    
16041                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
16042                    }
16043    
16044                    query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
16045    
16046                    if (!getDB().isSupportsInlineDistinct()) {
16047                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
16048                    }
16049    
16050                    if (orderByComparator != null) {
16051                            if (getDB().isSupportsInlineDistinct()) {
16052                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
16053                                            orderByComparator, true);
16054                            }
16055                            else {
16056                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
16057                                            orderByComparator, true);
16058                            }
16059                    }
16060                    else {
16061                            if (getDB().isSupportsInlineDistinct()) {
16062                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
16063                            }
16064                            else {
16065                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
16066                            }
16067                    }
16068    
16069                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16070                                    BlogsEntry.class.getName(),
16071                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16072    
16073                    Session session = null;
16074    
16075                    try {
16076                            session = openSession();
16077    
16078                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
16079    
16080                            if (getDB().isSupportsInlineDistinct()) {
16081                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
16082                            }
16083                            else {
16084                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
16085                            }
16086    
16087                            QueryPos qPos = QueryPos.getInstance(q);
16088    
16089                            qPos.add(groupId);
16090    
16091                            qPos.add(userId);
16092    
16093                            if (bindDisplayDate) {
16094                                    qPos.add(new Timestamp(displayDate.getTime()));
16095                            }
16096    
16097                            qPos.add(status);
16098    
16099                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
16100                    }
16101                    catch (Exception e) {
16102                            throw processException(e);
16103                    }
16104                    finally {
16105                            closeSession(session);
16106                    }
16107            }
16108    
16109            /**
16110             * 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;.
16111             *
16112             * @param entryId the primary key of the current blogs entry
16113             * @param groupId the group ID
16114             * @param userId the user ID
16115             * @param displayDate the display date
16116             * @param status the status
16117             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16118             * @return the previous, current, and next blogs entry
16119             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
16120             */
16121            @Override
16122            public BlogsEntry[] filterFindByG_U_LtD_S_PrevAndNext(long entryId,
16123                    long groupId, long userId, Date displayDate, int status,
16124                    OrderByComparator<BlogsEntry> orderByComparator)
16125                    throws NoSuchEntryException {
16126                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16127                            return findByG_U_LtD_S_PrevAndNext(entryId, groupId, userId,
16128                                    displayDate, status, orderByComparator);
16129                    }
16130    
16131                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
16132    
16133                    Session session = null;
16134    
16135                    try {
16136                            session = openSession();
16137    
16138                            BlogsEntry[] array = new BlogsEntryImpl[3];
16139    
16140                            array[0] = filterGetByG_U_LtD_S_PrevAndNext(session, blogsEntry,
16141                                            groupId, userId, displayDate, status, orderByComparator,
16142                                            true);
16143    
16144                            array[1] = blogsEntry;
16145    
16146                            array[2] = filterGetByG_U_LtD_S_PrevAndNext(session, blogsEntry,
16147                                            groupId, userId, displayDate, status, orderByComparator,
16148                                            false);
16149    
16150                            return array;
16151                    }
16152                    catch (Exception e) {
16153                            throw processException(e);
16154                    }
16155                    finally {
16156                            closeSession(session);
16157                    }
16158            }
16159    
16160            protected BlogsEntry filterGetByG_U_LtD_S_PrevAndNext(Session session,
16161                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
16162                    int status, OrderByComparator<BlogsEntry> orderByComparator,
16163                    boolean previous) {
16164                    StringBundler query = null;
16165    
16166                    if (orderByComparator != null) {
16167                            query = new StringBundler(6 +
16168                                            (orderByComparator.getOrderByFields().length * 6));
16169                    }
16170                    else {
16171                            query = new StringBundler(3);
16172                    }
16173    
16174                    if (getDB().isSupportsInlineDistinct()) {
16175                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
16176                    }
16177                    else {
16178                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
16179                    }
16180    
16181                    query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
16182    
16183                    query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
16184    
16185                    boolean bindDisplayDate = false;
16186    
16187                    if (displayDate == null) {
16188                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
16189                    }
16190                    else {
16191                            bindDisplayDate = true;
16192    
16193                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
16194                    }
16195    
16196                    query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
16197    
16198                    if (!getDB().isSupportsInlineDistinct()) {
16199                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
16200                    }
16201    
16202                    if (orderByComparator != null) {
16203                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
16204    
16205                            if (orderByConditionFields.length > 0) {
16206                                    query.append(WHERE_AND);
16207                            }
16208    
16209                            for (int i = 0; i < orderByConditionFields.length; i++) {
16210                                    if (getDB().isSupportsInlineDistinct()) {
16211                                            query.append(_ORDER_BY_ENTITY_ALIAS);
16212                                    }
16213                                    else {
16214                                            query.append(_ORDER_BY_ENTITY_TABLE);
16215                                    }
16216    
16217                                    query.append(orderByConditionFields[i]);
16218    
16219                                    if ((i + 1) < orderByConditionFields.length) {
16220                                            if (orderByComparator.isAscending() ^ previous) {
16221                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
16222                                            }
16223                                            else {
16224                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
16225                                            }
16226                                    }
16227                                    else {
16228                                            if (orderByComparator.isAscending() ^ previous) {
16229                                                    query.append(WHERE_GREATER_THAN);
16230                                            }
16231                                            else {
16232                                                    query.append(WHERE_LESSER_THAN);
16233                                            }
16234                                    }
16235                            }
16236    
16237                            query.append(ORDER_BY_CLAUSE);
16238    
16239                            String[] orderByFields = orderByComparator.getOrderByFields();
16240    
16241                            for (int i = 0; i < orderByFields.length; i++) {
16242                                    if (getDB().isSupportsInlineDistinct()) {
16243                                            query.append(_ORDER_BY_ENTITY_ALIAS);
16244                                    }
16245                                    else {
16246                                            query.append(_ORDER_BY_ENTITY_TABLE);
16247                                    }
16248    
16249                                    query.append(orderByFields[i]);
16250    
16251                                    if ((i + 1) < orderByFields.length) {
16252                                            if (orderByComparator.isAscending() ^ previous) {
16253                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
16254                                            }
16255                                            else {
16256                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
16257                                            }
16258                                    }
16259                                    else {
16260                                            if (orderByComparator.isAscending() ^ previous) {
16261                                                    query.append(ORDER_BY_ASC);
16262                                            }
16263                                            else {
16264                                                    query.append(ORDER_BY_DESC);
16265                                            }
16266                                    }
16267                            }
16268                    }
16269                    else {
16270                            if (getDB().isSupportsInlineDistinct()) {
16271                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
16272                            }
16273                            else {
16274                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
16275                            }
16276                    }
16277    
16278                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16279                                    BlogsEntry.class.getName(),
16280                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16281    
16282                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
16283    
16284                    q.setFirstResult(0);
16285                    q.setMaxResults(2);
16286    
16287                    if (getDB().isSupportsInlineDistinct()) {
16288                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
16289                    }
16290                    else {
16291                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
16292                    }
16293    
16294                    QueryPos qPos = QueryPos.getInstance(q);
16295    
16296                    qPos.add(groupId);
16297    
16298                    qPos.add(userId);
16299    
16300                    if (bindDisplayDate) {
16301                            qPos.add(new Timestamp(displayDate.getTime()));
16302                    }
16303    
16304                    qPos.add(status);
16305    
16306                    if (orderByComparator != null) {
16307                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
16308    
16309                            for (Object value : values) {
16310                                    qPos.add(value);
16311                            }
16312                    }
16313    
16314                    List<BlogsEntry> list = q.list();
16315    
16316                    if (list.size() == 2) {
16317                            return list.get(1);
16318                    }
16319                    else {
16320                            return null;
16321                    }
16322            }
16323    
16324            /**
16325             * Removes all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63; from the database.
16326             *
16327             * @param groupId the group ID
16328             * @param userId the user ID
16329             * @param displayDate the display date
16330             * @param status the status
16331             */
16332            @Override
16333            public void removeByG_U_LtD_S(long groupId, long userId, Date displayDate,
16334                    int status) {
16335                    for (BlogsEntry blogsEntry : findByG_U_LtD_S(groupId, userId,
16336                                    displayDate, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
16337                            remove(blogsEntry);
16338                    }
16339            }
16340    
16341            /**
16342             * Returns the number of blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status = &#63;.
16343             *
16344             * @param groupId the group ID
16345             * @param userId the user ID
16346             * @param displayDate the display date
16347             * @param status the status
16348             * @return the number of matching blogs entries
16349             */
16350            @Override
16351            public int countByG_U_LtD_S(long groupId, long userId, Date displayDate,
16352                    int status) {
16353                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD_S;
16354    
16355                    Object[] finderArgs = new Object[] { groupId, userId, displayDate, status };
16356    
16357                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
16358                                    this);
16359    
16360                    if (count == null) {
16361                            StringBundler query = new StringBundler(5);
16362    
16363                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
16364    
16365                            query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
16366    
16367                            query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
16368    
16369                            boolean bindDisplayDate = false;
16370    
16371                            if (displayDate == null) {
16372                                    query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
16373                            }
16374                            else {
16375                                    bindDisplayDate = true;
16376    
16377                                    query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
16378                            }
16379    
16380                            query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
16381    
16382                            String sql = query.toString();
16383    
16384                            Session session = null;
16385    
16386                            try {
16387                                    session = openSession();
16388    
16389                                    Query q = session.createQuery(sql);
16390    
16391                                    QueryPos qPos = QueryPos.getInstance(q);
16392    
16393                                    qPos.add(groupId);
16394    
16395                                    qPos.add(userId);
16396    
16397                                    if (bindDisplayDate) {
16398                                            qPos.add(new Timestamp(displayDate.getTime()));
16399                                    }
16400    
16401                                    qPos.add(status);
16402    
16403                                    count = (Long)q.uniqueResult();
16404    
16405                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
16406                            }
16407                            catch (Exception e) {
16408                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
16409    
16410                                    throw processException(e);
16411                            }
16412                            finally {
16413                                    closeSession(session);
16414                            }
16415                    }
16416    
16417                    return count.intValue();
16418            }
16419    
16420            /**
16421             * 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;.
16422             *
16423             * @param groupId the group ID
16424             * @param userId the user ID
16425             * @param displayDate the display date
16426             * @param status the status
16427             * @return the number of matching blogs entries that the user has permission to view
16428             */
16429            @Override
16430            public int filterCountByG_U_LtD_S(long groupId, long userId,
16431                    Date displayDate, int status) {
16432                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
16433                            return countByG_U_LtD_S(groupId, userId, displayDate, status);
16434                    }
16435    
16436                    StringBundler query = new StringBundler(5);
16437    
16438                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
16439    
16440                    query.append(_FINDER_COLUMN_G_U_LTD_S_GROUPID_2);
16441    
16442                    query.append(_FINDER_COLUMN_G_U_LTD_S_USERID_2);
16443    
16444                    boolean bindDisplayDate = false;
16445    
16446                    if (displayDate == null) {
16447                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1);
16448                    }
16449                    else {
16450                            bindDisplayDate = true;
16451    
16452                            query.append(_FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2);
16453                    }
16454    
16455                    query.append(_FINDER_COLUMN_G_U_LTD_S_STATUS_2);
16456    
16457                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
16458                                    BlogsEntry.class.getName(),
16459                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
16460    
16461                    Session session = null;
16462    
16463                    try {
16464                            session = openSession();
16465    
16466                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
16467    
16468                            q.addScalar(COUNT_COLUMN_NAME,
16469                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
16470    
16471                            QueryPos qPos = QueryPos.getInstance(q);
16472    
16473                            qPos.add(groupId);
16474    
16475                            qPos.add(userId);
16476    
16477                            if (bindDisplayDate) {
16478                                    qPos.add(new Timestamp(displayDate.getTime()));
16479                            }
16480    
16481                            qPos.add(status);
16482    
16483                            Long count = (Long)q.uniqueResult();
16484    
16485                            return count.intValue();
16486                    }
16487                    catch (Exception e) {
16488                            throw processException(e);
16489                    }
16490                    finally {
16491                            closeSession(session);
16492                    }
16493            }
16494    
16495            private static final String _FINDER_COLUMN_G_U_LTD_S_GROUPID_2 = "blogsEntry.groupId = ? AND ";
16496            private static final String _FINDER_COLUMN_G_U_LTD_S_USERID_2 = "blogsEntry.userId = ? AND ";
16497            private static final String _FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL AND ";
16498            private static final String _FINDER_COLUMN_G_U_LTD_S_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
16499            private static final String _FINDER_COLUMN_G_U_LTD_S_STATUS_2 = "blogsEntry.status = ?";
16500            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD_NOTS =
16501                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
16502                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, BlogsEntryImpl.class,
16503                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_LtD_NotS",
16504                            new String[] {
16505                                    Long.class.getName(), Long.class.getName(), Date.class.getName(),
16506                                    Integer.class.getName(),
16507                                    
16508                            Integer.class.getName(), Integer.class.getName(),
16509                                    OrderByComparator.class.getName()
16510                            });
16511            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD_NOTS =
16512                    new FinderPath(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
16513                            BlogsEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
16514                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_U_LtD_NotS",
16515                            new String[] {
16516                                    Long.class.getName(), Long.class.getName(), Date.class.getName(),
16517                                    Integer.class.getName()
16518                            });
16519    
16520            /**
16521             * Returns all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
16522             *
16523             * @param groupId the group ID
16524             * @param userId the user ID
16525             * @param displayDate the display date
16526             * @param status the status
16527             * @return the matching blogs entries
16528             */
16529            @Override
16530            public List<BlogsEntry> findByG_U_LtD_NotS(long groupId, long userId,
16531                    Date displayDate, int status) {
16532                    return findByG_U_LtD_NotS(groupId, userId, displayDate, status,
16533                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
16534            }
16535    
16536            /**
16537             * Returns a range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
16538             *
16539             * <p>
16540             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
16541             * </p>
16542             *
16543             * @param groupId the group ID
16544             * @param userId the user ID
16545             * @param displayDate the display date
16546             * @param status the status
16547             * @param start the lower bound of the range of blogs entries
16548             * @param end the upper bound of the range of blogs entries (not inclusive)
16549             * @return the range of matching blogs entries
16550             */
16551            @Override
16552            public List<BlogsEntry> findByG_U_LtD_NotS(long groupId, long userId,
16553                    Date displayDate, int status, int start, int end) {
16554                    return findByG_U_LtD_NotS(groupId, userId, displayDate, status, start,
16555                            end, null);
16556            }
16557    
16558            /**
16559             * Returns an ordered range of all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
16560             *
16561             * <p>
16562             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
16563             * </p>
16564             *
16565             * @param groupId the group ID
16566             * @param userId the user ID
16567             * @param displayDate the display date
16568             * @param status the status
16569             * @param start the lower bound of the range of blogs entries
16570             * @param end the upper bound of the range of blogs entries (not inclusive)
16571             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
16572             * @return the ordered range of matching blogs entries
16573             */
16574            @Override
16575            public List<BlogsEntry> findByG_U_LtD_NotS(long groupId, long userId,
16576                    Date displayDate, int status, int start, int end,
16577                    OrderByComparator<BlogsEntry> orderByComparator) {
16578                    boolean pagination = true;
16579                    FinderPath finderPath = null;
16580                    Object[] finderArgs = null;
16581    
16582                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_LTD_NOTS;
16583                    finderArgs = new Object[] {
16584                                    groupId, userId, displayDate, status,
16585                                    
16586                                    start, end, orderByComparator
16587                            };
16588    
16589                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
16590                                    finderArgs, this);
16591    
16592                    if ((list != null) && !list.isEmpty()) {
16593                            for (BlogsEntry blogsEntry : list) {
16594                                    if ((groupId != blogsEntry.getGroupId()) ||
16595                                                    (userId != blogsEntry.getUserId()) ||
16596                                                    (displayDate.getTime() <= blogsEntry.getDisplayDate()
16597                                                                                                                                    .getTime()) ||
16598                                                    (status == blogsEntry.getStatus())) {
16599                                            list = null;
16600    
16601                                            break;
16602                                    }
16603                            }
16604                    }
16605    
16606                    if (list == null) {
16607                            StringBundler query = null;
16608    
16609                            if (orderByComparator != null) {
16610                                    query = new StringBundler(6 +
16611                                                    (orderByComparator.getOrderByFields().length * 3));
16612                            }
16613                            else {
16614                                    query = new StringBundler(6);
16615                            }
16616    
16617                            query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
16618    
16619                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
16620    
16621                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
16622    
16623                            boolean bindDisplayDate = false;
16624    
16625                            if (displayDate == null) {
16626                                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
16627                            }
16628                            else {
16629                                    bindDisplayDate = true;
16630    
16631                                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
16632                            }
16633    
16634                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
16635    
16636                            if (orderByComparator != null) {
16637                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
16638                                            orderByComparator);
16639                            }
16640                            else
16641                             if (pagination) {
16642                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
16643                            }
16644    
16645                            String sql = query.toString();
16646    
16647                            Session session = null;
16648    
16649                            try {
16650                                    session = openSession();
16651    
16652                                    Query q = session.createQuery(sql);
16653    
16654                                    QueryPos qPos = QueryPos.getInstance(q);
16655    
16656                                    qPos.add(groupId);
16657    
16658                                    qPos.add(userId);
16659    
16660                                    if (bindDisplayDate) {
16661                                            qPos.add(new Timestamp(displayDate.getTime()));
16662                                    }
16663    
16664                                    qPos.add(status);
16665    
16666                                    if (!pagination) {
16667                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
16668                                                            start, end, false);
16669    
16670                                            Collections.sort(list);
16671    
16672                                            list = Collections.unmodifiableList(list);
16673                                    }
16674                                    else {
16675                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
16676                                                            start, end);
16677                                    }
16678    
16679                                    cacheResult(list);
16680    
16681                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
16682                            }
16683                            catch (Exception e) {
16684                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
16685    
16686                                    throw processException(e);
16687                            }
16688                            finally {
16689                                    closeSession(session);
16690                            }
16691                    }
16692    
16693                    return list;
16694            }
16695    
16696            /**
16697             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
16698             *
16699             * @param groupId the group ID
16700             * @param userId the user ID
16701             * @param displayDate the display date
16702             * @param status the status
16703             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16704             * @return the first matching blogs entry
16705             * @throws NoSuchEntryException if a matching blogs entry could not be found
16706             */
16707            @Override
16708            public BlogsEntry findByG_U_LtD_NotS_First(long groupId, long userId,
16709                    Date displayDate, int status,
16710                    OrderByComparator<BlogsEntry> orderByComparator)
16711                    throws NoSuchEntryException {
16712                    BlogsEntry blogsEntry = fetchByG_U_LtD_NotS_First(groupId, userId,
16713                                    displayDate, status, orderByComparator);
16714    
16715                    if (blogsEntry != null) {
16716                            return blogsEntry;
16717                    }
16718    
16719                    StringBundler msg = new StringBundler(10);
16720    
16721                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
16722    
16723                    msg.append("groupId=");
16724                    msg.append(groupId);
16725    
16726                    msg.append(", userId=");
16727                    msg.append(userId);
16728    
16729                    msg.append(", displayDate=");
16730                    msg.append(displayDate);
16731    
16732                    msg.append(", status=");
16733                    msg.append(status);
16734    
16735                    msg.append(StringPool.CLOSE_CURLY_BRACE);
16736    
16737                    throw new NoSuchEntryException(msg.toString());
16738            }
16739    
16740            /**
16741             * Returns the first blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
16742             *
16743             * @param groupId the group ID
16744             * @param userId the user ID
16745             * @param displayDate the display date
16746             * @param status the status
16747             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16748             * @return the first matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
16749             */
16750            @Override
16751            public BlogsEntry fetchByG_U_LtD_NotS_First(long groupId, long userId,
16752                    Date displayDate, int status,
16753                    OrderByComparator<BlogsEntry> orderByComparator) {
16754                    List<BlogsEntry> list = findByG_U_LtD_NotS(groupId, userId,
16755                                    displayDate, status, 0, 1, orderByComparator);
16756    
16757                    if (!list.isEmpty()) {
16758                            return list.get(0);
16759                    }
16760    
16761                    return null;
16762            }
16763    
16764            /**
16765             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
16766             *
16767             * @param groupId the group ID
16768             * @param userId the user ID
16769             * @param displayDate the display date
16770             * @param status the status
16771             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16772             * @return the last matching blogs entry
16773             * @throws NoSuchEntryException if a matching blogs entry could not be found
16774             */
16775            @Override
16776            public BlogsEntry findByG_U_LtD_NotS_Last(long groupId, long userId,
16777                    Date displayDate, int status,
16778                    OrderByComparator<BlogsEntry> orderByComparator)
16779                    throws NoSuchEntryException {
16780                    BlogsEntry blogsEntry = fetchByG_U_LtD_NotS_Last(groupId, userId,
16781                                    displayDate, status, orderByComparator);
16782    
16783                    if (blogsEntry != null) {
16784                            return blogsEntry;
16785                    }
16786    
16787                    StringBundler msg = new StringBundler(10);
16788    
16789                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
16790    
16791                    msg.append("groupId=");
16792                    msg.append(groupId);
16793    
16794                    msg.append(", userId=");
16795                    msg.append(userId);
16796    
16797                    msg.append(", displayDate=");
16798                    msg.append(displayDate);
16799    
16800                    msg.append(", status=");
16801                    msg.append(status);
16802    
16803                    msg.append(StringPool.CLOSE_CURLY_BRACE);
16804    
16805                    throw new NoSuchEntryException(msg.toString());
16806            }
16807    
16808            /**
16809             * Returns the last blogs entry in the ordered set where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
16810             *
16811             * @param groupId the group ID
16812             * @param userId the user ID
16813             * @param displayDate the display date
16814             * @param status the status
16815             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16816             * @return the last matching blogs entry, or <code>null</code> if a matching blogs entry could not be found
16817             */
16818            @Override
16819            public BlogsEntry fetchByG_U_LtD_NotS_Last(long groupId, long userId,
16820                    Date displayDate, int status,
16821                    OrderByComparator<BlogsEntry> orderByComparator) {
16822                    int count = countByG_U_LtD_NotS(groupId, userId, displayDate, status);
16823    
16824                    if (count == 0) {
16825                            return null;
16826                    }
16827    
16828                    List<BlogsEntry> list = findByG_U_LtD_NotS(groupId, userId,
16829                                    displayDate, status, count - 1, count, orderByComparator);
16830    
16831                    if (!list.isEmpty()) {
16832                            return list.get(0);
16833                    }
16834    
16835                    return null;
16836            }
16837    
16838            /**
16839             * 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;.
16840             *
16841             * @param entryId the primary key of the current blogs entry
16842             * @param groupId the group ID
16843             * @param userId the user ID
16844             * @param displayDate the display date
16845             * @param status the status
16846             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
16847             * @return the previous, current, and next blogs entry
16848             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
16849             */
16850            @Override
16851            public BlogsEntry[] findByG_U_LtD_NotS_PrevAndNext(long entryId,
16852                    long groupId, long userId, Date displayDate, int status,
16853                    OrderByComparator<BlogsEntry> orderByComparator)
16854                    throws NoSuchEntryException {
16855                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
16856    
16857                    Session session = null;
16858    
16859                    try {
16860                            session = openSession();
16861    
16862                            BlogsEntry[] array = new BlogsEntryImpl[3];
16863    
16864                            array[0] = getByG_U_LtD_NotS_PrevAndNext(session, blogsEntry,
16865                                            groupId, userId, displayDate, status, orderByComparator,
16866                                            true);
16867    
16868                            array[1] = blogsEntry;
16869    
16870                            array[2] = getByG_U_LtD_NotS_PrevAndNext(session, blogsEntry,
16871                                            groupId, userId, displayDate, status, orderByComparator,
16872                                            false);
16873    
16874                            return array;
16875                    }
16876                    catch (Exception e) {
16877                            throw processException(e);
16878                    }
16879                    finally {
16880                            closeSession(session);
16881                    }
16882            }
16883    
16884            protected BlogsEntry getByG_U_LtD_NotS_PrevAndNext(Session session,
16885                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
16886                    int status, OrderByComparator<BlogsEntry> orderByComparator,
16887                    boolean previous) {
16888                    StringBundler query = null;
16889    
16890                    if (orderByComparator != null) {
16891                            query = new StringBundler(6 +
16892                                            (orderByComparator.getOrderByFields().length * 6));
16893                    }
16894                    else {
16895                            query = new StringBundler(3);
16896                    }
16897    
16898                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE);
16899    
16900                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
16901    
16902                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
16903    
16904                    boolean bindDisplayDate = false;
16905    
16906                    if (displayDate == null) {
16907                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
16908                    }
16909                    else {
16910                            bindDisplayDate = true;
16911    
16912                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
16913                    }
16914    
16915                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
16916    
16917                    if (orderByComparator != null) {
16918                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
16919    
16920                            if (orderByConditionFields.length > 0) {
16921                                    query.append(WHERE_AND);
16922                            }
16923    
16924                            for (int i = 0; i < orderByConditionFields.length; i++) {
16925                                    query.append(_ORDER_BY_ENTITY_ALIAS);
16926                                    query.append(orderByConditionFields[i]);
16927    
16928                                    if ((i + 1) < orderByConditionFields.length) {
16929                                            if (orderByComparator.isAscending() ^ previous) {
16930                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
16931                                            }
16932                                            else {
16933                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
16934                                            }
16935                                    }
16936                                    else {
16937                                            if (orderByComparator.isAscending() ^ previous) {
16938                                                    query.append(WHERE_GREATER_THAN);
16939                                            }
16940                                            else {
16941                                                    query.append(WHERE_LESSER_THAN);
16942                                            }
16943                                    }
16944                            }
16945    
16946                            query.append(ORDER_BY_CLAUSE);
16947    
16948                            String[] orderByFields = orderByComparator.getOrderByFields();
16949    
16950                            for (int i = 0; i < orderByFields.length; i++) {
16951                                    query.append(_ORDER_BY_ENTITY_ALIAS);
16952                                    query.append(orderByFields[i]);
16953    
16954                                    if ((i + 1) < orderByFields.length) {
16955                                            if (orderByComparator.isAscending() ^ previous) {
16956                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
16957                                            }
16958                                            else {
16959                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
16960                                            }
16961                                    }
16962                                    else {
16963                                            if (orderByComparator.isAscending() ^ previous) {
16964                                                    query.append(ORDER_BY_ASC);
16965                                            }
16966                                            else {
16967                                                    query.append(ORDER_BY_DESC);
16968                                            }
16969                                    }
16970                            }
16971                    }
16972                    else {
16973                            query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
16974                    }
16975    
16976                    String sql = query.toString();
16977    
16978                    Query q = session.createQuery(sql);
16979    
16980                    q.setFirstResult(0);
16981                    q.setMaxResults(2);
16982    
16983                    QueryPos qPos = QueryPos.getInstance(q);
16984    
16985                    qPos.add(groupId);
16986    
16987                    qPos.add(userId);
16988    
16989                    if (bindDisplayDate) {
16990                            qPos.add(new Timestamp(displayDate.getTime()));
16991                    }
16992    
16993                    qPos.add(status);
16994    
16995                    if (orderByComparator != null) {
16996                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
16997    
16998                            for (Object value : values) {
16999                                    qPos.add(value);
17000                            }
17001                    }
17002    
17003                    List<BlogsEntry> list = q.list();
17004    
17005                    if (list.size() == 2) {
17006                            return list.get(1);
17007                    }
17008                    else {
17009                            return null;
17010                    }
17011            }
17012    
17013            /**
17014             * 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;.
17015             *
17016             * @param groupId the group ID
17017             * @param userId the user ID
17018             * @param displayDate the display date
17019             * @param status the status
17020             * @return the matching blogs entries that the user has permission to view
17021             */
17022            @Override
17023            public List<BlogsEntry> filterFindByG_U_LtD_NotS(long groupId, long userId,
17024                    Date displayDate, int status) {
17025                    return filterFindByG_U_LtD_NotS(groupId, userId, displayDate, status,
17026                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
17027            }
17028    
17029            /**
17030             * 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;.
17031             *
17032             * <p>
17033             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
17034             * </p>
17035             *
17036             * @param groupId the group ID
17037             * @param userId the user ID
17038             * @param displayDate the display date
17039             * @param status the status
17040             * @param start the lower bound of the range of blogs entries
17041             * @param end the upper bound of the range of blogs entries (not inclusive)
17042             * @return the range of matching blogs entries that the user has permission to view
17043             */
17044            @Override
17045            public List<BlogsEntry> filterFindByG_U_LtD_NotS(long groupId, long userId,
17046                    Date displayDate, int status, int start, int end) {
17047                    return filterFindByG_U_LtD_NotS(groupId, userId, displayDate, status,
17048                            start, end, null);
17049            }
17050    
17051            /**
17052             * 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;.
17053             *
17054             * <p>
17055             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
17056             * </p>
17057             *
17058             * @param groupId the group ID
17059             * @param userId the user ID
17060             * @param displayDate the display date
17061             * @param status the status
17062             * @param start the lower bound of the range of blogs entries
17063             * @param end the upper bound of the range of blogs entries (not inclusive)
17064             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
17065             * @return the ordered range of matching blogs entries that the user has permission to view
17066             */
17067            @Override
17068            public List<BlogsEntry> filterFindByG_U_LtD_NotS(long groupId, long userId,
17069                    Date displayDate, int status, int start, int end,
17070                    OrderByComparator<BlogsEntry> orderByComparator) {
17071                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17072                            return findByG_U_LtD_NotS(groupId, userId, displayDate, status,
17073                                    start, end, orderByComparator);
17074                    }
17075    
17076                    StringBundler query = null;
17077    
17078                    if (orderByComparator != null) {
17079                            query = new StringBundler(6 +
17080                                            (orderByComparator.getOrderByFields().length * 3));
17081                    }
17082                    else {
17083                            query = new StringBundler(6);
17084                    }
17085    
17086                    if (getDB().isSupportsInlineDistinct()) {
17087                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
17088                    }
17089                    else {
17090                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
17091                    }
17092    
17093                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
17094    
17095                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
17096    
17097                    boolean bindDisplayDate = false;
17098    
17099                    if (displayDate == null) {
17100                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
17101                    }
17102                    else {
17103                            bindDisplayDate = true;
17104    
17105                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
17106                    }
17107    
17108                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
17109    
17110                    if (!getDB().isSupportsInlineDistinct()) {
17111                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
17112                    }
17113    
17114                    if (orderByComparator != null) {
17115                            if (getDB().isSupportsInlineDistinct()) {
17116                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
17117                                            orderByComparator, true);
17118                            }
17119                            else {
17120                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
17121                                            orderByComparator, true);
17122                            }
17123                    }
17124                    else {
17125                            if (getDB().isSupportsInlineDistinct()) {
17126                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
17127                            }
17128                            else {
17129                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
17130                            }
17131                    }
17132    
17133                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17134                                    BlogsEntry.class.getName(),
17135                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17136    
17137                    Session session = null;
17138    
17139                    try {
17140                            session = openSession();
17141    
17142                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
17143    
17144                            if (getDB().isSupportsInlineDistinct()) {
17145                                    q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
17146                            }
17147                            else {
17148                                    q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
17149                            }
17150    
17151                            QueryPos qPos = QueryPos.getInstance(q);
17152    
17153                            qPos.add(groupId);
17154    
17155                            qPos.add(userId);
17156    
17157                            if (bindDisplayDate) {
17158                                    qPos.add(new Timestamp(displayDate.getTime()));
17159                            }
17160    
17161                            qPos.add(status);
17162    
17163                            return (List<BlogsEntry>)QueryUtil.list(q, getDialect(), start, end);
17164                    }
17165                    catch (Exception e) {
17166                            throw processException(e);
17167                    }
17168                    finally {
17169                            closeSession(session);
17170                    }
17171            }
17172    
17173            /**
17174             * 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;.
17175             *
17176             * @param entryId the primary key of the current blogs entry
17177             * @param groupId the group ID
17178             * @param userId the user ID
17179             * @param displayDate the display date
17180             * @param status the status
17181             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
17182             * @return the previous, current, and next blogs entry
17183             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
17184             */
17185            @Override
17186            public BlogsEntry[] filterFindByG_U_LtD_NotS_PrevAndNext(long entryId,
17187                    long groupId, long userId, Date displayDate, int status,
17188                    OrderByComparator<BlogsEntry> orderByComparator)
17189                    throws NoSuchEntryException {
17190                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17191                            return findByG_U_LtD_NotS_PrevAndNext(entryId, groupId, userId,
17192                                    displayDate, status, orderByComparator);
17193                    }
17194    
17195                    BlogsEntry blogsEntry = findByPrimaryKey(entryId);
17196    
17197                    Session session = null;
17198    
17199                    try {
17200                            session = openSession();
17201    
17202                            BlogsEntry[] array = new BlogsEntryImpl[3];
17203    
17204                            array[0] = filterGetByG_U_LtD_NotS_PrevAndNext(session, blogsEntry,
17205                                            groupId, userId, displayDate, status, orderByComparator,
17206                                            true);
17207    
17208                            array[1] = blogsEntry;
17209    
17210                            array[2] = filterGetByG_U_LtD_NotS_PrevAndNext(session, blogsEntry,
17211                                            groupId, userId, displayDate, status, orderByComparator,
17212                                            false);
17213    
17214                            return array;
17215                    }
17216                    catch (Exception e) {
17217                            throw processException(e);
17218                    }
17219                    finally {
17220                            closeSession(session);
17221                    }
17222            }
17223    
17224            protected BlogsEntry filterGetByG_U_LtD_NotS_PrevAndNext(Session session,
17225                    BlogsEntry blogsEntry, long groupId, long userId, Date displayDate,
17226                    int status, OrderByComparator<BlogsEntry> orderByComparator,
17227                    boolean previous) {
17228                    StringBundler query = null;
17229    
17230                    if (orderByComparator != null) {
17231                            query = new StringBundler(6 +
17232                                            (orderByComparator.getOrderByFields().length * 6));
17233                    }
17234                    else {
17235                            query = new StringBundler(3);
17236                    }
17237    
17238                    if (getDB().isSupportsInlineDistinct()) {
17239                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_WHERE);
17240                    }
17241                    else {
17242                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1);
17243                    }
17244    
17245                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
17246    
17247                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
17248    
17249                    boolean bindDisplayDate = false;
17250    
17251                    if (displayDate == null) {
17252                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
17253                    }
17254                    else {
17255                            bindDisplayDate = true;
17256    
17257                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
17258                    }
17259    
17260                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
17261    
17262                    if (!getDB().isSupportsInlineDistinct()) {
17263                            query.append(_FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2);
17264                    }
17265    
17266                    if (orderByComparator != null) {
17267                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
17268    
17269                            if (orderByConditionFields.length > 0) {
17270                                    query.append(WHERE_AND);
17271                            }
17272    
17273                            for (int i = 0; i < orderByConditionFields.length; i++) {
17274                                    if (getDB().isSupportsInlineDistinct()) {
17275                                            query.append(_ORDER_BY_ENTITY_ALIAS);
17276                                    }
17277                                    else {
17278                                            query.append(_ORDER_BY_ENTITY_TABLE);
17279                                    }
17280    
17281                                    query.append(orderByConditionFields[i]);
17282    
17283                                    if ((i + 1) < orderByConditionFields.length) {
17284                                            if (orderByComparator.isAscending() ^ previous) {
17285                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
17286                                            }
17287                                            else {
17288                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
17289                                            }
17290                                    }
17291                                    else {
17292                                            if (orderByComparator.isAscending() ^ previous) {
17293                                                    query.append(WHERE_GREATER_THAN);
17294                                            }
17295                                            else {
17296                                                    query.append(WHERE_LESSER_THAN);
17297                                            }
17298                                    }
17299                            }
17300    
17301                            query.append(ORDER_BY_CLAUSE);
17302    
17303                            String[] orderByFields = orderByComparator.getOrderByFields();
17304    
17305                            for (int i = 0; i < orderByFields.length; i++) {
17306                                    if (getDB().isSupportsInlineDistinct()) {
17307                                            query.append(_ORDER_BY_ENTITY_ALIAS);
17308                                    }
17309                                    else {
17310                                            query.append(_ORDER_BY_ENTITY_TABLE);
17311                                    }
17312    
17313                                    query.append(orderByFields[i]);
17314    
17315                                    if ((i + 1) < orderByFields.length) {
17316                                            if (orderByComparator.isAscending() ^ previous) {
17317                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
17318                                            }
17319                                            else {
17320                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
17321                                            }
17322                                    }
17323                                    else {
17324                                            if (orderByComparator.isAscending() ^ previous) {
17325                                                    query.append(ORDER_BY_ASC);
17326                                            }
17327                                            else {
17328                                                    query.append(ORDER_BY_DESC);
17329                                            }
17330                                    }
17331                            }
17332                    }
17333                    else {
17334                            if (getDB().isSupportsInlineDistinct()) {
17335                                    query.append(BlogsEntryModelImpl.ORDER_BY_JPQL);
17336                            }
17337                            else {
17338                                    query.append(BlogsEntryModelImpl.ORDER_BY_SQL);
17339                            }
17340                    }
17341    
17342                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17343                                    BlogsEntry.class.getName(),
17344                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17345    
17346                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
17347    
17348                    q.setFirstResult(0);
17349                    q.setMaxResults(2);
17350    
17351                    if (getDB().isSupportsInlineDistinct()) {
17352                            q.addEntity(_FILTER_ENTITY_ALIAS, BlogsEntryImpl.class);
17353                    }
17354                    else {
17355                            q.addEntity(_FILTER_ENTITY_TABLE, BlogsEntryImpl.class);
17356                    }
17357    
17358                    QueryPos qPos = QueryPos.getInstance(q);
17359    
17360                    qPos.add(groupId);
17361    
17362                    qPos.add(userId);
17363    
17364                    if (bindDisplayDate) {
17365                            qPos.add(new Timestamp(displayDate.getTime()));
17366                    }
17367    
17368                    qPos.add(status);
17369    
17370                    if (orderByComparator != null) {
17371                            Object[] values = orderByComparator.getOrderByConditionValues(blogsEntry);
17372    
17373                            for (Object value : values) {
17374                                    qPos.add(value);
17375                            }
17376                    }
17377    
17378                    List<BlogsEntry> list = q.list();
17379    
17380                    if (list.size() == 2) {
17381                            return list.get(1);
17382                    }
17383                    else {
17384                            return null;
17385                    }
17386            }
17387    
17388            /**
17389             * Removes all the blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63; from the database.
17390             *
17391             * @param groupId the group ID
17392             * @param userId the user ID
17393             * @param displayDate the display date
17394             * @param status the status
17395             */
17396            @Override
17397            public void removeByG_U_LtD_NotS(long groupId, long userId,
17398                    Date displayDate, int status) {
17399                    for (BlogsEntry blogsEntry : findByG_U_LtD_NotS(groupId, userId,
17400                                    displayDate, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
17401                            remove(blogsEntry);
17402                    }
17403            }
17404    
17405            /**
17406             * Returns the number of blogs entries where groupId = &#63; and userId = &#63; and displayDate &lt; &#63; and status &ne; &#63;.
17407             *
17408             * @param groupId the group ID
17409             * @param userId the user ID
17410             * @param displayDate the display date
17411             * @param status the status
17412             * @return the number of matching blogs entries
17413             */
17414            @Override
17415            public int countByG_U_LtD_NotS(long groupId, long userId, Date displayDate,
17416                    int status) {
17417                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_LTD_NOTS;
17418    
17419                    Object[] finderArgs = new Object[] { groupId, userId, displayDate, status };
17420    
17421                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
17422                                    this);
17423    
17424                    if (count == null) {
17425                            StringBundler query = new StringBundler(5);
17426    
17427                            query.append(_SQL_COUNT_BLOGSENTRY_WHERE);
17428    
17429                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
17430    
17431                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
17432    
17433                            boolean bindDisplayDate = false;
17434    
17435                            if (displayDate == null) {
17436                                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
17437                            }
17438                            else {
17439                                    bindDisplayDate = true;
17440    
17441                                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
17442                            }
17443    
17444                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
17445    
17446                            String sql = query.toString();
17447    
17448                            Session session = null;
17449    
17450                            try {
17451                                    session = openSession();
17452    
17453                                    Query q = session.createQuery(sql);
17454    
17455                                    QueryPos qPos = QueryPos.getInstance(q);
17456    
17457                                    qPos.add(groupId);
17458    
17459                                    qPos.add(userId);
17460    
17461                                    if (bindDisplayDate) {
17462                                            qPos.add(new Timestamp(displayDate.getTime()));
17463                                    }
17464    
17465                                    qPos.add(status);
17466    
17467                                    count = (Long)q.uniqueResult();
17468    
17469                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
17470                            }
17471                            catch (Exception e) {
17472                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
17473    
17474                                    throw processException(e);
17475                            }
17476                            finally {
17477                                    closeSession(session);
17478                            }
17479                    }
17480    
17481                    return count.intValue();
17482            }
17483    
17484            /**
17485             * 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;.
17486             *
17487             * @param groupId the group ID
17488             * @param userId the user ID
17489             * @param displayDate the display date
17490             * @param status the status
17491             * @return the number of matching blogs entries that the user has permission to view
17492             */
17493            @Override
17494            public int filterCountByG_U_LtD_NotS(long groupId, long userId,
17495                    Date displayDate, int status) {
17496                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
17497                            return countByG_U_LtD_NotS(groupId, userId, displayDate, status);
17498                    }
17499    
17500                    StringBundler query = new StringBundler(5);
17501    
17502                    query.append(_FILTER_SQL_COUNT_BLOGSENTRY_WHERE);
17503    
17504                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2);
17505    
17506                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_USERID_2);
17507    
17508                    boolean bindDisplayDate = false;
17509    
17510                    if (displayDate == null) {
17511                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1);
17512                    }
17513                    else {
17514                            bindDisplayDate = true;
17515    
17516                            query.append(_FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2);
17517                    }
17518    
17519                    query.append(_FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2);
17520    
17521                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
17522                                    BlogsEntry.class.getName(),
17523                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
17524    
17525                    Session session = null;
17526    
17527                    try {
17528                            session = openSession();
17529    
17530                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
17531    
17532                            q.addScalar(COUNT_COLUMN_NAME,
17533                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
17534    
17535                            QueryPos qPos = QueryPos.getInstance(q);
17536    
17537                            qPos.add(groupId);
17538    
17539                            qPos.add(userId);
17540    
17541                            if (bindDisplayDate) {
17542                                    qPos.add(new Timestamp(displayDate.getTime()));
17543                            }
17544    
17545                            qPos.add(status);
17546    
17547                            Long count = (Long)q.uniqueResult();
17548    
17549                            return count.intValue();
17550                    }
17551                    catch (Exception e) {
17552                            throw processException(e);
17553                    }
17554                    finally {
17555                            closeSession(session);
17556                    }
17557            }
17558    
17559            private static final String _FINDER_COLUMN_G_U_LTD_NOTS_GROUPID_2 = "blogsEntry.groupId = ? AND ";
17560            private static final String _FINDER_COLUMN_G_U_LTD_NOTS_USERID_2 = "blogsEntry.userId = ? AND ";
17561            private static final String _FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_1 = "blogsEntry.displayDate < NULL AND ";
17562            private static final String _FINDER_COLUMN_G_U_LTD_NOTS_DISPLAYDATE_2 = "blogsEntry.displayDate < ? AND ";
17563            private static final String _FINDER_COLUMN_G_U_LTD_NOTS_STATUS_2 = "blogsEntry.status != ?";
17564    
17565            public BlogsEntryPersistenceImpl() {
17566                    setModelClass(BlogsEntry.class);
17567            }
17568    
17569            /**
17570             * Caches the blogs entry in the entity cache if it is enabled.
17571             *
17572             * @param blogsEntry the blogs entry
17573             */
17574            @Override
17575            public void cacheResult(BlogsEntry blogsEntry) {
17576                    EntityCacheUtil.putResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
17577                            BlogsEntryImpl.class, blogsEntry.getPrimaryKey(), blogsEntry);
17578    
17579                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
17580                            new Object[] { blogsEntry.getUuid(), blogsEntry.getGroupId() },
17581                            blogsEntry);
17582    
17583                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_UT,
17584                            new Object[] { blogsEntry.getGroupId(), blogsEntry.getUrlTitle() },
17585                            blogsEntry);
17586    
17587                    blogsEntry.resetOriginalValues();
17588            }
17589    
17590            /**
17591             * Caches the blogs entries in the entity cache if it is enabled.
17592             *
17593             * @param blogsEntries the blogs entries
17594             */
17595            @Override
17596            public void cacheResult(List<BlogsEntry> blogsEntries) {
17597                    for (BlogsEntry blogsEntry : blogsEntries) {
17598                            if (EntityCacheUtil.getResult(
17599                                                    BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
17600                                                    BlogsEntryImpl.class, blogsEntry.getPrimaryKey()) == null) {
17601                                    cacheResult(blogsEntry);
17602                            }
17603                            else {
17604                                    blogsEntry.resetOriginalValues();
17605                            }
17606                    }
17607            }
17608    
17609            /**
17610             * Clears the cache for all blogs entries.
17611             *
17612             * <p>
17613             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
17614             * </p>
17615             */
17616            @Override
17617            public void clearCache() {
17618                    EntityCacheUtil.clearCache(BlogsEntryImpl.class);
17619    
17620                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
17621                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
17622                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
17623            }
17624    
17625            /**
17626             * Clears the cache for the blogs entry.
17627             *
17628             * <p>
17629             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
17630             * </p>
17631             */
17632            @Override
17633            public void clearCache(BlogsEntry blogsEntry) {
17634                    EntityCacheUtil.removeResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
17635                            BlogsEntryImpl.class, blogsEntry.getPrimaryKey());
17636    
17637                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
17638                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
17639    
17640                    clearUniqueFindersCache(blogsEntry);
17641            }
17642    
17643            @Override
17644            public void clearCache(List<BlogsEntry> blogsEntries) {
17645                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
17646                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
17647    
17648                    for (BlogsEntry blogsEntry : blogsEntries) {
17649                            EntityCacheUtil.removeResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
17650                                    BlogsEntryImpl.class, blogsEntry.getPrimaryKey());
17651    
17652                            clearUniqueFindersCache(blogsEntry);
17653                    }
17654            }
17655    
17656            protected void cacheUniqueFindersCache(BlogsEntry blogsEntry) {
17657                    if (blogsEntry.isNew()) {
17658                            Object[] args = new Object[] {
17659                                            blogsEntry.getUuid(), blogsEntry.getGroupId()
17660                                    };
17661    
17662                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
17663                                    Long.valueOf(1));
17664                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
17665                                    blogsEntry);
17666    
17667                            args = new Object[] {
17668                                            blogsEntry.getGroupId(), blogsEntry.getUrlTitle()
17669                                    };
17670    
17671                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_UT, args,
17672                                    Long.valueOf(1));
17673                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_UT, args,
17674                                    blogsEntry);
17675                    }
17676                    else {
17677                            BlogsEntryModelImpl blogsEntryModelImpl = (BlogsEntryModelImpl)blogsEntry;
17678    
17679                            if ((blogsEntryModelImpl.getColumnBitmask() &
17680                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
17681                                    Object[] args = new Object[] {
17682                                                    blogsEntry.getUuid(), blogsEntry.getGroupId()
17683                                            };
17684    
17685                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
17686                                            Long.valueOf(1));
17687                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
17688                                            blogsEntry);
17689                            }
17690    
17691                            if ((blogsEntryModelImpl.getColumnBitmask() &
17692                                            FINDER_PATH_FETCH_BY_G_UT.getColumnBitmask()) != 0) {
17693                                    Object[] args = new Object[] {
17694                                                    blogsEntry.getGroupId(), blogsEntry.getUrlTitle()
17695                                            };
17696    
17697                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_UT, args,
17698                                            Long.valueOf(1));
17699                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_UT, args,
17700                                            blogsEntry);
17701                            }
17702                    }
17703            }
17704    
17705            protected void clearUniqueFindersCache(BlogsEntry blogsEntry) {
17706                    BlogsEntryModelImpl blogsEntryModelImpl = (BlogsEntryModelImpl)blogsEntry;
17707    
17708                    Object[] args = new Object[] {
17709                                    blogsEntry.getUuid(), blogsEntry.getGroupId()
17710                            };
17711    
17712                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
17713                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
17714    
17715                    if ((blogsEntryModelImpl.getColumnBitmask() &
17716                                    FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
17717                            args = new Object[] {
17718                                            blogsEntryModelImpl.getOriginalUuid(),
17719                                            blogsEntryModelImpl.getOriginalGroupId()
17720                                    };
17721    
17722                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
17723                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
17724                    }
17725    
17726                    args = new Object[] { blogsEntry.getGroupId(), blogsEntry.getUrlTitle() };
17727    
17728                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT, args);
17729                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_UT, args);
17730    
17731                    if ((blogsEntryModelImpl.getColumnBitmask() &
17732                                    FINDER_PATH_FETCH_BY_G_UT.getColumnBitmask()) != 0) {
17733                            args = new Object[] {
17734                                            blogsEntryModelImpl.getOriginalGroupId(),
17735                                            blogsEntryModelImpl.getOriginalUrlTitle()
17736                                    };
17737    
17738                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_UT, args);
17739                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_UT, args);
17740                    }
17741            }
17742    
17743            /**
17744             * Creates a new blogs entry with the primary key. Does not add the blogs entry to the database.
17745             *
17746             * @param entryId the primary key for the new blogs entry
17747             * @return the new blogs entry
17748             */
17749            @Override
17750            public BlogsEntry create(long entryId) {
17751                    BlogsEntry blogsEntry = new BlogsEntryImpl();
17752    
17753                    blogsEntry.setNew(true);
17754                    blogsEntry.setPrimaryKey(entryId);
17755    
17756                    String uuid = PortalUUIDUtil.generate();
17757    
17758                    blogsEntry.setUuid(uuid);
17759    
17760                    return blogsEntry;
17761            }
17762    
17763            /**
17764             * Removes the blogs entry with the primary key from the database. Also notifies the appropriate model listeners.
17765             *
17766             * @param entryId the primary key of the blogs entry
17767             * @return the blogs entry that was removed
17768             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
17769             */
17770            @Override
17771            public BlogsEntry remove(long entryId) throws NoSuchEntryException {
17772                    return remove((Serializable)entryId);
17773            }
17774    
17775            /**
17776             * Removes the blogs entry with the primary key from the database. Also notifies the appropriate model listeners.
17777             *
17778             * @param primaryKey the primary key of the blogs entry
17779             * @return the blogs entry that was removed
17780             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
17781             */
17782            @Override
17783            public BlogsEntry remove(Serializable primaryKey)
17784                    throws NoSuchEntryException {
17785                    Session session = null;
17786    
17787                    try {
17788                            session = openSession();
17789    
17790                            BlogsEntry blogsEntry = (BlogsEntry)session.get(BlogsEntryImpl.class,
17791                                            primaryKey);
17792    
17793                            if (blogsEntry == null) {
17794                                    if (_log.isWarnEnabled()) {
17795                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
17796                                    }
17797    
17798                                    throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
17799                                            primaryKey);
17800                            }
17801    
17802                            return remove(blogsEntry);
17803                    }
17804                    catch (NoSuchEntryException nsee) {
17805                            throw nsee;
17806                    }
17807                    catch (Exception e) {
17808                            throw processException(e);
17809                    }
17810                    finally {
17811                            closeSession(session);
17812                    }
17813            }
17814    
17815            @Override
17816            protected BlogsEntry removeImpl(BlogsEntry blogsEntry) {
17817                    blogsEntry = toUnwrappedModel(blogsEntry);
17818    
17819                    Session session = null;
17820    
17821                    try {
17822                            session = openSession();
17823    
17824                            if (!session.contains(blogsEntry)) {
17825                                    blogsEntry = (BlogsEntry)session.get(BlogsEntryImpl.class,
17826                                                    blogsEntry.getPrimaryKeyObj());
17827                            }
17828    
17829                            if (blogsEntry != null) {
17830                                    session.delete(blogsEntry);
17831                            }
17832                    }
17833                    catch (Exception e) {
17834                            throw processException(e);
17835                    }
17836                    finally {
17837                            closeSession(session);
17838                    }
17839    
17840                    if (blogsEntry != null) {
17841                            clearCache(blogsEntry);
17842                    }
17843    
17844                    return blogsEntry;
17845            }
17846    
17847            @Override
17848            public BlogsEntry updateImpl(BlogsEntry blogsEntry) {
17849                    blogsEntry = toUnwrappedModel(blogsEntry);
17850    
17851                    boolean isNew = blogsEntry.isNew();
17852    
17853                    BlogsEntryModelImpl blogsEntryModelImpl = (BlogsEntryModelImpl)blogsEntry;
17854    
17855                    if (Validator.isNull(blogsEntry.getUuid())) {
17856                            String uuid = PortalUUIDUtil.generate();
17857    
17858                            blogsEntry.setUuid(uuid);
17859                    }
17860    
17861                    ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();
17862    
17863                    Date now = new Date();
17864    
17865                    if (isNew && (blogsEntry.getCreateDate() == null)) {
17866                            if (serviceContext == null) {
17867                                    blogsEntry.setCreateDate(now);
17868                            }
17869                            else {
17870                                    blogsEntry.setCreateDate(serviceContext.getCreateDate(now));
17871                            }
17872                    }
17873    
17874                    if (!blogsEntryModelImpl.hasSetModifiedDate()) {
17875                            if (serviceContext == null) {
17876                                    blogsEntry.setModifiedDate(now);
17877                            }
17878                            else {
17879                                    blogsEntry.setModifiedDate(serviceContext.getModifiedDate(now));
17880                            }
17881                    }
17882    
17883                    long userId = GetterUtil.getLong(PrincipalThreadLocal.getName());
17884    
17885                    if (userId > 0) {
17886                            long companyId = blogsEntry.getCompanyId();
17887    
17888                            long groupId = blogsEntry.getGroupId();
17889    
17890                            long entryId = 0;
17891    
17892                            if (!isNew) {
17893                                    entryId = blogsEntry.getPrimaryKey();
17894                            }
17895    
17896                            try {
17897                                    blogsEntry.setTitle(SanitizerUtil.sanitize(companyId, groupId,
17898                                                    userId, BlogsEntry.class.getName(), entryId,
17899                                                    ContentTypes.TEXT_PLAIN, Sanitizer.MODE_ALL,
17900                                                    blogsEntry.getTitle(), null));
17901    
17902                                    blogsEntry.setContent(SanitizerUtil.sanitize(companyId,
17903                                                    groupId, userId, BlogsEntry.class.getName(), entryId,
17904                                                    ContentTypes.TEXT_HTML, Sanitizer.MODE_ALL,
17905                                                    blogsEntry.getContent(), null));
17906                            }
17907                            catch (SanitizerException se) {
17908                                    throw new SystemException(se);
17909                            }
17910                    }
17911    
17912                    Session session = null;
17913    
17914                    try {
17915                            session = openSession();
17916    
17917                            if (blogsEntry.isNew()) {
17918                                    session.save(blogsEntry);
17919    
17920                                    blogsEntry.setNew(false);
17921                            }
17922                            else {
17923                                    session.merge(blogsEntry);
17924                            }
17925                    }
17926                    catch (Exception e) {
17927                            throw processException(e);
17928                    }
17929                    finally {
17930                            closeSession(session);
17931                    }
17932    
17933                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
17934    
17935                    if (isNew || !BlogsEntryModelImpl.COLUMN_BITMASK_ENABLED) {
17936                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
17937                    }
17938    
17939                    else {
17940                            if ((blogsEntryModelImpl.getColumnBitmask() &
17941                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
17942                                    Object[] args = new Object[] {
17943                                                    blogsEntryModelImpl.getOriginalUuid()
17944                                            };
17945    
17946                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
17947                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
17948                                            args);
17949    
17950                                    args = new Object[] { blogsEntryModelImpl.getUuid() };
17951    
17952                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
17953                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
17954                                            args);
17955                            }
17956    
17957                            if ((blogsEntryModelImpl.getColumnBitmask() &
17958                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
17959                                    Object[] args = new Object[] {
17960                                                    blogsEntryModelImpl.getOriginalUuid(),
17961                                                    blogsEntryModelImpl.getOriginalCompanyId()
17962                                            };
17963    
17964                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
17965                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
17966                                            args);
17967    
17968                                    args = new Object[] {
17969                                                    blogsEntryModelImpl.getUuid(),
17970                                                    blogsEntryModelImpl.getCompanyId()
17971                                            };
17972    
17973                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
17974                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
17975                                            args);
17976                            }
17977    
17978                            if ((blogsEntryModelImpl.getColumnBitmask() &
17979                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
17980                                    Object[] args = new Object[] {
17981                                                    blogsEntryModelImpl.getOriginalGroupId()
17982                                            };
17983    
17984                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
17985                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
17986                                            args);
17987    
17988                                    args = new Object[] { blogsEntryModelImpl.getGroupId() };
17989    
17990                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
17991                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
17992                                            args);
17993                            }
17994    
17995                            if ((blogsEntryModelImpl.getColumnBitmask() &
17996                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
17997                                    Object[] args = new Object[] {
17998                                                    blogsEntryModelImpl.getOriginalCompanyId()
17999                                            };
18000    
18001                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
18002                                            args);
18003                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
18004                                            args);
18005    
18006                                    args = new Object[] { blogsEntryModelImpl.getCompanyId() };
18007    
18008                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
18009                                            args);
18010                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
18011                                            args);
18012                            }
18013    
18014                            if ((blogsEntryModelImpl.getColumnBitmask() &
18015                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S.getColumnBitmask()) != 0) {
18016                                    Object[] args = new Object[] {
18017                                                    blogsEntryModelImpl.getOriginalGroupId(),
18018                                                    blogsEntryModelImpl.getOriginalStatus()
18019                                            };
18020    
18021                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
18022                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
18023                                            args);
18024    
18025                                    args = new Object[] {
18026                                                    blogsEntryModelImpl.getGroupId(),
18027                                                    blogsEntryModelImpl.getStatus()
18028                                            };
18029    
18030                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
18031                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
18032                                            args);
18033                            }
18034    
18035                            if ((blogsEntryModelImpl.getColumnBitmask() &
18036                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U.getColumnBitmask()) != 0) {
18037                                    Object[] args = new Object[] {
18038                                                    blogsEntryModelImpl.getOriginalCompanyId(),
18039                                                    blogsEntryModelImpl.getOriginalUserId()
18040                                            };
18041    
18042                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_U, args);
18043                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U,
18044                                            args);
18045    
18046                                    args = new Object[] {
18047                                                    blogsEntryModelImpl.getCompanyId(),
18048                                                    blogsEntryModelImpl.getUserId()
18049                                            };
18050    
18051                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_U, args);
18052                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U,
18053                                            args);
18054                            }
18055    
18056                            if ((blogsEntryModelImpl.getColumnBitmask() &
18057                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S.getColumnBitmask()) != 0) {
18058                                    Object[] args = new Object[] {
18059                                                    blogsEntryModelImpl.getOriginalCompanyId(),
18060                                                    blogsEntryModelImpl.getOriginalStatus()
18061                                            };
18062    
18063                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_S, args);
18064                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S,
18065                                            args);
18066    
18067                                    args = new Object[] {
18068                                                    blogsEntryModelImpl.getCompanyId(),
18069                                                    blogsEntryModelImpl.getStatus()
18070                                            };
18071    
18072                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_S, args);
18073                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S,
18074                                            args);
18075                            }
18076    
18077                            if ((blogsEntryModelImpl.getColumnBitmask() &
18078                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S.getColumnBitmask()) != 0) {
18079                                    Object[] args = new Object[] {
18080                                                    blogsEntryModelImpl.getOriginalGroupId(),
18081                                                    blogsEntryModelImpl.getOriginalUserId(),
18082                                                    blogsEntryModelImpl.getOriginalStatus()
18083                                            };
18084    
18085                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_S, args);
18086                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S,
18087                                            args);
18088    
18089                                    args = new Object[] {
18090                                                    blogsEntryModelImpl.getGroupId(),
18091                                                    blogsEntryModelImpl.getUserId(),
18092                                                    blogsEntryModelImpl.getStatus()
18093                                            };
18094    
18095                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_S, args);
18096                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S,
18097                                            args);
18098                            }
18099    
18100                            if ((blogsEntryModelImpl.getColumnBitmask() &
18101                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U_S.getColumnBitmask()) != 0) {
18102                                    Object[] args = new Object[] {
18103                                                    blogsEntryModelImpl.getOriginalCompanyId(),
18104                                                    blogsEntryModelImpl.getOriginalUserId(),
18105                                                    blogsEntryModelImpl.getOriginalStatus()
18106                                            };
18107    
18108                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_U_S, args);
18109                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U_S,
18110                                            args);
18111    
18112                                    args = new Object[] {
18113                                                    blogsEntryModelImpl.getCompanyId(),
18114                                                    blogsEntryModelImpl.getUserId(),
18115                                                    blogsEntryModelImpl.getStatus()
18116                                            };
18117    
18118                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_U_S, args);
18119                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_U_S,
18120                                            args);
18121                            }
18122                    }
18123    
18124                    EntityCacheUtil.putResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18125                            BlogsEntryImpl.class, blogsEntry.getPrimaryKey(), blogsEntry, false);
18126    
18127                    clearUniqueFindersCache(blogsEntry);
18128                    cacheUniqueFindersCache(blogsEntry);
18129    
18130                    blogsEntry.resetOriginalValues();
18131    
18132                    return blogsEntry;
18133            }
18134    
18135            protected BlogsEntry toUnwrappedModel(BlogsEntry blogsEntry) {
18136                    if (blogsEntry instanceof BlogsEntryImpl) {
18137                            return blogsEntry;
18138                    }
18139    
18140                    BlogsEntryImpl blogsEntryImpl = new BlogsEntryImpl();
18141    
18142                    blogsEntryImpl.setNew(blogsEntry.isNew());
18143                    blogsEntryImpl.setPrimaryKey(blogsEntry.getPrimaryKey());
18144    
18145                    blogsEntryImpl.setUuid(blogsEntry.getUuid());
18146                    blogsEntryImpl.setEntryId(blogsEntry.getEntryId());
18147                    blogsEntryImpl.setGroupId(blogsEntry.getGroupId());
18148                    blogsEntryImpl.setCompanyId(blogsEntry.getCompanyId());
18149                    blogsEntryImpl.setUserId(blogsEntry.getUserId());
18150                    blogsEntryImpl.setUserName(blogsEntry.getUserName());
18151                    blogsEntryImpl.setCreateDate(blogsEntry.getCreateDate());
18152                    blogsEntryImpl.setModifiedDate(blogsEntry.getModifiedDate());
18153                    blogsEntryImpl.setTitle(blogsEntry.getTitle());
18154                    blogsEntryImpl.setSubtitle(blogsEntry.getSubtitle());
18155                    blogsEntryImpl.setUrlTitle(blogsEntry.getUrlTitle());
18156                    blogsEntryImpl.setDescription(blogsEntry.getDescription());
18157                    blogsEntryImpl.setContent(blogsEntry.getContent());
18158                    blogsEntryImpl.setDisplayDate(blogsEntry.getDisplayDate());
18159                    blogsEntryImpl.setAllowPingbacks(blogsEntry.isAllowPingbacks());
18160                    blogsEntryImpl.setAllowTrackbacks(blogsEntry.isAllowTrackbacks());
18161                    blogsEntryImpl.setTrackbacks(blogsEntry.getTrackbacks());
18162                    blogsEntryImpl.setCoverImageCaption(blogsEntry.getCoverImageCaption());
18163                    blogsEntryImpl.setCoverImageFileEntryId(blogsEntry.getCoverImageFileEntryId());
18164                    blogsEntryImpl.setCoverImageURL(blogsEntry.getCoverImageURL());
18165                    blogsEntryImpl.setSmallImage(blogsEntry.isSmallImage());
18166                    blogsEntryImpl.setSmallImageFileEntryId(blogsEntry.getSmallImageFileEntryId());
18167                    blogsEntryImpl.setSmallImageId(blogsEntry.getSmallImageId());
18168                    blogsEntryImpl.setSmallImageURL(blogsEntry.getSmallImageURL());
18169                    blogsEntryImpl.setStatus(blogsEntry.getStatus());
18170                    blogsEntryImpl.setStatusByUserId(blogsEntry.getStatusByUserId());
18171                    blogsEntryImpl.setStatusByUserName(blogsEntry.getStatusByUserName());
18172                    blogsEntryImpl.setStatusDate(blogsEntry.getStatusDate());
18173    
18174                    return blogsEntryImpl;
18175            }
18176    
18177            /**
18178             * Returns the blogs entry with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
18179             *
18180             * @param primaryKey the primary key of the blogs entry
18181             * @return the blogs entry
18182             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
18183             */
18184            @Override
18185            public BlogsEntry findByPrimaryKey(Serializable primaryKey)
18186                    throws NoSuchEntryException {
18187                    BlogsEntry blogsEntry = fetchByPrimaryKey(primaryKey);
18188    
18189                    if (blogsEntry == null) {
18190                            if (_log.isWarnEnabled()) {
18191                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
18192                            }
18193    
18194                            throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
18195                                    primaryKey);
18196                    }
18197    
18198                    return blogsEntry;
18199            }
18200    
18201            /**
18202             * Returns the blogs entry with the primary key or throws a {@link NoSuchEntryException} if it could not be found.
18203             *
18204             * @param entryId the primary key of the blogs entry
18205             * @return the blogs entry
18206             * @throws NoSuchEntryException if a blogs entry with the primary key could not be found
18207             */
18208            @Override
18209            public BlogsEntry findByPrimaryKey(long entryId)
18210                    throws NoSuchEntryException {
18211                    return findByPrimaryKey((Serializable)entryId);
18212            }
18213    
18214            /**
18215             * Returns the blogs entry with the primary key or returns <code>null</code> if it could not be found.
18216             *
18217             * @param primaryKey the primary key of the blogs entry
18218             * @return the blogs entry, or <code>null</code> if a blogs entry with the primary key could not be found
18219             */
18220            @Override
18221            public BlogsEntry fetchByPrimaryKey(Serializable primaryKey) {
18222                    BlogsEntry blogsEntry = (BlogsEntry)EntityCacheUtil.getResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18223                                    BlogsEntryImpl.class, primaryKey);
18224    
18225                    if (blogsEntry == _nullBlogsEntry) {
18226                            return null;
18227                    }
18228    
18229                    if (blogsEntry == null) {
18230                            Session session = null;
18231    
18232                            try {
18233                                    session = openSession();
18234    
18235                                    blogsEntry = (BlogsEntry)session.get(BlogsEntryImpl.class,
18236                                                    primaryKey);
18237    
18238                                    if (blogsEntry != null) {
18239                                            cacheResult(blogsEntry);
18240                                    }
18241                                    else {
18242                                            EntityCacheUtil.putResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18243                                                    BlogsEntryImpl.class, primaryKey, _nullBlogsEntry);
18244                                    }
18245                            }
18246                            catch (Exception e) {
18247                                    EntityCacheUtil.removeResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18248                                            BlogsEntryImpl.class, primaryKey);
18249    
18250                                    throw processException(e);
18251                            }
18252                            finally {
18253                                    closeSession(session);
18254                            }
18255                    }
18256    
18257                    return blogsEntry;
18258            }
18259    
18260            /**
18261             * Returns the blogs entry with the primary key or returns <code>null</code> if it could not be found.
18262             *
18263             * @param entryId the primary key of the blogs entry
18264             * @return the blogs entry, or <code>null</code> if a blogs entry with the primary key could not be found
18265             */
18266            @Override
18267            public BlogsEntry fetchByPrimaryKey(long entryId) {
18268                    return fetchByPrimaryKey((Serializable)entryId);
18269            }
18270    
18271            @Override
18272            public Map<Serializable, BlogsEntry> fetchByPrimaryKeys(
18273                    Set<Serializable> primaryKeys) {
18274                    if (primaryKeys.isEmpty()) {
18275                            return Collections.emptyMap();
18276                    }
18277    
18278                    Map<Serializable, BlogsEntry> map = new HashMap<Serializable, BlogsEntry>();
18279    
18280                    if (primaryKeys.size() == 1) {
18281                            Iterator<Serializable> iterator = primaryKeys.iterator();
18282    
18283                            Serializable primaryKey = iterator.next();
18284    
18285                            BlogsEntry blogsEntry = fetchByPrimaryKey(primaryKey);
18286    
18287                            if (blogsEntry != null) {
18288                                    map.put(primaryKey, blogsEntry);
18289                            }
18290    
18291                            return map;
18292                    }
18293    
18294                    Set<Serializable> uncachedPrimaryKeys = null;
18295    
18296                    for (Serializable primaryKey : primaryKeys) {
18297                            BlogsEntry blogsEntry = (BlogsEntry)EntityCacheUtil.getResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18298                                            BlogsEntryImpl.class, primaryKey);
18299    
18300                            if (blogsEntry == null) {
18301                                    if (uncachedPrimaryKeys == null) {
18302                                            uncachedPrimaryKeys = new HashSet<Serializable>();
18303                                    }
18304    
18305                                    uncachedPrimaryKeys.add(primaryKey);
18306                            }
18307                            else {
18308                                    map.put(primaryKey, blogsEntry);
18309                            }
18310                    }
18311    
18312                    if (uncachedPrimaryKeys == null) {
18313                            return map;
18314                    }
18315    
18316                    StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
18317                                    1);
18318    
18319                    query.append(_SQL_SELECT_BLOGSENTRY_WHERE_PKS_IN);
18320    
18321                    for (Serializable primaryKey : uncachedPrimaryKeys) {
18322                            query.append(String.valueOf(primaryKey));
18323    
18324                            query.append(StringPool.COMMA);
18325                    }
18326    
18327                    query.setIndex(query.index() - 1);
18328    
18329                    query.append(StringPool.CLOSE_PARENTHESIS);
18330    
18331                    String sql = query.toString();
18332    
18333                    Session session = null;
18334    
18335                    try {
18336                            session = openSession();
18337    
18338                            Query q = session.createQuery(sql);
18339    
18340                            for (BlogsEntry blogsEntry : (List<BlogsEntry>)q.list()) {
18341                                    map.put(blogsEntry.getPrimaryKeyObj(), blogsEntry);
18342    
18343                                    cacheResult(blogsEntry);
18344    
18345                                    uncachedPrimaryKeys.remove(blogsEntry.getPrimaryKeyObj());
18346                            }
18347    
18348                            for (Serializable primaryKey : uncachedPrimaryKeys) {
18349                                    EntityCacheUtil.putResult(BlogsEntryModelImpl.ENTITY_CACHE_ENABLED,
18350                                            BlogsEntryImpl.class, primaryKey, _nullBlogsEntry);
18351                            }
18352                    }
18353                    catch (Exception e) {
18354                            throw processException(e);
18355                    }
18356                    finally {
18357                            closeSession(session);
18358                    }
18359    
18360                    return map;
18361            }
18362    
18363            /**
18364             * Returns all the blogs entries.
18365             *
18366             * @return the blogs entries
18367             */
18368            @Override
18369            public List<BlogsEntry> findAll() {
18370                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
18371            }
18372    
18373            /**
18374             * Returns a range of all the blogs entries.
18375             *
18376             * <p>
18377             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
18378             * </p>
18379             *
18380             * @param start the lower bound of the range of blogs entries
18381             * @param end the upper bound of the range of blogs entries (not inclusive)
18382             * @return the range of blogs entries
18383             */
18384            @Override
18385            public List<BlogsEntry> findAll(int start, int end) {
18386                    return findAll(start, end, null);
18387            }
18388    
18389            /**
18390             * Returns an ordered range of all the blogs entries.
18391             *
18392             * <p>
18393             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link BlogsEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
18394             * </p>
18395             *
18396             * @param start the lower bound of the range of blogs entries
18397             * @param end the upper bound of the range of blogs entries (not inclusive)
18398             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
18399             * @return the ordered range of blogs entries
18400             */
18401            @Override
18402            public List<BlogsEntry> findAll(int start, int end,
18403                    OrderByComparator<BlogsEntry> orderByComparator) {
18404                    boolean pagination = true;
18405                    FinderPath finderPath = null;
18406                    Object[] finderArgs = null;
18407    
18408                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
18409                                    (orderByComparator == null)) {
18410                            pagination = false;
18411                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
18412                            finderArgs = FINDER_ARGS_EMPTY;
18413                    }
18414                    else {
18415                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
18416                            finderArgs = new Object[] { start, end, orderByComparator };
18417                    }
18418    
18419                    List<BlogsEntry> list = (List<BlogsEntry>)FinderCacheUtil.getResult(finderPath,
18420                                    finderArgs, this);
18421    
18422                    if (list == null) {
18423                            StringBundler query = null;
18424                            String sql = null;
18425    
18426                            if (orderByComparator != null) {
18427                                    query = new StringBundler(2 +
18428                                                    (orderByComparator.getOrderByFields().length * 3));
18429    
18430                                    query.append(_SQL_SELECT_BLOGSENTRY);
18431    
18432                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
18433                                            orderByComparator);
18434    
18435                                    sql = query.toString();
18436                            }
18437                            else {
18438                                    sql = _SQL_SELECT_BLOGSENTRY;
18439    
18440                                    if (pagination) {
18441                                            sql = sql.concat(BlogsEntryModelImpl.ORDER_BY_JPQL);
18442                                    }
18443                            }
18444    
18445                            Session session = null;
18446    
18447                            try {
18448                                    session = openSession();
18449    
18450                                    Query q = session.createQuery(sql);
18451    
18452                                    if (!pagination) {
18453                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
18454                                                            start, end, false);
18455    
18456                                            Collections.sort(list);
18457    
18458                                            list = Collections.unmodifiableList(list);
18459                                    }
18460                                    else {
18461                                            list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
18462                                                            start, end);
18463                                    }
18464    
18465                                    cacheResult(list);
18466    
18467                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
18468                            }
18469                            catch (Exception e) {
18470                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
18471    
18472                                    throw processException(e);
18473                            }
18474                            finally {
18475                                    closeSession(session);
18476                            }
18477                    }
18478    
18479                    return list;
18480            }
18481    
18482            /**
18483             * Removes all the blogs entries from the database.
18484             *
18485             */
18486            @Override
18487            public void removeAll() {
18488                    for (BlogsEntry blogsEntry : findAll()) {
18489                            remove(blogsEntry);
18490                    }
18491            }
18492    
18493            /**
18494             * Returns the number of blogs entries.
18495             *
18496             * @return the number of blogs entries
18497             */
18498            @Override
18499            public int countAll() {
18500                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
18501                                    FINDER_ARGS_EMPTY, this);
18502    
18503                    if (count == null) {
18504                            Session session = null;
18505    
18506                            try {
18507                                    session = openSession();
18508    
18509                                    Query q = session.createQuery(_SQL_COUNT_BLOGSENTRY);
18510    
18511                                    count = (Long)q.uniqueResult();
18512    
18513                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
18514                                            FINDER_ARGS_EMPTY, count);
18515                            }
18516                            catch (Exception e) {
18517                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
18518                                            FINDER_ARGS_EMPTY);
18519    
18520                                    throw processException(e);
18521                            }
18522                            finally {
18523                                    closeSession(session);
18524                            }
18525                    }
18526    
18527                    return count.intValue();
18528            }
18529    
18530            @Override
18531            protected Set<String> getBadColumnNames() {
18532                    return _badColumnNames;
18533            }
18534    
18535            /**
18536             * Initializes the blogs entry persistence.
18537             */
18538            public void afterPropertiesSet() {
18539            }
18540    
18541            public void destroy() {
18542                    EntityCacheUtil.removeCache(BlogsEntryImpl.class.getName());
18543                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
18544                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
18545                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
18546            }
18547    
18548            private static final String _SQL_SELECT_BLOGSENTRY = "SELECT blogsEntry FROM BlogsEntry blogsEntry";
18549            private static final String _SQL_SELECT_BLOGSENTRY_WHERE_PKS_IN = "SELECT blogsEntry FROM BlogsEntry blogsEntry WHERE entryId IN (";
18550            private static final String _SQL_SELECT_BLOGSENTRY_WHERE = "SELECT blogsEntry FROM BlogsEntry blogsEntry WHERE ";
18551            private static final String _SQL_COUNT_BLOGSENTRY = "SELECT COUNT(blogsEntry) FROM BlogsEntry blogsEntry";
18552            private static final String _SQL_COUNT_BLOGSENTRY_WHERE = "SELECT COUNT(blogsEntry) FROM BlogsEntry blogsEntry WHERE ";
18553            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "blogsEntry.entryId";
18554            private static final String _FILTER_SQL_SELECT_BLOGSENTRY_WHERE = "SELECT DISTINCT {blogsEntry.*} FROM BlogsEntry blogsEntry WHERE ";
18555            private static final String _FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1 =
18556                    "SELECT {BlogsEntry.*} FROM (SELECT DISTINCT blogsEntry.entryId FROM BlogsEntry blogsEntry WHERE ";
18557            private static final String _FILTER_SQL_SELECT_BLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2 =
18558                    ") TEMP_TABLE INNER JOIN BlogsEntry ON TEMP_TABLE.entryId = BlogsEntry.entryId";
18559            private static final String _FILTER_SQL_COUNT_BLOGSENTRY_WHERE = "SELECT COUNT(DISTINCT blogsEntry.entryId) AS COUNT_VALUE FROM BlogsEntry blogsEntry WHERE ";
18560            private static final String _FILTER_ENTITY_ALIAS = "blogsEntry";
18561            private static final String _FILTER_ENTITY_TABLE = "BlogsEntry";
18562            private static final String _ORDER_BY_ENTITY_ALIAS = "blogsEntry.";
18563            private static final String _ORDER_BY_ENTITY_TABLE = "BlogsEntry.";
18564            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No BlogsEntry exists with the primary key ";
18565            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No BlogsEntry exists with the key {";
18566            private static final Log _log = LogFactoryUtil.getLog(BlogsEntryPersistenceImpl.class);
18567            private static final Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
18568                                    "uuid"
18569                            });
18570            private static final BlogsEntry _nullBlogsEntry = new BlogsEntryImpl() {
18571                            @Override
18572                            public Object clone() {
18573                                    return this;
18574                            }
18575    
18576                            @Override
18577                            public CacheModel<BlogsEntry> toCacheModel() {
18578                                    return _nullBlogsEntryCacheModel;
18579                            }
18580                    };
18581    
18582            private static final CacheModel<BlogsEntry> _nullBlogsEntryCacheModel = new CacheModel<BlogsEntry>() {
18583                            @Override
18584                            public BlogsEntry toEntityModel() {
18585                                    return _nullBlogsEntry;
18586                            }
18587                    };
18588    }