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.bookmarks.service.persistence.impl;
016    
017    import aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022    import com.liferay.portal.kernel.dao.orm.FinderPath;
023    import com.liferay.portal.kernel.dao.orm.Query;
024    import com.liferay.portal.kernel.dao.orm.QueryPos;
025    import com.liferay.portal.kernel.dao.orm.QueryUtil;
026    import com.liferay.portal.kernel.dao.orm.Session;
027    import com.liferay.portal.kernel.log.Log;
028    import com.liferay.portal.kernel.log.LogFactoryUtil;
029    import com.liferay.portal.kernel.util.ArrayUtil;
030    import com.liferay.portal.kernel.util.OrderByComparator;
031    import com.liferay.portal.kernel.util.SetUtil;
032    import com.liferay.portal.kernel.util.StringBundler;
033    import com.liferay.portal.kernel.util.StringPool;
034    import com.liferay.portal.kernel.util.StringUtil;
035    import com.liferay.portal.kernel.util.Validator;
036    import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
037    import com.liferay.portal.model.CacheModel;
038    import com.liferay.portal.security.permission.InlineSQLHelperUtil;
039    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
040    
041    import com.liferay.portlet.bookmarks.NoSuchEntryException;
042    import com.liferay.portlet.bookmarks.model.BookmarksEntry;
043    import com.liferay.portlet.bookmarks.model.impl.BookmarksEntryImpl;
044    import com.liferay.portlet.bookmarks.model.impl.BookmarksEntryModelImpl;
045    import com.liferay.portlet.bookmarks.service.persistence.BookmarksEntryPersistence;
046    
047    import java.io.Serializable;
048    
049    import java.util.Collections;
050    import java.util.HashMap;
051    import java.util.HashSet;
052    import java.util.Iterator;
053    import java.util.List;
054    import java.util.Map;
055    import java.util.Set;
056    
057    /**
058     * The persistence implementation for the bookmarks entry service.
059     *
060     * <p>
061     * Caching information and settings can be found in <code>portal.properties</code>
062     * </p>
063     *
064     * @author Brian Wing Shun Chan
065     * @see BookmarksEntryPersistence
066     * @see BookmarksEntryUtil
067     * @generated
068     */
069    @ProviderType
070    public class BookmarksEntryPersistenceImpl extends BasePersistenceImpl<BookmarksEntry>
071            implements BookmarksEntryPersistence {
072            /*
073             * NOTE FOR DEVELOPERS:
074             *
075             * Never modify or reference this class directly. Always use {@link BookmarksEntryUtil} to access the bookmarks entry persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
076             */
077            public static final String FINDER_CLASS_NAME_ENTITY = BookmarksEntryImpl.class.getName();
078            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
079                    ".List1";
080            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
081                    ".List2";
082            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
083                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
084                            BookmarksEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
085                            "findAll", new String[0]);
086            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
087                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
088                            BookmarksEntryImpl.class,
089                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
090            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
091                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
092                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
093            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_RESOURCEBLOCKID =
094                    new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
095                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
096                            BookmarksEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
097                            "findByResourceBlockId",
098                            new String[] {
099                                    Long.class.getName(),
100                                    
101                            Integer.class.getName(), Integer.class.getName(),
102                                    OrderByComparator.class.getName()
103                            });
104            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEBLOCKID =
105                    new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
106                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
107                            BookmarksEntryImpl.class,
108                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByResourceBlockId",
109                            new String[] { Long.class.getName() },
110                            BookmarksEntryModelImpl.RESOURCEBLOCKID_COLUMN_BITMASK |
111                            BookmarksEntryModelImpl.FOLDERID_COLUMN_BITMASK |
112                            BookmarksEntryModelImpl.NAME_COLUMN_BITMASK);
113            public static final FinderPath FINDER_PATH_COUNT_BY_RESOURCEBLOCKID = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
114                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
115                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
116                            "countByResourceBlockId", new String[] { Long.class.getName() });
117    
118            /**
119             * Returns all the bookmarks entries where resourceBlockId = &#63;.
120             *
121             * @param resourceBlockId the resource block ID
122             * @return the matching bookmarks entries
123             */
124            @Override
125            public List<BookmarksEntry> findByResourceBlockId(long resourceBlockId) {
126                    return findByResourceBlockId(resourceBlockId, QueryUtil.ALL_POS,
127                            QueryUtil.ALL_POS, null);
128            }
129    
130            /**
131             * Returns a range of all the bookmarks entries where resourceBlockId = &#63;.
132             *
133             * <p>
134             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.bookmarks.model.impl.BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
135             * </p>
136             *
137             * @param resourceBlockId the resource block ID
138             * @param start the lower bound of the range of bookmarks entries
139             * @param end the upper bound of the range of bookmarks entries (not inclusive)
140             * @return the range of matching bookmarks entries
141             */
142            @Override
143            public List<BookmarksEntry> findByResourceBlockId(long resourceBlockId,
144                    int start, int end) {
145                    return findByResourceBlockId(resourceBlockId, start, end, null);
146            }
147    
148            /**
149             * Returns an ordered range of all the bookmarks entries where resourceBlockId = &#63;.
150             *
151             * <p>
152             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.bookmarks.model.impl.BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
153             * </p>
154             *
155             * @param resourceBlockId the resource block ID
156             * @param start the lower bound of the range of bookmarks entries
157             * @param end the upper bound of the range of bookmarks entries (not inclusive)
158             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
159             * @return the ordered range of matching bookmarks entries
160             */
161            @Override
162            public List<BookmarksEntry> findByResourceBlockId(long resourceBlockId,
163                    int start, int end, OrderByComparator<BookmarksEntry> orderByComparator) {
164                    boolean pagination = true;
165                    FinderPath finderPath = null;
166                    Object[] finderArgs = null;
167    
168                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
169                                    (orderByComparator == null)) {
170                            pagination = false;
171                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEBLOCKID;
172                            finderArgs = new Object[] { resourceBlockId };
173                    }
174                    else {
175                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_RESOURCEBLOCKID;
176                            finderArgs = new Object[] {
177                                            resourceBlockId,
178                                            
179                                            start, end, orderByComparator
180                                    };
181                    }
182    
183                    List<BookmarksEntry> list = (List<BookmarksEntry>)FinderCacheUtil.getResult(finderPath,
184                                    finderArgs, this);
185    
186                    if ((list != null) && !list.isEmpty()) {
187                            for (BookmarksEntry bookmarksEntry : list) {
188                                    if ((resourceBlockId != bookmarksEntry.getResourceBlockId())) {
189                                            list = null;
190    
191                                            break;
192                                    }
193                            }
194                    }
195    
196                    if (list == null) {
197                            StringBundler query = null;
198    
199                            if (orderByComparator != null) {
200                                    query = new StringBundler(3 +
201                                                    (orderByComparator.getOrderByFields().length * 3));
202                            }
203                            else {
204                                    query = new StringBundler(3);
205                            }
206    
207                            query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
208    
209                            query.append(_FINDER_COLUMN_RESOURCEBLOCKID_RESOURCEBLOCKID_2);
210    
211                            if (orderByComparator != null) {
212                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
213                                            orderByComparator);
214                            }
215                            else
216                             if (pagination) {
217                                    query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
218                            }
219    
220                            String sql = query.toString();
221    
222                            Session session = null;
223    
224                            try {
225                                    session = openSession();
226    
227                                    Query q = session.createQuery(sql);
228    
229                                    QueryPos qPos = QueryPos.getInstance(q);
230    
231                                    qPos.add(resourceBlockId);
232    
233                                    if (!pagination) {
234                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
235                                                            getDialect(), start, end, false);
236    
237                                            Collections.sort(list);
238    
239                                            list = Collections.unmodifiableList(list);
240                                    }
241                                    else {
242                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
243                                                            getDialect(), start, end);
244                                    }
245    
246                                    cacheResult(list);
247    
248                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
249                            }
250                            catch (Exception e) {
251                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
252    
253                                    throw processException(e);
254                            }
255                            finally {
256                                    closeSession(session);
257                            }
258                    }
259    
260                    return list;
261            }
262    
263            /**
264             * Returns the first bookmarks entry in the ordered set where resourceBlockId = &#63;.
265             *
266             * @param resourceBlockId the resource block ID
267             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
268             * @return the first matching bookmarks entry
269             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
270             */
271            @Override
272            public BookmarksEntry findByResourceBlockId_First(long resourceBlockId,
273                    OrderByComparator<BookmarksEntry> orderByComparator)
274                    throws NoSuchEntryException {
275                    BookmarksEntry bookmarksEntry = fetchByResourceBlockId_First(resourceBlockId,
276                                    orderByComparator);
277    
278                    if (bookmarksEntry != null) {
279                            return bookmarksEntry;
280                    }
281    
282                    StringBundler msg = new StringBundler(4);
283    
284                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
285    
286                    msg.append("resourceBlockId=");
287                    msg.append(resourceBlockId);
288    
289                    msg.append(StringPool.CLOSE_CURLY_BRACE);
290    
291                    throw new NoSuchEntryException(msg.toString());
292            }
293    
294            /**
295             * Returns the first bookmarks entry in the ordered set where resourceBlockId = &#63;.
296             *
297             * @param resourceBlockId the resource block ID
298             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
299             * @return the first matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
300             */
301            @Override
302            public BookmarksEntry fetchByResourceBlockId_First(long resourceBlockId,
303                    OrderByComparator<BookmarksEntry> orderByComparator) {
304                    List<BookmarksEntry> list = findByResourceBlockId(resourceBlockId, 0,
305                                    1, orderByComparator);
306    
307                    if (!list.isEmpty()) {
308                            return list.get(0);
309                    }
310    
311                    return null;
312            }
313    
314            /**
315             * Returns the last bookmarks entry in the ordered set where resourceBlockId = &#63;.
316             *
317             * @param resourceBlockId the resource block ID
318             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
319             * @return the last matching bookmarks entry
320             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
321             */
322            @Override
323            public BookmarksEntry findByResourceBlockId_Last(long resourceBlockId,
324                    OrderByComparator<BookmarksEntry> orderByComparator)
325                    throws NoSuchEntryException {
326                    BookmarksEntry bookmarksEntry = fetchByResourceBlockId_Last(resourceBlockId,
327                                    orderByComparator);
328    
329                    if (bookmarksEntry != null) {
330                            return bookmarksEntry;
331                    }
332    
333                    StringBundler msg = new StringBundler(4);
334    
335                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
336    
337                    msg.append("resourceBlockId=");
338                    msg.append(resourceBlockId);
339    
340                    msg.append(StringPool.CLOSE_CURLY_BRACE);
341    
342                    throw new NoSuchEntryException(msg.toString());
343            }
344    
345            /**
346             * Returns the last bookmarks entry in the ordered set where resourceBlockId = &#63;.
347             *
348             * @param resourceBlockId the resource block ID
349             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
350             * @return the last matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
351             */
352            @Override
353            public BookmarksEntry fetchByResourceBlockId_Last(long resourceBlockId,
354                    OrderByComparator<BookmarksEntry> orderByComparator) {
355                    int count = countByResourceBlockId(resourceBlockId);
356    
357                    if (count == 0) {
358                            return null;
359                    }
360    
361                    List<BookmarksEntry> list = findByResourceBlockId(resourceBlockId,
362                                    count - 1, count, orderByComparator);
363    
364                    if (!list.isEmpty()) {
365                            return list.get(0);
366                    }
367    
368                    return null;
369            }
370    
371            /**
372             * Returns the bookmarks entries before and after the current bookmarks entry in the ordered set where resourceBlockId = &#63;.
373             *
374             * @param entryId the primary key of the current bookmarks entry
375             * @param resourceBlockId the resource block ID
376             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
377             * @return the previous, current, and next bookmarks entry
378             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
379             */
380            @Override
381            public BookmarksEntry[] findByResourceBlockId_PrevAndNext(long entryId,
382                    long resourceBlockId,
383                    OrderByComparator<BookmarksEntry> orderByComparator)
384                    throws NoSuchEntryException {
385                    BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
386    
387                    Session session = null;
388    
389                    try {
390                            session = openSession();
391    
392                            BookmarksEntry[] array = new BookmarksEntryImpl[3];
393    
394                            array[0] = getByResourceBlockId_PrevAndNext(session,
395                                            bookmarksEntry, resourceBlockId, orderByComparator, true);
396    
397                            array[1] = bookmarksEntry;
398    
399                            array[2] = getByResourceBlockId_PrevAndNext(session,
400                                            bookmarksEntry, resourceBlockId, orderByComparator, false);
401    
402                            return array;
403                    }
404                    catch (Exception e) {
405                            throw processException(e);
406                    }
407                    finally {
408                            closeSession(session);
409                    }
410            }
411    
412            protected BookmarksEntry getByResourceBlockId_PrevAndNext(Session session,
413                    BookmarksEntry bookmarksEntry, long resourceBlockId,
414                    OrderByComparator<BookmarksEntry> orderByComparator, boolean previous) {
415                    StringBundler query = null;
416    
417                    if (orderByComparator != null) {
418                            query = new StringBundler(6 +
419                                            (orderByComparator.getOrderByFields().length * 6));
420                    }
421                    else {
422                            query = new StringBundler(3);
423                    }
424    
425                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
426    
427                    query.append(_FINDER_COLUMN_RESOURCEBLOCKID_RESOURCEBLOCKID_2);
428    
429                    if (orderByComparator != null) {
430                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
431    
432                            if (orderByConditionFields.length > 0) {
433                                    query.append(WHERE_AND);
434                            }
435    
436                            for (int i = 0; i < orderByConditionFields.length; i++) {
437                                    query.append(_ORDER_BY_ENTITY_ALIAS);
438                                    query.append(orderByConditionFields[i]);
439    
440                                    if ((i + 1) < orderByConditionFields.length) {
441                                            if (orderByComparator.isAscending() ^ previous) {
442                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
443                                            }
444                                            else {
445                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
446                                            }
447                                    }
448                                    else {
449                                            if (orderByComparator.isAscending() ^ previous) {
450                                                    query.append(WHERE_GREATER_THAN);
451                                            }
452                                            else {
453                                                    query.append(WHERE_LESSER_THAN);
454                                            }
455                                    }
456                            }
457    
458                            query.append(ORDER_BY_CLAUSE);
459    
460                            String[] orderByFields = orderByComparator.getOrderByFields();
461    
462                            for (int i = 0; i < orderByFields.length; i++) {
463                                    query.append(_ORDER_BY_ENTITY_ALIAS);
464                                    query.append(orderByFields[i]);
465    
466                                    if ((i + 1) < orderByFields.length) {
467                                            if (orderByComparator.isAscending() ^ previous) {
468                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
469                                            }
470                                            else {
471                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
472                                            }
473                                    }
474                                    else {
475                                            if (orderByComparator.isAscending() ^ previous) {
476                                                    query.append(ORDER_BY_ASC);
477                                            }
478                                            else {
479                                                    query.append(ORDER_BY_DESC);
480                                            }
481                                    }
482                            }
483                    }
484                    else {
485                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
486                    }
487    
488                    String sql = query.toString();
489    
490                    Query q = session.createQuery(sql);
491    
492                    q.setFirstResult(0);
493                    q.setMaxResults(2);
494    
495                    QueryPos qPos = QueryPos.getInstance(q);
496    
497                    qPos.add(resourceBlockId);
498    
499                    if (orderByComparator != null) {
500                            Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry);
501    
502                            for (Object value : values) {
503                                    qPos.add(value);
504                            }
505                    }
506    
507                    List<BookmarksEntry> list = q.list();
508    
509                    if (list.size() == 2) {
510                            return list.get(1);
511                    }
512                    else {
513                            return null;
514                    }
515            }
516    
517            /**
518             * Removes all the bookmarks entries where resourceBlockId = &#63; from the database.
519             *
520             * @param resourceBlockId the resource block ID
521             */
522            @Override
523            public void removeByResourceBlockId(long resourceBlockId) {
524                    for (BookmarksEntry bookmarksEntry : findByResourceBlockId(
525                                    resourceBlockId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
526                            remove(bookmarksEntry);
527                    }
528            }
529    
530            /**
531             * Returns the number of bookmarks entries where resourceBlockId = &#63;.
532             *
533             * @param resourceBlockId the resource block ID
534             * @return the number of matching bookmarks entries
535             */
536            @Override
537            public int countByResourceBlockId(long resourceBlockId) {
538                    FinderPath finderPath = FINDER_PATH_COUNT_BY_RESOURCEBLOCKID;
539    
540                    Object[] finderArgs = new Object[] { resourceBlockId };
541    
542                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
543                                    this);
544    
545                    if (count == null) {
546                            StringBundler query = new StringBundler(2);
547    
548                            query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
549    
550                            query.append(_FINDER_COLUMN_RESOURCEBLOCKID_RESOURCEBLOCKID_2);
551    
552                            String sql = query.toString();
553    
554                            Session session = null;
555    
556                            try {
557                                    session = openSession();
558    
559                                    Query q = session.createQuery(sql);
560    
561                                    QueryPos qPos = QueryPos.getInstance(q);
562    
563                                    qPos.add(resourceBlockId);
564    
565                                    count = (Long)q.uniqueResult();
566    
567                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
568                            }
569                            catch (Exception e) {
570                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
571    
572                                    throw processException(e);
573                            }
574                            finally {
575                                    closeSession(session);
576                            }
577                    }
578    
579                    return count.intValue();
580            }
581    
582            private static final String _FINDER_COLUMN_RESOURCEBLOCKID_RESOURCEBLOCKID_2 =
583                    "bookmarksEntry.resourceBlockId = ?";
584            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
585                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
586                            BookmarksEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
587                            "findByUuid",
588                            new String[] {
589                                    String.class.getName(),
590                                    
591                            Integer.class.getName(), Integer.class.getName(),
592                                    OrderByComparator.class.getName()
593                            });
594            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
595                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
596                            BookmarksEntryImpl.class,
597                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
598                            new String[] { String.class.getName() },
599                            BookmarksEntryModelImpl.UUID_COLUMN_BITMASK |
600                            BookmarksEntryModelImpl.FOLDERID_COLUMN_BITMASK |
601                            BookmarksEntryModelImpl.NAME_COLUMN_BITMASK);
602            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
603                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
604                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
605                            new String[] { String.class.getName() });
606    
607            /**
608             * Returns all the bookmarks entries where uuid = &#63;.
609             *
610             * @param uuid the uuid
611             * @return the matching bookmarks entries
612             */
613            @Override
614            public List<BookmarksEntry> findByUuid(String uuid) {
615                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
616            }
617    
618            /**
619             * Returns a range of all the bookmarks entries where uuid = &#63;.
620             *
621             * <p>
622             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.bookmarks.model.impl.BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
623             * </p>
624             *
625             * @param uuid the uuid
626             * @param start the lower bound of the range of bookmarks entries
627             * @param end the upper bound of the range of bookmarks entries (not inclusive)
628             * @return the range of matching bookmarks entries
629             */
630            @Override
631            public List<BookmarksEntry> findByUuid(String uuid, int start, int end) {
632                    return findByUuid(uuid, start, end, null);
633            }
634    
635            /**
636             * Returns an ordered range of all the bookmarks entries where uuid = &#63;.
637             *
638             * <p>
639             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.bookmarks.model.impl.BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
640             * </p>
641             *
642             * @param uuid the uuid
643             * @param start the lower bound of the range of bookmarks entries
644             * @param end the upper bound of the range of bookmarks entries (not inclusive)
645             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
646             * @return the ordered range of matching bookmarks entries
647             */
648            @Override
649            public List<BookmarksEntry> findByUuid(String uuid, int start, int end,
650                    OrderByComparator<BookmarksEntry> orderByComparator) {
651                    boolean pagination = true;
652                    FinderPath finderPath = null;
653                    Object[] finderArgs = null;
654    
655                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
656                                    (orderByComparator == null)) {
657                            pagination = false;
658                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
659                            finderArgs = new Object[] { uuid };
660                    }
661                    else {
662                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
663                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
664                    }
665    
666                    List<BookmarksEntry> list = (List<BookmarksEntry>)FinderCacheUtil.getResult(finderPath,
667                                    finderArgs, this);
668    
669                    if ((list != null) && !list.isEmpty()) {
670                            for (BookmarksEntry bookmarksEntry : list) {
671                                    if (!Validator.equals(uuid, bookmarksEntry.getUuid())) {
672                                            list = null;
673    
674                                            break;
675                                    }
676                            }
677                    }
678    
679                    if (list == null) {
680                            StringBundler query = null;
681    
682                            if (orderByComparator != null) {
683                                    query = new StringBundler(3 +
684                                                    (orderByComparator.getOrderByFields().length * 3));
685                            }
686                            else {
687                                    query = new StringBundler(3);
688                            }
689    
690                            query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
691    
692                            boolean bindUuid = false;
693    
694                            if (uuid == null) {
695                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
696                            }
697                            else if (uuid.equals(StringPool.BLANK)) {
698                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
699                            }
700                            else {
701                                    bindUuid = true;
702    
703                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
704                            }
705    
706                            if (orderByComparator != null) {
707                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
708                                            orderByComparator);
709                            }
710                            else
711                             if (pagination) {
712                                    query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
713                            }
714    
715                            String sql = query.toString();
716    
717                            Session session = null;
718    
719                            try {
720                                    session = openSession();
721    
722                                    Query q = session.createQuery(sql);
723    
724                                    QueryPos qPos = QueryPos.getInstance(q);
725    
726                                    if (bindUuid) {
727                                            qPos.add(uuid);
728                                    }
729    
730                                    if (!pagination) {
731                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
732                                                            getDialect(), start, end, false);
733    
734                                            Collections.sort(list);
735    
736                                            list = Collections.unmodifiableList(list);
737                                    }
738                                    else {
739                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
740                                                            getDialect(), start, end);
741                                    }
742    
743                                    cacheResult(list);
744    
745                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
746                            }
747                            catch (Exception e) {
748                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
749    
750                                    throw processException(e);
751                            }
752                            finally {
753                                    closeSession(session);
754                            }
755                    }
756    
757                    return list;
758            }
759    
760            /**
761             * Returns the first bookmarks entry in the ordered set where uuid = &#63;.
762             *
763             * @param uuid the uuid
764             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
765             * @return the first matching bookmarks entry
766             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
767             */
768            @Override
769            public BookmarksEntry findByUuid_First(String uuid,
770                    OrderByComparator<BookmarksEntry> orderByComparator)
771                    throws NoSuchEntryException {
772                    BookmarksEntry bookmarksEntry = fetchByUuid_First(uuid,
773                                    orderByComparator);
774    
775                    if (bookmarksEntry != null) {
776                            return bookmarksEntry;
777                    }
778    
779                    StringBundler msg = new StringBundler(4);
780    
781                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
782    
783                    msg.append("uuid=");
784                    msg.append(uuid);
785    
786                    msg.append(StringPool.CLOSE_CURLY_BRACE);
787    
788                    throw new NoSuchEntryException(msg.toString());
789            }
790    
791            /**
792             * Returns the first bookmarks entry in the ordered set where uuid = &#63;.
793             *
794             * @param uuid the uuid
795             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
796             * @return the first matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
797             */
798            @Override
799            public BookmarksEntry fetchByUuid_First(String uuid,
800                    OrderByComparator<BookmarksEntry> orderByComparator) {
801                    List<BookmarksEntry> list = findByUuid(uuid, 0, 1, orderByComparator);
802    
803                    if (!list.isEmpty()) {
804                            return list.get(0);
805                    }
806    
807                    return null;
808            }
809    
810            /**
811             * Returns the last bookmarks entry in the ordered set where uuid = &#63;.
812             *
813             * @param uuid the uuid
814             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
815             * @return the last matching bookmarks entry
816             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
817             */
818            @Override
819            public BookmarksEntry findByUuid_Last(String uuid,
820                    OrderByComparator<BookmarksEntry> orderByComparator)
821                    throws NoSuchEntryException {
822                    BookmarksEntry bookmarksEntry = fetchByUuid_Last(uuid, orderByComparator);
823    
824                    if (bookmarksEntry != null) {
825                            return bookmarksEntry;
826                    }
827    
828                    StringBundler msg = new StringBundler(4);
829    
830                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
831    
832                    msg.append("uuid=");
833                    msg.append(uuid);
834    
835                    msg.append(StringPool.CLOSE_CURLY_BRACE);
836    
837                    throw new NoSuchEntryException(msg.toString());
838            }
839    
840            /**
841             * Returns the last bookmarks entry in the ordered set where uuid = &#63;.
842             *
843             * @param uuid the uuid
844             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
845             * @return the last matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
846             */
847            @Override
848            public BookmarksEntry fetchByUuid_Last(String uuid,
849                    OrderByComparator<BookmarksEntry> orderByComparator) {
850                    int count = countByUuid(uuid);
851    
852                    if (count == 0) {
853                            return null;
854                    }
855    
856                    List<BookmarksEntry> list = findByUuid(uuid, count - 1, count,
857                                    orderByComparator);
858    
859                    if (!list.isEmpty()) {
860                            return list.get(0);
861                    }
862    
863                    return null;
864            }
865    
866            /**
867             * Returns the bookmarks entries before and after the current bookmarks entry in the ordered set where uuid = &#63;.
868             *
869             * @param entryId the primary key of the current bookmarks entry
870             * @param uuid the uuid
871             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
872             * @return the previous, current, and next bookmarks entry
873             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
874             */
875            @Override
876            public BookmarksEntry[] findByUuid_PrevAndNext(long entryId, String uuid,
877                    OrderByComparator<BookmarksEntry> orderByComparator)
878                    throws NoSuchEntryException {
879                    BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
880    
881                    Session session = null;
882    
883                    try {
884                            session = openSession();
885    
886                            BookmarksEntry[] array = new BookmarksEntryImpl[3];
887    
888                            array[0] = getByUuid_PrevAndNext(session, bookmarksEntry, uuid,
889                                            orderByComparator, true);
890    
891                            array[1] = bookmarksEntry;
892    
893                            array[2] = getByUuid_PrevAndNext(session, bookmarksEntry, uuid,
894                                            orderByComparator, false);
895    
896                            return array;
897                    }
898                    catch (Exception e) {
899                            throw processException(e);
900                    }
901                    finally {
902                            closeSession(session);
903                    }
904            }
905    
906            protected BookmarksEntry getByUuid_PrevAndNext(Session session,
907                    BookmarksEntry bookmarksEntry, String uuid,
908                    OrderByComparator<BookmarksEntry> orderByComparator, boolean previous) {
909                    StringBundler query = null;
910    
911                    if (orderByComparator != null) {
912                            query = new StringBundler(6 +
913                                            (orderByComparator.getOrderByFields().length * 6));
914                    }
915                    else {
916                            query = new StringBundler(3);
917                    }
918    
919                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
920    
921                    boolean bindUuid = false;
922    
923                    if (uuid == null) {
924                            query.append(_FINDER_COLUMN_UUID_UUID_1);
925                    }
926                    else if (uuid.equals(StringPool.BLANK)) {
927                            query.append(_FINDER_COLUMN_UUID_UUID_3);
928                    }
929                    else {
930                            bindUuid = true;
931    
932                            query.append(_FINDER_COLUMN_UUID_UUID_2);
933                    }
934    
935                    if (orderByComparator != null) {
936                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
937    
938                            if (orderByConditionFields.length > 0) {
939                                    query.append(WHERE_AND);
940                            }
941    
942                            for (int i = 0; i < orderByConditionFields.length; i++) {
943                                    query.append(_ORDER_BY_ENTITY_ALIAS);
944                                    query.append(orderByConditionFields[i]);
945    
946                                    if ((i + 1) < orderByConditionFields.length) {
947                                            if (orderByComparator.isAscending() ^ previous) {
948                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
949                                            }
950                                            else {
951                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
952                                            }
953                                    }
954                                    else {
955                                            if (orderByComparator.isAscending() ^ previous) {
956                                                    query.append(WHERE_GREATER_THAN);
957                                            }
958                                            else {
959                                                    query.append(WHERE_LESSER_THAN);
960                                            }
961                                    }
962                            }
963    
964                            query.append(ORDER_BY_CLAUSE);
965    
966                            String[] orderByFields = orderByComparator.getOrderByFields();
967    
968                            for (int i = 0; i < orderByFields.length; i++) {
969                                    query.append(_ORDER_BY_ENTITY_ALIAS);
970                                    query.append(orderByFields[i]);
971    
972                                    if ((i + 1) < orderByFields.length) {
973                                            if (orderByComparator.isAscending() ^ previous) {
974                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
975                                            }
976                                            else {
977                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
978                                            }
979                                    }
980                                    else {
981                                            if (orderByComparator.isAscending() ^ previous) {
982                                                    query.append(ORDER_BY_ASC);
983                                            }
984                                            else {
985                                                    query.append(ORDER_BY_DESC);
986                                            }
987                                    }
988                            }
989                    }
990                    else {
991                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
992                    }
993    
994                    String sql = query.toString();
995    
996                    Query q = session.createQuery(sql);
997    
998                    q.setFirstResult(0);
999                    q.setMaxResults(2);
1000    
1001                    QueryPos qPos = QueryPos.getInstance(q);
1002    
1003                    if (bindUuid) {
1004                            qPos.add(uuid);
1005                    }
1006    
1007                    if (orderByComparator != null) {
1008                            Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry);
1009    
1010                            for (Object value : values) {
1011                                    qPos.add(value);
1012                            }
1013                    }
1014    
1015                    List<BookmarksEntry> list = q.list();
1016    
1017                    if (list.size() == 2) {
1018                            return list.get(1);
1019                    }
1020                    else {
1021                            return null;
1022                    }
1023            }
1024    
1025            /**
1026             * Removes all the bookmarks entries where uuid = &#63; from the database.
1027             *
1028             * @param uuid the uuid
1029             */
1030            @Override
1031            public void removeByUuid(String uuid) {
1032                    for (BookmarksEntry bookmarksEntry : findByUuid(uuid,
1033                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1034                            remove(bookmarksEntry);
1035                    }
1036            }
1037    
1038            /**
1039             * Returns the number of bookmarks entries where uuid = &#63;.
1040             *
1041             * @param uuid the uuid
1042             * @return the number of matching bookmarks entries
1043             */
1044            @Override
1045            public int countByUuid(String uuid) {
1046                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
1047    
1048                    Object[] finderArgs = new Object[] { uuid };
1049    
1050                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1051                                    this);
1052    
1053                    if (count == null) {
1054                            StringBundler query = new StringBundler(2);
1055    
1056                            query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
1057    
1058                            boolean bindUuid = false;
1059    
1060                            if (uuid == null) {
1061                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
1062                            }
1063                            else if (uuid.equals(StringPool.BLANK)) {
1064                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
1065                            }
1066                            else {
1067                                    bindUuid = true;
1068    
1069                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
1070                            }
1071    
1072                            String sql = query.toString();
1073    
1074                            Session session = null;
1075    
1076                            try {
1077                                    session = openSession();
1078    
1079                                    Query q = session.createQuery(sql);
1080    
1081                                    QueryPos qPos = QueryPos.getInstance(q);
1082    
1083                                    if (bindUuid) {
1084                                            qPos.add(uuid);
1085                                    }
1086    
1087                                    count = (Long)q.uniqueResult();
1088    
1089                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
1090                            }
1091                            catch (Exception e) {
1092                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1093    
1094                                    throw processException(e);
1095                            }
1096                            finally {
1097                                    closeSession(session);
1098                            }
1099                    }
1100    
1101                    return count.intValue();
1102            }
1103    
1104            private static final String _FINDER_COLUMN_UUID_UUID_1 = "bookmarksEntry.uuid IS NULL";
1105            private static final String _FINDER_COLUMN_UUID_UUID_2 = "bookmarksEntry.uuid = ?";
1106            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(bookmarksEntry.uuid IS NULL OR bookmarksEntry.uuid = '')";
1107            public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
1108                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
1109                            BookmarksEntryImpl.class, FINDER_CLASS_NAME_ENTITY,
1110                            "fetchByUUID_G",
1111                            new String[] { String.class.getName(), Long.class.getName() },
1112                            BookmarksEntryModelImpl.UUID_COLUMN_BITMASK |
1113                            BookmarksEntryModelImpl.GROUPID_COLUMN_BITMASK);
1114            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
1115                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
1116                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
1117                            new String[] { String.class.getName(), Long.class.getName() });
1118    
1119            /**
1120             * Returns the bookmarks entry where uuid = &#63; and groupId = &#63; or throws a {@link com.liferay.portlet.bookmarks.NoSuchEntryException} if it could not be found.
1121             *
1122             * @param uuid the uuid
1123             * @param groupId the group ID
1124             * @return the matching bookmarks entry
1125             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
1126             */
1127            @Override
1128            public BookmarksEntry findByUUID_G(String uuid, long groupId)
1129                    throws NoSuchEntryException {
1130                    BookmarksEntry bookmarksEntry = fetchByUUID_G(uuid, groupId);
1131    
1132                    if (bookmarksEntry == null) {
1133                            StringBundler msg = new StringBundler(6);
1134    
1135                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1136    
1137                            msg.append("uuid=");
1138                            msg.append(uuid);
1139    
1140                            msg.append(", groupId=");
1141                            msg.append(groupId);
1142    
1143                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1144    
1145                            if (_log.isWarnEnabled()) {
1146                                    _log.warn(msg.toString());
1147                            }
1148    
1149                            throw new NoSuchEntryException(msg.toString());
1150                    }
1151    
1152                    return bookmarksEntry;
1153            }
1154    
1155            /**
1156             * Returns the bookmarks entry where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
1157             *
1158             * @param uuid the uuid
1159             * @param groupId the group ID
1160             * @return the matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
1161             */
1162            @Override
1163            public BookmarksEntry fetchByUUID_G(String uuid, long groupId) {
1164                    return fetchByUUID_G(uuid, groupId, true);
1165            }
1166    
1167            /**
1168             * Returns the bookmarks entry where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
1169             *
1170             * @param uuid the uuid
1171             * @param groupId the group ID
1172             * @param retrieveFromCache whether to use the finder cache
1173             * @return the matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
1174             */
1175            @Override
1176            public BookmarksEntry fetchByUUID_G(String uuid, long groupId,
1177                    boolean retrieveFromCache) {
1178                    Object[] finderArgs = new Object[] { uuid, groupId };
1179    
1180                    Object result = null;
1181    
1182                    if (retrieveFromCache) {
1183                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
1184                                            finderArgs, this);
1185                    }
1186    
1187                    if (result instanceof BookmarksEntry) {
1188                            BookmarksEntry bookmarksEntry = (BookmarksEntry)result;
1189    
1190                            if (!Validator.equals(uuid, bookmarksEntry.getUuid()) ||
1191                                            (groupId != bookmarksEntry.getGroupId())) {
1192                                    result = null;
1193                            }
1194                    }
1195    
1196                    if (result == null) {
1197                            StringBundler query = new StringBundler(4);
1198    
1199                            query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
1200    
1201                            boolean bindUuid = false;
1202    
1203                            if (uuid == null) {
1204                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1205                            }
1206                            else if (uuid.equals(StringPool.BLANK)) {
1207                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1208                            }
1209                            else {
1210                                    bindUuid = true;
1211    
1212                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1213                            }
1214    
1215                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1216    
1217                            String sql = query.toString();
1218    
1219                            Session session = null;
1220    
1221                            try {
1222                                    session = openSession();
1223    
1224                                    Query q = session.createQuery(sql);
1225    
1226                                    QueryPos qPos = QueryPos.getInstance(q);
1227    
1228                                    if (bindUuid) {
1229                                            qPos.add(uuid);
1230                                    }
1231    
1232                                    qPos.add(groupId);
1233    
1234                                    List<BookmarksEntry> list = q.list();
1235    
1236                                    if (list.isEmpty()) {
1237                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1238                                                    finderArgs, list);
1239                                    }
1240                                    else {
1241                                            BookmarksEntry bookmarksEntry = list.get(0);
1242    
1243                                            result = bookmarksEntry;
1244    
1245                                            cacheResult(bookmarksEntry);
1246    
1247                                            if ((bookmarksEntry.getUuid() == null) ||
1248                                                            !bookmarksEntry.getUuid().equals(uuid) ||
1249                                                            (bookmarksEntry.getGroupId() != groupId)) {
1250                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1251                                                            finderArgs, bookmarksEntry);
1252                                            }
1253                                    }
1254                            }
1255                            catch (Exception e) {
1256                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
1257                                            finderArgs);
1258    
1259                                    throw processException(e);
1260                            }
1261                            finally {
1262                                    closeSession(session);
1263                            }
1264                    }
1265    
1266                    if (result instanceof List<?>) {
1267                            return null;
1268                    }
1269                    else {
1270                            return (BookmarksEntry)result;
1271                    }
1272            }
1273    
1274            /**
1275             * Removes the bookmarks entry where uuid = &#63; and groupId = &#63; from the database.
1276             *
1277             * @param uuid the uuid
1278             * @param groupId the group ID
1279             * @return the bookmarks entry that was removed
1280             */
1281            @Override
1282            public BookmarksEntry removeByUUID_G(String uuid, long groupId)
1283                    throws NoSuchEntryException {
1284                    BookmarksEntry bookmarksEntry = findByUUID_G(uuid, groupId);
1285    
1286                    return remove(bookmarksEntry);
1287            }
1288    
1289            /**
1290             * Returns the number of bookmarks entries where uuid = &#63; and groupId = &#63;.
1291             *
1292             * @param uuid the uuid
1293             * @param groupId the group ID
1294             * @return the number of matching bookmarks entries
1295             */
1296            @Override
1297            public int countByUUID_G(String uuid, long groupId) {
1298                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_G;
1299    
1300                    Object[] finderArgs = new Object[] { uuid, groupId };
1301    
1302                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1303                                    this);
1304    
1305                    if (count == null) {
1306                            StringBundler query = new StringBundler(3);
1307    
1308                            query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
1309    
1310                            boolean bindUuid = false;
1311    
1312                            if (uuid == null) {
1313                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1314                            }
1315                            else if (uuid.equals(StringPool.BLANK)) {
1316                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1317                            }
1318                            else {
1319                                    bindUuid = true;
1320    
1321                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1322                            }
1323    
1324                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1325    
1326                            String sql = query.toString();
1327    
1328                            Session session = null;
1329    
1330                            try {
1331                                    session = openSession();
1332    
1333                                    Query q = session.createQuery(sql);
1334    
1335                                    QueryPos qPos = QueryPos.getInstance(q);
1336    
1337                                    if (bindUuid) {
1338                                            qPos.add(uuid);
1339                                    }
1340    
1341                                    qPos.add(groupId);
1342    
1343                                    count = (Long)q.uniqueResult();
1344    
1345                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
1346                            }
1347                            catch (Exception e) {
1348                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1349    
1350                                    throw processException(e);
1351                            }
1352                            finally {
1353                                    closeSession(session);
1354                            }
1355                    }
1356    
1357                    return count.intValue();
1358            }
1359    
1360            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "bookmarksEntry.uuid IS NULL AND ";
1361            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "bookmarksEntry.uuid = ? AND ";
1362            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(bookmarksEntry.uuid IS NULL OR bookmarksEntry.uuid = '') AND ";
1363            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "bookmarksEntry.groupId = ?";
1364            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
1365                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
1366                            BookmarksEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
1367                            "findByUuid_C",
1368                            new String[] {
1369                                    String.class.getName(), Long.class.getName(),
1370                                    
1371                            Integer.class.getName(), Integer.class.getName(),
1372                                    OrderByComparator.class.getName()
1373                            });
1374            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
1375                    new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
1376                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
1377                            BookmarksEntryImpl.class,
1378                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
1379                            new String[] { String.class.getName(), Long.class.getName() },
1380                            BookmarksEntryModelImpl.UUID_COLUMN_BITMASK |
1381                            BookmarksEntryModelImpl.COMPANYID_COLUMN_BITMASK |
1382                            BookmarksEntryModelImpl.FOLDERID_COLUMN_BITMASK |
1383                            BookmarksEntryModelImpl.NAME_COLUMN_BITMASK);
1384            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
1385                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
1386                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
1387                            new String[] { String.class.getName(), Long.class.getName() });
1388    
1389            /**
1390             * Returns all the bookmarks entries where uuid = &#63; and companyId = &#63;.
1391             *
1392             * @param uuid the uuid
1393             * @param companyId the company ID
1394             * @return the matching bookmarks entries
1395             */
1396            @Override
1397            public List<BookmarksEntry> findByUuid_C(String uuid, long companyId) {
1398                    return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
1399                            QueryUtil.ALL_POS, null);
1400            }
1401    
1402            /**
1403             * Returns a range of all the bookmarks entries where uuid = &#63; and companyId = &#63;.
1404             *
1405             * <p>
1406             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.bookmarks.model.impl.BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1407             * </p>
1408             *
1409             * @param uuid the uuid
1410             * @param companyId the company ID
1411             * @param start the lower bound of the range of bookmarks entries
1412             * @param end the upper bound of the range of bookmarks entries (not inclusive)
1413             * @return the range of matching bookmarks entries
1414             */
1415            @Override
1416            public List<BookmarksEntry> findByUuid_C(String uuid, long companyId,
1417                    int start, int end) {
1418                    return findByUuid_C(uuid, companyId, start, end, null);
1419            }
1420    
1421            /**
1422             * Returns an ordered range of all the bookmarks entries where uuid = &#63; and companyId = &#63;.
1423             *
1424             * <p>
1425             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.bookmarks.model.impl.BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1426             * </p>
1427             *
1428             * @param uuid the uuid
1429             * @param companyId the company ID
1430             * @param start the lower bound of the range of bookmarks entries
1431             * @param end the upper bound of the range of bookmarks entries (not inclusive)
1432             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1433             * @return the ordered range of matching bookmarks entries
1434             */
1435            @Override
1436            public List<BookmarksEntry> findByUuid_C(String uuid, long companyId,
1437                    int start, int end, OrderByComparator<BookmarksEntry> orderByComparator) {
1438                    boolean pagination = true;
1439                    FinderPath finderPath = null;
1440                    Object[] finderArgs = null;
1441    
1442                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1443                                    (orderByComparator == null)) {
1444                            pagination = false;
1445                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
1446                            finderArgs = new Object[] { uuid, companyId };
1447                    }
1448                    else {
1449                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
1450                            finderArgs = new Object[] {
1451                                            uuid, companyId,
1452                                            
1453                                            start, end, orderByComparator
1454                                    };
1455                    }
1456    
1457                    List<BookmarksEntry> list = (List<BookmarksEntry>)FinderCacheUtil.getResult(finderPath,
1458                                    finderArgs, this);
1459    
1460                    if ((list != null) && !list.isEmpty()) {
1461                            for (BookmarksEntry bookmarksEntry : list) {
1462                                    if (!Validator.equals(uuid, bookmarksEntry.getUuid()) ||
1463                                                    (companyId != bookmarksEntry.getCompanyId())) {
1464                                            list = null;
1465    
1466                                            break;
1467                                    }
1468                            }
1469                    }
1470    
1471                    if (list == null) {
1472                            StringBundler query = null;
1473    
1474                            if (orderByComparator != null) {
1475                                    query = new StringBundler(4 +
1476                                                    (orderByComparator.getOrderByFields().length * 3));
1477                            }
1478                            else {
1479                                    query = new StringBundler(4);
1480                            }
1481    
1482                            query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
1483    
1484                            boolean bindUuid = false;
1485    
1486                            if (uuid == null) {
1487                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1488                            }
1489                            else if (uuid.equals(StringPool.BLANK)) {
1490                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1491                            }
1492                            else {
1493                                    bindUuid = true;
1494    
1495                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1496                            }
1497    
1498                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1499    
1500                            if (orderByComparator != null) {
1501                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1502                                            orderByComparator);
1503                            }
1504                            else
1505                             if (pagination) {
1506                                    query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
1507                            }
1508    
1509                            String sql = query.toString();
1510    
1511                            Session session = null;
1512    
1513                            try {
1514                                    session = openSession();
1515    
1516                                    Query q = session.createQuery(sql);
1517    
1518                                    QueryPos qPos = QueryPos.getInstance(q);
1519    
1520                                    if (bindUuid) {
1521                                            qPos.add(uuid);
1522                                    }
1523    
1524                                    qPos.add(companyId);
1525    
1526                                    if (!pagination) {
1527                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
1528                                                            getDialect(), start, end, false);
1529    
1530                                            Collections.sort(list);
1531    
1532                                            list = Collections.unmodifiableList(list);
1533                                    }
1534                                    else {
1535                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
1536                                                            getDialect(), start, end);
1537                                    }
1538    
1539                                    cacheResult(list);
1540    
1541                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1542                            }
1543                            catch (Exception e) {
1544                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1545    
1546                                    throw processException(e);
1547                            }
1548                            finally {
1549                                    closeSession(session);
1550                            }
1551                    }
1552    
1553                    return list;
1554            }
1555    
1556            /**
1557             * Returns the first bookmarks entry in the ordered set where uuid = &#63; and companyId = &#63;.
1558             *
1559             * @param uuid the uuid
1560             * @param companyId the company ID
1561             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1562             * @return the first matching bookmarks entry
1563             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
1564             */
1565            @Override
1566            public BookmarksEntry findByUuid_C_First(String uuid, long companyId,
1567                    OrderByComparator<BookmarksEntry> orderByComparator)
1568                    throws NoSuchEntryException {
1569                    BookmarksEntry bookmarksEntry = fetchByUuid_C_First(uuid, companyId,
1570                                    orderByComparator);
1571    
1572                    if (bookmarksEntry != null) {
1573                            return bookmarksEntry;
1574                    }
1575    
1576                    StringBundler msg = new StringBundler(6);
1577    
1578                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1579    
1580                    msg.append("uuid=");
1581                    msg.append(uuid);
1582    
1583                    msg.append(", companyId=");
1584                    msg.append(companyId);
1585    
1586                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1587    
1588                    throw new NoSuchEntryException(msg.toString());
1589            }
1590    
1591            /**
1592             * Returns the first bookmarks entry in the ordered set where uuid = &#63; and companyId = &#63;.
1593             *
1594             * @param uuid the uuid
1595             * @param companyId the company ID
1596             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1597             * @return the first matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
1598             */
1599            @Override
1600            public BookmarksEntry fetchByUuid_C_First(String uuid, long companyId,
1601                    OrderByComparator<BookmarksEntry> orderByComparator) {
1602                    List<BookmarksEntry> list = findByUuid_C(uuid, companyId, 0, 1,
1603                                    orderByComparator);
1604    
1605                    if (!list.isEmpty()) {
1606                            return list.get(0);
1607                    }
1608    
1609                    return null;
1610            }
1611    
1612            /**
1613             * Returns the last bookmarks entry in the ordered set where uuid = &#63; and companyId = &#63;.
1614             *
1615             * @param uuid the uuid
1616             * @param companyId the company ID
1617             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1618             * @return the last matching bookmarks entry
1619             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
1620             */
1621            @Override
1622            public BookmarksEntry findByUuid_C_Last(String uuid, long companyId,
1623                    OrderByComparator<BookmarksEntry> orderByComparator)
1624                    throws NoSuchEntryException {
1625                    BookmarksEntry bookmarksEntry = fetchByUuid_C_Last(uuid, companyId,
1626                                    orderByComparator);
1627    
1628                    if (bookmarksEntry != null) {
1629                            return bookmarksEntry;
1630                    }
1631    
1632                    StringBundler msg = new StringBundler(6);
1633    
1634                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1635    
1636                    msg.append("uuid=");
1637                    msg.append(uuid);
1638    
1639                    msg.append(", companyId=");
1640                    msg.append(companyId);
1641    
1642                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1643    
1644                    throw new NoSuchEntryException(msg.toString());
1645            }
1646    
1647            /**
1648             * Returns the last bookmarks entry in the ordered set where uuid = &#63; and companyId = &#63;.
1649             *
1650             * @param uuid the uuid
1651             * @param companyId the company ID
1652             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1653             * @return the last matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
1654             */
1655            @Override
1656            public BookmarksEntry fetchByUuid_C_Last(String uuid, long companyId,
1657                    OrderByComparator<BookmarksEntry> orderByComparator) {
1658                    int count = countByUuid_C(uuid, companyId);
1659    
1660                    if (count == 0) {
1661                            return null;
1662                    }
1663    
1664                    List<BookmarksEntry> list = findByUuid_C(uuid, companyId, count - 1,
1665                                    count, orderByComparator);
1666    
1667                    if (!list.isEmpty()) {
1668                            return list.get(0);
1669                    }
1670    
1671                    return null;
1672            }
1673    
1674            /**
1675             * Returns the bookmarks entries before and after the current bookmarks entry in the ordered set where uuid = &#63; and companyId = &#63;.
1676             *
1677             * @param entryId the primary key of the current bookmarks entry
1678             * @param uuid the uuid
1679             * @param companyId the company ID
1680             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1681             * @return the previous, current, and next bookmarks entry
1682             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
1683             */
1684            @Override
1685            public BookmarksEntry[] findByUuid_C_PrevAndNext(long entryId, String uuid,
1686                    long companyId, OrderByComparator<BookmarksEntry> orderByComparator)
1687                    throws NoSuchEntryException {
1688                    BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
1689    
1690                    Session session = null;
1691    
1692                    try {
1693                            session = openSession();
1694    
1695                            BookmarksEntry[] array = new BookmarksEntryImpl[3];
1696    
1697                            array[0] = getByUuid_C_PrevAndNext(session, bookmarksEntry, uuid,
1698                                            companyId, orderByComparator, true);
1699    
1700                            array[1] = bookmarksEntry;
1701    
1702                            array[2] = getByUuid_C_PrevAndNext(session, bookmarksEntry, uuid,
1703                                            companyId, orderByComparator, false);
1704    
1705                            return array;
1706                    }
1707                    catch (Exception e) {
1708                            throw processException(e);
1709                    }
1710                    finally {
1711                            closeSession(session);
1712                    }
1713            }
1714    
1715            protected BookmarksEntry getByUuid_C_PrevAndNext(Session session,
1716                    BookmarksEntry bookmarksEntry, String uuid, long companyId,
1717                    OrderByComparator<BookmarksEntry> orderByComparator, boolean previous) {
1718                    StringBundler query = null;
1719    
1720                    if (orderByComparator != null) {
1721                            query = new StringBundler(6 +
1722                                            (orderByComparator.getOrderByFields().length * 6));
1723                    }
1724                    else {
1725                            query = new StringBundler(3);
1726                    }
1727    
1728                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
1729    
1730                    boolean bindUuid = false;
1731    
1732                    if (uuid == null) {
1733                            query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1734                    }
1735                    else if (uuid.equals(StringPool.BLANK)) {
1736                            query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1737                    }
1738                    else {
1739                            bindUuid = true;
1740    
1741                            query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1742                    }
1743    
1744                    query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1745    
1746                    if (orderByComparator != null) {
1747                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1748    
1749                            if (orderByConditionFields.length > 0) {
1750                                    query.append(WHERE_AND);
1751                            }
1752    
1753                            for (int i = 0; i < orderByConditionFields.length; i++) {
1754                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1755                                    query.append(orderByConditionFields[i]);
1756    
1757                                    if ((i + 1) < orderByConditionFields.length) {
1758                                            if (orderByComparator.isAscending() ^ previous) {
1759                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1760                                            }
1761                                            else {
1762                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1763                                            }
1764                                    }
1765                                    else {
1766                                            if (orderByComparator.isAscending() ^ previous) {
1767                                                    query.append(WHERE_GREATER_THAN);
1768                                            }
1769                                            else {
1770                                                    query.append(WHERE_LESSER_THAN);
1771                                            }
1772                                    }
1773                            }
1774    
1775                            query.append(ORDER_BY_CLAUSE);
1776    
1777                            String[] orderByFields = orderByComparator.getOrderByFields();
1778    
1779                            for (int i = 0; i < orderByFields.length; i++) {
1780                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1781                                    query.append(orderByFields[i]);
1782    
1783                                    if ((i + 1) < orderByFields.length) {
1784                                            if (orderByComparator.isAscending() ^ previous) {
1785                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1786                                            }
1787                                            else {
1788                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1789                                            }
1790                                    }
1791                                    else {
1792                                            if (orderByComparator.isAscending() ^ previous) {
1793                                                    query.append(ORDER_BY_ASC);
1794                                            }
1795                                            else {
1796                                                    query.append(ORDER_BY_DESC);
1797                                            }
1798                                    }
1799                            }
1800                    }
1801                    else {
1802                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
1803                    }
1804    
1805                    String sql = query.toString();
1806    
1807                    Query q = session.createQuery(sql);
1808    
1809                    q.setFirstResult(0);
1810                    q.setMaxResults(2);
1811    
1812                    QueryPos qPos = QueryPos.getInstance(q);
1813    
1814                    if (bindUuid) {
1815                            qPos.add(uuid);
1816                    }
1817    
1818                    qPos.add(companyId);
1819    
1820                    if (orderByComparator != null) {
1821                            Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry);
1822    
1823                            for (Object value : values) {
1824                                    qPos.add(value);
1825                            }
1826                    }
1827    
1828                    List<BookmarksEntry> list = q.list();
1829    
1830                    if (list.size() == 2) {
1831                            return list.get(1);
1832                    }
1833                    else {
1834                            return null;
1835                    }
1836            }
1837    
1838            /**
1839             * Removes all the bookmarks entries where uuid = &#63; and companyId = &#63; from the database.
1840             *
1841             * @param uuid the uuid
1842             * @param companyId the company ID
1843             */
1844            @Override
1845            public void removeByUuid_C(String uuid, long companyId) {
1846                    for (BookmarksEntry bookmarksEntry : findByUuid_C(uuid, companyId,
1847                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1848                            remove(bookmarksEntry);
1849                    }
1850            }
1851    
1852            /**
1853             * Returns the number of bookmarks entries where uuid = &#63; and companyId = &#63;.
1854             *
1855             * @param uuid the uuid
1856             * @param companyId the company ID
1857             * @return the number of matching bookmarks entries
1858             */
1859            @Override
1860            public int countByUuid_C(String uuid, long companyId) {
1861                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1862    
1863                    Object[] finderArgs = new Object[] { uuid, companyId };
1864    
1865                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1866                                    this);
1867    
1868                    if (count == null) {
1869                            StringBundler query = new StringBundler(3);
1870    
1871                            query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
1872    
1873                            boolean bindUuid = false;
1874    
1875                            if (uuid == null) {
1876                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1877                            }
1878                            else if (uuid.equals(StringPool.BLANK)) {
1879                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1880                            }
1881                            else {
1882                                    bindUuid = true;
1883    
1884                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1885                            }
1886    
1887                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1888    
1889                            String sql = query.toString();
1890    
1891                            Session session = null;
1892    
1893                            try {
1894                                    session = openSession();
1895    
1896                                    Query q = session.createQuery(sql);
1897    
1898                                    QueryPos qPos = QueryPos.getInstance(q);
1899    
1900                                    if (bindUuid) {
1901                                            qPos.add(uuid);
1902                                    }
1903    
1904                                    qPos.add(companyId);
1905    
1906                                    count = (Long)q.uniqueResult();
1907    
1908                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
1909                            }
1910                            catch (Exception e) {
1911                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1912    
1913                                    throw processException(e);
1914                            }
1915                            finally {
1916                                    closeSession(session);
1917                            }
1918                    }
1919    
1920                    return count.intValue();
1921            }
1922    
1923            private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "bookmarksEntry.uuid IS NULL AND ";
1924            private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "bookmarksEntry.uuid = ? AND ";
1925            private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(bookmarksEntry.uuid IS NULL OR bookmarksEntry.uuid = '') AND ";
1926            private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "bookmarksEntry.companyId = ?";
1927            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
1928                    new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
1929                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
1930                            BookmarksEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
1931                            "findByCompanyId",
1932                            new String[] {
1933                                    Long.class.getName(),
1934                                    
1935                            Integer.class.getName(), Integer.class.getName(),
1936                                    OrderByComparator.class.getName()
1937                            });
1938            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
1939                    new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
1940                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
1941                            BookmarksEntryImpl.class,
1942                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
1943                            new String[] { Long.class.getName() },
1944                            BookmarksEntryModelImpl.COMPANYID_COLUMN_BITMASK |
1945                            BookmarksEntryModelImpl.FOLDERID_COLUMN_BITMASK |
1946                            BookmarksEntryModelImpl.NAME_COLUMN_BITMASK);
1947            public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
1948                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
1949                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
1950                            new String[] { Long.class.getName() });
1951    
1952            /**
1953             * Returns all the bookmarks entries where companyId = &#63;.
1954             *
1955             * @param companyId the company ID
1956             * @return the matching bookmarks entries
1957             */
1958            @Override
1959            public List<BookmarksEntry> findByCompanyId(long companyId) {
1960                    return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1961                            null);
1962            }
1963    
1964            /**
1965             * Returns a range of all the bookmarks entries where companyId = &#63;.
1966             *
1967             * <p>
1968             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.bookmarks.model.impl.BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1969             * </p>
1970             *
1971             * @param companyId the company ID
1972             * @param start the lower bound of the range of bookmarks entries
1973             * @param end the upper bound of the range of bookmarks entries (not inclusive)
1974             * @return the range of matching bookmarks entries
1975             */
1976            @Override
1977            public List<BookmarksEntry> findByCompanyId(long companyId, int start,
1978                    int end) {
1979                    return findByCompanyId(companyId, start, end, null);
1980            }
1981    
1982            /**
1983             * Returns an ordered range of all the bookmarks entries where companyId = &#63;.
1984             *
1985             * <p>
1986             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.bookmarks.model.impl.BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1987             * </p>
1988             *
1989             * @param companyId the company ID
1990             * @param start the lower bound of the range of bookmarks entries
1991             * @param end the upper bound of the range of bookmarks entries (not inclusive)
1992             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1993             * @return the ordered range of matching bookmarks entries
1994             */
1995            @Override
1996            public List<BookmarksEntry> findByCompanyId(long companyId, int start,
1997                    int end, OrderByComparator<BookmarksEntry> orderByComparator) {
1998                    boolean pagination = true;
1999                    FinderPath finderPath = null;
2000                    Object[] finderArgs = null;
2001    
2002                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2003                                    (orderByComparator == null)) {
2004                            pagination = false;
2005                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
2006                            finderArgs = new Object[] { companyId };
2007                    }
2008                    else {
2009                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
2010                            finderArgs = new Object[] { companyId, start, end, orderByComparator };
2011                    }
2012    
2013                    List<BookmarksEntry> list = (List<BookmarksEntry>)FinderCacheUtil.getResult(finderPath,
2014                                    finderArgs, this);
2015    
2016                    if ((list != null) && !list.isEmpty()) {
2017                            for (BookmarksEntry bookmarksEntry : list) {
2018                                    if ((companyId != bookmarksEntry.getCompanyId())) {
2019                                            list = null;
2020    
2021                                            break;
2022                                    }
2023                            }
2024                    }
2025    
2026                    if (list == null) {
2027                            StringBundler query = null;
2028    
2029                            if (orderByComparator != null) {
2030                                    query = new StringBundler(3 +
2031                                                    (orderByComparator.getOrderByFields().length * 3));
2032                            }
2033                            else {
2034                                    query = new StringBundler(3);
2035                            }
2036    
2037                            query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
2038    
2039                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2040    
2041                            if (orderByComparator != null) {
2042                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2043                                            orderByComparator);
2044                            }
2045                            else
2046                             if (pagination) {
2047                                    query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
2048                            }
2049    
2050                            String sql = query.toString();
2051    
2052                            Session session = null;
2053    
2054                            try {
2055                                    session = openSession();
2056    
2057                                    Query q = session.createQuery(sql);
2058    
2059                                    QueryPos qPos = QueryPos.getInstance(q);
2060    
2061                                    qPos.add(companyId);
2062    
2063                                    if (!pagination) {
2064                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
2065                                                            getDialect(), start, end, false);
2066    
2067                                            Collections.sort(list);
2068    
2069                                            list = Collections.unmodifiableList(list);
2070                                    }
2071                                    else {
2072                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
2073                                                            getDialect(), start, end);
2074                                    }
2075    
2076                                    cacheResult(list);
2077    
2078                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
2079                            }
2080                            catch (Exception e) {
2081                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2082    
2083                                    throw processException(e);
2084                            }
2085                            finally {
2086                                    closeSession(session);
2087                            }
2088                    }
2089    
2090                    return list;
2091            }
2092    
2093            /**
2094             * Returns the first bookmarks entry in the ordered set where companyId = &#63;.
2095             *
2096             * @param companyId the company ID
2097             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2098             * @return the first matching bookmarks entry
2099             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
2100             */
2101            @Override
2102            public BookmarksEntry findByCompanyId_First(long companyId,
2103                    OrderByComparator<BookmarksEntry> orderByComparator)
2104                    throws NoSuchEntryException {
2105                    BookmarksEntry bookmarksEntry = fetchByCompanyId_First(companyId,
2106                                    orderByComparator);
2107    
2108                    if (bookmarksEntry != null) {
2109                            return bookmarksEntry;
2110                    }
2111    
2112                    StringBundler msg = new StringBundler(4);
2113    
2114                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2115    
2116                    msg.append("companyId=");
2117                    msg.append(companyId);
2118    
2119                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2120    
2121                    throw new NoSuchEntryException(msg.toString());
2122            }
2123    
2124            /**
2125             * Returns the first bookmarks entry in the ordered set where companyId = &#63;.
2126             *
2127             * @param companyId the company ID
2128             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2129             * @return the first matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
2130             */
2131            @Override
2132            public BookmarksEntry fetchByCompanyId_First(long companyId,
2133                    OrderByComparator<BookmarksEntry> orderByComparator) {
2134                    List<BookmarksEntry> list = findByCompanyId(companyId, 0, 1,
2135                                    orderByComparator);
2136    
2137                    if (!list.isEmpty()) {
2138                            return list.get(0);
2139                    }
2140    
2141                    return null;
2142            }
2143    
2144            /**
2145             * Returns the last bookmarks entry in the ordered set where companyId = &#63;.
2146             *
2147             * @param companyId the company ID
2148             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2149             * @return the last matching bookmarks entry
2150             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
2151             */
2152            @Override
2153            public BookmarksEntry findByCompanyId_Last(long companyId,
2154                    OrderByComparator<BookmarksEntry> orderByComparator)
2155                    throws NoSuchEntryException {
2156                    BookmarksEntry bookmarksEntry = fetchByCompanyId_Last(companyId,
2157                                    orderByComparator);
2158    
2159                    if (bookmarksEntry != null) {
2160                            return bookmarksEntry;
2161                    }
2162    
2163                    StringBundler msg = new StringBundler(4);
2164    
2165                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2166    
2167                    msg.append("companyId=");
2168                    msg.append(companyId);
2169    
2170                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2171    
2172                    throw new NoSuchEntryException(msg.toString());
2173            }
2174    
2175            /**
2176             * Returns the last bookmarks entry in the ordered set where companyId = &#63;.
2177             *
2178             * @param companyId the company ID
2179             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2180             * @return the last matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
2181             */
2182            @Override
2183            public BookmarksEntry fetchByCompanyId_Last(long companyId,
2184                    OrderByComparator<BookmarksEntry> orderByComparator) {
2185                    int count = countByCompanyId(companyId);
2186    
2187                    if (count == 0) {
2188                            return null;
2189                    }
2190    
2191                    List<BookmarksEntry> list = findByCompanyId(companyId, count - 1,
2192                                    count, orderByComparator);
2193    
2194                    if (!list.isEmpty()) {
2195                            return list.get(0);
2196                    }
2197    
2198                    return null;
2199            }
2200    
2201            /**
2202             * Returns the bookmarks entries before and after the current bookmarks entry in the ordered set where companyId = &#63;.
2203             *
2204             * @param entryId the primary key of the current bookmarks entry
2205             * @param companyId the company ID
2206             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2207             * @return the previous, current, and next bookmarks entry
2208             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
2209             */
2210            @Override
2211            public BookmarksEntry[] findByCompanyId_PrevAndNext(long entryId,
2212                    long companyId, OrderByComparator<BookmarksEntry> orderByComparator)
2213                    throws NoSuchEntryException {
2214                    BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
2215    
2216                    Session session = null;
2217    
2218                    try {
2219                            session = openSession();
2220    
2221                            BookmarksEntry[] array = new BookmarksEntryImpl[3];
2222    
2223                            array[0] = getByCompanyId_PrevAndNext(session, bookmarksEntry,
2224                                            companyId, orderByComparator, true);
2225    
2226                            array[1] = bookmarksEntry;
2227    
2228                            array[2] = getByCompanyId_PrevAndNext(session, bookmarksEntry,
2229                                            companyId, orderByComparator, false);
2230    
2231                            return array;
2232                    }
2233                    catch (Exception e) {
2234                            throw processException(e);
2235                    }
2236                    finally {
2237                            closeSession(session);
2238                    }
2239            }
2240    
2241            protected BookmarksEntry getByCompanyId_PrevAndNext(Session session,
2242                    BookmarksEntry bookmarksEntry, long companyId,
2243                    OrderByComparator<BookmarksEntry> orderByComparator, boolean previous) {
2244                    StringBundler query = null;
2245    
2246                    if (orderByComparator != null) {
2247                            query = new StringBundler(6 +
2248                                            (orderByComparator.getOrderByFields().length * 6));
2249                    }
2250                    else {
2251                            query = new StringBundler(3);
2252                    }
2253    
2254                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
2255    
2256                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2257    
2258                    if (orderByComparator != null) {
2259                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2260    
2261                            if (orderByConditionFields.length > 0) {
2262                                    query.append(WHERE_AND);
2263                            }
2264    
2265                            for (int i = 0; i < orderByConditionFields.length; i++) {
2266                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2267                                    query.append(orderByConditionFields[i]);
2268    
2269                                    if ((i + 1) < orderByConditionFields.length) {
2270                                            if (orderByComparator.isAscending() ^ previous) {
2271                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2272                                            }
2273                                            else {
2274                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2275                                            }
2276                                    }
2277                                    else {
2278                                            if (orderByComparator.isAscending() ^ previous) {
2279                                                    query.append(WHERE_GREATER_THAN);
2280                                            }
2281                                            else {
2282                                                    query.append(WHERE_LESSER_THAN);
2283                                            }
2284                                    }
2285                            }
2286    
2287                            query.append(ORDER_BY_CLAUSE);
2288    
2289                            String[] orderByFields = orderByComparator.getOrderByFields();
2290    
2291                            for (int i = 0; i < orderByFields.length; i++) {
2292                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2293                                    query.append(orderByFields[i]);
2294    
2295                                    if ((i + 1) < orderByFields.length) {
2296                                            if (orderByComparator.isAscending() ^ previous) {
2297                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2298                                            }
2299                                            else {
2300                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2301                                            }
2302                                    }
2303                                    else {
2304                                            if (orderByComparator.isAscending() ^ previous) {
2305                                                    query.append(ORDER_BY_ASC);
2306                                            }
2307                                            else {
2308                                                    query.append(ORDER_BY_DESC);
2309                                            }
2310                                    }
2311                            }
2312                    }
2313                    else {
2314                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
2315                    }
2316    
2317                    String sql = query.toString();
2318    
2319                    Query q = session.createQuery(sql);
2320    
2321                    q.setFirstResult(0);
2322                    q.setMaxResults(2);
2323    
2324                    QueryPos qPos = QueryPos.getInstance(q);
2325    
2326                    qPos.add(companyId);
2327    
2328                    if (orderByComparator != null) {
2329                            Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry);
2330    
2331                            for (Object value : values) {
2332                                    qPos.add(value);
2333                            }
2334                    }
2335    
2336                    List<BookmarksEntry> list = q.list();
2337    
2338                    if (list.size() == 2) {
2339                            return list.get(1);
2340                    }
2341                    else {
2342                            return null;
2343                    }
2344            }
2345    
2346            /**
2347             * Removes all the bookmarks entries where companyId = &#63; from the database.
2348             *
2349             * @param companyId the company ID
2350             */
2351            @Override
2352            public void removeByCompanyId(long companyId) {
2353                    for (BookmarksEntry bookmarksEntry : findByCompanyId(companyId,
2354                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2355                            remove(bookmarksEntry);
2356                    }
2357            }
2358    
2359            /**
2360             * Returns the number of bookmarks entries where companyId = &#63;.
2361             *
2362             * @param companyId the company ID
2363             * @return the number of matching bookmarks entries
2364             */
2365            @Override
2366            public int countByCompanyId(long companyId) {
2367                    FinderPath finderPath = FINDER_PATH_COUNT_BY_COMPANYID;
2368    
2369                    Object[] finderArgs = new Object[] { companyId };
2370    
2371                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2372                                    this);
2373    
2374                    if (count == null) {
2375                            StringBundler query = new StringBundler(2);
2376    
2377                            query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
2378    
2379                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2380    
2381                            String sql = query.toString();
2382    
2383                            Session session = null;
2384    
2385                            try {
2386                                    session = openSession();
2387    
2388                                    Query q = session.createQuery(sql);
2389    
2390                                    QueryPos qPos = QueryPos.getInstance(q);
2391    
2392                                    qPos.add(companyId);
2393    
2394                                    count = (Long)q.uniqueResult();
2395    
2396                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
2397                            }
2398                            catch (Exception e) {
2399                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2400    
2401                                    throw processException(e);
2402                            }
2403                            finally {
2404                                    closeSession(session);
2405                            }
2406                    }
2407    
2408                    return count.intValue();
2409            }
2410    
2411            private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "bookmarksEntry.companyId = ?";
2412            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
2413                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
2414                            BookmarksEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
2415                            "findByG_F",
2416                            new String[] {
2417                                    Long.class.getName(), Long.class.getName(),
2418                                    
2419                            Integer.class.getName(), Integer.class.getName(),
2420                                    OrderByComparator.class.getName()
2421                            });
2422            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
2423                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
2424                            BookmarksEntryImpl.class,
2425                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_F",
2426                            new String[] { Long.class.getName(), Long.class.getName() },
2427                            BookmarksEntryModelImpl.GROUPID_COLUMN_BITMASK |
2428                            BookmarksEntryModelImpl.FOLDERID_COLUMN_BITMASK |
2429                            BookmarksEntryModelImpl.NAME_COLUMN_BITMASK);
2430            public static final FinderPath FINDER_PATH_COUNT_BY_G_F = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
2431                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
2432                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_F",
2433                            new String[] { Long.class.getName(), Long.class.getName() });
2434            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
2435                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
2436                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_F",
2437                            new String[] { Long.class.getName(), Long.class.getName() });
2438    
2439            /**
2440             * Returns all the bookmarks entries where groupId = &#63; and folderId = &#63;.
2441             *
2442             * @param groupId the group ID
2443             * @param folderId the folder ID
2444             * @return the matching bookmarks entries
2445             */
2446            @Override
2447            public List<BookmarksEntry> findByG_F(long groupId, long folderId) {
2448                    return findByG_F(groupId, folderId, QueryUtil.ALL_POS,
2449                            QueryUtil.ALL_POS, null);
2450            }
2451    
2452            /**
2453             * Returns a range of all the bookmarks entries where groupId = &#63; and folderId = &#63;.
2454             *
2455             * <p>
2456             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.bookmarks.model.impl.BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2457             * </p>
2458             *
2459             * @param groupId the group ID
2460             * @param folderId the folder ID
2461             * @param start the lower bound of the range of bookmarks entries
2462             * @param end the upper bound of the range of bookmarks entries (not inclusive)
2463             * @return the range of matching bookmarks entries
2464             */
2465            @Override
2466            public List<BookmarksEntry> findByG_F(long groupId, long folderId,
2467                    int start, int end) {
2468                    return findByG_F(groupId, folderId, start, end, null);
2469            }
2470    
2471            /**
2472             * Returns an ordered range of all the bookmarks entries where groupId = &#63; and folderId = &#63;.
2473             *
2474             * <p>
2475             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.bookmarks.model.impl.BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2476             * </p>
2477             *
2478             * @param groupId the group ID
2479             * @param folderId the folder ID
2480             * @param start the lower bound of the range of bookmarks entries
2481             * @param end the upper bound of the range of bookmarks entries (not inclusive)
2482             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2483             * @return the ordered range of matching bookmarks entries
2484             */
2485            @Override
2486            public List<BookmarksEntry> findByG_F(long groupId, long folderId,
2487                    int start, int end, OrderByComparator<BookmarksEntry> orderByComparator) {
2488                    boolean pagination = true;
2489                    FinderPath finderPath = null;
2490                    Object[] finderArgs = null;
2491    
2492                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2493                                    (orderByComparator == null)) {
2494                            pagination = false;
2495                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F;
2496                            finderArgs = new Object[] { groupId, folderId };
2497                    }
2498                    else {
2499                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F;
2500                            finderArgs = new Object[] {
2501                                            groupId, folderId,
2502                                            
2503                                            start, end, orderByComparator
2504                                    };
2505                    }
2506    
2507                    List<BookmarksEntry> list = (List<BookmarksEntry>)FinderCacheUtil.getResult(finderPath,
2508                                    finderArgs, this);
2509    
2510                    if ((list != null) && !list.isEmpty()) {
2511                            for (BookmarksEntry bookmarksEntry : list) {
2512                                    if ((groupId != bookmarksEntry.getGroupId()) ||
2513                                                    (folderId != bookmarksEntry.getFolderId())) {
2514                                            list = null;
2515    
2516                                            break;
2517                                    }
2518                            }
2519                    }
2520    
2521                    if (list == null) {
2522                            StringBundler query = null;
2523    
2524                            if (orderByComparator != null) {
2525                                    query = new StringBundler(4 +
2526                                                    (orderByComparator.getOrderByFields().length * 3));
2527                            }
2528                            else {
2529                                    query = new StringBundler(4);
2530                            }
2531    
2532                            query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
2533    
2534                            query.append(_FINDER_COLUMN_G_F_GROUPID_2);
2535    
2536                            query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
2537    
2538                            if (orderByComparator != null) {
2539                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2540                                            orderByComparator);
2541                            }
2542                            else
2543                             if (pagination) {
2544                                    query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
2545                            }
2546    
2547                            String sql = query.toString();
2548    
2549                            Session session = null;
2550    
2551                            try {
2552                                    session = openSession();
2553    
2554                                    Query q = session.createQuery(sql);
2555    
2556                                    QueryPos qPos = QueryPos.getInstance(q);
2557    
2558                                    qPos.add(groupId);
2559    
2560                                    qPos.add(folderId);
2561    
2562                                    if (!pagination) {
2563                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
2564                                                            getDialect(), start, end, false);
2565    
2566                                            Collections.sort(list);
2567    
2568                                            list = Collections.unmodifiableList(list);
2569                                    }
2570                                    else {
2571                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
2572                                                            getDialect(), start, end);
2573                                    }
2574    
2575                                    cacheResult(list);
2576    
2577                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
2578                            }
2579                            catch (Exception e) {
2580                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2581    
2582                                    throw processException(e);
2583                            }
2584                            finally {
2585                                    closeSession(session);
2586                            }
2587                    }
2588    
2589                    return list;
2590            }
2591    
2592            /**
2593             * Returns the first bookmarks entry in the ordered set where groupId = &#63; and folderId = &#63;.
2594             *
2595             * @param groupId the group ID
2596             * @param folderId the folder ID
2597             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2598             * @return the first matching bookmarks entry
2599             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
2600             */
2601            @Override
2602            public BookmarksEntry findByG_F_First(long groupId, long folderId,
2603                    OrderByComparator<BookmarksEntry> orderByComparator)
2604                    throws NoSuchEntryException {
2605                    BookmarksEntry bookmarksEntry = fetchByG_F_First(groupId, folderId,
2606                                    orderByComparator);
2607    
2608                    if (bookmarksEntry != null) {
2609                            return bookmarksEntry;
2610                    }
2611    
2612                    StringBundler msg = new StringBundler(6);
2613    
2614                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2615    
2616                    msg.append("groupId=");
2617                    msg.append(groupId);
2618    
2619                    msg.append(", folderId=");
2620                    msg.append(folderId);
2621    
2622                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2623    
2624                    throw new NoSuchEntryException(msg.toString());
2625            }
2626    
2627            /**
2628             * Returns the first bookmarks entry in the ordered set where groupId = &#63; and folderId = &#63;.
2629             *
2630             * @param groupId the group ID
2631             * @param folderId the folder ID
2632             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2633             * @return the first matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
2634             */
2635            @Override
2636            public BookmarksEntry fetchByG_F_First(long groupId, long folderId,
2637                    OrderByComparator<BookmarksEntry> orderByComparator) {
2638                    List<BookmarksEntry> list = findByG_F(groupId, folderId, 0, 1,
2639                                    orderByComparator);
2640    
2641                    if (!list.isEmpty()) {
2642                            return list.get(0);
2643                    }
2644    
2645                    return null;
2646            }
2647    
2648            /**
2649             * Returns the last bookmarks entry in the ordered set where groupId = &#63; and folderId = &#63;.
2650             *
2651             * @param groupId the group ID
2652             * @param folderId the folder ID
2653             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2654             * @return the last matching bookmarks entry
2655             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
2656             */
2657            @Override
2658            public BookmarksEntry findByG_F_Last(long groupId, long folderId,
2659                    OrderByComparator<BookmarksEntry> orderByComparator)
2660                    throws NoSuchEntryException {
2661                    BookmarksEntry bookmarksEntry = fetchByG_F_Last(groupId, folderId,
2662                                    orderByComparator);
2663    
2664                    if (bookmarksEntry != null) {
2665                            return bookmarksEntry;
2666                    }
2667    
2668                    StringBundler msg = new StringBundler(6);
2669    
2670                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2671    
2672                    msg.append("groupId=");
2673                    msg.append(groupId);
2674    
2675                    msg.append(", folderId=");
2676                    msg.append(folderId);
2677    
2678                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2679    
2680                    throw new NoSuchEntryException(msg.toString());
2681            }
2682    
2683            /**
2684             * Returns the last bookmarks entry in the ordered set where groupId = &#63; and folderId = &#63;.
2685             *
2686             * @param groupId the group ID
2687             * @param folderId the folder ID
2688             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2689             * @return the last matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
2690             */
2691            @Override
2692            public BookmarksEntry fetchByG_F_Last(long groupId, long folderId,
2693                    OrderByComparator<BookmarksEntry> orderByComparator) {
2694                    int count = countByG_F(groupId, folderId);
2695    
2696                    if (count == 0) {
2697                            return null;
2698                    }
2699    
2700                    List<BookmarksEntry> list = findByG_F(groupId, folderId, count - 1,
2701                                    count, orderByComparator);
2702    
2703                    if (!list.isEmpty()) {
2704                            return list.get(0);
2705                    }
2706    
2707                    return null;
2708            }
2709    
2710            /**
2711             * Returns the bookmarks entries before and after the current bookmarks entry in the ordered set where groupId = &#63; and folderId = &#63;.
2712             *
2713             * @param entryId the primary key of the current bookmarks entry
2714             * @param groupId the group ID
2715             * @param folderId the folder ID
2716             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2717             * @return the previous, current, and next bookmarks entry
2718             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
2719             */
2720            @Override
2721            public BookmarksEntry[] findByG_F_PrevAndNext(long entryId, long groupId,
2722                    long folderId, OrderByComparator<BookmarksEntry> orderByComparator)
2723                    throws NoSuchEntryException {
2724                    BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
2725    
2726                    Session session = null;
2727    
2728                    try {
2729                            session = openSession();
2730    
2731                            BookmarksEntry[] array = new BookmarksEntryImpl[3];
2732    
2733                            array[0] = getByG_F_PrevAndNext(session, bookmarksEntry, groupId,
2734                                            folderId, orderByComparator, true);
2735    
2736                            array[1] = bookmarksEntry;
2737    
2738                            array[2] = getByG_F_PrevAndNext(session, bookmarksEntry, groupId,
2739                                            folderId, orderByComparator, false);
2740    
2741                            return array;
2742                    }
2743                    catch (Exception e) {
2744                            throw processException(e);
2745                    }
2746                    finally {
2747                            closeSession(session);
2748                    }
2749            }
2750    
2751            protected BookmarksEntry getByG_F_PrevAndNext(Session session,
2752                    BookmarksEntry bookmarksEntry, long groupId, long folderId,
2753                    OrderByComparator<BookmarksEntry> orderByComparator, boolean previous) {
2754                    StringBundler query = null;
2755    
2756                    if (orderByComparator != null) {
2757                            query = new StringBundler(6 +
2758                                            (orderByComparator.getOrderByFields().length * 6));
2759                    }
2760                    else {
2761                            query = new StringBundler(3);
2762                    }
2763    
2764                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
2765    
2766                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
2767    
2768                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
2769    
2770                    if (orderByComparator != null) {
2771                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2772    
2773                            if (orderByConditionFields.length > 0) {
2774                                    query.append(WHERE_AND);
2775                            }
2776    
2777                            for (int i = 0; i < orderByConditionFields.length; i++) {
2778                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2779                                    query.append(orderByConditionFields[i]);
2780    
2781                                    if ((i + 1) < orderByConditionFields.length) {
2782                                            if (orderByComparator.isAscending() ^ previous) {
2783                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2784                                            }
2785                                            else {
2786                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2787                                            }
2788                                    }
2789                                    else {
2790                                            if (orderByComparator.isAscending() ^ previous) {
2791                                                    query.append(WHERE_GREATER_THAN);
2792                                            }
2793                                            else {
2794                                                    query.append(WHERE_LESSER_THAN);
2795                                            }
2796                                    }
2797                            }
2798    
2799                            query.append(ORDER_BY_CLAUSE);
2800    
2801                            String[] orderByFields = orderByComparator.getOrderByFields();
2802    
2803                            for (int i = 0; i < orderByFields.length; i++) {
2804                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2805                                    query.append(orderByFields[i]);
2806    
2807                                    if ((i + 1) < orderByFields.length) {
2808                                            if (orderByComparator.isAscending() ^ previous) {
2809                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2810                                            }
2811                                            else {
2812                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2813                                            }
2814                                    }
2815                                    else {
2816                                            if (orderByComparator.isAscending() ^ previous) {
2817                                                    query.append(ORDER_BY_ASC);
2818                                            }
2819                                            else {
2820                                                    query.append(ORDER_BY_DESC);
2821                                            }
2822                                    }
2823                            }
2824                    }
2825                    else {
2826                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
2827                    }
2828    
2829                    String sql = query.toString();
2830    
2831                    Query q = session.createQuery(sql);
2832    
2833                    q.setFirstResult(0);
2834                    q.setMaxResults(2);
2835    
2836                    QueryPos qPos = QueryPos.getInstance(q);
2837    
2838                    qPos.add(groupId);
2839    
2840                    qPos.add(folderId);
2841    
2842                    if (orderByComparator != null) {
2843                            Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry);
2844    
2845                            for (Object value : values) {
2846                                    qPos.add(value);
2847                            }
2848                    }
2849    
2850                    List<BookmarksEntry> list = q.list();
2851    
2852                    if (list.size() == 2) {
2853                            return list.get(1);
2854                    }
2855                    else {
2856                            return null;
2857                    }
2858            }
2859    
2860            /**
2861             * Returns all the bookmarks entries that the user has permission to view where groupId = &#63; and folderId = &#63;.
2862             *
2863             * @param groupId the group ID
2864             * @param folderId the folder ID
2865             * @return the matching bookmarks entries that the user has permission to view
2866             */
2867            @Override
2868            public List<BookmarksEntry> filterFindByG_F(long groupId, long folderId) {
2869                    return filterFindByG_F(groupId, folderId, QueryUtil.ALL_POS,
2870                            QueryUtil.ALL_POS, null);
2871            }
2872    
2873            /**
2874             * Returns a range of all the bookmarks entries that the user has permission to view where groupId = &#63; and folderId = &#63;.
2875             *
2876             * <p>
2877             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.bookmarks.model.impl.BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2878             * </p>
2879             *
2880             * @param groupId the group ID
2881             * @param folderId the folder ID
2882             * @param start the lower bound of the range of bookmarks entries
2883             * @param end the upper bound of the range of bookmarks entries (not inclusive)
2884             * @return the range of matching bookmarks entries that the user has permission to view
2885             */
2886            @Override
2887            public List<BookmarksEntry> filterFindByG_F(long groupId, long folderId,
2888                    int start, int end) {
2889                    return filterFindByG_F(groupId, folderId, start, end, null);
2890            }
2891    
2892            /**
2893             * Returns an ordered range of all the bookmarks entries that the user has permissions to view where groupId = &#63; and folderId = &#63;.
2894             *
2895             * <p>
2896             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.bookmarks.model.impl.BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2897             * </p>
2898             *
2899             * @param groupId the group ID
2900             * @param folderId the folder ID
2901             * @param start the lower bound of the range of bookmarks entries
2902             * @param end the upper bound of the range of bookmarks entries (not inclusive)
2903             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2904             * @return the ordered range of matching bookmarks entries that the user has permission to view
2905             */
2906            @Override
2907            public List<BookmarksEntry> filterFindByG_F(long groupId, long folderId,
2908                    int start, int end, OrderByComparator<BookmarksEntry> orderByComparator) {
2909                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2910                            return findByG_F(groupId, folderId, start, end, orderByComparator);
2911                    }
2912    
2913                    StringBundler query = null;
2914    
2915                    if (orderByComparator != null) {
2916                            query = new StringBundler(4 +
2917                                            (orderByComparator.getOrderByFields().length * 3));
2918                    }
2919                    else {
2920                            query = new StringBundler(4);
2921                    }
2922    
2923                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
2924    
2925                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
2926    
2927                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
2928    
2929                    if (orderByComparator != null) {
2930                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2931                                    orderByComparator);
2932                    }
2933                    else {
2934                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
2935                    }
2936    
2937                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2938                                    BookmarksEntry.class.getName(),
2939                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
2940                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
2941    
2942                    Session session = null;
2943    
2944                    try {
2945                            session = openSession();
2946    
2947                            Query q = session.createQuery(sql);
2948    
2949                            QueryPos qPos = QueryPos.getInstance(q);
2950    
2951                            qPos.add(groupId);
2952    
2953                            qPos.add(folderId);
2954    
2955                            return (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start,
2956                                    end);
2957                    }
2958                    catch (Exception e) {
2959                            throw processException(e);
2960                    }
2961                    finally {
2962                            closeSession(session);
2963                    }
2964            }
2965    
2966            /**
2967             * Returns the bookmarks entries before and after the current bookmarks entry in the ordered set of bookmarks entries that the user has permission to view where groupId = &#63; and folderId = &#63;.
2968             *
2969             * @param entryId the primary key of the current bookmarks entry
2970             * @param groupId the group ID
2971             * @param folderId the folder ID
2972             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2973             * @return the previous, current, and next bookmarks entry
2974             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
2975             */
2976            @Override
2977            public BookmarksEntry[] filterFindByG_F_PrevAndNext(long entryId,
2978                    long groupId, long folderId,
2979                    OrderByComparator<BookmarksEntry> orderByComparator)
2980                    throws NoSuchEntryException {
2981                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2982                            return findByG_F_PrevAndNext(entryId, groupId, folderId,
2983                                    orderByComparator);
2984                    }
2985    
2986                    BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
2987    
2988                    Session session = null;
2989    
2990                    try {
2991                            session = openSession();
2992    
2993                            BookmarksEntry[] array = new BookmarksEntryImpl[3];
2994    
2995                            array[0] = filterGetByG_F_PrevAndNext(session, bookmarksEntry,
2996                                            groupId, folderId, orderByComparator, true);
2997    
2998                            array[1] = bookmarksEntry;
2999    
3000                            array[2] = filterGetByG_F_PrevAndNext(session, bookmarksEntry,
3001                                            groupId, folderId, orderByComparator, false);
3002    
3003                            return array;
3004                    }
3005                    catch (Exception e) {
3006                            throw processException(e);
3007                    }
3008                    finally {
3009                            closeSession(session);
3010                    }
3011            }
3012    
3013            protected BookmarksEntry filterGetByG_F_PrevAndNext(Session session,
3014                    BookmarksEntry bookmarksEntry, long groupId, long folderId,
3015                    OrderByComparator<BookmarksEntry> orderByComparator, boolean previous) {
3016                    StringBundler query = null;
3017    
3018                    if (orderByComparator != null) {
3019                            query = new StringBundler(6 +
3020                                            (orderByComparator.getOrderByFields().length * 6));
3021                    }
3022                    else {
3023                            query = new StringBundler(3);
3024                    }
3025    
3026                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
3027    
3028                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
3029    
3030                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
3031    
3032                    if (orderByComparator != null) {
3033                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3034    
3035                            if (orderByConditionFields.length > 0) {
3036                                    query.append(WHERE_AND);
3037                            }
3038    
3039                            for (int i = 0; i < orderByConditionFields.length; i++) {
3040                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3041                                    query.append(orderByConditionFields[i]);
3042    
3043                                    if ((i + 1) < orderByConditionFields.length) {
3044                                            if (orderByComparator.isAscending() ^ previous) {
3045                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3046                                            }
3047                                            else {
3048                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3049                                            }
3050                                    }
3051                                    else {
3052                                            if (orderByComparator.isAscending() ^ previous) {
3053                                                    query.append(WHERE_GREATER_THAN);
3054                                            }
3055                                            else {
3056                                                    query.append(WHERE_LESSER_THAN);
3057                                            }
3058                                    }
3059                            }
3060    
3061                            query.append(ORDER_BY_CLAUSE);
3062    
3063                            String[] orderByFields = orderByComparator.getOrderByFields();
3064    
3065                            for (int i = 0; i < orderByFields.length; i++) {
3066                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3067                                    query.append(orderByFields[i]);
3068    
3069                                    if ((i + 1) < orderByFields.length) {
3070                                            if (orderByComparator.isAscending() ^ previous) {
3071                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3072                                            }
3073                                            else {
3074                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3075                                            }
3076                                    }
3077                                    else {
3078                                            if (orderByComparator.isAscending() ^ previous) {
3079                                                    query.append(ORDER_BY_ASC);
3080                                            }
3081                                            else {
3082                                                    query.append(ORDER_BY_DESC);
3083                                            }
3084                                    }
3085                            }
3086                    }
3087                    else {
3088                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
3089                    }
3090    
3091                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3092                                    BookmarksEntry.class.getName(),
3093                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
3094                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
3095    
3096                    Query q = session.createQuery(sql);
3097    
3098                    q.setFirstResult(0);
3099                    q.setMaxResults(2);
3100    
3101                    QueryPos qPos = QueryPos.getInstance(q);
3102    
3103                    qPos.add(groupId);
3104    
3105                    qPos.add(folderId);
3106    
3107                    if (orderByComparator != null) {
3108                            Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry);
3109    
3110                            for (Object value : values) {
3111                                    qPos.add(value);
3112                            }
3113                    }
3114    
3115                    List<BookmarksEntry> list = q.list();
3116    
3117                    if (list.size() == 2) {
3118                            return list.get(1);
3119                    }
3120                    else {
3121                            return null;
3122                    }
3123            }
3124    
3125            /**
3126             * Returns all the bookmarks entries that the user has permission to view where groupId = &#63; and folderId = any &#63;.
3127             *
3128             * @param groupId the group ID
3129             * @param folderIds the folder IDs
3130             * @return the matching bookmarks entries that the user has permission to view
3131             */
3132            @Override
3133            public List<BookmarksEntry> filterFindByG_F(long groupId, long[] folderIds) {
3134                    return filterFindByG_F(groupId, folderIds, QueryUtil.ALL_POS,
3135                            QueryUtil.ALL_POS, null);
3136            }
3137    
3138            /**
3139             * Returns a range of all the bookmarks entries that the user has permission to view where groupId = &#63; and folderId = any &#63;.
3140             *
3141             * <p>
3142             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.bookmarks.model.impl.BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3143             * </p>
3144             *
3145             * @param groupId the group ID
3146             * @param folderIds the folder IDs
3147             * @param start the lower bound of the range of bookmarks entries
3148             * @param end the upper bound of the range of bookmarks entries (not inclusive)
3149             * @return the range of matching bookmarks entries that the user has permission to view
3150             */
3151            @Override
3152            public List<BookmarksEntry> filterFindByG_F(long groupId, long[] folderIds,
3153                    int start, int end) {
3154                    return filterFindByG_F(groupId, folderIds, start, end, null);
3155            }
3156    
3157            /**
3158             * Returns an ordered range of all the bookmarks entries that the user has permission to view where groupId = &#63; and folderId = any &#63;.
3159             *
3160             * <p>
3161             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.bookmarks.model.impl.BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3162             * </p>
3163             *
3164             * @param groupId the group ID
3165             * @param folderIds the folder IDs
3166             * @param start the lower bound of the range of bookmarks entries
3167             * @param end the upper bound of the range of bookmarks entries (not inclusive)
3168             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3169             * @return the ordered range of matching bookmarks entries that the user has permission to view
3170             */
3171            @Override
3172            public List<BookmarksEntry> filterFindByG_F(long groupId, long[] folderIds,
3173                    int start, int end, OrderByComparator<BookmarksEntry> orderByComparator) {
3174                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3175                            return findByG_F(groupId, folderIds, start, end, orderByComparator);
3176                    }
3177    
3178                    if (folderIds == null) {
3179                            folderIds = new long[0];
3180                    }
3181                    else {
3182                            folderIds = ArrayUtil.unique(folderIds);
3183                    }
3184    
3185                    StringBundler query = new StringBundler();
3186    
3187                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
3188    
3189                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
3190    
3191                    if (folderIds.length > 0) {
3192                            query.append(StringPool.OPEN_PARENTHESIS);
3193    
3194                            query.append(_FINDER_COLUMN_G_F_FOLDERID_7);
3195    
3196                            query.append(StringUtil.merge(folderIds));
3197    
3198                            query.append(StringPool.CLOSE_PARENTHESIS);
3199    
3200                            query.append(StringPool.CLOSE_PARENTHESIS);
3201                    }
3202    
3203                    query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
3204                            query.index() - 1);
3205    
3206                    if (orderByComparator != null) {
3207                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3208                                    orderByComparator);
3209                    }
3210                    else {
3211                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
3212                    }
3213    
3214                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3215                                    BookmarksEntry.class.getName(),
3216                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
3217                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
3218    
3219                    Session session = null;
3220    
3221                    try {
3222                            session = openSession();
3223    
3224                            Query q = session.createQuery(sql);
3225    
3226                            QueryPos qPos = QueryPos.getInstance(q);
3227    
3228                            qPos.add(groupId);
3229    
3230                            return (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start,
3231                                    end);
3232                    }
3233                    catch (Exception e) {
3234                            throw processException(e);
3235                    }
3236                    finally {
3237                            closeSession(session);
3238                    }
3239            }
3240    
3241            /**
3242             * Returns all the bookmarks entries where groupId = &#63; and folderId = any &#63;.
3243             *
3244             * <p>
3245             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.bookmarks.model.impl.BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3246             * </p>
3247             *
3248             * @param groupId the group ID
3249             * @param folderIds the folder IDs
3250             * @return the matching bookmarks entries
3251             */
3252            @Override
3253            public List<BookmarksEntry> findByG_F(long groupId, long[] folderIds) {
3254                    return findByG_F(groupId, folderIds, QueryUtil.ALL_POS,
3255                            QueryUtil.ALL_POS, null);
3256            }
3257    
3258            /**
3259             * Returns a range of all the bookmarks entries where groupId = &#63; and folderId = any &#63;.
3260             *
3261             * <p>
3262             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.bookmarks.model.impl.BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3263             * </p>
3264             *
3265             * @param groupId the group ID
3266             * @param folderIds the folder IDs
3267             * @param start the lower bound of the range of bookmarks entries
3268             * @param end the upper bound of the range of bookmarks entries (not inclusive)
3269             * @return the range of matching bookmarks entries
3270             */
3271            @Override
3272            public List<BookmarksEntry> findByG_F(long groupId, long[] folderIds,
3273                    int start, int end) {
3274                    return findByG_F(groupId, folderIds, start, end, null);
3275            }
3276    
3277            /**
3278             * Returns an ordered range of all the bookmarks entries where groupId = &#63; and folderId = any &#63;.
3279             *
3280             * <p>
3281             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.bookmarks.model.impl.BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3282             * </p>
3283             *
3284             * @param groupId the group ID
3285             * @param folderIds the folder IDs
3286             * @param start the lower bound of the range of bookmarks entries
3287             * @param end the upper bound of the range of bookmarks entries (not inclusive)
3288             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3289             * @return the ordered range of matching bookmarks entries
3290             */
3291            @Override
3292            public List<BookmarksEntry> findByG_F(long groupId, long[] folderIds,
3293                    int start, int end, OrderByComparator<BookmarksEntry> orderByComparator) {
3294                    if (folderIds == null) {
3295                            folderIds = new long[0];
3296                    }
3297                    else {
3298                            folderIds = ArrayUtil.unique(folderIds);
3299                    }
3300    
3301                    if (folderIds.length == 1) {
3302                            return findByG_F(groupId, folderIds[0], start, end,
3303                                    orderByComparator);
3304                    }
3305    
3306                    boolean pagination = true;
3307                    Object[] finderArgs = null;
3308    
3309                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3310                                    (orderByComparator == null)) {
3311                            pagination = false;
3312                            finderArgs = new Object[] { groupId, StringUtil.merge(folderIds) };
3313                    }
3314                    else {
3315                            finderArgs = new Object[] {
3316                                            groupId, StringUtil.merge(folderIds),
3317                                            
3318                                            start, end, orderByComparator
3319                                    };
3320                    }
3321    
3322                    List<BookmarksEntry> list = (List<BookmarksEntry>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F,
3323                                    finderArgs, this);
3324    
3325                    if ((list != null) && !list.isEmpty()) {
3326                            for (BookmarksEntry bookmarksEntry : list) {
3327                                    if ((groupId != bookmarksEntry.getGroupId()) ||
3328                                                    !ArrayUtil.contains(folderIds,
3329                                                            bookmarksEntry.getFolderId())) {
3330                                            list = null;
3331    
3332                                            break;
3333                                    }
3334                            }
3335                    }
3336    
3337                    if (list == null) {
3338                            StringBundler query = new StringBundler();
3339    
3340                            query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
3341    
3342                            query.append(_FINDER_COLUMN_G_F_GROUPID_2);
3343    
3344                            if (folderIds.length > 0) {
3345                                    query.append(StringPool.OPEN_PARENTHESIS);
3346    
3347                                    query.append(_FINDER_COLUMN_G_F_FOLDERID_7);
3348    
3349                                    query.append(StringUtil.merge(folderIds));
3350    
3351                                    query.append(StringPool.CLOSE_PARENTHESIS);
3352    
3353                                    query.append(StringPool.CLOSE_PARENTHESIS);
3354                            }
3355    
3356                            query.setStringAt(removeConjunction(query.stringAt(query.index() -
3357                                                    1)), query.index() - 1);
3358    
3359                            if (orderByComparator != null) {
3360                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3361                                            orderByComparator);
3362                            }
3363                            else
3364                             if (pagination) {
3365                                    query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
3366                            }
3367    
3368                            String sql = query.toString();
3369    
3370                            Session session = null;
3371    
3372                            try {
3373                                    session = openSession();
3374    
3375                                    Query q = session.createQuery(sql);
3376    
3377                                    QueryPos qPos = QueryPos.getInstance(q);
3378    
3379                                    qPos.add(groupId);
3380    
3381                                    if (!pagination) {
3382                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
3383                                                            getDialect(), start, end, false);
3384    
3385                                            Collections.sort(list);
3386    
3387                                            list = Collections.unmodifiableList(list);
3388                                    }
3389                                    else {
3390                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
3391                                                            getDialect(), start, end);
3392                                    }
3393    
3394                                    cacheResult(list);
3395    
3396                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F,
3397                                            finderArgs, list);
3398                            }
3399                            catch (Exception e) {
3400                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F,
3401                                            finderArgs);
3402    
3403                                    throw processException(e);
3404                            }
3405                            finally {
3406                                    closeSession(session);
3407                            }
3408                    }
3409    
3410                    return list;
3411            }
3412    
3413            /**
3414             * Removes all the bookmarks entries where groupId = &#63; and folderId = &#63; from the database.
3415             *
3416             * @param groupId the group ID
3417             * @param folderId the folder ID
3418             */
3419            @Override
3420            public void removeByG_F(long groupId, long folderId) {
3421                    for (BookmarksEntry bookmarksEntry : findByG_F(groupId, folderId,
3422                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3423                            remove(bookmarksEntry);
3424                    }
3425            }
3426    
3427            /**
3428             * Returns the number of bookmarks entries where groupId = &#63; and folderId = &#63;.
3429             *
3430             * @param groupId the group ID
3431             * @param folderId the folder ID
3432             * @return the number of matching bookmarks entries
3433             */
3434            @Override
3435            public int countByG_F(long groupId, long folderId) {
3436                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_F;
3437    
3438                    Object[] finderArgs = new Object[] { groupId, folderId };
3439    
3440                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3441                                    this);
3442    
3443                    if (count == null) {
3444                            StringBundler query = new StringBundler(3);
3445    
3446                            query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
3447    
3448                            query.append(_FINDER_COLUMN_G_F_GROUPID_2);
3449    
3450                            query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
3451    
3452                            String sql = query.toString();
3453    
3454                            Session session = null;
3455    
3456                            try {
3457                                    session = openSession();
3458    
3459                                    Query q = session.createQuery(sql);
3460    
3461                                    QueryPos qPos = QueryPos.getInstance(q);
3462    
3463                                    qPos.add(groupId);
3464    
3465                                    qPos.add(folderId);
3466    
3467                                    count = (Long)q.uniqueResult();
3468    
3469                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
3470                            }
3471                            catch (Exception e) {
3472                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3473    
3474                                    throw processException(e);
3475                            }
3476                            finally {
3477                                    closeSession(session);
3478                            }
3479                    }
3480    
3481                    return count.intValue();
3482            }
3483    
3484            /**
3485             * Returns the number of bookmarks entries where groupId = &#63; and folderId = any &#63;.
3486             *
3487             * @param groupId the group ID
3488             * @param folderIds the folder IDs
3489             * @return the number of matching bookmarks entries
3490             */
3491            @Override
3492            public int countByG_F(long groupId, long[] folderIds) {
3493                    if (folderIds == null) {
3494                            folderIds = new long[0];
3495                    }
3496                    else {
3497                            folderIds = ArrayUtil.unique(folderIds);
3498                    }
3499    
3500                    Object[] finderArgs = new Object[] { groupId, StringUtil.merge(folderIds) };
3501    
3502                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F,
3503                                    finderArgs, this);
3504    
3505                    if (count == null) {
3506                            StringBundler query = new StringBundler();
3507    
3508                            query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
3509    
3510                            query.append(_FINDER_COLUMN_G_F_GROUPID_2);
3511    
3512                            if (folderIds.length > 0) {
3513                                    query.append(StringPool.OPEN_PARENTHESIS);
3514    
3515                                    query.append(_FINDER_COLUMN_G_F_FOLDERID_7);
3516    
3517                                    query.append(StringUtil.merge(folderIds));
3518    
3519                                    query.append(StringPool.CLOSE_PARENTHESIS);
3520    
3521                                    query.append(StringPool.CLOSE_PARENTHESIS);
3522                            }
3523    
3524                            query.setStringAt(removeConjunction(query.stringAt(query.index() -
3525                                                    1)), query.index() - 1);
3526    
3527                            String sql = query.toString();
3528    
3529                            Session session = null;
3530    
3531                            try {
3532                                    session = openSession();
3533    
3534                                    Query q = session.createQuery(sql);
3535    
3536                                    QueryPos qPos = QueryPos.getInstance(q);
3537    
3538                                    qPos.add(groupId);
3539    
3540                                    count = (Long)q.uniqueResult();
3541    
3542                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F,
3543                                            finderArgs, count);
3544                            }
3545                            catch (Exception e) {
3546                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F,
3547                                            finderArgs);
3548    
3549                                    throw processException(e);
3550                            }
3551                            finally {
3552                                    closeSession(session);
3553                            }
3554                    }
3555    
3556                    return count.intValue();
3557            }
3558    
3559            /**
3560             * Returns the number of bookmarks entries that the user has permission to view where groupId = &#63; and folderId = &#63;.
3561             *
3562             * @param groupId the group ID
3563             * @param folderId the folder ID
3564             * @return the number of matching bookmarks entries that the user has permission to view
3565             */
3566            @Override
3567            public int filterCountByG_F(long groupId, long folderId) {
3568                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3569                            return countByG_F(groupId, folderId);
3570                    }
3571    
3572                    StringBundler query = new StringBundler(3);
3573    
3574                    query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
3575    
3576                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
3577    
3578                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
3579    
3580                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3581                                    BookmarksEntry.class.getName(),
3582                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
3583                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
3584    
3585                    Session session = null;
3586    
3587                    try {
3588                            session = openSession();
3589    
3590                            Query q = session.createQuery(sql);
3591    
3592                            QueryPos qPos = QueryPos.getInstance(q);
3593    
3594                            qPos.add(groupId);
3595    
3596                            qPos.add(folderId);
3597    
3598                            Long count = (Long)q.uniqueResult();
3599    
3600                            return count.intValue();
3601                    }
3602                    catch (Exception e) {
3603                            throw processException(e);
3604                    }
3605                    finally {
3606                            closeSession(session);
3607                    }
3608            }
3609    
3610            /**
3611             * Returns the number of bookmarks entries that the user has permission to view where groupId = &#63; and folderId = any &#63;.
3612             *
3613             * @param groupId the group ID
3614             * @param folderIds the folder IDs
3615             * @return the number of matching bookmarks entries that the user has permission to view
3616             */
3617            @Override
3618            public int filterCountByG_F(long groupId, long[] folderIds) {
3619                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3620                            return countByG_F(groupId, folderIds);
3621                    }
3622    
3623                    if (folderIds == null) {
3624                            folderIds = new long[0];
3625                    }
3626                    else {
3627                            folderIds = ArrayUtil.unique(folderIds);
3628                    }
3629    
3630                    StringBundler query = new StringBundler();
3631    
3632                    query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
3633    
3634                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
3635    
3636                    if (folderIds.length > 0) {
3637                            query.append(StringPool.OPEN_PARENTHESIS);
3638    
3639                            query.append(_FINDER_COLUMN_G_F_FOLDERID_7);
3640    
3641                            query.append(StringUtil.merge(folderIds));
3642    
3643                            query.append(StringPool.CLOSE_PARENTHESIS);
3644    
3645                            query.append(StringPool.CLOSE_PARENTHESIS);
3646                    }
3647    
3648                    query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
3649                            query.index() - 1);
3650    
3651                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3652                                    BookmarksEntry.class.getName(),
3653                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
3654                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
3655    
3656                    Session session = null;
3657    
3658                    try {
3659                            session = openSession();
3660    
3661                            Query q = session.createQuery(sql);
3662    
3663                            QueryPos qPos = QueryPos.getInstance(q);
3664    
3665                            qPos.add(groupId);
3666    
3667                            Long count = (Long)q.uniqueResult();
3668    
3669                            return count.intValue();
3670                    }
3671                    catch (Exception e) {
3672                            throw processException(e);
3673                    }
3674                    finally {
3675                            closeSession(session);
3676                    }
3677            }
3678    
3679            private static final String _FINDER_COLUMN_G_F_GROUPID_2 = "bookmarksEntry.groupId = ? AND ";
3680            private static final String _FINDER_COLUMN_G_F_FOLDERID_2 = "bookmarksEntry.folderId = ?";
3681            private static final String _FINDER_COLUMN_G_F_FOLDERID_7 = "bookmarksEntry.folderId IN (";
3682            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
3683                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
3684                            BookmarksEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
3685                            "findByG_S",
3686                            new String[] {
3687                                    Long.class.getName(), Integer.class.getName(),
3688                                    
3689                            Integer.class.getName(), Integer.class.getName(),
3690                                    OrderByComparator.class.getName()
3691                            });
3692            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
3693                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
3694                            BookmarksEntryImpl.class,
3695                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_S",
3696                            new String[] { Long.class.getName(), Integer.class.getName() },
3697                            BookmarksEntryModelImpl.GROUPID_COLUMN_BITMASK |
3698                            BookmarksEntryModelImpl.STATUS_COLUMN_BITMASK |
3699                            BookmarksEntryModelImpl.FOLDERID_COLUMN_BITMASK |
3700                            BookmarksEntryModelImpl.NAME_COLUMN_BITMASK);
3701            public static final FinderPath FINDER_PATH_COUNT_BY_G_S = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
3702                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
3703                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_S",
3704                            new String[] { Long.class.getName(), Integer.class.getName() });
3705    
3706            /**
3707             * Returns all the bookmarks entries where groupId = &#63; and status = &#63;.
3708             *
3709             * @param groupId the group ID
3710             * @param status the status
3711             * @return the matching bookmarks entries
3712             */
3713            @Override
3714            public List<BookmarksEntry> findByG_S(long groupId, int status) {
3715                    return findByG_S(groupId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
3716                            null);
3717            }
3718    
3719            /**
3720             * Returns a range of all the bookmarks entries where groupId = &#63; and status = &#63;.
3721             *
3722             * <p>
3723             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.bookmarks.model.impl.BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3724             * </p>
3725             *
3726             * @param groupId the group ID
3727             * @param status the status
3728             * @param start the lower bound of the range of bookmarks entries
3729             * @param end the upper bound of the range of bookmarks entries (not inclusive)
3730             * @return the range of matching bookmarks entries
3731             */
3732            @Override
3733            public List<BookmarksEntry> findByG_S(long groupId, int status, int start,
3734                    int end) {
3735                    return findByG_S(groupId, status, start, end, null);
3736            }
3737    
3738            /**
3739             * Returns an ordered range of all the bookmarks entries where groupId = &#63; and status = &#63;.
3740             *
3741             * <p>
3742             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.bookmarks.model.impl.BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3743             * </p>
3744             *
3745             * @param groupId the group ID
3746             * @param status the status
3747             * @param start the lower bound of the range of bookmarks entries
3748             * @param end the upper bound of the range of bookmarks entries (not inclusive)
3749             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3750             * @return the ordered range of matching bookmarks entries
3751             */
3752            @Override
3753            public List<BookmarksEntry> findByG_S(long groupId, int status, int start,
3754                    int end, OrderByComparator<BookmarksEntry> orderByComparator) {
3755                    boolean pagination = true;
3756                    FinderPath finderPath = null;
3757                    Object[] finderArgs = null;
3758    
3759                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3760                                    (orderByComparator == null)) {
3761                            pagination = false;
3762                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S;
3763                            finderArgs = new Object[] { groupId, status };
3764                    }
3765                    else {
3766                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S;
3767                            finderArgs = new Object[] {
3768                                            groupId, status,
3769                                            
3770                                            start, end, orderByComparator
3771                                    };
3772                    }
3773    
3774                    List<BookmarksEntry> list = (List<BookmarksEntry>)FinderCacheUtil.getResult(finderPath,
3775                                    finderArgs, this);
3776    
3777                    if ((list != null) && !list.isEmpty()) {
3778                            for (BookmarksEntry bookmarksEntry : list) {
3779                                    if ((groupId != bookmarksEntry.getGroupId()) ||
3780                                                    (status != bookmarksEntry.getStatus())) {
3781                                            list = null;
3782    
3783                                            break;
3784                                    }
3785                            }
3786                    }
3787    
3788                    if (list == null) {
3789                            StringBundler query = null;
3790    
3791                            if (orderByComparator != null) {
3792                                    query = new StringBundler(4 +
3793                                                    (orderByComparator.getOrderByFields().length * 3));
3794                            }
3795                            else {
3796                                    query = new StringBundler(4);
3797                            }
3798    
3799                            query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
3800    
3801                            query.append(_FINDER_COLUMN_G_S_GROUPID_2);
3802    
3803                            query.append(_FINDER_COLUMN_G_S_STATUS_2);
3804    
3805                            if (orderByComparator != null) {
3806                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3807                                            orderByComparator);
3808                            }
3809                            else
3810                             if (pagination) {
3811                                    query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
3812                            }
3813    
3814                            String sql = query.toString();
3815    
3816                            Session session = null;
3817    
3818                            try {
3819                                    session = openSession();
3820    
3821                                    Query q = session.createQuery(sql);
3822    
3823                                    QueryPos qPos = QueryPos.getInstance(q);
3824    
3825                                    qPos.add(groupId);
3826    
3827                                    qPos.add(status);
3828    
3829                                    if (!pagination) {
3830                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
3831                                                            getDialect(), start, end, false);
3832    
3833                                            Collections.sort(list);
3834    
3835                                            list = Collections.unmodifiableList(list);
3836                                    }
3837                                    else {
3838                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
3839                                                            getDialect(), start, end);
3840                                    }
3841    
3842                                    cacheResult(list);
3843    
3844                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
3845                            }
3846                            catch (Exception e) {
3847                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3848    
3849                                    throw processException(e);
3850                            }
3851                            finally {
3852                                    closeSession(session);
3853                            }
3854                    }
3855    
3856                    return list;
3857            }
3858    
3859            /**
3860             * Returns the first bookmarks entry in the ordered set where groupId = &#63; and status = &#63;.
3861             *
3862             * @param groupId the group ID
3863             * @param status the status
3864             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3865             * @return the first matching bookmarks entry
3866             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
3867             */
3868            @Override
3869            public BookmarksEntry findByG_S_First(long groupId, int status,
3870                    OrderByComparator<BookmarksEntry> orderByComparator)
3871                    throws NoSuchEntryException {
3872                    BookmarksEntry bookmarksEntry = fetchByG_S_First(groupId, status,
3873                                    orderByComparator);
3874    
3875                    if (bookmarksEntry != null) {
3876                            return bookmarksEntry;
3877                    }
3878    
3879                    StringBundler msg = new StringBundler(6);
3880    
3881                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3882    
3883                    msg.append("groupId=");
3884                    msg.append(groupId);
3885    
3886                    msg.append(", status=");
3887                    msg.append(status);
3888    
3889                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3890    
3891                    throw new NoSuchEntryException(msg.toString());
3892            }
3893    
3894            /**
3895             * Returns the first bookmarks entry in the ordered set where groupId = &#63; and status = &#63;.
3896             *
3897             * @param groupId the group ID
3898             * @param status the status
3899             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3900             * @return the first matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
3901             */
3902            @Override
3903            public BookmarksEntry fetchByG_S_First(long groupId, int status,
3904                    OrderByComparator<BookmarksEntry> orderByComparator) {
3905                    List<BookmarksEntry> list = findByG_S(groupId, status, 0, 1,
3906                                    orderByComparator);
3907    
3908                    if (!list.isEmpty()) {
3909                            return list.get(0);
3910                    }
3911    
3912                    return null;
3913            }
3914    
3915            /**
3916             * Returns the last bookmarks entry in the ordered set where groupId = &#63; and status = &#63;.
3917             *
3918             * @param groupId the group ID
3919             * @param status the status
3920             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3921             * @return the last matching bookmarks entry
3922             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
3923             */
3924            @Override
3925            public BookmarksEntry findByG_S_Last(long groupId, int status,
3926                    OrderByComparator<BookmarksEntry> orderByComparator)
3927                    throws NoSuchEntryException {
3928                    BookmarksEntry bookmarksEntry = fetchByG_S_Last(groupId, status,
3929                                    orderByComparator);
3930    
3931                    if (bookmarksEntry != null) {
3932                            return bookmarksEntry;
3933                    }
3934    
3935                    StringBundler msg = new StringBundler(6);
3936    
3937                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3938    
3939                    msg.append("groupId=");
3940                    msg.append(groupId);
3941    
3942                    msg.append(", status=");
3943                    msg.append(status);
3944    
3945                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3946    
3947                    throw new NoSuchEntryException(msg.toString());
3948            }
3949    
3950            /**
3951             * Returns the last bookmarks entry in the ordered set where groupId = &#63; and status = &#63;.
3952             *
3953             * @param groupId the group ID
3954             * @param status the status
3955             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3956             * @return the last matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
3957             */
3958            @Override
3959            public BookmarksEntry fetchByG_S_Last(long groupId, int status,
3960                    OrderByComparator<BookmarksEntry> orderByComparator) {
3961                    int count = countByG_S(groupId, status);
3962    
3963                    if (count == 0) {
3964                            return null;
3965                    }
3966    
3967                    List<BookmarksEntry> list = findByG_S(groupId, status, count - 1,
3968                                    count, orderByComparator);
3969    
3970                    if (!list.isEmpty()) {
3971                            return list.get(0);
3972                    }
3973    
3974                    return null;
3975            }
3976    
3977            /**
3978             * Returns the bookmarks entries before and after the current bookmarks entry in the ordered set where groupId = &#63; and status = &#63;.
3979             *
3980             * @param entryId the primary key of the current bookmarks entry
3981             * @param groupId the group ID
3982             * @param status the status
3983             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3984             * @return the previous, current, and next bookmarks entry
3985             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
3986             */
3987            @Override
3988            public BookmarksEntry[] findByG_S_PrevAndNext(long entryId, long groupId,
3989                    int status, OrderByComparator<BookmarksEntry> orderByComparator)
3990                    throws NoSuchEntryException {
3991                    BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
3992    
3993                    Session session = null;
3994    
3995                    try {
3996                            session = openSession();
3997    
3998                            BookmarksEntry[] array = new BookmarksEntryImpl[3];
3999    
4000                            array[0] = getByG_S_PrevAndNext(session, bookmarksEntry, groupId,
4001                                            status, orderByComparator, true);
4002    
4003                            array[1] = bookmarksEntry;
4004    
4005                            array[2] = getByG_S_PrevAndNext(session, bookmarksEntry, groupId,
4006                                            status, orderByComparator, false);
4007    
4008                            return array;
4009                    }
4010                    catch (Exception e) {
4011                            throw processException(e);
4012                    }
4013                    finally {
4014                            closeSession(session);
4015                    }
4016            }
4017    
4018            protected BookmarksEntry getByG_S_PrevAndNext(Session session,
4019                    BookmarksEntry bookmarksEntry, long groupId, int status,
4020                    OrderByComparator<BookmarksEntry> orderByComparator, boolean previous) {
4021                    StringBundler query = null;
4022    
4023                    if (orderByComparator != null) {
4024                            query = new StringBundler(6 +
4025                                            (orderByComparator.getOrderByFields().length * 6));
4026                    }
4027                    else {
4028                            query = new StringBundler(3);
4029                    }
4030    
4031                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
4032    
4033                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4034    
4035                    query.append(_FINDER_COLUMN_G_S_STATUS_2);
4036    
4037                    if (orderByComparator != null) {
4038                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4039    
4040                            if (orderByConditionFields.length > 0) {
4041                                    query.append(WHERE_AND);
4042                            }
4043    
4044                            for (int i = 0; i < orderByConditionFields.length; i++) {
4045                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4046                                    query.append(orderByConditionFields[i]);
4047    
4048                                    if ((i + 1) < orderByConditionFields.length) {
4049                                            if (orderByComparator.isAscending() ^ previous) {
4050                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4051                                            }
4052                                            else {
4053                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4054                                            }
4055                                    }
4056                                    else {
4057                                            if (orderByComparator.isAscending() ^ previous) {
4058                                                    query.append(WHERE_GREATER_THAN);
4059                                            }
4060                                            else {
4061                                                    query.append(WHERE_LESSER_THAN);
4062                                            }
4063                                    }
4064                            }
4065    
4066                            query.append(ORDER_BY_CLAUSE);
4067    
4068                            String[] orderByFields = orderByComparator.getOrderByFields();
4069    
4070                            for (int i = 0; i < orderByFields.length; i++) {
4071                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4072                                    query.append(orderByFields[i]);
4073    
4074                                    if ((i + 1) < orderByFields.length) {
4075                                            if (orderByComparator.isAscending() ^ previous) {
4076                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4077                                            }
4078                                            else {
4079                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4080                                            }
4081                                    }
4082                                    else {
4083                                            if (orderByComparator.isAscending() ^ previous) {
4084                                                    query.append(ORDER_BY_ASC);
4085                                            }
4086                                            else {
4087                                                    query.append(ORDER_BY_DESC);
4088                                            }
4089                                    }
4090                            }
4091                    }
4092                    else {
4093                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
4094                    }
4095    
4096                    String sql = query.toString();
4097    
4098                    Query q = session.createQuery(sql);
4099    
4100                    q.setFirstResult(0);
4101                    q.setMaxResults(2);
4102    
4103                    QueryPos qPos = QueryPos.getInstance(q);
4104    
4105                    qPos.add(groupId);
4106    
4107                    qPos.add(status);
4108    
4109                    if (orderByComparator != null) {
4110                            Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry);
4111    
4112                            for (Object value : values) {
4113                                    qPos.add(value);
4114                            }
4115                    }
4116    
4117                    List<BookmarksEntry> list = q.list();
4118    
4119                    if (list.size() == 2) {
4120                            return list.get(1);
4121                    }
4122                    else {
4123                            return null;
4124                    }
4125            }
4126    
4127            /**
4128             * Returns all the bookmarks entries that the user has permission to view where groupId = &#63; and status = &#63;.
4129             *
4130             * @param groupId the group ID
4131             * @param status the status
4132             * @return the matching bookmarks entries that the user has permission to view
4133             */
4134            @Override
4135            public List<BookmarksEntry> filterFindByG_S(long groupId, int status) {
4136                    return filterFindByG_S(groupId, status, QueryUtil.ALL_POS,
4137                            QueryUtil.ALL_POS, null);
4138            }
4139    
4140            /**
4141             * Returns a range of all the bookmarks entries that the user has permission to view where groupId = &#63; and status = &#63;.
4142             *
4143             * <p>
4144             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.bookmarks.model.impl.BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4145             * </p>
4146             *
4147             * @param groupId the group ID
4148             * @param status the status
4149             * @param start the lower bound of the range of bookmarks entries
4150             * @param end the upper bound of the range of bookmarks entries (not inclusive)
4151             * @return the range of matching bookmarks entries that the user has permission to view
4152             */
4153            @Override
4154            public List<BookmarksEntry> filterFindByG_S(long groupId, int status,
4155                    int start, int end) {
4156                    return filterFindByG_S(groupId, status, start, end, null);
4157            }
4158    
4159            /**
4160             * Returns an ordered range of all the bookmarks entries that the user has permissions to view where groupId = &#63; and status = &#63;.
4161             *
4162             * <p>
4163             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.bookmarks.model.impl.BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4164             * </p>
4165             *
4166             * @param groupId the group ID
4167             * @param status the status
4168             * @param start the lower bound of the range of bookmarks entries
4169             * @param end the upper bound of the range of bookmarks entries (not inclusive)
4170             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4171             * @return the ordered range of matching bookmarks entries that the user has permission to view
4172             */
4173            @Override
4174            public List<BookmarksEntry> filterFindByG_S(long groupId, int status,
4175                    int start, int end, OrderByComparator<BookmarksEntry> orderByComparator) {
4176                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4177                            return findByG_S(groupId, status, start, end, orderByComparator);
4178                    }
4179    
4180                    StringBundler query = null;
4181    
4182                    if (orderByComparator != null) {
4183                            query = new StringBundler(4 +
4184                                            (orderByComparator.getOrderByFields().length * 3));
4185                    }
4186                    else {
4187                            query = new StringBundler(4);
4188                    }
4189    
4190                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
4191    
4192                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4193    
4194                    query.append(_FINDER_COLUMN_G_S_STATUS_2);
4195    
4196                    if (orderByComparator != null) {
4197                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4198                                    orderByComparator);
4199                    }
4200                    else {
4201                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
4202                    }
4203    
4204                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4205                                    BookmarksEntry.class.getName(),
4206                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
4207                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
4208    
4209                    Session session = null;
4210    
4211                    try {
4212                            session = openSession();
4213    
4214                            Query q = session.createQuery(sql);
4215    
4216                            QueryPos qPos = QueryPos.getInstance(q);
4217    
4218                            qPos.add(groupId);
4219    
4220                            qPos.add(status);
4221    
4222                            return (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start,
4223                                    end);
4224                    }
4225                    catch (Exception e) {
4226                            throw processException(e);
4227                    }
4228                    finally {
4229                            closeSession(session);
4230                    }
4231            }
4232    
4233            /**
4234             * Returns the bookmarks entries before and after the current bookmarks entry in the ordered set of bookmarks entries that the user has permission to view where groupId = &#63; and status = &#63;.
4235             *
4236             * @param entryId the primary key of the current bookmarks entry
4237             * @param groupId the group ID
4238             * @param status the status
4239             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4240             * @return the previous, current, and next bookmarks entry
4241             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
4242             */
4243            @Override
4244            public BookmarksEntry[] filterFindByG_S_PrevAndNext(long entryId,
4245                    long groupId, int status,
4246                    OrderByComparator<BookmarksEntry> orderByComparator)
4247                    throws NoSuchEntryException {
4248                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4249                            return findByG_S_PrevAndNext(entryId, groupId, status,
4250                                    orderByComparator);
4251                    }
4252    
4253                    BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
4254    
4255                    Session session = null;
4256    
4257                    try {
4258                            session = openSession();
4259    
4260                            BookmarksEntry[] array = new BookmarksEntryImpl[3];
4261    
4262                            array[0] = filterGetByG_S_PrevAndNext(session, bookmarksEntry,
4263                                            groupId, status, orderByComparator, true);
4264    
4265                            array[1] = bookmarksEntry;
4266    
4267                            array[2] = filterGetByG_S_PrevAndNext(session, bookmarksEntry,
4268                                            groupId, status, orderByComparator, false);
4269    
4270                            return array;
4271                    }
4272                    catch (Exception e) {
4273                            throw processException(e);
4274                    }
4275                    finally {
4276                            closeSession(session);
4277                    }
4278            }
4279    
4280            protected BookmarksEntry filterGetByG_S_PrevAndNext(Session session,
4281                    BookmarksEntry bookmarksEntry, long groupId, int status,
4282                    OrderByComparator<BookmarksEntry> orderByComparator, boolean previous) {
4283                    StringBundler query = null;
4284    
4285                    if (orderByComparator != null) {
4286                            query = new StringBundler(6 +
4287                                            (orderByComparator.getOrderByFields().length * 6));
4288                    }
4289                    else {
4290                            query = new StringBundler(3);
4291                    }
4292    
4293                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
4294    
4295                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4296    
4297                    query.append(_FINDER_COLUMN_G_S_STATUS_2);
4298    
4299                    if (orderByComparator != null) {
4300                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4301    
4302                            if (orderByConditionFields.length > 0) {
4303                                    query.append(WHERE_AND);
4304                            }
4305    
4306                            for (int i = 0; i < orderByConditionFields.length; i++) {
4307                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4308                                    query.append(orderByConditionFields[i]);
4309    
4310                                    if ((i + 1) < orderByConditionFields.length) {
4311                                            if (orderByComparator.isAscending() ^ previous) {
4312                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4313                                            }
4314                                            else {
4315                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4316                                            }
4317                                    }
4318                                    else {
4319                                            if (orderByComparator.isAscending() ^ previous) {
4320                                                    query.append(WHERE_GREATER_THAN);
4321                                            }
4322                                            else {
4323                                                    query.append(WHERE_LESSER_THAN);
4324                                            }
4325                                    }
4326                            }
4327    
4328                            query.append(ORDER_BY_CLAUSE);
4329    
4330                            String[] orderByFields = orderByComparator.getOrderByFields();
4331    
4332                            for (int i = 0; i < orderByFields.length; i++) {
4333                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4334                                    query.append(orderByFields[i]);
4335    
4336                                    if ((i + 1) < orderByFields.length) {
4337                                            if (orderByComparator.isAscending() ^ previous) {
4338                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4339                                            }
4340                                            else {
4341                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4342                                            }
4343                                    }
4344                                    else {
4345                                            if (orderByComparator.isAscending() ^ previous) {
4346                                                    query.append(ORDER_BY_ASC);
4347                                            }
4348                                            else {
4349                                                    query.append(ORDER_BY_DESC);
4350                                            }
4351                                    }
4352                            }
4353                    }
4354                    else {
4355                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
4356                    }
4357    
4358                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4359                                    BookmarksEntry.class.getName(),
4360                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
4361                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
4362    
4363                    Query q = session.createQuery(sql);
4364    
4365                    q.setFirstResult(0);
4366                    q.setMaxResults(2);
4367    
4368                    QueryPos qPos = QueryPos.getInstance(q);
4369    
4370                    qPos.add(groupId);
4371    
4372                    qPos.add(status);
4373    
4374                    if (orderByComparator != null) {
4375                            Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry);
4376    
4377                            for (Object value : values) {
4378                                    qPos.add(value);
4379                            }
4380                    }
4381    
4382                    List<BookmarksEntry> list = q.list();
4383    
4384                    if (list.size() == 2) {
4385                            return list.get(1);
4386                    }
4387                    else {
4388                            return null;
4389                    }
4390            }
4391    
4392            /**
4393             * Removes all the bookmarks entries where groupId = &#63; and status = &#63; from the database.
4394             *
4395             * @param groupId the group ID
4396             * @param status the status
4397             */
4398            @Override
4399            public void removeByG_S(long groupId, int status) {
4400                    for (BookmarksEntry bookmarksEntry : findByG_S(groupId, status,
4401                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
4402                            remove(bookmarksEntry);
4403                    }
4404            }
4405    
4406            /**
4407             * Returns the number of bookmarks entries where groupId = &#63; and status = &#63;.
4408             *
4409             * @param groupId the group ID
4410             * @param status the status
4411             * @return the number of matching bookmarks entries
4412             */
4413            @Override
4414            public int countByG_S(long groupId, int status) {
4415                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_S;
4416    
4417                    Object[] finderArgs = new Object[] { groupId, status };
4418    
4419                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
4420                                    this);
4421    
4422                    if (count == null) {
4423                            StringBundler query = new StringBundler(3);
4424    
4425                            query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
4426    
4427                            query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4428    
4429                            query.append(_FINDER_COLUMN_G_S_STATUS_2);
4430    
4431                            String sql = query.toString();
4432    
4433                            Session session = null;
4434    
4435                            try {
4436                                    session = openSession();
4437    
4438                                    Query q = session.createQuery(sql);
4439    
4440                                    QueryPos qPos = QueryPos.getInstance(q);
4441    
4442                                    qPos.add(groupId);
4443    
4444                                    qPos.add(status);
4445    
4446                                    count = (Long)q.uniqueResult();
4447    
4448                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
4449                            }
4450                            catch (Exception e) {
4451                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4452    
4453                                    throw processException(e);
4454                            }
4455                            finally {
4456                                    closeSession(session);
4457                            }
4458                    }
4459    
4460                    return count.intValue();
4461            }
4462    
4463            /**
4464             * Returns the number of bookmarks entries that the user has permission to view where groupId = &#63; and status = &#63;.
4465             *
4466             * @param groupId the group ID
4467             * @param status the status
4468             * @return the number of matching bookmarks entries that the user has permission to view
4469             */
4470            @Override
4471            public int filterCountByG_S(long groupId, int status) {
4472                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4473                            return countByG_S(groupId, status);
4474                    }
4475    
4476                    StringBundler query = new StringBundler(3);
4477    
4478                    query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
4479    
4480                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4481    
4482                    query.append(_FINDER_COLUMN_G_S_STATUS_2);
4483    
4484                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4485                                    BookmarksEntry.class.getName(),
4486                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
4487                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
4488    
4489                    Session session = null;
4490    
4491                    try {
4492                            session = openSession();
4493    
4494                            Query q = session.createQuery(sql);
4495    
4496                            QueryPos qPos = QueryPos.getInstance(q);
4497    
4498                            qPos.add(groupId);
4499    
4500                            qPos.add(status);
4501    
4502                            Long count = (Long)q.uniqueResult();
4503    
4504                            return count.intValue();
4505                    }
4506                    catch (Exception e) {
4507                            throw processException(e);
4508                    }
4509                    finally {
4510                            closeSession(session);
4511                    }
4512            }
4513    
4514            private static final String _FINDER_COLUMN_G_S_GROUPID_2 = "bookmarksEntry.groupId = ? AND ";
4515            private static final String _FINDER_COLUMN_G_S_STATUS_2 = "bookmarksEntry.status = ?";
4516            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_NOTS = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
4517                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
4518                            BookmarksEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
4519                            "findByG_NotS",
4520                            new String[] {
4521                                    Long.class.getName(), Integer.class.getName(),
4522                                    
4523                            Integer.class.getName(), Integer.class.getName(),
4524                                    OrderByComparator.class.getName()
4525                            });
4526            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_NOTS = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
4527                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
4528                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_NotS",
4529                            new String[] { Long.class.getName(), Integer.class.getName() });
4530    
4531            /**
4532             * Returns all the bookmarks entries where groupId = &#63; and status &ne; &#63;.
4533             *
4534             * @param groupId the group ID
4535             * @param status the status
4536             * @return the matching bookmarks entries
4537             */
4538            @Override
4539            public List<BookmarksEntry> findByG_NotS(long groupId, int status) {
4540                    return findByG_NotS(groupId, status, QueryUtil.ALL_POS,
4541                            QueryUtil.ALL_POS, null);
4542            }
4543    
4544            /**
4545             * Returns a range of all the bookmarks entries where groupId = &#63; and status &ne; &#63;.
4546             *
4547             * <p>
4548             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.bookmarks.model.impl.BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4549             * </p>
4550             *
4551             * @param groupId the group ID
4552             * @param status the status
4553             * @param start the lower bound of the range of bookmarks entries
4554             * @param end the upper bound of the range of bookmarks entries (not inclusive)
4555             * @return the range of matching bookmarks entries
4556             */
4557            @Override
4558            public List<BookmarksEntry> findByG_NotS(long groupId, int status,
4559                    int start, int end) {
4560                    return findByG_NotS(groupId, status, start, end, null);
4561            }
4562    
4563            /**
4564             * Returns an ordered range of all the bookmarks entries where groupId = &#63; and status &ne; &#63;.
4565             *
4566             * <p>
4567             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.bookmarks.model.impl.BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4568             * </p>
4569             *
4570             * @param groupId the group ID
4571             * @param status the status
4572             * @param start the lower bound of the range of bookmarks entries
4573             * @param end the upper bound of the range of bookmarks entries (not inclusive)
4574             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4575             * @return the ordered range of matching bookmarks entries
4576             */
4577            @Override
4578            public List<BookmarksEntry> findByG_NotS(long groupId, int status,
4579                    int start, int end, OrderByComparator<BookmarksEntry> orderByComparator) {
4580                    boolean pagination = true;
4581                    FinderPath finderPath = null;
4582                    Object[] finderArgs = null;
4583    
4584                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_NOTS;
4585                    finderArgs = new Object[] { groupId, status, start, end, orderByComparator };
4586    
4587                    List<BookmarksEntry> list = (List<BookmarksEntry>)FinderCacheUtil.getResult(finderPath,
4588                                    finderArgs, this);
4589    
4590                    if ((list != null) && !list.isEmpty()) {
4591                            for (BookmarksEntry bookmarksEntry : list) {
4592                                    if ((groupId != bookmarksEntry.getGroupId()) ||
4593                                                    (status == bookmarksEntry.getStatus())) {
4594                                            list = null;
4595    
4596                                            break;
4597                                    }
4598                            }
4599                    }
4600    
4601                    if (list == null) {
4602                            StringBundler query = null;
4603    
4604                            if (orderByComparator != null) {
4605                                    query = new StringBundler(4 +
4606                                                    (orderByComparator.getOrderByFields().length * 3));
4607                            }
4608                            else {
4609                                    query = new StringBundler(4);
4610                            }
4611    
4612                            query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
4613    
4614                            query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
4615    
4616                            query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
4617    
4618                            if (orderByComparator != null) {
4619                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4620                                            orderByComparator);
4621                            }
4622                            else
4623                             if (pagination) {
4624                                    query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
4625                            }
4626    
4627                            String sql = query.toString();
4628    
4629                            Session session = null;
4630    
4631                            try {
4632                                    session = openSession();
4633    
4634                                    Query q = session.createQuery(sql);
4635    
4636                                    QueryPos qPos = QueryPos.getInstance(q);
4637    
4638                                    qPos.add(groupId);
4639    
4640                                    qPos.add(status);
4641    
4642                                    if (!pagination) {
4643                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
4644                                                            getDialect(), start, end, false);
4645    
4646                                            Collections.sort(list);
4647    
4648                                            list = Collections.unmodifiableList(list);
4649                                    }
4650                                    else {
4651                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
4652                                                            getDialect(), start, end);
4653                                    }
4654    
4655                                    cacheResult(list);
4656    
4657                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
4658                            }
4659                            catch (Exception e) {
4660                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4661    
4662                                    throw processException(e);
4663                            }
4664                            finally {
4665                                    closeSession(session);
4666                            }
4667                    }
4668    
4669                    return list;
4670            }
4671    
4672            /**
4673             * Returns the first bookmarks entry in the ordered set where groupId = &#63; and status &ne; &#63;.
4674             *
4675             * @param groupId the group ID
4676             * @param status the status
4677             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4678             * @return the first matching bookmarks entry
4679             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
4680             */
4681            @Override
4682            public BookmarksEntry findByG_NotS_First(long groupId, int status,
4683                    OrderByComparator<BookmarksEntry> orderByComparator)
4684                    throws NoSuchEntryException {
4685                    BookmarksEntry bookmarksEntry = fetchByG_NotS_First(groupId, status,
4686                                    orderByComparator);
4687    
4688                    if (bookmarksEntry != null) {
4689                            return bookmarksEntry;
4690                    }
4691    
4692                    StringBundler msg = new StringBundler(6);
4693    
4694                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4695    
4696                    msg.append("groupId=");
4697                    msg.append(groupId);
4698    
4699                    msg.append(", status=");
4700                    msg.append(status);
4701    
4702                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4703    
4704                    throw new NoSuchEntryException(msg.toString());
4705            }
4706    
4707            /**
4708             * Returns the first bookmarks entry in the ordered set where groupId = &#63; and status &ne; &#63;.
4709             *
4710             * @param groupId the group ID
4711             * @param status the status
4712             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4713             * @return the first matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
4714             */
4715            @Override
4716            public BookmarksEntry fetchByG_NotS_First(long groupId, int status,
4717                    OrderByComparator<BookmarksEntry> orderByComparator) {
4718                    List<BookmarksEntry> list = findByG_NotS(groupId, status, 0, 1,
4719                                    orderByComparator);
4720    
4721                    if (!list.isEmpty()) {
4722                            return list.get(0);
4723                    }
4724    
4725                    return null;
4726            }
4727    
4728            /**
4729             * Returns the last bookmarks entry in the ordered set where groupId = &#63; and status &ne; &#63;.
4730             *
4731             * @param groupId the group ID
4732             * @param status the status
4733             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4734             * @return the last matching bookmarks entry
4735             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
4736             */
4737            @Override
4738            public BookmarksEntry findByG_NotS_Last(long groupId, int status,
4739                    OrderByComparator<BookmarksEntry> orderByComparator)
4740                    throws NoSuchEntryException {
4741                    BookmarksEntry bookmarksEntry = fetchByG_NotS_Last(groupId, status,
4742                                    orderByComparator);
4743    
4744                    if (bookmarksEntry != null) {
4745                            return bookmarksEntry;
4746                    }
4747    
4748                    StringBundler msg = new StringBundler(6);
4749    
4750                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4751    
4752                    msg.append("groupId=");
4753                    msg.append(groupId);
4754    
4755                    msg.append(", status=");
4756                    msg.append(status);
4757    
4758                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4759    
4760                    throw new NoSuchEntryException(msg.toString());
4761            }
4762    
4763            /**
4764             * Returns the last bookmarks entry in the ordered set where groupId = &#63; and status &ne; &#63;.
4765             *
4766             * @param groupId the group ID
4767             * @param status the status
4768             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4769             * @return the last matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
4770             */
4771            @Override
4772            public BookmarksEntry fetchByG_NotS_Last(long groupId, int status,
4773                    OrderByComparator<BookmarksEntry> orderByComparator) {
4774                    int count = countByG_NotS(groupId, status);
4775    
4776                    if (count == 0) {
4777                            return null;
4778                    }
4779    
4780                    List<BookmarksEntry> list = findByG_NotS(groupId, status, count - 1,
4781                                    count, orderByComparator);
4782    
4783                    if (!list.isEmpty()) {
4784                            return list.get(0);
4785                    }
4786    
4787                    return null;
4788            }
4789    
4790            /**
4791             * Returns the bookmarks entries before and after the current bookmarks entry in the ordered set where groupId = &#63; and status &ne; &#63;.
4792             *
4793             * @param entryId the primary key of the current bookmarks entry
4794             * @param groupId the group ID
4795             * @param status the status
4796             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4797             * @return the previous, current, and next bookmarks entry
4798             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
4799             */
4800            @Override
4801            public BookmarksEntry[] findByG_NotS_PrevAndNext(long entryId,
4802                    long groupId, int status,
4803                    OrderByComparator<BookmarksEntry> orderByComparator)
4804                    throws NoSuchEntryException {
4805                    BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
4806    
4807                    Session session = null;
4808    
4809                    try {
4810                            session = openSession();
4811    
4812                            BookmarksEntry[] array = new BookmarksEntryImpl[3];
4813    
4814                            array[0] = getByG_NotS_PrevAndNext(session, bookmarksEntry,
4815                                            groupId, status, orderByComparator, true);
4816    
4817                            array[1] = bookmarksEntry;
4818    
4819                            array[2] = getByG_NotS_PrevAndNext(session, bookmarksEntry,
4820                                            groupId, status, orderByComparator, false);
4821    
4822                            return array;
4823                    }
4824                    catch (Exception e) {
4825                            throw processException(e);
4826                    }
4827                    finally {
4828                            closeSession(session);
4829                    }
4830            }
4831    
4832            protected BookmarksEntry getByG_NotS_PrevAndNext(Session session,
4833                    BookmarksEntry bookmarksEntry, long groupId, int status,
4834                    OrderByComparator<BookmarksEntry> orderByComparator, boolean previous) {
4835                    StringBundler query = null;
4836    
4837                    if (orderByComparator != null) {
4838                            query = new StringBundler(6 +
4839                                            (orderByComparator.getOrderByFields().length * 6));
4840                    }
4841                    else {
4842                            query = new StringBundler(3);
4843                    }
4844    
4845                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
4846    
4847                    query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
4848    
4849                    query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
4850    
4851                    if (orderByComparator != null) {
4852                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4853    
4854                            if (orderByConditionFields.length > 0) {
4855                                    query.append(WHERE_AND);
4856                            }
4857    
4858                            for (int i = 0; i < orderByConditionFields.length; i++) {
4859                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4860                                    query.append(orderByConditionFields[i]);
4861    
4862                                    if ((i + 1) < orderByConditionFields.length) {
4863                                            if (orderByComparator.isAscending() ^ previous) {
4864                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4865                                            }
4866                                            else {
4867                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4868                                            }
4869                                    }
4870                                    else {
4871                                            if (orderByComparator.isAscending() ^ previous) {
4872                                                    query.append(WHERE_GREATER_THAN);
4873                                            }
4874                                            else {
4875                                                    query.append(WHERE_LESSER_THAN);
4876                                            }
4877                                    }
4878                            }
4879    
4880                            query.append(ORDER_BY_CLAUSE);
4881    
4882                            String[] orderByFields = orderByComparator.getOrderByFields();
4883    
4884                            for (int i = 0; i < orderByFields.length; i++) {
4885                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4886                                    query.append(orderByFields[i]);
4887    
4888                                    if ((i + 1) < orderByFields.length) {
4889                                            if (orderByComparator.isAscending() ^ previous) {
4890                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4891                                            }
4892                                            else {
4893                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4894                                            }
4895                                    }
4896                                    else {
4897                                            if (orderByComparator.isAscending() ^ previous) {
4898                                                    query.append(ORDER_BY_ASC);
4899                                            }
4900                                            else {
4901                                                    query.append(ORDER_BY_DESC);
4902                                            }
4903                                    }
4904                            }
4905                    }
4906                    else {
4907                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
4908                    }
4909    
4910                    String sql = query.toString();
4911    
4912                    Query q = session.createQuery(sql);
4913    
4914                    q.setFirstResult(0);
4915                    q.setMaxResults(2);
4916    
4917                    QueryPos qPos = QueryPos.getInstance(q);
4918    
4919                    qPos.add(groupId);
4920    
4921                    qPos.add(status);
4922    
4923                    if (orderByComparator != null) {
4924                            Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry);
4925    
4926                            for (Object value : values) {
4927                                    qPos.add(value);
4928                            }
4929                    }
4930    
4931                    List<BookmarksEntry> list = q.list();
4932    
4933                    if (list.size() == 2) {
4934                            return list.get(1);
4935                    }
4936                    else {
4937                            return null;
4938                    }
4939            }
4940    
4941            /**
4942             * Returns all the bookmarks entries that the user has permission to view where groupId = &#63; and status &ne; &#63;.
4943             *
4944             * @param groupId the group ID
4945             * @param status the status
4946             * @return the matching bookmarks entries that the user has permission to view
4947             */
4948            @Override
4949            public List<BookmarksEntry> filterFindByG_NotS(long groupId, int status) {
4950                    return filterFindByG_NotS(groupId, status, QueryUtil.ALL_POS,
4951                            QueryUtil.ALL_POS, null);
4952            }
4953    
4954            /**
4955             * Returns a range of all the bookmarks entries that the user has permission to view where groupId = &#63; and status &ne; &#63;.
4956             *
4957             * <p>
4958             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.bookmarks.model.impl.BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4959             * </p>
4960             *
4961             * @param groupId the group ID
4962             * @param status the status
4963             * @param start the lower bound of the range of bookmarks entries
4964             * @param end the upper bound of the range of bookmarks entries (not inclusive)
4965             * @return the range of matching bookmarks entries that the user has permission to view
4966             */
4967            @Override
4968            public List<BookmarksEntry> filterFindByG_NotS(long groupId, int status,
4969                    int start, int end) {
4970                    return filterFindByG_NotS(groupId, status, start, end, null);
4971            }
4972    
4973            /**
4974             * Returns an ordered range of all the bookmarks entries that the user has permissions to view where groupId = &#63; and status &ne; &#63;.
4975             *
4976             * <p>
4977             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.bookmarks.model.impl.BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4978             * </p>
4979             *
4980             * @param groupId the group ID
4981             * @param status the status
4982             * @param start the lower bound of the range of bookmarks entries
4983             * @param end the upper bound of the range of bookmarks entries (not inclusive)
4984             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4985             * @return the ordered range of matching bookmarks entries that the user has permission to view
4986             */
4987            @Override
4988            public List<BookmarksEntry> filterFindByG_NotS(long groupId, int status,
4989                    int start, int end, OrderByComparator<BookmarksEntry> orderByComparator) {
4990                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4991                            return findByG_NotS(groupId, status, start, end, orderByComparator);
4992                    }
4993    
4994                    StringBundler query = null;
4995    
4996                    if (orderByComparator != null) {
4997                            query = new StringBundler(4 +
4998                                            (orderByComparator.getOrderByFields().length * 3));
4999                    }
5000                    else {
5001                            query = new StringBundler(4);
5002                    }
5003    
5004                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
5005    
5006                    query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
5007    
5008                    query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
5009    
5010                    if (orderByComparator != null) {
5011                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5012                                    orderByComparator);
5013                    }
5014                    else {
5015                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
5016                    }
5017    
5018                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5019                                    BookmarksEntry.class.getName(),
5020                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
5021                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
5022    
5023                    Session session = null;
5024    
5025                    try {
5026                            session = openSession();
5027    
5028                            Query q = session.createQuery(sql);
5029    
5030                            QueryPos qPos = QueryPos.getInstance(q);
5031    
5032                            qPos.add(groupId);
5033    
5034                            qPos.add(status);
5035    
5036                            return (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start,
5037                                    end);
5038                    }
5039                    catch (Exception e) {
5040                            throw processException(e);
5041                    }
5042                    finally {
5043                            closeSession(session);
5044                    }
5045            }
5046    
5047            /**
5048             * Returns the bookmarks entries before and after the current bookmarks entry in the ordered set of bookmarks entries that the user has permission to view where groupId = &#63; and status &ne; &#63;.
5049             *
5050             * @param entryId the primary key of the current bookmarks entry
5051             * @param groupId the group ID
5052             * @param status the status
5053             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5054             * @return the previous, current, and next bookmarks entry
5055             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
5056             */
5057            @Override
5058            public BookmarksEntry[] filterFindByG_NotS_PrevAndNext(long entryId,
5059                    long groupId, int status,
5060                    OrderByComparator<BookmarksEntry> orderByComparator)
5061                    throws NoSuchEntryException {
5062                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5063                            return findByG_NotS_PrevAndNext(entryId, groupId, status,
5064                                    orderByComparator);
5065                    }
5066    
5067                    BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
5068    
5069                    Session session = null;
5070    
5071                    try {
5072                            session = openSession();
5073    
5074                            BookmarksEntry[] array = new BookmarksEntryImpl[3];
5075    
5076                            array[0] = filterGetByG_NotS_PrevAndNext(session, bookmarksEntry,
5077                                            groupId, status, orderByComparator, true);
5078    
5079                            array[1] = bookmarksEntry;
5080    
5081                            array[2] = filterGetByG_NotS_PrevAndNext(session, bookmarksEntry,
5082                                            groupId, status, orderByComparator, false);
5083    
5084                            return array;
5085                    }
5086                    catch (Exception e) {
5087                            throw processException(e);
5088                    }
5089                    finally {
5090                            closeSession(session);
5091                    }
5092            }
5093    
5094            protected BookmarksEntry filterGetByG_NotS_PrevAndNext(Session session,
5095                    BookmarksEntry bookmarksEntry, long groupId, int status,
5096                    OrderByComparator<BookmarksEntry> orderByComparator, boolean previous) {
5097                    StringBundler query = null;
5098    
5099                    if (orderByComparator != null) {
5100                            query = new StringBundler(6 +
5101                                            (orderByComparator.getOrderByFields().length * 6));
5102                    }
5103                    else {
5104                            query = new StringBundler(3);
5105                    }
5106    
5107                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
5108    
5109                    query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
5110    
5111                    query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
5112    
5113                    if (orderByComparator != null) {
5114                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5115    
5116                            if (orderByConditionFields.length > 0) {
5117                                    query.append(WHERE_AND);
5118                            }
5119    
5120                            for (int i = 0; i < orderByConditionFields.length; i++) {
5121                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5122                                    query.append(orderByConditionFields[i]);
5123    
5124                                    if ((i + 1) < orderByConditionFields.length) {
5125                                            if (orderByComparator.isAscending() ^ previous) {
5126                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5127                                            }
5128                                            else {
5129                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5130                                            }
5131                                    }
5132                                    else {
5133                                            if (orderByComparator.isAscending() ^ previous) {
5134                                                    query.append(WHERE_GREATER_THAN);
5135                                            }
5136                                            else {
5137                                                    query.append(WHERE_LESSER_THAN);
5138                                            }
5139                                    }
5140                            }
5141    
5142                            query.append(ORDER_BY_CLAUSE);
5143    
5144                            String[] orderByFields = orderByComparator.getOrderByFields();
5145    
5146                            for (int i = 0; i < orderByFields.length; i++) {
5147                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5148                                    query.append(orderByFields[i]);
5149    
5150                                    if ((i + 1) < orderByFields.length) {
5151                                            if (orderByComparator.isAscending() ^ previous) {
5152                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5153                                            }
5154                                            else {
5155                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5156                                            }
5157                                    }
5158                                    else {
5159                                            if (orderByComparator.isAscending() ^ previous) {
5160                                                    query.append(ORDER_BY_ASC);
5161                                            }
5162                                            else {
5163                                                    query.append(ORDER_BY_DESC);
5164                                            }
5165                                    }
5166                            }
5167                    }
5168                    else {
5169                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
5170                    }
5171    
5172                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5173                                    BookmarksEntry.class.getName(),
5174                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
5175                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
5176    
5177                    Query q = session.createQuery(sql);
5178    
5179                    q.setFirstResult(0);
5180                    q.setMaxResults(2);
5181    
5182                    QueryPos qPos = QueryPos.getInstance(q);
5183    
5184                    qPos.add(groupId);
5185    
5186                    qPos.add(status);
5187    
5188                    if (orderByComparator != null) {
5189                            Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry);
5190    
5191                            for (Object value : values) {
5192                                    qPos.add(value);
5193                            }
5194                    }
5195    
5196                    List<BookmarksEntry> list = q.list();
5197    
5198                    if (list.size() == 2) {
5199                            return list.get(1);
5200                    }
5201                    else {
5202                            return null;
5203                    }
5204            }
5205    
5206            /**
5207             * Removes all the bookmarks entries where groupId = &#63; and status &ne; &#63; from the database.
5208             *
5209             * @param groupId the group ID
5210             * @param status the status
5211             */
5212            @Override
5213            public void removeByG_NotS(long groupId, int status) {
5214                    for (BookmarksEntry bookmarksEntry : findByG_NotS(groupId, status,
5215                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
5216                            remove(bookmarksEntry);
5217                    }
5218            }
5219    
5220            /**
5221             * Returns the number of bookmarks entries where groupId = &#63; and status &ne; &#63;.
5222             *
5223             * @param groupId the group ID
5224             * @param status the status
5225             * @return the number of matching bookmarks entries
5226             */
5227            @Override
5228            public int countByG_NotS(long groupId, int status) {
5229                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_NOTS;
5230    
5231                    Object[] finderArgs = new Object[] { groupId, status };
5232    
5233                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
5234                                    this);
5235    
5236                    if (count == null) {
5237                            StringBundler query = new StringBundler(3);
5238    
5239                            query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
5240    
5241                            query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
5242    
5243                            query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
5244    
5245                            String sql = query.toString();
5246    
5247                            Session session = null;
5248    
5249                            try {
5250                                    session = openSession();
5251    
5252                                    Query q = session.createQuery(sql);
5253    
5254                                    QueryPos qPos = QueryPos.getInstance(q);
5255    
5256                                    qPos.add(groupId);
5257    
5258                                    qPos.add(status);
5259    
5260                                    count = (Long)q.uniqueResult();
5261    
5262                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
5263                            }
5264                            catch (Exception e) {
5265                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5266    
5267                                    throw processException(e);
5268                            }
5269                            finally {
5270                                    closeSession(session);
5271                            }
5272                    }
5273    
5274                    return count.intValue();
5275            }
5276    
5277            /**
5278             * Returns the number of bookmarks entries that the user has permission to view where groupId = &#63; and status &ne; &#63;.
5279             *
5280             * @param groupId the group ID
5281             * @param status the status
5282             * @return the number of matching bookmarks entries that the user has permission to view
5283             */
5284            @Override
5285            public int filterCountByG_NotS(long groupId, int status) {
5286                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5287                            return countByG_NotS(groupId, status);
5288                    }
5289    
5290                    StringBundler query = new StringBundler(3);
5291    
5292                    query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
5293    
5294                    query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
5295    
5296                    query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
5297    
5298                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5299                                    BookmarksEntry.class.getName(),
5300                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
5301                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
5302    
5303                    Session session = null;
5304    
5305                    try {
5306                            session = openSession();
5307    
5308                            Query q = session.createQuery(sql);
5309    
5310                            QueryPos qPos = QueryPos.getInstance(q);
5311    
5312                            qPos.add(groupId);
5313    
5314                            qPos.add(status);
5315    
5316                            Long count = (Long)q.uniqueResult();
5317    
5318                            return count.intValue();
5319                    }
5320                    catch (Exception e) {
5321                            throw processException(e);
5322                    }
5323                    finally {
5324                            closeSession(session);
5325                    }
5326            }
5327    
5328            private static final String _FINDER_COLUMN_G_NOTS_GROUPID_2 = "bookmarksEntry.groupId = ? AND ";
5329            private static final String _FINDER_COLUMN_G_NOTS_STATUS_2 = "bookmarksEntry.status != ?";
5330            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_NOTS = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
5331                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
5332                            BookmarksEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
5333                            "findByC_NotS",
5334                            new String[] {
5335                                    Long.class.getName(), Integer.class.getName(),
5336                                    
5337                            Integer.class.getName(), Integer.class.getName(),
5338                                    OrderByComparator.class.getName()
5339                            });
5340            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_NOTS = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
5341                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
5342                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_NotS",
5343                            new String[] { Long.class.getName(), Integer.class.getName() });
5344    
5345            /**
5346             * Returns all the bookmarks entries where companyId = &#63; and status &ne; &#63;.
5347             *
5348             * @param companyId the company ID
5349             * @param status the status
5350             * @return the matching bookmarks entries
5351             */
5352            @Override
5353            public List<BookmarksEntry> findByC_NotS(long companyId, int status) {
5354                    return findByC_NotS(companyId, status, QueryUtil.ALL_POS,
5355                            QueryUtil.ALL_POS, null);
5356            }
5357    
5358            /**
5359             * Returns a range of all the bookmarks entries where companyId = &#63; and status &ne; &#63;.
5360             *
5361             * <p>
5362             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.bookmarks.model.impl.BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5363             * </p>
5364             *
5365             * @param companyId the company ID
5366             * @param status the status
5367             * @param start the lower bound of the range of bookmarks entries
5368             * @param end the upper bound of the range of bookmarks entries (not inclusive)
5369             * @return the range of matching bookmarks entries
5370             */
5371            @Override
5372            public List<BookmarksEntry> findByC_NotS(long companyId, int status,
5373                    int start, int end) {
5374                    return findByC_NotS(companyId, status, start, end, null);
5375            }
5376    
5377            /**
5378             * Returns an ordered range of all the bookmarks entries where companyId = &#63; and status &ne; &#63;.
5379             *
5380             * <p>
5381             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.bookmarks.model.impl.BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5382             * </p>
5383             *
5384             * @param companyId the company ID
5385             * @param status the status
5386             * @param start the lower bound of the range of bookmarks entries
5387             * @param end the upper bound of the range of bookmarks entries (not inclusive)
5388             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5389             * @return the ordered range of matching bookmarks entries
5390             */
5391            @Override
5392            public List<BookmarksEntry> findByC_NotS(long companyId, int status,
5393                    int start, int end, OrderByComparator<BookmarksEntry> orderByComparator) {
5394                    boolean pagination = true;
5395                    FinderPath finderPath = null;
5396                    Object[] finderArgs = null;
5397    
5398                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_NOTS;
5399                    finderArgs = new Object[] {
5400                                    companyId, status,
5401                                    
5402                                    start, end, orderByComparator
5403                            };
5404    
5405                    List<BookmarksEntry> list = (List<BookmarksEntry>)FinderCacheUtil.getResult(finderPath,
5406                                    finderArgs, this);
5407    
5408                    if ((list != null) && !list.isEmpty()) {
5409                            for (BookmarksEntry bookmarksEntry : list) {
5410                                    if ((companyId != bookmarksEntry.getCompanyId()) ||
5411                                                    (status == bookmarksEntry.getStatus())) {
5412                                            list = null;
5413    
5414                                            break;
5415                                    }
5416                            }
5417                    }
5418    
5419                    if (list == null) {
5420                            StringBundler query = null;
5421    
5422                            if (orderByComparator != null) {
5423                                    query = new StringBundler(4 +
5424                                                    (orderByComparator.getOrderByFields().length * 3));
5425                            }
5426                            else {
5427                                    query = new StringBundler(4);
5428                            }
5429    
5430                            query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
5431    
5432                            query.append(_FINDER_COLUMN_C_NOTS_COMPANYID_2);
5433    
5434                            query.append(_FINDER_COLUMN_C_NOTS_STATUS_2);
5435    
5436                            if (orderByComparator != null) {
5437                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5438                                            orderByComparator);
5439                            }
5440                            else
5441                             if (pagination) {
5442                                    query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
5443                            }
5444    
5445                            String sql = query.toString();
5446    
5447                            Session session = null;
5448    
5449                            try {
5450                                    session = openSession();
5451    
5452                                    Query q = session.createQuery(sql);
5453    
5454                                    QueryPos qPos = QueryPos.getInstance(q);
5455    
5456                                    qPos.add(companyId);
5457    
5458                                    qPos.add(status);
5459    
5460                                    if (!pagination) {
5461                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
5462                                                            getDialect(), start, end, false);
5463    
5464                                            Collections.sort(list);
5465    
5466                                            list = Collections.unmodifiableList(list);
5467                                    }
5468                                    else {
5469                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
5470                                                            getDialect(), start, end);
5471                                    }
5472    
5473                                    cacheResult(list);
5474    
5475                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
5476                            }
5477                            catch (Exception e) {
5478                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5479    
5480                                    throw processException(e);
5481                            }
5482                            finally {
5483                                    closeSession(session);
5484                            }
5485                    }
5486    
5487                    return list;
5488            }
5489    
5490            /**
5491             * Returns the first bookmarks entry in the ordered set where companyId = &#63; and status &ne; &#63;.
5492             *
5493             * @param companyId the company ID
5494             * @param status the status
5495             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5496             * @return the first matching bookmarks entry
5497             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
5498             */
5499            @Override
5500            public BookmarksEntry findByC_NotS_First(long companyId, int status,
5501                    OrderByComparator<BookmarksEntry> orderByComparator)
5502                    throws NoSuchEntryException {
5503                    BookmarksEntry bookmarksEntry = fetchByC_NotS_First(companyId, status,
5504                                    orderByComparator);
5505    
5506                    if (bookmarksEntry != null) {
5507                            return bookmarksEntry;
5508                    }
5509    
5510                    StringBundler msg = new StringBundler(6);
5511    
5512                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5513    
5514                    msg.append("companyId=");
5515                    msg.append(companyId);
5516    
5517                    msg.append(", status=");
5518                    msg.append(status);
5519    
5520                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5521    
5522                    throw new NoSuchEntryException(msg.toString());
5523            }
5524    
5525            /**
5526             * Returns the first bookmarks entry in the ordered set where companyId = &#63; and status &ne; &#63;.
5527             *
5528             * @param companyId the company ID
5529             * @param status the status
5530             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5531             * @return the first matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
5532             */
5533            @Override
5534            public BookmarksEntry fetchByC_NotS_First(long companyId, int status,
5535                    OrderByComparator<BookmarksEntry> orderByComparator) {
5536                    List<BookmarksEntry> list = findByC_NotS(companyId, status, 0, 1,
5537                                    orderByComparator);
5538    
5539                    if (!list.isEmpty()) {
5540                            return list.get(0);
5541                    }
5542    
5543                    return null;
5544            }
5545    
5546            /**
5547             * Returns the last bookmarks entry in the ordered set where companyId = &#63; and status &ne; &#63;.
5548             *
5549             * @param companyId the company ID
5550             * @param status the status
5551             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5552             * @return the last matching bookmarks entry
5553             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
5554             */
5555            @Override
5556            public BookmarksEntry findByC_NotS_Last(long companyId, int status,
5557                    OrderByComparator<BookmarksEntry> orderByComparator)
5558                    throws NoSuchEntryException {
5559                    BookmarksEntry bookmarksEntry = fetchByC_NotS_Last(companyId, status,
5560                                    orderByComparator);
5561    
5562                    if (bookmarksEntry != null) {
5563                            return bookmarksEntry;
5564                    }
5565    
5566                    StringBundler msg = new StringBundler(6);
5567    
5568                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5569    
5570                    msg.append("companyId=");
5571                    msg.append(companyId);
5572    
5573                    msg.append(", status=");
5574                    msg.append(status);
5575    
5576                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5577    
5578                    throw new NoSuchEntryException(msg.toString());
5579            }
5580    
5581            /**
5582             * Returns the last bookmarks entry in the ordered set where companyId = &#63; and status &ne; &#63;.
5583             *
5584             * @param companyId the company ID
5585             * @param status the status
5586             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5587             * @return the last matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
5588             */
5589            @Override
5590            public BookmarksEntry fetchByC_NotS_Last(long companyId, int status,
5591                    OrderByComparator<BookmarksEntry> orderByComparator) {
5592                    int count = countByC_NotS(companyId, status);
5593    
5594                    if (count == 0) {
5595                            return null;
5596                    }
5597    
5598                    List<BookmarksEntry> list = findByC_NotS(companyId, status, count - 1,
5599                                    count, orderByComparator);
5600    
5601                    if (!list.isEmpty()) {
5602                            return list.get(0);
5603                    }
5604    
5605                    return null;
5606            }
5607    
5608            /**
5609             * Returns the bookmarks entries before and after the current bookmarks entry in the ordered set where companyId = &#63; and status &ne; &#63;.
5610             *
5611             * @param entryId the primary key of the current bookmarks entry
5612             * @param companyId the company ID
5613             * @param status the status
5614             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5615             * @return the previous, current, and next bookmarks entry
5616             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
5617             */
5618            @Override
5619            public BookmarksEntry[] findByC_NotS_PrevAndNext(long entryId,
5620                    long companyId, int status,
5621                    OrderByComparator<BookmarksEntry> orderByComparator)
5622                    throws NoSuchEntryException {
5623                    BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
5624    
5625                    Session session = null;
5626    
5627                    try {
5628                            session = openSession();
5629    
5630                            BookmarksEntry[] array = new BookmarksEntryImpl[3];
5631    
5632                            array[0] = getByC_NotS_PrevAndNext(session, bookmarksEntry,
5633                                            companyId, status, orderByComparator, true);
5634    
5635                            array[1] = bookmarksEntry;
5636    
5637                            array[2] = getByC_NotS_PrevAndNext(session, bookmarksEntry,
5638                                            companyId, status, orderByComparator, false);
5639    
5640                            return array;
5641                    }
5642                    catch (Exception e) {
5643                            throw processException(e);
5644                    }
5645                    finally {
5646                            closeSession(session);
5647                    }
5648            }
5649    
5650            protected BookmarksEntry getByC_NotS_PrevAndNext(Session session,
5651                    BookmarksEntry bookmarksEntry, long companyId, int status,
5652                    OrderByComparator<BookmarksEntry> orderByComparator, boolean previous) {
5653                    StringBundler query = null;
5654    
5655                    if (orderByComparator != null) {
5656                            query = new StringBundler(6 +
5657                                            (orderByComparator.getOrderByFields().length * 6));
5658                    }
5659                    else {
5660                            query = new StringBundler(3);
5661                    }
5662    
5663                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
5664    
5665                    query.append(_FINDER_COLUMN_C_NOTS_COMPANYID_2);
5666    
5667                    query.append(_FINDER_COLUMN_C_NOTS_STATUS_2);
5668    
5669                    if (orderByComparator != null) {
5670                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5671    
5672                            if (orderByConditionFields.length > 0) {
5673                                    query.append(WHERE_AND);
5674                            }
5675    
5676                            for (int i = 0; i < orderByConditionFields.length; i++) {
5677                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5678                                    query.append(orderByConditionFields[i]);
5679    
5680                                    if ((i + 1) < orderByConditionFields.length) {
5681                                            if (orderByComparator.isAscending() ^ previous) {
5682                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5683                                            }
5684                                            else {
5685                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5686                                            }
5687                                    }
5688                                    else {
5689                                            if (orderByComparator.isAscending() ^ previous) {
5690                                                    query.append(WHERE_GREATER_THAN);
5691                                            }
5692                                            else {
5693                                                    query.append(WHERE_LESSER_THAN);
5694                                            }
5695                                    }
5696                            }
5697    
5698                            query.append(ORDER_BY_CLAUSE);
5699    
5700                            String[] orderByFields = orderByComparator.getOrderByFields();
5701    
5702                            for (int i = 0; i < orderByFields.length; i++) {
5703                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5704                                    query.append(orderByFields[i]);
5705    
5706                                    if ((i + 1) < orderByFields.length) {
5707                                            if (orderByComparator.isAscending() ^ previous) {
5708                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5709                                            }
5710                                            else {
5711                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5712                                            }
5713                                    }
5714                                    else {
5715                                            if (orderByComparator.isAscending() ^ previous) {
5716                                                    query.append(ORDER_BY_ASC);
5717                                            }
5718                                            else {
5719                                                    query.append(ORDER_BY_DESC);
5720                                            }
5721                                    }
5722                            }
5723                    }
5724                    else {
5725                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
5726                    }
5727    
5728                    String sql = query.toString();
5729    
5730                    Query q = session.createQuery(sql);
5731    
5732                    q.setFirstResult(0);
5733                    q.setMaxResults(2);
5734    
5735                    QueryPos qPos = QueryPos.getInstance(q);
5736    
5737                    qPos.add(companyId);
5738    
5739                    qPos.add(status);
5740    
5741                    if (orderByComparator != null) {
5742                            Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry);
5743    
5744                            for (Object value : values) {
5745                                    qPos.add(value);
5746                            }
5747                    }
5748    
5749                    List<BookmarksEntry> list = q.list();
5750    
5751                    if (list.size() == 2) {
5752                            return list.get(1);
5753                    }
5754                    else {
5755                            return null;
5756                    }
5757            }
5758    
5759            /**
5760             * Removes all the bookmarks entries where companyId = &#63; and status &ne; &#63; from the database.
5761             *
5762             * @param companyId the company ID
5763             * @param status the status
5764             */
5765            @Override
5766            public void removeByC_NotS(long companyId, int status) {
5767                    for (BookmarksEntry bookmarksEntry : findByC_NotS(companyId, status,
5768                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
5769                            remove(bookmarksEntry);
5770                    }
5771            }
5772    
5773            /**
5774             * Returns the number of bookmarks entries where companyId = &#63; and status &ne; &#63;.
5775             *
5776             * @param companyId the company ID
5777             * @param status the status
5778             * @return the number of matching bookmarks entries
5779             */
5780            @Override
5781            public int countByC_NotS(long companyId, int status) {
5782                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_NOTS;
5783    
5784                    Object[] finderArgs = new Object[] { companyId, status };
5785    
5786                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
5787                                    this);
5788    
5789                    if (count == null) {
5790                            StringBundler query = new StringBundler(3);
5791    
5792                            query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
5793    
5794                            query.append(_FINDER_COLUMN_C_NOTS_COMPANYID_2);
5795    
5796                            query.append(_FINDER_COLUMN_C_NOTS_STATUS_2);
5797    
5798                            String sql = query.toString();
5799    
5800                            Session session = null;
5801    
5802                            try {
5803                                    session = openSession();
5804    
5805                                    Query q = session.createQuery(sql);
5806    
5807                                    QueryPos qPos = QueryPos.getInstance(q);
5808    
5809                                    qPos.add(companyId);
5810    
5811                                    qPos.add(status);
5812    
5813                                    count = (Long)q.uniqueResult();
5814    
5815                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
5816                            }
5817                            catch (Exception e) {
5818                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5819    
5820                                    throw processException(e);
5821                            }
5822                            finally {
5823                                    closeSession(session);
5824                            }
5825                    }
5826    
5827                    return count.intValue();
5828            }
5829    
5830            private static final String _FINDER_COLUMN_C_NOTS_COMPANYID_2 = "bookmarksEntry.companyId = ? AND ";
5831            private static final String _FINDER_COLUMN_C_NOTS_STATUS_2 = "bookmarksEntry.status != ?";
5832            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_S = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
5833                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
5834                            BookmarksEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
5835                            "findByG_U_S",
5836                            new String[] {
5837                                    Long.class.getName(), Long.class.getName(),
5838                                    Integer.class.getName(),
5839                                    
5840                            Integer.class.getName(), Integer.class.getName(),
5841                                    OrderByComparator.class.getName()
5842                            });
5843            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
5844                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
5845                            BookmarksEntryImpl.class,
5846                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U_S",
5847                            new String[] {
5848                                    Long.class.getName(), Long.class.getName(),
5849                                    Integer.class.getName()
5850                            },
5851                            BookmarksEntryModelImpl.GROUPID_COLUMN_BITMASK |
5852                            BookmarksEntryModelImpl.USERID_COLUMN_BITMASK |
5853                            BookmarksEntryModelImpl.STATUS_COLUMN_BITMASK |
5854                            BookmarksEntryModelImpl.FOLDERID_COLUMN_BITMASK |
5855                            BookmarksEntryModelImpl.NAME_COLUMN_BITMASK);
5856            public static final FinderPath FINDER_PATH_COUNT_BY_G_U_S = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
5857                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
5858                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U_S",
5859                            new String[] {
5860                                    Long.class.getName(), Long.class.getName(),
5861                                    Integer.class.getName()
5862                            });
5863    
5864            /**
5865             * Returns all the bookmarks entries where groupId = &#63; and userId = &#63; and status = &#63;.
5866             *
5867             * @param groupId the group ID
5868             * @param userId the user ID
5869             * @param status the status
5870             * @return the matching bookmarks entries
5871             */
5872            @Override
5873            public List<BookmarksEntry> findByG_U_S(long groupId, long userId,
5874                    int status) {
5875                    return findByG_U_S(groupId, userId, status, QueryUtil.ALL_POS,
5876                            QueryUtil.ALL_POS, null);
5877            }
5878    
5879            /**
5880             * Returns a range of all the bookmarks entries where groupId = &#63; and userId = &#63; and status = &#63;.
5881             *
5882             * <p>
5883             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.bookmarks.model.impl.BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5884             * </p>
5885             *
5886             * @param groupId the group ID
5887             * @param userId the user ID
5888             * @param status the status
5889             * @param start the lower bound of the range of bookmarks entries
5890             * @param end the upper bound of the range of bookmarks entries (not inclusive)
5891             * @return the range of matching bookmarks entries
5892             */
5893            @Override
5894            public List<BookmarksEntry> findByG_U_S(long groupId, long userId,
5895                    int status, int start, int end) {
5896                    return findByG_U_S(groupId, userId, status, start, end, null);
5897            }
5898    
5899            /**
5900             * Returns an ordered range of all the bookmarks entries where groupId = &#63; and userId = &#63; and status = &#63;.
5901             *
5902             * <p>
5903             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.bookmarks.model.impl.BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5904             * </p>
5905             *
5906             * @param groupId the group ID
5907             * @param userId the user ID
5908             * @param status the status
5909             * @param start the lower bound of the range of bookmarks entries
5910             * @param end the upper bound of the range of bookmarks entries (not inclusive)
5911             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5912             * @return the ordered range of matching bookmarks entries
5913             */
5914            @Override
5915            public List<BookmarksEntry> findByG_U_S(long groupId, long userId,
5916                    int status, int start, int end,
5917                    OrderByComparator<BookmarksEntry> orderByComparator) {
5918                    boolean pagination = true;
5919                    FinderPath finderPath = null;
5920                    Object[] finderArgs = null;
5921    
5922                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5923                                    (orderByComparator == null)) {
5924                            pagination = false;
5925                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S;
5926                            finderArgs = new Object[] { groupId, userId, status };
5927                    }
5928                    else {
5929                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_S;
5930                            finderArgs = new Object[] {
5931                                            groupId, userId, status,
5932                                            
5933                                            start, end, orderByComparator
5934                                    };
5935                    }
5936    
5937                    List<BookmarksEntry> list = (List<BookmarksEntry>)FinderCacheUtil.getResult(finderPath,
5938                                    finderArgs, this);
5939    
5940                    if ((list != null) && !list.isEmpty()) {
5941                            for (BookmarksEntry bookmarksEntry : list) {
5942                                    if ((groupId != bookmarksEntry.getGroupId()) ||
5943                                                    (userId != bookmarksEntry.getUserId()) ||
5944                                                    (status != bookmarksEntry.getStatus())) {
5945                                            list = null;
5946    
5947                                            break;
5948                                    }
5949                            }
5950                    }
5951    
5952                    if (list == null) {
5953                            StringBundler query = null;
5954    
5955                            if (orderByComparator != null) {
5956                                    query = new StringBundler(5 +
5957                                                    (orderByComparator.getOrderByFields().length * 3));
5958                            }
5959                            else {
5960                                    query = new StringBundler(5);
5961                            }
5962    
5963                            query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
5964    
5965                            query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
5966    
5967                            query.append(_FINDER_COLUMN_G_U_S_USERID_2);
5968    
5969                            query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
5970    
5971                            if (orderByComparator != null) {
5972                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5973                                            orderByComparator);
5974                            }
5975                            else
5976                             if (pagination) {
5977                                    query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
5978                            }
5979    
5980                            String sql = query.toString();
5981    
5982                            Session session = null;
5983    
5984                            try {
5985                                    session = openSession();
5986    
5987                                    Query q = session.createQuery(sql);
5988    
5989                                    QueryPos qPos = QueryPos.getInstance(q);
5990    
5991                                    qPos.add(groupId);
5992    
5993                                    qPos.add(userId);
5994    
5995                                    qPos.add(status);
5996    
5997                                    if (!pagination) {
5998                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
5999                                                            getDialect(), start, end, false);
6000    
6001                                            Collections.sort(list);
6002    
6003                                            list = Collections.unmodifiableList(list);
6004                                    }
6005                                    else {
6006                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
6007                                                            getDialect(), start, end);
6008                                    }
6009    
6010                                    cacheResult(list);
6011    
6012                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
6013                            }
6014                            catch (Exception e) {
6015                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6016    
6017                                    throw processException(e);
6018                            }
6019                            finally {
6020                                    closeSession(session);
6021                            }
6022                    }
6023    
6024                    return list;
6025            }
6026    
6027            /**
6028             * Returns the first bookmarks entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
6029             *
6030             * @param groupId the group ID
6031             * @param userId the user ID
6032             * @param status the status
6033             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6034             * @return the first matching bookmarks entry
6035             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
6036             */
6037            @Override
6038            public BookmarksEntry findByG_U_S_First(long groupId, long userId,
6039                    int status, OrderByComparator<BookmarksEntry> orderByComparator)
6040                    throws NoSuchEntryException {
6041                    BookmarksEntry bookmarksEntry = fetchByG_U_S_First(groupId, userId,
6042                                    status, orderByComparator);
6043    
6044                    if (bookmarksEntry != null) {
6045                            return bookmarksEntry;
6046                    }
6047    
6048                    StringBundler msg = new StringBundler(8);
6049    
6050                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6051    
6052                    msg.append("groupId=");
6053                    msg.append(groupId);
6054    
6055                    msg.append(", userId=");
6056                    msg.append(userId);
6057    
6058                    msg.append(", status=");
6059                    msg.append(status);
6060    
6061                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6062    
6063                    throw new NoSuchEntryException(msg.toString());
6064            }
6065    
6066            /**
6067             * Returns the first bookmarks entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
6068             *
6069             * @param groupId the group ID
6070             * @param userId the user ID
6071             * @param status the status
6072             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6073             * @return the first matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
6074             */
6075            @Override
6076            public BookmarksEntry fetchByG_U_S_First(long groupId, long userId,
6077                    int status, OrderByComparator<BookmarksEntry> orderByComparator) {
6078                    List<BookmarksEntry> list = findByG_U_S(groupId, userId, status, 0, 1,
6079                                    orderByComparator);
6080    
6081                    if (!list.isEmpty()) {
6082                            return list.get(0);
6083                    }
6084    
6085                    return null;
6086            }
6087    
6088            /**
6089             * Returns the last bookmarks entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
6090             *
6091             * @param groupId the group ID
6092             * @param userId the user ID
6093             * @param status the status
6094             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6095             * @return the last matching bookmarks entry
6096             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
6097             */
6098            @Override
6099            public BookmarksEntry findByG_U_S_Last(long groupId, long userId,
6100                    int status, OrderByComparator<BookmarksEntry> orderByComparator)
6101                    throws NoSuchEntryException {
6102                    BookmarksEntry bookmarksEntry = fetchByG_U_S_Last(groupId, userId,
6103                                    status, orderByComparator);
6104    
6105                    if (bookmarksEntry != null) {
6106                            return bookmarksEntry;
6107                    }
6108    
6109                    StringBundler msg = new StringBundler(8);
6110    
6111                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6112    
6113                    msg.append("groupId=");
6114                    msg.append(groupId);
6115    
6116                    msg.append(", userId=");
6117                    msg.append(userId);
6118    
6119                    msg.append(", status=");
6120                    msg.append(status);
6121    
6122                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6123    
6124                    throw new NoSuchEntryException(msg.toString());
6125            }
6126    
6127            /**
6128             * Returns the last bookmarks entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
6129             *
6130             * @param groupId the group ID
6131             * @param userId the user ID
6132             * @param status the status
6133             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6134             * @return the last matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
6135             */
6136            @Override
6137            public BookmarksEntry fetchByG_U_S_Last(long groupId, long userId,
6138                    int status, OrderByComparator<BookmarksEntry> orderByComparator) {
6139                    int count = countByG_U_S(groupId, userId, status);
6140    
6141                    if (count == 0) {
6142                            return null;
6143                    }
6144    
6145                    List<BookmarksEntry> list = findByG_U_S(groupId, userId, status,
6146                                    count - 1, count, orderByComparator);
6147    
6148                    if (!list.isEmpty()) {
6149                            return list.get(0);
6150                    }
6151    
6152                    return null;
6153            }
6154    
6155            /**
6156             * Returns the bookmarks entries before and after the current bookmarks entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
6157             *
6158             * @param entryId the primary key of the current bookmarks entry
6159             * @param groupId the group ID
6160             * @param userId the user ID
6161             * @param status the status
6162             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6163             * @return the previous, current, and next bookmarks entry
6164             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
6165             */
6166            @Override
6167            public BookmarksEntry[] findByG_U_S_PrevAndNext(long entryId, long groupId,
6168                    long userId, int status,
6169                    OrderByComparator<BookmarksEntry> orderByComparator)
6170                    throws NoSuchEntryException {
6171                    BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
6172    
6173                    Session session = null;
6174    
6175                    try {
6176                            session = openSession();
6177    
6178                            BookmarksEntry[] array = new BookmarksEntryImpl[3];
6179    
6180                            array[0] = getByG_U_S_PrevAndNext(session, bookmarksEntry, groupId,
6181                                            userId, status, orderByComparator, true);
6182    
6183                            array[1] = bookmarksEntry;
6184    
6185                            array[2] = getByG_U_S_PrevAndNext(session, bookmarksEntry, groupId,
6186                                            userId, status, orderByComparator, false);
6187    
6188                            return array;
6189                    }
6190                    catch (Exception e) {
6191                            throw processException(e);
6192                    }
6193                    finally {
6194                            closeSession(session);
6195                    }
6196            }
6197    
6198            protected BookmarksEntry getByG_U_S_PrevAndNext(Session session,
6199                    BookmarksEntry bookmarksEntry, long groupId, long userId, int status,
6200                    OrderByComparator<BookmarksEntry> orderByComparator, boolean previous) {
6201                    StringBundler query = null;
6202    
6203                    if (orderByComparator != null) {
6204                            query = new StringBundler(6 +
6205                                            (orderByComparator.getOrderByFields().length * 6));
6206                    }
6207                    else {
6208                            query = new StringBundler(3);
6209                    }
6210    
6211                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
6212    
6213                    query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
6214    
6215                    query.append(_FINDER_COLUMN_G_U_S_USERID_2);
6216    
6217                    query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
6218    
6219                    if (orderByComparator != null) {
6220                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6221    
6222                            if (orderByConditionFields.length > 0) {
6223                                    query.append(WHERE_AND);
6224                            }
6225    
6226                            for (int i = 0; i < orderByConditionFields.length; i++) {
6227                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6228                                    query.append(orderByConditionFields[i]);
6229    
6230                                    if ((i + 1) < orderByConditionFields.length) {
6231                                            if (orderByComparator.isAscending() ^ previous) {
6232                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6233                                            }
6234                                            else {
6235                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6236                                            }
6237                                    }
6238                                    else {
6239                                            if (orderByComparator.isAscending() ^ previous) {
6240                                                    query.append(WHERE_GREATER_THAN);
6241                                            }
6242                                            else {
6243                                                    query.append(WHERE_LESSER_THAN);
6244                                            }
6245                                    }
6246                            }
6247    
6248                            query.append(ORDER_BY_CLAUSE);
6249    
6250                            String[] orderByFields = orderByComparator.getOrderByFields();
6251    
6252                            for (int i = 0; i < orderByFields.length; i++) {
6253                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6254                                    query.append(orderByFields[i]);
6255    
6256                                    if ((i + 1) < orderByFields.length) {
6257                                            if (orderByComparator.isAscending() ^ previous) {
6258                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6259                                            }
6260                                            else {
6261                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6262                                            }
6263                                    }
6264                                    else {
6265                                            if (orderByComparator.isAscending() ^ previous) {
6266                                                    query.append(ORDER_BY_ASC);
6267                                            }
6268                                            else {
6269                                                    query.append(ORDER_BY_DESC);
6270                                            }
6271                                    }
6272                            }
6273                    }
6274                    else {
6275                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
6276                    }
6277    
6278                    String sql = query.toString();
6279    
6280                    Query q = session.createQuery(sql);
6281    
6282                    q.setFirstResult(0);
6283                    q.setMaxResults(2);
6284    
6285                    QueryPos qPos = QueryPos.getInstance(q);
6286    
6287                    qPos.add(groupId);
6288    
6289                    qPos.add(userId);
6290    
6291                    qPos.add(status);
6292    
6293                    if (orderByComparator != null) {
6294                            Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry);
6295    
6296                            for (Object value : values) {
6297                                    qPos.add(value);
6298                            }
6299                    }
6300    
6301                    List<BookmarksEntry> list = q.list();
6302    
6303                    if (list.size() == 2) {
6304                            return list.get(1);
6305                    }
6306                    else {
6307                            return null;
6308                    }
6309            }
6310    
6311            /**
6312             * Returns all the bookmarks entries that the user has permission to view where groupId = &#63; and userId = &#63; and status = &#63;.
6313             *
6314             * @param groupId the group ID
6315             * @param userId the user ID
6316             * @param status the status
6317             * @return the matching bookmarks entries that the user has permission to view
6318             */
6319            @Override
6320            public List<BookmarksEntry> filterFindByG_U_S(long groupId, long userId,
6321                    int status) {
6322                    return filterFindByG_U_S(groupId, userId, status, QueryUtil.ALL_POS,
6323                            QueryUtil.ALL_POS, null);
6324            }
6325    
6326            /**
6327             * Returns a range of all the bookmarks entries that the user has permission to view where groupId = &#63; and userId = &#63; and status = &#63;.
6328             *
6329             * <p>
6330             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.bookmarks.model.impl.BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6331             * </p>
6332             *
6333             * @param groupId the group ID
6334             * @param userId the user ID
6335             * @param status the status
6336             * @param start the lower bound of the range of bookmarks entries
6337             * @param end the upper bound of the range of bookmarks entries (not inclusive)
6338             * @return the range of matching bookmarks entries that the user has permission to view
6339             */
6340            @Override
6341            public List<BookmarksEntry> filterFindByG_U_S(long groupId, long userId,
6342                    int status, int start, int end) {
6343                    return filterFindByG_U_S(groupId, userId, status, start, end, null);
6344            }
6345    
6346            /**
6347             * Returns an ordered range of all the bookmarks entries that the user has permissions to view where groupId = &#63; and userId = &#63; and status = &#63;.
6348             *
6349             * <p>
6350             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.bookmarks.model.impl.BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6351             * </p>
6352             *
6353             * @param groupId the group ID
6354             * @param userId the user ID
6355             * @param status the status
6356             * @param start the lower bound of the range of bookmarks entries
6357             * @param end the upper bound of the range of bookmarks entries (not inclusive)
6358             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6359             * @return the ordered range of matching bookmarks entries that the user has permission to view
6360             */
6361            @Override
6362            public List<BookmarksEntry> filterFindByG_U_S(long groupId, long userId,
6363                    int status, int start, int end,
6364                    OrderByComparator<BookmarksEntry> orderByComparator) {
6365                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6366                            return findByG_U_S(groupId, userId, status, start, end,
6367                                    orderByComparator);
6368                    }
6369    
6370                    StringBundler query = null;
6371    
6372                    if (orderByComparator != null) {
6373                            query = new StringBundler(5 +
6374                                            (orderByComparator.getOrderByFields().length * 3));
6375                    }
6376                    else {
6377                            query = new StringBundler(5);
6378                    }
6379    
6380                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
6381    
6382                    query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
6383    
6384                    query.append(_FINDER_COLUMN_G_U_S_USERID_2);
6385    
6386                    query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
6387    
6388                    if (orderByComparator != null) {
6389                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6390                                    orderByComparator);
6391                    }
6392                    else {
6393                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
6394                    }
6395    
6396                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6397                                    BookmarksEntry.class.getName(),
6398                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
6399                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
6400    
6401                    Session session = null;
6402    
6403                    try {
6404                            session = openSession();
6405    
6406                            Query q = session.createQuery(sql);
6407    
6408                            QueryPos qPos = QueryPos.getInstance(q);
6409    
6410                            qPos.add(groupId);
6411    
6412                            qPos.add(userId);
6413    
6414                            qPos.add(status);
6415    
6416                            return (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start,
6417                                    end);
6418                    }
6419                    catch (Exception e) {
6420                            throw processException(e);
6421                    }
6422                    finally {
6423                            closeSession(session);
6424                    }
6425            }
6426    
6427            /**
6428             * Returns the bookmarks entries before and after the current bookmarks entry in the ordered set of bookmarks entries that the user has permission to view where groupId = &#63; and userId = &#63; and status = &#63;.
6429             *
6430             * @param entryId the primary key of the current bookmarks entry
6431             * @param groupId the group ID
6432             * @param userId the user ID
6433             * @param status the status
6434             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6435             * @return the previous, current, and next bookmarks entry
6436             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
6437             */
6438            @Override
6439            public BookmarksEntry[] filterFindByG_U_S_PrevAndNext(long entryId,
6440                    long groupId, long userId, int status,
6441                    OrderByComparator<BookmarksEntry> orderByComparator)
6442                    throws NoSuchEntryException {
6443                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6444                            return findByG_U_S_PrevAndNext(entryId, groupId, userId, status,
6445                                    orderByComparator);
6446                    }
6447    
6448                    BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
6449    
6450                    Session session = null;
6451    
6452                    try {
6453                            session = openSession();
6454    
6455                            BookmarksEntry[] array = new BookmarksEntryImpl[3];
6456    
6457                            array[0] = filterGetByG_U_S_PrevAndNext(session, bookmarksEntry,
6458                                            groupId, userId, status, orderByComparator, true);
6459    
6460                            array[1] = bookmarksEntry;
6461    
6462                            array[2] = filterGetByG_U_S_PrevAndNext(session, bookmarksEntry,
6463                                            groupId, userId, status, orderByComparator, false);
6464    
6465                            return array;
6466                    }
6467                    catch (Exception e) {
6468                            throw processException(e);
6469                    }
6470                    finally {
6471                            closeSession(session);
6472                    }
6473            }
6474    
6475            protected BookmarksEntry filterGetByG_U_S_PrevAndNext(Session session,
6476                    BookmarksEntry bookmarksEntry, long groupId, long userId, int status,
6477                    OrderByComparator<BookmarksEntry> orderByComparator, boolean previous) {
6478                    StringBundler query = null;
6479    
6480                    if (orderByComparator != null) {
6481                            query = new StringBundler(6 +
6482                                            (orderByComparator.getOrderByFields().length * 6));
6483                    }
6484                    else {
6485                            query = new StringBundler(3);
6486                    }
6487    
6488                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
6489    
6490                    query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
6491    
6492                    query.append(_FINDER_COLUMN_G_U_S_USERID_2);
6493    
6494                    query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
6495    
6496                    if (orderByComparator != null) {
6497                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6498    
6499                            if (orderByConditionFields.length > 0) {
6500                                    query.append(WHERE_AND);
6501                            }
6502    
6503                            for (int i = 0; i < orderByConditionFields.length; i++) {
6504                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6505                                    query.append(orderByConditionFields[i]);
6506    
6507                                    if ((i + 1) < orderByConditionFields.length) {
6508                                            if (orderByComparator.isAscending() ^ previous) {
6509                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6510                                            }
6511                                            else {
6512                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6513                                            }
6514                                    }
6515                                    else {
6516                                            if (orderByComparator.isAscending() ^ previous) {
6517                                                    query.append(WHERE_GREATER_THAN);
6518                                            }
6519                                            else {
6520                                                    query.append(WHERE_LESSER_THAN);
6521                                            }
6522                                    }
6523                            }
6524    
6525                            query.append(ORDER_BY_CLAUSE);
6526    
6527                            String[] orderByFields = orderByComparator.getOrderByFields();
6528    
6529                            for (int i = 0; i < orderByFields.length; i++) {
6530                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6531                                    query.append(orderByFields[i]);
6532    
6533                                    if ((i + 1) < orderByFields.length) {
6534                                            if (orderByComparator.isAscending() ^ previous) {
6535                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6536                                            }
6537                                            else {
6538                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6539                                            }
6540                                    }
6541                                    else {
6542                                            if (orderByComparator.isAscending() ^ previous) {
6543                                                    query.append(ORDER_BY_ASC);
6544                                            }
6545                                            else {
6546                                                    query.append(ORDER_BY_DESC);
6547                                            }
6548                                    }
6549                            }
6550                    }
6551                    else {
6552                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
6553                    }
6554    
6555                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6556                                    BookmarksEntry.class.getName(),
6557                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
6558                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
6559    
6560                    Query q = session.createQuery(sql);
6561    
6562                    q.setFirstResult(0);
6563                    q.setMaxResults(2);
6564    
6565                    QueryPos qPos = QueryPos.getInstance(q);
6566    
6567                    qPos.add(groupId);
6568    
6569                    qPos.add(userId);
6570    
6571                    qPos.add(status);
6572    
6573                    if (orderByComparator != null) {
6574                            Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry);
6575    
6576                            for (Object value : values) {
6577                                    qPos.add(value);
6578                            }
6579                    }
6580    
6581                    List<BookmarksEntry> list = q.list();
6582    
6583                    if (list.size() == 2) {
6584                            return list.get(1);
6585                    }
6586                    else {
6587                            return null;
6588                    }
6589            }
6590    
6591            /**
6592             * Removes all the bookmarks entries where groupId = &#63; and userId = &#63; and status = &#63; from the database.
6593             *
6594             * @param groupId the group ID
6595             * @param userId the user ID
6596             * @param status the status
6597             */
6598            @Override
6599            public void removeByG_U_S(long groupId, long userId, int status) {
6600                    for (BookmarksEntry bookmarksEntry : findByG_U_S(groupId, userId,
6601                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
6602                            remove(bookmarksEntry);
6603                    }
6604            }
6605    
6606            /**
6607             * Returns the number of bookmarks entries where groupId = &#63; and userId = &#63; and status = &#63;.
6608             *
6609             * @param groupId the group ID
6610             * @param userId the user ID
6611             * @param status the status
6612             * @return the number of matching bookmarks entries
6613             */
6614            @Override
6615            public int countByG_U_S(long groupId, long userId, int status) {
6616                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_U_S;
6617    
6618                    Object[] finderArgs = new Object[] { groupId, userId, status };
6619    
6620                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
6621                                    this);
6622    
6623                    if (count == null) {
6624                            StringBundler query = new StringBundler(4);
6625    
6626                            query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
6627    
6628                            query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
6629    
6630                            query.append(_FINDER_COLUMN_G_U_S_USERID_2);
6631    
6632                            query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
6633    
6634                            String sql = query.toString();
6635    
6636                            Session session = null;
6637    
6638                            try {
6639                                    session = openSession();
6640    
6641                                    Query q = session.createQuery(sql);
6642    
6643                                    QueryPos qPos = QueryPos.getInstance(q);
6644    
6645                                    qPos.add(groupId);
6646    
6647                                    qPos.add(userId);
6648    
6649                                    qPos.add(status);
6650    
6651                                    count = (Long)q.uniqueResult();
6652    
6653                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
6654                            }
6655                            catch (Exception e) {
6656                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6657    
6658                                    throw processException(e);
6659                            }
6660                            finally {
6661                                    closeSession(session);
6662                            }
6663                    }
6664    
6665                    return count.intValue();
6666            }
6667    
6668            /**
6669             * Returns the number of bookmarks entries that the user has permission to view where groupId = &#63; and userId = &#63; and status = &#63;.
6670             *
6671             * @param groupId the group ID
6672             * @param userId the user ID
6673             * @param status the status
6674             * @return the number of matching bookmarks entries that the user has permission to view
6675             */
6676            @Override
6677            public int filterCountByG_U_S(long groupId, long userId, int status) {
6678                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6679                            return countByG_U_S(groupId, userId, status);
6680                    }
6681    
6682                    StringBundler query = new StringBundler(4);
6683    
6684                    query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
6685    
6686                    query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
6687    
6688                    query.append(_FINDER_COLUMN_G_U_S_USERID_2);
6689    
6690                    query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
6691    
6692                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6693                                    BookmarksEntry.class.getName(),
6694                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
6695                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
6696    
6697                    Session session = null;
6698    
6699                    try {
6700                            session = openSession();
6701    
6702                            Query q = session.createQuery(sql);
6703    
6704                            QueryPos qPos = QueryPos.getInstance(q);
6705    
6706                            qPos.add(groupId);
6707    
6708                            qPos.add(userId);
6709    
6710                            qPos.add(status);
6711    
6712                            Long count = (Long)q.uniqueResult();
6713    
6714                            return count.intValue();
6715                    }
6716                    catch (Exception e) {
6717                            throw processException(e);
6718                    }
6719                    finally {
6720                            closeSession(session);
6721                    }
6722            }
6723    
6724            private static final String _FINDER_COLUMN_G_U_S_GROUPID_2 = "bookmarksEntry.groupId = ? AND ";
6725            private static final String _FINDER_COLUMN_G_U_S_USERID_2 = "bookmarksEntry.userId = ? AND ";
6726            private static final String _FINDER_COLUMN_G_U_S_STATUS_2 = "bookmarksEntry.status = ?";
6727            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_NOTS = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
6728                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
6729                            BookmarksEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
6730                            "findByG_U_NotS",
6731                            new String[] {
6732                                    Long.class.getName(), Long.class.getName(),
6733                                    Integer.class.getName(),
6734                                    
6735                            Integer.class.getName(), Integer.class.getName(),
6736                                    OrderByComparator.class.getName()
6737                            });
6738            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_NOTS =
6739                    new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
6740                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
6741                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_U_NotS",
6742                            new String[] {
6743                                    Long.class.getName(), Long.class.getName(),
6744                                    Integer.class.getName()
6745                            });
6746    
6747            /**
6748             * Returns all the bookmarks entries where groupId = &#63; and userId = &#63; and status &ne; &#63;.
6749             *
6750             * @param groupId the group ID
6751             * @param userId the user ID
6752             * @param status the status
6753             * @return the matching bookmarks entries
6754             */
6755            @Override
6756            public List<BookmarksEntry> findByG_U_NotS(long groupId, long userId,
6757                    int status) {
6758                    return findByG_U_NotS(groupId, userId, status, QueryUtil.ALL_POS,
6759                            QueryUtil.ALL_POS, null);
6760            }
6761    
6762            /**
6763             * Returns a range of all the bookmarks entries where groupId = &#63; and userId = &#63; and status &ne; &#63;.
6764             *
6765             * <p>
6766             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.bookmarks.model.impl.BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6767             * </p>
6768             *
6769             * @param groupId the group ID
6770             * @param userId the user ID
6771             * @param status the status
6772             * @param start the lower bound of the range of bookmarks entries
6773             * @param end the upper bound of the range of bookmarks entries (not inclusive)
6774             * @return the range of matching bookmarks entries
6775             */
6776            @Override
6777            public List<BookmarksEntry> findByG_U_NotS(long groupId, long userId,
6778                    int status, int start, int end) {
6779                    return findByG_U_NotS(groupId, userId, status, start, end, null);
6780            }
6781    
6782            /**
6783             * Returns an ordered range of all the bookmarks entries where groupId = &#63; and userId = &#63; and status &ne; &#63;.
6784             *
6785             * <p>
6786             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.bookmarks.model.impl.BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6787             * </p>
6788             *
6789             * @param groupId the group ID
6790             * @param userId the user ID
6791             * @param status the status
6792             * @param start the lower bound of the range of bookmarks entries
6793             * @param end the upper bound of the range of bookmarks entries (not inclusive)
6794             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6795             * @return the ordered range of matching bookmarks entries
6796             */
6797            @Override
6798            public List<BookmarksEntry> findByG_U_NotS(long groupId, long userId,
6799                    int status, int start, int end,
6800                    OrderByComparator<BookmarksEntry> orderByComparator) {
6801                    boolean pagination = true;
6802                    FinderPath finderPath = null;
6803                    Object[] finderArgs = null;
6804    
6805                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_NOTS;
6806                    finderArgs = new Object[] {
6807                                    groupId, userId, status,
6808                                    
6809                                    start, end, orderByComparator
6810                            };
6811    
6812                    List<BookmarksEntry> list = (List<BookmarksEntry>)FinderCacheUtil.getResult(finderPath,
6813                                    finderArgs, this);
6814    
6815                    if ((list != null) && !list.isEmpty()) {
6816                            for (BookmarksEntry bookmarksEntry : list) {
6817                                    if ((groupId != bookmarksEntry.getGroupId()) ||
6818                                                    (userId != bookmarksEntry.getUserId()) ||
6819                                                    (status == bookmarksEntry.getStatus())) {
6820                                            list = null;
6821    
6822                                            break;
6823                                    }
6824                            }
6825                    }
6826    
6827                    if (list == null) {
6828                            StringBundler query = null;
6829    
6830                            if (orderByComparator != null) {
6831                                    query = new StringBundler(5 +
6832                                                    (orderByComparator.getOrderByFields().length * 3));
6833                            }
6834                            else {
6835                                    query = new StringBundler(5);
6836                            }
6837    
6838                            query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
6839    
6840                            query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
6841    
6842                            query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
6843    
6844                            query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
6845    
6846                            if (orderByComparator != null) {
6847                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6848                                            orderByComparator);
6849                            }
6850                            else
6851                             if (pagination) {
6852                                    query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
6853                            }
6854    
6855                            String sql = query.toString();
6856    
6857                            Session session = null;
6858    
6859                            try {
6860                                    session = openSession();
6861    
6862                                    Query q = session.createQuery(sql);
6863    
6864                                    QueryPos qPos = QueryPos.getInstance(q);
6865    
6866                                    qPos.add(groupId);
6867    
6868                                    qPos.add(userId);
6869    
6870                                    qPos.add(status);
6871    
6872                                    if (!pagination) {
6873                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
6874                                                            getDialect(), start, end, false);
6875    
6876                                            Collections.sort(list);
6877    
6878                                            list = Collections.unmodifiableList(list);
6879                                    }
6880                                    else {
6881                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
6882                                                            getDialect(), start, end);
6883                                    }
6884    
6885                                    cacheResult(list);
6886    
6887                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
6888                            }
6889                            catch (Exception e) {
6890                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6891    
6892                                    throw processException(e);
6893                            }
6894                            finally {
6895                                    closeSession(session);
6896                            }
6897                    }
6898    
6899                    return list;
6900            }
6901    
6902            /**
6903             * Returns the first bookmarks entry in the ordered set where groupId = &#63; and userId = &#63; and status &ne; &#63;.
6904             *
6905             * @param groupId the group ID
6906             * @param userId the user ID
6907             * @param status the status
6908             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6909             * @return the first matching bookmarks entry
6910             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
6911             */
6912            @Override
6913            public BookmarksEntry findByG_U_NotS_First(long groupId, long userId,
6914                    int status, OrderByComparator<BookmarksEntry> orderByComparator)
6915                    throws NoSuchEntryException {
6916                    BookmarksEntry bookmarksEntry = fetchByG_U_NotS_First(groupId, userId,
6917                                    status, orderByComparator);
6918    
6919                    if (bookmarksEntry != null) {
6920                            return bookmarksEntry;
6921                    }
6922    
6923                    StringBundler msg = new StringBundler(8);
6924    
6925                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6926    
6927                    msg.append("groupId=");
6928                    msg.append(groupId);
6929    
6930                    msg.append(", userId=");
6931                    msg.append(userId);
6932    
6933                    msg.append(", status=");
6934                    msg.append(status);
6935    
6936                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6937    
6938                    throw new NoSuchEntryException(msg.toString());
6939            }
6940    
6941            /**
6942             * Returns the first bookmarks entry in the ordered set where groupId = &#63; and userId = &#63; and status &ne; &#63;.
6943             *
6944             * @param groupId the group ID
6945             * @param userId the user ID
6946             * @param status the status
6947             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6948             * @return the first matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
6949             */
6950            @Override
6951            public BookmarksEntry fetchByG_U_NotS_First(long groupId, long userId,
6952                    int status, OrderByComparator<BookmarksEntry> orderByComparator) {
6953                    List<BookmarksEntry> list = findByG_U_NotS(groupId, userId, status, 0,
6954                                    1, orderByComparator);
6955    
6956                    if (!list.isEmpty()) {
6957                            return list.get(0);
6958                    }
6959    
6960                    return null;
6961            }
6962    
6963            /**
6964             * Returns the last bookmarks entry in the ordered set where groupId = &#63; and userId = &#63; and status &ne; &#63;.
6965             *
6966             * @param groupId the group ID
6967             * @param userId the user ID
6968             * @param status the status
6969             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6970             * @return the last matching bookmarks entry
6971             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
6972             */
6973            @Override
6974            public BookmarksEntry findByG_U_NotS_Last(long groupId, long userId,
6975                    int status, OrderByComparator<BookmarksEntry> orderByComparator)
6976                    throws NoSuchEntryException {
6977                    BookmarksEntry bookmarksEntry = fetchByG_U_NotS_Last(groupId, userId,
6978                                    status, orderByComparator);
6979    
6980                    if (bookmarksEntry != null) {
6981                            return bookmarksEntry;
6982                    }
6983    
6984                    StringBundler msg = new StringBundler(8);
6985    
6986                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6987    
6988                    msg.append("groupId=");
6989                    msg.append(groupId);
6990    
6991                    msg.append(", userId=");
6992                    msg.append(userId);
6993    
6994                    msg.append(", status=");
6995                    msg.append(status);
6996    
6997                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6998    
6999                    throw new NoSuchEntryException(msg.toString());
7000            }
7001    
7002            /**
7003             * Returns the last bookmarks entry in the ordered set where groupId = &#63; and userId = &#63; and status &ne; &#63;.
7004             *
7005             * @param groupId the group ID
7006             * @param userId the user ID
7007             * @param status the status
7008             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7009             * @return the last matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
7010             */
7011            @Override
7012            public BookmarksEntry fetchByG_U_NotS_Last(long groupId, long userId,
7013                    int status, OrderByComparator<BookmarksEntry> orderByComparator) {
7014                    int count = countByG_U_NotS(groupId, userId, status);
7015    
7016                    if (count == 0) {
7017                            return null;
7018                    }
7019    
7020                    List<BookmarksEntry> list = findByG_U_NotS(groupId, userId, status,
7021                                    count - 1, count, orderByComparator);
7022    
7023                    if (!list.isEmpty()) {
7024                            return list.get(0);
7025                    }
7026    
7027                    return null;
7028            }
7029    
7030            /**
7031             * Returns the bookmarks entries before and after the current bookmarks entry in the ordered set where groupId = &#63; and userId = &#63; and status &ne; &#63;.
7032             *
7033             * @param entryId the primary key of the current bookmarks entry
7034             * @param groupId the group ID
7035             * @param userId the user ID
7036             * @param status the status
7037             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7038             * @return the previous, current, and next bookmarks entry
7039             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
7040             */
7041            @Override
7042            public BookmarksEntry[] findByG_U_NotS_PrevAndNext(long entryId,
7043                    long groupId, long userId, int status,
7044                    OrderByComparator<BookmarksEntry> orderByComparator)
7045                    throws NoSuchEntryException {
7046                    BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
7047    
7048                    Session session = null;
7049    
7050                    try {
7051                            session = openSession();
7052    
7053                            BookmarksEntry[] array = new BookmarksEntryImpl[3];
7054    
7055                            array[0] = getByG_U_NotS_PrevAndNext(session, bookmarksEntry,
7056                                            groupId, userId, status, orderByComparator, true);
7057    
7058                            array[1] = bookmarksEntry;
7059    
7060                            array[2] = getByG_U_NotS_PrevAndNext(session, bookmarksEntry,
7061                                            groupId, userId, status, orderByComparator, false);
7062    
7063                            return array;
7064                    }
7065                    catch (Exception e) {
7066                            throw processException(e);
7067                    }
7068                    finally {
7069                            closeSession(session);
7070                    }
7071            }
7072    
7073            protected BookmarksEntry getByG_U_NotS_PrevAndNext(Session session,
7074                    BookmarksEntry bookmarksEntry, long groupId, long userId, int status,
7075                    OrderByComparator<BookmarksEntry> orderByComparator, boolean previous) {
7076                    StringBundler query = null;
7077    
7078                    if (orderByComparator != null) {
7079                            query = new StringBundler(6 +
7080                                            (orderByComparator.getOrderByFields().length * 6));
7081                    }
7082                    else {
7083                            query = new StringBundler(3);
7084                    }
7085    
7086                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
7087    
7088                    query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
7089    
7090                    query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
7091    
7092                    query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
7093    
7094                    if (orderByComparator != null) {
7095                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7096    
7097                            if (orderByConditionFields.length > 0) {
7098                                    query.append(WHERE_AND);
7099                            }
7100    
7101                            for (int i = 0; i < orderByConditionFields.length; i++) {
7102                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7103                                    query.append(orderByConditionFields[i]);
7104    
7105                                    if ((i + 1) < orderByConditionFields.length) {
7106                                            if (orderByComparator.isAscending() ^ previous) {
7107                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7108                                            }
7109                                            else {
7110                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7111                                            }
7112                                    }
7113                                    else {
7114                                            if (orderByComparator.isAscending() ^ previous) {
7115                                                    query.append(WHERE_GREATER_THAN);
7116                                            }
7117                                            else {
7118                                                    query.append(WHERE_LESSER_THAN);
7119                                            }
7120                                    }
7121                            }
7122    
7123                            query.append(ORDER_BY_CLAUSE);
7124    
7125                            String[] orderByFields = orderByComparator.getOrderByFields();
7126    
7127                            for (int i = 0; i < orderByFields.length; i++) {
7128                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7129                                    query.append(orderByFields[i]);
7130    
7131                                    if ((i + 1) < orderByFields.length) {
7132                                            if (orderByComparator.isAscending() ^ previous) {
7133                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7134                                            }
7135                                            else {
7136                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7137                                            }
7138                                    }
7139                                    else {
7140                                            if (orderByComparator.isAscending() ^ previous) {
7141                                                    query.append(ORDER_BY_ASC);
7142                                            }
7143                                            else {
7144                                                    query.append(ORDER_BY_DESC);
7145                                            }
7146                                    }
7147                            }
7148                    }
7149                    else {
7150                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
7151                    }
7152    
7153                    String sql = query.toString();
7154    
7155                    Query q = session.createQuery(sql);
7156    
7157                    q.setFirstResult(0);
7158                    q.setMaxResults(2);
7159    
7160                    QueryPos qPos = QueryPos.getInstance(q);
7161    
7162                    qPos.add(groupId);
7163    
7164                    qPos.add(userId);
7165    
7166                    qPos.add(status);
7167    
7168                    if (orderByComparator != null) {
7169                            Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry);
7170    
7171                            for (Object value : values) {
7172                                    qPos.add(value);
7173                            }
7174                    }
7175    
7176                    List<BookmarksEntry> list = q.list();
7177    
7178                    if (list.size() == 2) {
7179                            return list.get(1);
7180                    }
7181                    else {
7182                            return null;
7183                    }
7184            }
7185    
7186            /**
7187             * Returns all the bookmarks entries that the user has permission to view where groupId = &#63; and userId = &#63; and status &ne; &#63;.
7188             *
7189             * @param groupId the group ID
7190             * @param userId the user ID
7191             * @param status the status
7192             * @return the matching bookmarks entries that the user has permission to view
7193             */
7194            @Override
7195            public List<BookmarksEntry> filterFindByG_U_NotS(long groupId, long userId,
7196                    int status) {
7197                    return filterFindByG_U_NotS(groupId, userId, status, QueryUtil.ALL_POS,
7198                            QueryUtil.ALL_POS, null);
7199            }
7200    
7201            /**
7202             * Returns a range of all the bookmarks entries that the user has permission to view where groupId = &#63; and userId = &#63; and status &ne; &#63;.
7203             *
7204             * <p>
7205             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.bookmarks.model.impl.BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7206             * </p>
7207             *
7208             * @param groupId the group ID
7209             * @param userId the user ID
7210             * @param status the status
7211             * @param start the lower bound of the range of bookmarks entries
7212             * @param end the upper bound of the range of bookmarks entries (not inclusive)
7213             * @return the range of matching bookmarks entries that the user has permission to view
7214             */
7215            @Override
7216            public List<BookmarksEntry> filterFindByG_U_NotS(long groupId, long userId,
7217                    int status, int start, int end) {
7218                    return filterFindByG_U_NotS(groupId, userId, status, start, end, null);
7219            }
7220    
7221            /**
7222             * Returns an ordered range of all the bookmarks entries that the user has permissions to view where groupId = &#63; and userId = &#63; and status &ne; &#63;.
7223             *
7224             * <p>
7225             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.bookmarks.model.impl.BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7226             * </p>
7227             *
7228             * @param groupId the group ID
7229             * @param userId the user ID
7230             * @param status the status
7231             * @param start the lower bound of the range of bookmarks entries
7232             * @param end the upper bound of the range of bookmarks entries (not inclusive)
7233             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7234             * @return the ordered range of matching bookmarks entries that the user has permission to view
7235             */
7236            @Override
7237            public List<BookmarksEntry> filterFindByG_U_NotS(long groupId, long userId,
7238                    int status, int start, int end,
7239                    OrderByComparator<BookmarksEntry> orderByComparator) {
7240                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7241                            return findByG_U_NotS(groupId, userId, status, start, end,
7242                                    orderByComparator);
7243                    }
7244    
7245                    StringBundler query = null;
7246    
7247                    if (orderByComparator != null) {
7248                            query = new StringBundler(5 +
7249                                            (orderByComparator.getOrderByFields().length * 3));
7250                    }
7251                    else {
7252                            query = new StringBundler(5);
7253                    }
7254    
7255                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
7256    
7257                    query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
7258    
7259                    query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
7260    
7261                    query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
7262    
7263                    if (orderByComparator != null) {
7264                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7265                                    orderByComparator);
7266                    }
7267                    else {
7268                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
7269                    }
7270    
7271                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7272                                    BookmarksEntry.class.getName(),
7273                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
7274                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
7275    
7276                    Session session = null;
7277    
7278                    try {
7279                            session = openSession();
7280    
7281                            Query q = session.createQuery(sql);
7282    
7283                            QueryPos qPos = QueryPos.getInstance(q);
7284    
7285                            qPos.add(groupId);
7286    
7287                            qPos.add(userId);
7288    
7289                            qPos.add(status);
7290    
7291                            return (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start,
7292                                    end);
7293                    }
7294                    catch (Exception e) {
7295                            throw processException(e);
7296                    }
7297                    finally {
7298                            closeSession(session);
7299                    }
7300            }
7301    
7302            /**
7303             * Returns the bookmarks entries before and after the current bookmarks entry in the ordered set of bookmarks entries that the user has permission to view where groupId = &#63; and userId = &#63; and status &ne; &#63;.
7304             *
7305             * @param entryId the primary key of the current bookmarks entry
7306             * @param groupId the group ID
7307             * @param userId the user ID
7308             * @param status the status
7309             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7310             * @return the previous, current, and next bookmarks entry
7311             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
7312             */
7313            @Override
7314            public BookmarksEntry[] filterFindByG_U_NotS_PrevAndNext(long entryId,
7315                    long groupId, long userId, int status,
7316                    OrderByComparator<BookmarksEntry> orderByComparator)
7317                    throws NoSuchEntryException {
7318                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7319                            return findByG_U_NotS_PrevAndNext(entryId, groupId, userId, status,
7320                                    orderByComparator);
7321                    }
7322    
7323                    BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
7324    
7325                    Session session = null;
7326    
7327                    try {
7328                            session = openSession();
7329    
7330                            BookmarksEntry[] array = new BookmarksEntryImpl[3];
7331    
7332                            array[0] = filterGetByG_U_NotS_PrevAndNext(session, bookmarksEntry,
7333                                            groupId, userId, status, orderByComparator, true);
7334    
7335                            array[1] = bookmarksEntry;
7336    
7337                            array[2] = filterGetByG_U_NotS_PrevAndNext(session, bookmarksEntry,
7338                                            groupId, userId, status, orderByComparator, false);
7339    
7340                            return array;
7341                    }
7342                    catch (Exception e) {
7343                            throw processException(e);
7344                    }
7345                    finally {
7346                            closeSession(session);
7347                    }
7348            }
7349    
7350            protected BookmarksEntry filterGetByG_U_NotS_PrevAndNext(Session session,
7351                    BookmarksEntry bookmarksEntry, long groupId, long userId, int status,
7352                    OrderByComparator<BookmarksEntry> orderByComparator, boolean previous) {
7353                    StringBundler query = null;
7354    
7355                    if (orderByComparator != null) {
7356                            query = new StringBundler(6 +
7357                                            (orderByComparator.getOrderByFields().length * 6));
7358                    }
7359                    else {
7360                            query = new StringBundler(3);
7361                    }
7362    
7363                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
7364    
7365                    query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
7366    
7367                    query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
7368    
7369                    query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
7370    
7371                    if (orderByComparator != null) {
7372                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7373    
7374                            if (orderByConditionFields.length > 0) {
7375                                    query.append(WHERE_AND);
7376                            }
7377    
7378                            for (int i = 0; i < orderByConditionFields.length; i++) {
7379                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7380                                    query.append(orderByConditionFields[i]);
7381    
7382                                    if ((i + 1) < orderByConditionFields.length) {
7383                                            if (orderByComparator.isAscending() ^ previous) {
7384                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7385                                            }
7386                                            else {
7387                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7388                                            }
7389                                    }
7390                                    else {
7391                                            if (orderByComparator.isAscending() ^ previous) {
7392                                                    query.append(WHERE_GREATER_THAN);
7393                                            }
7394                                            else {
7395                                                    query.append(WHERE_LESSER_THAN);
7396                                            }
7397                                    }
7398                            }
7399    
7400                            query.append(ORDER_BY_CLAUSE);
7401    
7402                            String[] orderByFields = orderByComparator.getOrderByFields();
7403    
7404                            for (int i = 0; i < orderByFields.length; i++) {
7405                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7406                                    query.append(orderByFields[i]);
7407    
7408                                    if ((i + 1) < orderByFields.length) {
7409                                            if (orderByComparator.isAscending() ^ previous) {
7410                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7411                                            }
7412                                            else {
7413                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7414                                            }
7415                                    }
7416                                    else {
7417                                            if (orderByComparator.isAscending() ^ previous) {
7418                                                    query.append(ORDER_BY_ASC);
7419                                            }
7420                                            else {
7421                                                    query.append(ORDER_BY_DESC);
7422                                            }
7423                                    }
7424                            }
7425                    }
7426                    else {
7427                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
7428                    }
7429    
7430                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7431                                    BookmarksEntry.class.getName(),
7432                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
7433                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
7434    
7435                    Query q = session.createQuery(sql);
7436    
7437                    q.setFirstResult(0);
7438                    q.setMaxResults(2);
7439    
7440                    QueryPos qPos = QueryPos.getInstance(q);
7441    
7442                    qPos.add(groupId);
7443    
7444                    qPos.add(userId);
7445    
7446                    qPos.add(status);
7447    
7448                    if (orderByComparator != null) {
7449                            Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry);
7450    
7451                            for (Object value : values) {
7452                                    qPos.add(value);
7453                            }
7454                    }
7455    
7456                    List<BookmarksEntry> list = q.list();
7457    
7458                    if (list.size() == 2) {
7459                            return list.get(1);
7460                    }
7461                    else {
7462                            return null;
7463                    }
7464            }
7465    
7466            /**
7467             * Removes all the bookmarks entries where groupId = &#63; and userId = &#63; and status &ne; &#63; from the database.
7468             *
7469             * @param groupId the group ID
7470             * @param userId the user ID
7471             * @param status the status
7472             */
7473            @Override
7474            public void removeByG_U_NotS(long groupId, long userId, int status) {
7475                    for (BookmarksEntry bookmarksEntry : findByG_U_NotS(groupId, userId,
7476                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
7477                            remove(bookmarksEntry);
7478                    }
7479            }
7480    
7481            /**
7482             * Returns the number of bookmarks entries where groupId = &#63; and userId = &#63; and status &ne; &#63;.
7483             *
7484             * @param groupId the group ID
7485             * @param userId the user ID
7486             * @param status the status
7487             * @return the number of matching bookmarks entries
7488             */
7489            @Override
7490            public int countByG_U_NotS(long groupId, long userId, int status) {
7491                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_NOTS;
7492    
7493                    Object[] finderArgs = new Object[] { groupId, userId, status };
7494    
7495                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
7496                                    this);
7497    
7498                    if (count == null) {
7499                            StringBundler query = new StringBundler(4);
7500    
7501                            query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
7502    
7503                            query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
7504    
7505                            query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
7506    
7507                            query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
7508    
7509                            String sql = query.toString();
7510    
7511                            Session session = null;
7512    
7513                            try {
7514                                    session = openSession();
7515    
7516                                    Query q = session.createQuery(sql);
7517    
7518                                    QueryPos qPos = QueryPos.getInstance(q);
7519    
7520                                    qPos.add(groupId);
7521    
7522                                    qPos.add(userId);
7523    
7524                                    qPos.add(status);
7525    
7526                                    count = (Long)q.uniqueResult();
7527    
7528                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
7529                            }
7530                            catch (Exception e) {
7531                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
7532    
7533                                    throw processException(e);
7534                            }
7535                            finally {
7536                                    closeSession(session);
7537                            }
7538                    }
7539    
7540                    return count.intValue();
7541            }
7542    
7543            /**
7544             * Returns the number of bookmarks entries that the user has permission to view where groupId = &#63; and userId = &#63; and status &ne; &#63;.
7545             *
7546             * @param groupId the group ID
7547             * @param userId the user ID
7548             * @param status the status
7549             * @return the number of matching bookmarks entries that the user has permission to view
7550             */
7551            @Override
7552            public int filterCountByG_U_NotS(long groupId, long userId, int status) {
7553                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7554                            return countByG_U_NotS(groupId, userId, status);
7555                    }
7556    
7557                    StringBundler query = new StringBundler(4);
7558    
7559                    query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
7560    
7561                    query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
7562    
7563                    query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
7564    
7565                    query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
7566    
7567                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7568                                    BookmarksEntry.class.getName(),
7569                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
7570                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
7571    
7572                    Session session = null;
7573    
7574                    try {
7575                            session = openSession();
7576    
7577                            Query q = session.createQuery(sql);
7578    
7579                            QueryPos qPos = QueryPos.getInstance(q);
7580    
7581                            qPos.add(groupId);
7582    
7583                            qPos.add(userId);
7584    
7585                            qPos.add(status);
7586    
7587                            Long count = (Long)q.uniqueResult();
7588    
7589                            return count.intValue();
7590                    }
7591                    catch (Exception e) {
7592                            throw processException(e);
7593                    }
7594                    finally {
7595                            closeSession(session);
7596                    }
7597            }
7598    
7599            private static final String _FINDER_COLUMN_G_U_NOTS_GROUPID_2 = "bookmarksEntry.groupId = ? AND ";
7600            private static final String _FINDER_COLUMN_G_U_NOTS_USERID_2 = "bookmarksEntry.userId = ? AND ";
7601            private static final String _FINDER_COLUMN_G_U_NOTS_STATUS_2 = "bookmarksEntry.status != ?";
7602            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_S = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
7603                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
7604                            BookmarksEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
7605                            "findByG_F_S",
7606                            new String[] {
7607                                    Long.class.getName(), Long.class.getName(),
7608                                    Integer.class.getName(),
7609                                    
7610                            Integer.class.getName(), Integer.class.getName(),
7611                                    OrderByComparator.class.getName()
7612                            });
7613            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_S = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
7614                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
7615                            BookmarksEntryImpl.class,
7616                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_F_S",
7617                            new String[] {
7618                                    Long.class.getName(), Long.class.getName(),
7619                                    Integer.class.getName()
7620                            },
7621                            BookmarksEntryModelImpl.GROUPID_COLUMN_BITMASK |
7622                            BookmarksEntryModelImpl.FOLDERID_COLUMN_BITMASK |
7623                            BookmarksEntryModelImpl.STATUS_COLUMN_BITMASK |
7624                            BookmarksEntryModelImpl.NAME_COLUMN_BITMASK);
7625            public static final FinderPath FINDER_PATH_COUNT_BY_G_F_S = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
7626                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
7627                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_F_S",
7628                            new String[] {
7629                                    Long.class.getName(), Long.class.getName(),
7630                                    Integer.class.getName()
7631                            });
7632            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_S = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
7633                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
7634                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_F_S",
7635                            new String[] {
7636                                    Long.class.getName(), Long.class.getName(),
7637                                    Integer.class.getName()
7638                            });
7639    
7640            /**
7641             * Returns all the bookmarks entries where groupId = &#63; and folderId = &#63; and status = &#63;.
7642             *
7643             * @param groupId the group ID
7644             * @param folderId the folder ID
7645             * @param status the status
7646             * @return the matching bookmarks entries
7647             */
7648            @Override
7649            public List<BookmarksEntry> findByG_F_S(long groupId, long folderId,
7650                    int status) {
7651                    return findByG_F_S(groupId, folderId, status, QueryUtil.ALL_POS,
7652                            QueryUtil.ALL_POS, null);
7653            }
7654    
7655            /**
7656             * Returns a range of all the bookmarks entries where groupId = &#63; and folderId = &#63; and status = &#63;.
7657             *
7658             * <p>
7659             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.bookmarks.model.impl.BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7660             * </p>
7661             *
7662             * @param groupId the group ID
7663             * @param folderId the folder ID
7664             * @param status the status
7665             * @param start the lower bound of the range of bookmarks entries
7666             * @param end the upper bound of the range of bookmarks entries (not inclusive)
7667             * @return the range of matching bookmarks entries
7668             */
7669            @Override
7670            public List<BookmarksEntry> findByG_F_S(long groupId, long folderId,
7671                    int status, int start, int end) {
7672                    return findByG_F_S(groupId, folderId, status, start, end, null);
7673            }
7674    
7675            /**
7676             * Returns an ordered range of all the bookmarks entries where groupId = &#63; and folderId = &#63; and status = &#63;.
7677             *
7678             * <p>
7679             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.bookmarks.model.impl.BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7680             * </p>
7681             *
7682             * @param groupId the group ID
7683             * @param folderId the folder ID
7684             * @param status the status
7685             * @param start the lower bound of the range of bookmarks entries
7686             * @param end the upper bound of the range of bookmarks entries (not inclusive)
7687             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7688             * @return the ordered range of matching bookmarks entries
7689             */
7690            @Override
7691            public List<BookmarksEntry> findByG_F_S(long groupId, long folderId,
7692                    int status, int start, int end,
7693                    OrderByComparator<BookmarksEntry> orderByComparator) {
7694                    boolean pagination = true;
7695                    FinderPath finderPath = null;
7696                    Object[] finderArgs = null;
7697    
7698                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
7699                                    (orderByComparator == null)) {
7700                            pagination = false;
7701                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_S;
7702                            finderArgs = new Object[] { groupId, folderId, status };
7703                    }
7704                    else {
7705                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_S;
7706                            finderArgs = new Object[] {
7707                                            groupId, folderId, status,
7708                                            
7709                                            start, end, orderByComparator
7710                                    };
7711                    }
7712    
7713                    List<BookmarksEntry> list = (List<BookmarksEntry>)FinderCacheUtil.getResult(finderPath,
7714                                    finderArgs, this);
7715    
7716                    if ((list != null) && !list.isEmpty()) {
7717                            for (BookmarksEntry bookmarksEntry : list) {
7718                                    if ((groupId != bookmarksEntry.getGroupId()) ||
7719                                                    (folderId != bookmarksEntry.getFolderId()) ||
7720                                                    (status != bookmarksEntry.getStatus())) {
7721                                            list = null;
7722    
7723                                            break;
7724                                    }
7725                            }
7726                    }
7727    
7728                    if (list == null) {
7729                            StringBundler query = null;
7730    
7731                            if (orderByComparator != null) {
7732                                    query = new StringBundler(5 +
7733                                                    (orderByComparator.getOrderByFields().length * 3));
7734                            }
7735                            else {
7736                                    query = new StringBundler(5);
7737                            }
7738    
7739                            query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
7740    
7741                            query.append(_FINDER_COLUMN_G_F_S_GROUPID_2);
7742    
7743                            query.append(_FINDER_COLUMN_G_F_S_FOLDERID_2);
7744    
7745                            query.append(_FINDER_COLUMN_G_F_S_STATUS_2);
7746    
7747                            if (orderByComparator != null) {
7748                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7749                                            orderByComparator);
7750                            }
7751                            else
7752                             if (pagination) {
7753                                    query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
7754                            }
7755    
7756                            String sql = query.toString();
7757    
7758                            Session session = null;
7759    
7760                            try {
7761                                    session = openSession();
7762    
7763                                    Query q = session.createQuery(sql);
7764    
7765                                    QueryPos qPos = QueryPos.getInstance(q);
7766    
7767                                    qPos.add(groupId);
7768    
7769                                    qPos.add(folderId);
7770    
7771                                    qPos.add(status);
7772    
7773                                    if (!pagination) {
7774                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
7775                                                            getDialect(), start, end, false);
7776    
7777                                            Collections.sort(list);
7778    
7779                                            list = Collections.unmodifiableList(list);
7780                                    }
7781                                    else {
7782                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
7783                                                            getDialect(), start, end);
7784                                    }
7785    
7786                                    cacheResult(list);
7787    
7788                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
7789                            }
7790                            catch (Exception e) {
7791                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
7792    
7793                                    throw processException(e);
7794                            }
7795                            finally {
7796                                    closeSession(session);
7797                            }
7798                    }
7799    
7800                    return list;
7801            }
7802    
7803            /**
7804             * Returns the first bookmarks entry in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
7805             *
7806             * @param groupId the group ID
7807             * @param folderId the folder ID
7808             * @param status the status
7809             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7810             * @return the first matching bookmarks entry
7811             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
7812             */
7813            @Override
7814            public BookmarksEntry findByG_F_S_First(long groupId, long folderId,
7815                    int status, OrderByComparator<BookmarksEntry> orderByComparator)
7816                    throws NoSuchEntryException {
7817                    BookmarksEntry bookmarksEntry = fetchByG_F_S_First(groupId, folderId,
7818                                    status, orderByComparator);
7819    
7820                    if (bookmarksEntry != null) {
7821                            return bookmarksEntry;
7822                    }
7823    
7824                    StringBundler msg = new StringBundler(8);
7825    
7826                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7827    
7828                    msg.append("groupId=");
7829                    msg.append(groupId);
7830    
7831                    msg.append(", folderId=");
7832                    msg.append(folderId);
7833    
7834                    msg.append(", status=");
7835                    msg.append(status);
7836    
7837                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7838    
7839                    throw new NoSuchEntryException(msg.toString());
7840            }
7841    
7842            /**
7843             * Returns the first bookmarks entry in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
7844             *
7845             * @param groupId the group ID
7846             * @param folderId the folder ID
7847             * @param status the status
7848             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7849             * @return the first matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
7850             */
7851            @Override
7852            public BookmarksEntry fetchByG_F_S_First(long groupId, long folderId,
7853                    int status, OrderByComparator<BookmarksEntry> orderByComparator) {
7854                    List<BookmarksEntry> list = findByG_F_S(groupId, folderId, status, 0,
7855                                    1, orderByComparator);
7856    
7857                    if (!list.isEmpty()) {
7858                            return list.get(0);
7859                    }
7860    
7861                    return null;
7862            }
7863    
7864            /**
7865             * Returns the last bookmarks entry in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
7866             *
7867             * @param groupId the group ID
7868             * @param folderId the folder ID
7869             * @param status the status
7870             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7871             * @return the last matching bookmarks entry
7872             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
7873             */
7874            @Override
7875            public BookmarksEntry findByG_F_S_Last(long groupId, long folderId,
7876                    int status, OrderByComparator<BookmarksEntry> orderByComparator)
7877                    throws NoSuchEntryException {
7878                    BookmarksEntry bookmarksEntry = fetchByG_F_S_Last(groupId, folderId,
7879                                    status, orderByComparator);
7880    
7881                    if (bookmarksEntry != null) {
7882                            return bookmarksEntry;
7883                    }
7884    
7885                    StringBundler msg = new StringBundler(8);
7886    
7887                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7888    
7889                    msg.append("groupId=");
7890                    msg.append(groupId);
7891    
7892                    msg.append(", folderId=");
7893                    msg.append(folderId);
7894    
7895                    msg.append(", status=");
7896                    msg.append(status);
7897    
7898                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7899    
7900                    throw new NoSuchEntryException(msg.toString());
7901            }
7902    
7903            /**
7904             * Returns the last bookmarks entry in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
7905             *
7906             * @param groupId the group ID
7907             * @param folderId the folder ID
7908             * @param status the status
7909             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7910             * @return the last matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
7911             */
7912            @Override
7913            public BookmarksEntry fetchByG_F_S_Last(long groupId, long folderId,
7914                    int status, OrderByComparator<BookmarksEntry> orderByComparator) {
7915                    int count = countByG_F_S(groupId, folderId, status);
7916    
7917                    if (count == 0) {
7918                            return null;
7919                    }
7920    
7921                    List<BookmarksEntry> list = findByG_F_S(groupId, folderId, status,
7922                                    count - 1, count, orderByComparator);
7923    
7924                    if (!list.isEmpty()) {
7925                            return list.get(0);
7926                    }
7927    
7928                    return null;
7929            }
7930    
7931            /**
7932             * Returns the bookmarks entries before and after the current bookmarks entry in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
7933             *
7934             * @param entryId the primary key of the current bookmarks entry
7935             * @param groupId the group ID
7936             * @param folderId the folder ID
7937             * @param status the status
7938             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7939             * @return the previous, current, and next bookmarks entry
7940             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
7941             */
7942            @Override
7943            public BookmarksEntry[] findByG_F_S_PrevAndNext(long entryId, long groupId,
7944                    long folderId, int status,
7945                    OrderByComparator<BookmarksEntry> orderByComparator)
7946                    throws NoSuchEntryException {
7947                    BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
7948    
7949                    Session session = null;
7950    
7951                    try {
7952                            session = openSession();
7953    
7954                            BookmarksEntry[] array = new BookmarksEntryImpl[3];
7955    
7956                            array[0] = getByG_F_S_PrevAndNext(session, bookmarksEntry, groupId,
7957                                            folderId, status, orderByComparator, true);
7958    
7959                            array[1] = bookmarksEntry;
7960    
7961                            array[2] = getByG_F_S_PrevAndNext(session, bookmarksEntry, groupId,
7962                                            folderId, status, orderByComparator, false);
7963    
7964                            return array;
7965                    }
7966                    catch (Exception e) {
7967                            throw processException(e);
7968                    }
7969                    finally {
7970                            closeSession(session);
7971                    }
7972            }
7973    
7974            protected BookmarksEntry getByG_F_S_PrevAndNext(Session session,
7975                    BookmarksEntry bookmarksEntry, long groupId, long folderId, int status,
7976                    OrderByComparator<BookmarksEntry> orderByComparator, boolean previous) {
7977                    StringBundler query = null;
7978    
7979                    if (orderByComparator != null) {
7980                            query = new StringBundler(6 +
7981                                            (orderByComparator.getOrderByFields().length * 6));
7982                    }
7983                    else {
7984                            query = new StringBundler(3);
7985                    }
7986    
7987                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
7988    
7989                    query.append(_FINDER_COLUMN_G_F_S_GROUPID_2);
7990    
7991                    query.append(_FINDER_COLUMN_G_F_S_FOLDERID_2);
7992    
7993                    query.append(_FINDER_COLUMN_G_F_S_STATUS_2);
7994    
7995                    if (orderByComparator != null) {
7996                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7997    
7998                            if (orderByConditionFields.length > 0) {
7999                                    query.append(WHERE_AND);
8000                            }
8001    
8002                            for (int i = 0; i < orderByConditionFields.length; i++) {
8003                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8004                                    query.append(orderByConditionFields[i]);
8005    
8006                                    if ((i + 1) < orderByConditionFields.length) {
8007                                            if (orderByComparator.isAscending() ^ previous) {
8008                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8009                                            }
8010                                            else {
8011                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8012                                            }
8013                                    }
8014                                    else {
8015                                            if (orderByComparator.isAscending() ^ previous) {
8016                                                    query.append(WHERE_GREATER_THAN);
8017                                            }
8018                                            else {
8019                                                    query.append(WHERE_LESSER_THAN);
8020                                            }
8021                                    }
8022                            }
8023    
8024                            query.append(ORDER_BY_CLAUSE);
8025    
8026                            String[] orderByFields = orderByComparator.getOrderByFields();
8027    
8028                            for (int i = 0; i < orderByFields.length; i++) {
8029                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8030                                    query.append(orderByFields[i]);
8031    
8032                                    if ((i + 1) < orderByFields.length) {
8033                                            if (orderByComparator.isAscending() ^ previous) {
8034                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8035                                            }
8036                                            else {
8037                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8038                                            }
8039                                    }
8040                                    else {
8041                                            if (orderByComparator.isAscending() ^ previous) {
8042                                                    query.append(ORDER_BY_ASC);
8043                                            }
8044                                            else {
8045                                                    query.append(ORDER_BY_DESC);
8046                                            }
8047                                    }
8048                            }
8049                    }
8050                    else {
8051                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
8052                    }
8053    
8054                    String sql = query.toString();
8055    
8056                    Query q = session.createQuery(sql);
8057    
8058                    q.setFirstResult(0);
8059                    q.setMaxResults(2);
8060    
8061                    QueryPos qPos = QueryPos.getInstance(q);
8062    
8063                    qPos.add(groupId);
8064    
8065                    qPos.add(folderId);
8066    
8067                    qPos.add(status);
8068    
8069                    if (orderByComparator != null) {
8070                            Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry);
8071    
8072                            for (Object value : values) {
8073                                    qPos.add(value);
8074                            }
8075                    }
8076    
8077                    List<BookmarksEntry> list = q.list();
8078    
8079                    if (list.size() == 2) {
8080                            return list.get(1);
8081                    }
8082                    else {
8083                            return null;
8084                    }
8085            }
8086    
8087            /**
8088             * Returns all the bookmarks entries that the user has permission to view where groupId = &#63; and folderId = &#63; and status = &#63;.
8089             *
8090             * @param groupId the group ID
8091             * @param folderId the folder ID
8092             * @param status the status
8093             * @return the matching bookmarks entries that the user has permission to view
8094             */
8095            @Override
8096            public List<BookmarksEntry> filterFindByG_F_S(long groupId, long folderId,
8097                    int status) {
8098                    return filterFindByG_F_S(groupId, folderId, status, QueryUtil.ALL_POS,
8099                            QueryUtil.ALL_POS, null);
8100            }
8101    
8102            /**
8103             * Returns a range of all the bookmarks entries that the user has permission to view where groupId = &#63; and folderId = &#63; and status = &#63;.
8104             *
8105             * <p>
8106             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.bookmarks.model.impl.BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8107             * </p>
8108             *
8109             * @param groupId the group ID
8110             * @param folderId the folder ID
8111             * @param status the status
8112             * @param start the lower bound of the range of bookmarks entries
8113             * @param end the upper bound of the range of bookmarks entries (not inclusive)
8114             * @return the range of matching bookmarks entries that the user has permission to view
8115             */
8116            @Override
8117            public List<BookmarksEntry> filterFindByG_F_S(long groupId, long folderId,
8118                    int status, int start, int end) {
8119                    return filterFindByG_F_S(groupId, folderId, status, start, end, null);
8120            }
8121    
8122            /**
8123             * Returns an ordered range of all the bookmarks entries that the user has permissions to view where groupId = &#63; and folderId = &#63; and status = &#63;.
8124             *
8125             * <p>
8126             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.bookmarks.model.impl.BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8127             * </p>
8128             *
8129             * @param groupId the group ID
8130             * @param folderId the folder ID
8131             * @param status the status
8132             * @param start the lower bound of the range of bookmarks entries
8133             * @param end the upper bound of the range of bookmarks entries (not inclusive)
8134             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8135             * @return the ordered range of matching bookmarks entries that the user has permission to view
8136             */
8137            @Override
8138            public List<BookmarksEntry> filterFindByG_F_S(long groupId, long folderId,
8139                    int status, int start, int end,
8140                    OrderByComparator<BookmarksEntry> orderByComparator) {
8141                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8142                            return findByG_F_S(groupId, folderId, status, start, end,
8143                                    orderByComparator);
8144                    }
8145    
8146                    StringBundler query = null;
8147    
8148                    if (orderByComparator != null) {
8149                            query = new StringBundler(5 +
8150                                            (orderByComparator.getOrderByFields().length * 3));
8151                    }
8152                    else {
8153                            query = new StringBundler(5);
8154                    }
8155    
8156                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
8157    
8158                    query.append(_FINDER_COLUMN_G_F_S_GROUPID_2);
8159    
8160                    query.append(_FINDER_COLUMN_G_F_S_FOLDERID_2);
8161    
8162                    query.append(_FINDER_COLUMN_G_F_S_STATUS_2);
8163    
8164                    if (orderByComparator != null) {
8165                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8166                                    orderByComparator);
8167                    }
8168                    else {
8169                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
8170                    }
8171    
8172                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8173                                    BookmarksEntry.class.getName(),
8174                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
8175                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
8176    
8177                    Session session = null;
8178    
8179                    try {
8180                            session = openSession();
8181    
8182                            Query q = session.createQuery(sql);
8183    
8184                            QueryPos qPos = QueryPos.getInstance(q);
8185    
8186                            qPos.add(groupId);
8187    
8188                            qPos.add(folderId);
8189    
8190                            qPos.add(status);
8191    
8192                            return (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start,
8193                                    end);
8194                    }
8195                    catch (Exception e) {
8196                            throw processException(e);
8197                    }
8198                    finally {
8199                            closeSession(session);
8200                    }
8201            }
8202    
8203            /**
8204             * Returns the bookmarks entries before and after the current bookmarks entry in the ordered set of bookmarks entries that the user has permission to view where groupId = &#63; and folderId = &#63; and status = &#63;.
8205             *
8206             * @param entryId the primary key of the current bookmarks entry
8207             * @param groupId the group ID
8208             * @param folderId the folder ID
8209             * @param status the status
8210             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8211             * @return the previous, current, and next bookmarks entry
8212             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
8213             */
8214            @Override
8215            public BookmarksEntry[] filterFindByG_F_S_PrevAndNext(long entryId,
8216                    long groupId, long folderId, int status,
8217                    OrderByComparator<BookmarksEntry> orderByComparator)
8218                    throws NoSuchEntryException {
8219                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8220                            return findByG_F_S_PrevAndNext(entryId, groupId, folderId, status,
8221                                    orderByComparator);
8222                    }
8223    
8224                    BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
8225    
8226                    Session session = null;
8227    
8228                    try {
8229                            session = openSession();
8230    
8231                            BookmarksEntry[] array = new BookmarksEntryImpl[3];
8232    
8233                            array[0] = filterGetByG_F_S_PrevAndNext(session, bookmarksEntry,
8234                                            groupId, folderId, status, orderByComparator, true);
8235    
8236                            array[1] = bookmarksEntry;
8237    
8238                            array[2] = filterGetByG_F_S_PrevAndNext(session, bookmarksEntry,
8239                                            groupId, folderId, status, orderByComparator, false);
8240    
8241                            return array;
8242                    }
8243                    catch (Exception e) {
8244                            throw processException(e);
8245                    }
8246                    finally {
8247                            closeSession(session);
8248                    }
8249            }
8250    
8251            protected BookmarksEntry filterGetByG_F_S_PrevAndNext(Session session,
8252                    BookmarksEntry bookmarksEntry, long groupId, long folderId, int status,
8253                    OrderByComparator<BookmarksEntry> orderByComparator, boolean previous) {
8254                    StringBundler query = null;
8255    
8256                    if (orderByComparator != null) {
8257                            query = new StringBundler(6 +
8258                                            (orderByComparator.getOrderByFields().length * 6));
8259                    }
8260                    else {
8261                            query = new StringBundler(3);
8262                    }
8263    
8264                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
8265    
8266                    query.append(_FINDER_COLUMN_G_F_S_GROUPID_2);
8267    
8268                    query.append(_FINDER_COLUMN_G_F_S_FOLDERID_2);
8269    
8270                    query.append(_FINDER_COLUMN_G_F_S_STATUS_2);
8271    
8272                    if (orderByComparator != null) {
8273                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8274    
8275                            if (orderByConditionFields.length > 0) {
8276                                    query.append(WHERE_AND);
8277                            }
8278    
8279                            for (int i = 0; i < orderByConditionFields.length; i++) {
8280                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8281                                    query.append(orderByConditionFields[i]);
8282    
8283                                    if ((i + 1) < orderByConditionFields.length) {
8284                                            if (orderByComparator.isAscending() ^ previous) {
8285                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8286                                            }
8287                                            else {
8288                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8289                                            }
8290                                    }
8291                                    else {
8292                                            if (orderByComparator.isAscending() ^ previous) {
8293                                                    query.append(WHERE_GREATER_THAN);
8294                                            }
8295                                            else {
8296                                                    query.append(WHERE_LESSER_THAN);
8297                                            }
8298                                    }
8299                            }
8300    
8301                            query.append(ORDER_BY_CLAUSE);
8302    
8303                            String[] orderByFields = orderByComparator.getOrderByFields();
8304    
8305                            for (int i = 0; i < orderByFields.length; i++) {
8306                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8307                                    query.append(orderByFields[i]);
8308    
8309                                    if ((i + 1) < orderByFields.length) {
8310                                            if (orderByComparator.isAscending() ^ previous) {
8311                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8312                                            }
8313                                            else {
8314                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8315                                            }
8316                                    }
8317                                    else {
8318                                            if (orderByComparator.isAscending() ^ previous) {
8319                                                    query.append(ORDER_BY_ASC);
8320                                            }
8321                                            else {
8322                                                    query.append(ORDER_BY_DESC);
8323                                            }
8324                                    }
8325                            }
8326                    }
8327                    else {
8328                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
8329                    }
8330    
8331                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8332                                    BookmarksEntry.class.getName(),
8333                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
8334                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
8335    
8336                    Query q = session.createQuery(sql);
8337    
8338                    q.setFirstResult(0);
8339                    q.setMaxResults(2);
8340    
8341                    QueryPos qPos = QueryPos.getInstance(q);
8342    
8343                    qPos.add(groupId);
8344    
8345                    qPos.add(folderId);
8346    
8347                    qPos.add(status);
8348    
8349                    if (orderByComparator != null) {
8350                            Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry);
8351    
8352                            for (Object value : values) {
8353                                    qPos.add(value);
8354                            }
8355                    }
8356    
8357                    List<BookmarksEntry> list = q.list();
8358    
8359                    if (list.size() == 2) {
8360                            return list.get(1);
8361                    }
8362                    else {
8363                            return null;
8364                    }
8365            }
8366    
8367            /**
8368             * Returns all the bookmarks entries that the user has permission to view where groupId = &#63; and folderId = any &#63; and status = &#63;.
8369             *
8370             * @param groupId the group ID
8371             * @param folderIds the folder IDs
8372             * @param status the status
8373             * @return the matching bookmarks entries that the user has permission to view
8374             */
8375            @Override
8376            public List<BookmarksEntry> filterFindByG_F_S(long groupId,
8377                    long[] folderIds, int status) {
8378                    return filterFindByG_F_S(groupId, folderIds, status, QueryUtil.ALL_POS,
8379                            QueryUtil.ALL_POS, null);
8380            }
8381    
8382            /**
8383             * Returns a range of all the bookmarks entries that the user has permission to view where groupId = &#63; and folderId = any &#63; and status = &#63;.
8384             *
8385             * <p>
8386             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.bookmarks.model.impl.BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8387             * </p>
8388             *
8389             * @param groupId the group ID
8390             * @param folderIds the folder IDs
8391             * @param status the status
8392             * @param start the lower bound of the range of bookmarks entries
8393             * @param end the upper bound of the range of bookmarks entries (not inclusive)
8394             * @return the range of matching bookmarks entries that the user has permission to view
8395             */
8396            @Override
8397            public List<BookmarksEntry> filterFindByG_F_S(long groupId,
8398                    long[] folderIds, int status, int start, int end) {
8399                    return filterFindByG_F_S(groupId, folderIds, status, start, end, null);
8400            }
8401    
8402            /**
8403             * Returns an ordered range of all the bookmarks entries that the user has permission to view where groupId = &#63; and folderId = any &#63; and status = &#63;.
8404             *
8405             * <p>
8406             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.bookmarks.model.impl.BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8407             * </p>
8408             *
8409             * @param groupId the group ID
8410             * @param folderIds the folder IDs
8411             * @param status the status
8412             * @param start the lower bound of the range of bookmarks entries
8413             * @param end the upper bound of the range of bookmarks entries (not inclusive)
8414             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8415             * @return the ordered range of matching bookmarks entries that the user has permission to view
8416             */
8417            @Override
8418            public List<BookmarksEntry> filterFindByG_F_S(long groupId,
8419                    long[] folderIds, int status, int start, int end,
8420                    OrderByComparator<BookmarksEntry> orderByComparator) {
8421                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8422                            return findByG_F_S(groupId, folderIds, status, start, end,
8423                                    orderByComparator);
8424                    }
8425    
8426                    if (folderIds == null) {
8427                            folderIds = new long[0];
8428                    }
8429                    else {
8430                            folderIds = ArrayUtil.unique(folderIds);
8431                    }
8432    
8433                    StringBundler query = new StringBundler();
8434    
8435                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
8436    
8437                    query.append(_FINDER_COLUMN_G_F_S_GROUPID_2);
8438    
8439                    if (folderIds.length > 0) {
8440                            query.append(StringPool.OPEN_PARENTHESIS);
8441    
8442                            query.append(_FINDER_COLUMN_G_F_S_FOLDERID_7);
8443    
8444                            query.append(StringUtil.merge(folderIds));
8445    
8446                            query.append(StringPool.CLOSE_PARENTHESIS);
8447    
8448                            query.append(StringPool.CLOSE_PARENTHESIS);
8449    
8450                            query.append(WHERE_AND);
8451                    }
8452    
8453                    query.append(_FINDER_COLUMN_G_F_S_STATUS_2);
8454    
8455                    query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
8456                            query.index() - 1);
8457    
8458                    if (orderByComparator != null) {
8459                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8460                                    orderByComparator);
8461                    }
8462                    else {
8463                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
8464                    }
8465    
8466                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8467                                    BookmarksEntry.class.getName(),
8468                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
8469                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
8470    
8471                    Session session = null;
8472    
8473                    try {
8474                            session = openSession();
8475    
8476                            Query q = session.createQuery(sql);
8477    
8478                            QueryPos qPos = QueryPos.getInstance(q);
8479    
8480                            qPos.add(groupId);
8481    
8482                            qPos.add(status);
8483    
8484                            return (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start,
8485                                    end);
8486                    }
8487                    catch (Exception e) {
8488                            throw processException(e);
8489                    }
8490                    finally {
8491                            closeSession(session);
8492                    }
8493            }
8494    
8495            /**
8496             * Returns all the bookmarks entries where groupId = &#63; and folderId = any &#63; and status = &#63;.
8497             *
8498             * <p>
8499             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.bookmarks.model.impl.BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8500             * </p>
8501             *
8502             * @param groupId the group ID
8503             * @param folderIds the folder IDs
8504             * @param status the status
8505             * @return the matching bookmarks entries
8506             */
8507            @Override
8508            public List<BookmarksEntry> findByG_F_S(long groupId, long[] folderIds,
8509                    int status) {
8510                    return findByG_F_S(groupId, folderIds, status, QueryUtil.ALL_POS,
8511                            QueryUtil.ALL_POS, null);
8512            }
8513    
8514            /**
8515             * Returns a range of all the bookmarks entries where groupId = &#63; and folderId = any &#63; and status = &#63;.
8516             *
8517             * <p>
8518             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.bookmarks.model.impl.BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8519             * </p>
8520             *
8521             * @param groupId the group ID
8522             * @param folderIds the folder IDs
8523             * @param status the status
8524             * @param start the lower bound of the range of bookmarks entries
8525             * @param end the upper bound of the range of bookmarks entries (not inclusive)
8526             * @return the range of matching bookmarks entries
8527             */
8528            @Override
8529            public List<BookmarksEntry> findByG_F_S(long groupId, long[] folderIds,
8530                    int status, int start, int end) {
8531                    return findByG_F_S(groupId, folderIds, status, start, end, null);
8532            }
8533    
8534            /**
8535             * Returns an ordered range of all the bookmarks entries where groupId = &#63; and folderId = any &#63; and status = &#63;.
8536             *
8537             * <p>
8538             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.bookmarks.model.impl.BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8539             * </p>
8540             *
8541             * @param groupId the group ID
8542             * @param folderIds the folder IDs
8543             * @param status the status
8544             * @param start the lower bound of the range of bookmarks entries
8545             * @param end the upper bound of the range of bookmarks entries (not inclusive)
8546             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8547             * @return the ordered range of matching bookmarks entries
8548             */
8549            @Override
8550            public List<BookmarksEntry> findByG_F_S(long groupId, long[] folderIds,
8551                    int status, int start, int end,
8552                    OrderByComparator<BookmarksEntry> orderByComparator) {
8553                    if (folderIds == null) {
8554                            folderIds = new long[0];
8555                    }
8556                    else {
8557                            folderIds = ArrayUtil.unique(folderIds);
8558                    }
8559    
8560                    if (folderIds.length == 1) {
8561                            return findByG_F_S(groupId, folderIds[0], status, start, end,
8562                                    orderByComparator);
8563                    }
8564    
8565                    boolean pagination = true;
8566                    Object[] finderArgs = null;
8567    
8568                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
8569                                    (orderByComparator == null)) {
8570                            pagination = false;
8571                            finderArgs = new Object[] {
8572                                            groupId, StringUtil.merge(folderIds), status
8573                                    };
8574                    }
8575                    else {
8576                            finderArgs = new Object[] {
8577                                            groupId, StringUtil.merge(folderIds), status,
8578                                            
8579                                            start, end, orderByComparator
8580                                    };
8581                    }
8582    
8583                    List<BookmarksEntry> list = (List<BookmarksEntry>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_S,
8584                                    finderArgs, this);
8585    
8586                    if ((list != null) && !list.isEmpty()) {
8587                            for (BookmarksEntry bookmarksEntry : list) {
8588                                    if ((groupId != bookmarksEntry.getGroupId()) ||
8589                                                    !ArrayUtil.contains(folderIds,
8590                                                            bookmarksEntry.getFolderId()) ||
8591                                                    (status != bookmarksEntry.getStatus())) {
8592                                            list = null;
8593    
8594                                            break;
8595                                    }
8596                            }
8597                    }
8598    
8599                    if (list == null) {
8600                            StringBundler query = new StringBundler();
8601    
8602                            query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
8603    
8604                            query.append(_FINDER_COLUMN_G_F_S_GROUPID_2);
8605    
8606                            if (folderIds.length > 0) {
8607                                    query.append(StringPool.OPEN_PARENTHESIS);
8608    
8609                                    query.append(_FINDER_COLUMN_G_F_S_FOLDERID_7);
8610    
8611                                    query.append(StringUtil.merge(folderIds));
8612    
8613                                    query.append(StringPool.CLOSE_PARENTHESIS);
8614    
8615                                    query.append(StringPool.CLOSE_PARENTHESIS);
8616    
8617                                    query.append(WHERE_AND);
8618                            }
8619    
8620                            query.append(_FINDER_COLUMN_G_F_S_STATUS_2);
8621    
8622                            query.setStringAt(removeConjunction(query.stringAt(query.index() -
8623                                                    1)), query.index() - 1);
8624    
8625                            if (orderByComparator != null) {
8626                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8627                                            orderByComparator);
8628                            }
8629                            else
8630                             if (pagination) {
8631                                    query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
8632                            }
8633    
8634                            String sql = query.toString();
8635    
8636                            Session session = null;
8637    
8638                            try {
8639                                    session = openSession();
8640    
8641                                    Query q = session.createQuery(sql);
8642    
8643                                    QueryPos qPos = QueryPos.getInstance(q);
8644    
8645                                    qPos.add(groupId);
8646    
8647                                    qPos.add(status);
8648    
8649                                    if (!pagination) {
8650                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
8651                                                            getDialect(), start, end, false);
8652    
8653                                            Collections.sort(list);
8654    
8655                                            list = Collections.unmodifiableList(list);
8656                                    }
8657                                    else {
8658                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
8659                                                            getDialect(), start, end);
8660                                    }
8661    
8662                                    cacheResult(list);
8663    
8664                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_S,
8665                                            finderArgs, list);
8666                            }
8667                            catch (Exception e) {
8668                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_S,
8669                                            finderArgs);
8670    
8671                                    throw processException(e);
8672                            }
8673                            finally {
8674                                    closeSession(session);
8675                            }
8676                    }
8677    
8678                    return list;
8679            }
8680    
8681            /**
8682             * Removes all the bookmarks entries where groupId = &#63; and folderId = &#63; and status = &#63; from the database.
8683             *
8684             * @param groupId the group ID
8685             * @param folderId the folder ID
8686             * @param status the status
8687             */
8688            @Override
8689            public void removeByG_F_S(long groupId, long folderId, int status) {
8690                    for (BookmarksEntry bookmarksEntry : findByG_F_S(groupId, folderId,
8691                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
8692                            remove(bookmarksEntry);
8693                    }
8694            }
8695    
8696            /**
8697             * Returns the number of bookmarks entries where groupId = &#63; and folderId = &#63; and status = &#63;.
8698             *
8699             * @param groupId the group ID
8700             * @param folderId the folder ID
8701             * @param status the status
8702             * @return the number of matching bookmarks entries
8703             */
8704            @Override
8705            public int countByG_F_S(long groupId, long folderId, int status) {
8706                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_F_S;
8707    
8708                    Object[] finderArgs = new Object[] { groupId, folderId, status };
8709    
8710                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
8711                                    this);
8712    
8713                    if (count == null) {
8714                            StringBundler query = new StringBundler(4);
8715    
8716                            query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
8717    
8718                            query.append(_FINDER_COLUMN_G_F_S_GROUPID_2);
8719    
8720                            query.append(_FINDER_COLUMN_G_F_S_FOLDERID_2);
8721    
8722                            query.append(_FINDER_COLUMN_G_F_S_STATUS_2);
8723    
8724                            String sql = query.toString();
8725    
8726                            Session session = null;
8727    
8728                            try {
8729                                    session = openSession();
8730    
8731                                    Query q = session.createQuery(sql);
8732    
8733                                    QueryPos qPos = QueryPos.getInstance(q);
8734    
8735                                    qPos.add(groupId);
8736    
8737                                    qPos.add(folderId);
8738    
8739                                    qPos.add(status);
8740    
8741                                    count = (Long)q.uniqueResult();
8742    
8743                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
8744                            }
8745                            catch (Exception e) {
8746                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
8747    
8748                                    throw processException(e);
8749                            }
8750                            finally {
8751                                    closeSession(session);
8752                            }
8753                    }
8754    
8755                    return count.intValue();
8756            }
8757    
8758            /**
8759             * Returns the number of bookmarks entries where groupId = &#63; and folderId = any &#63; and status = &#63;.
8760             *
8761             * @param groupId the group ID
8762             * @param folderIds the folder IDs
8763             * @param status the status
8764             * @return the number of matching bookmarks entries
8765             */
8766            @Override
8767            public int countByG_F_S(long groupId, long[] folderIds, int status) {
8768                    if (folderIds == null) {
8769                            folderIds = new long[0];
8770                    }
8771                    else {
8772                            folderIds = ArrayUtil.unique(folderIds);
8773                    }
8774    
8775                    Object[] finderArgs = new Object[] {
8776                                    groupId, StringUtil.merge(folderIds), status
8777                            };
8778    
8779                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_S,
8780                                    finderArgs, this);
8781    
8782                    if (count == null) {
8783                            StringBundler query = new StringBundler();
8784    
8785                            query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
8786    
8787                            query.append(_FINDER_COLUMN_G_F_S_GROUPID_2);
8788    
8789                            if (folderIds.length > 0) {
8790                                    query.append(StringPool.OPEN_PARENTHESIS);
8791    
8792                                    query.append(_FINDER_COLUMN_G_F_S_FOLDERID_7);
8793    
8794                                    query.append(StringUtil.merge(folderIds));
8795    
8796                                    query.append(StringPool.CLOSE_PARENTHESIS);
8797    
8798                                    query.append(StringPool.CLOSE_PARENTHESIS);
8799    
8800                                    query.append(WHERE_AND);
8801                            }
8802    
8803                            query.append(_FINDER_COLUMN_G_F_S_STATUS_2);
8804    
8805                            query.setStringAt(removeConjunction(query.stringAt(query.index() -
8806                                                    1)), query.index() - 1);
8807    
8808                            String sql = query.toString();
8809    
8810                            Session session = null;
8811    
8812                            try {
8813                                    session = openSession();
8814    
8815                                    Query q = session.createQuery(sql);
8816    
8817                                    QueryPos qPos = QueryPos.getInstance(q);
8818    
8819                                    qPos.add(groupId);
8820    
8821                                    qPos.add(status);
8822    
8823                                    count = (Long)q.uniqueResult();
8824    
8825                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_S,
8826                                            finderArgs, count);
8827                            }
8828                            catch (Exception e) {
8829                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_S,
8830                                            finderArgs);
8831    
8832                                    throw processException(e);
8833                            }
8834                            finally {
8835                                    closeSession(session);
8836                            }
8837                    }
8838    
8839                    return count.intValue();
8840            }
8841    
8842            /**
8843             * Returns the number of bookmarks entries that the user has permission to view where groupId = &#63; and folderId = &#63; and status = &#63;.
8844             *
8845             * @param groupId the group ID
8846             * @param folderId the folder ID
8847             * @param status the status
8848             * @return the number of matching bookmarks entries that the user has permission to view
8849             */
8850            @Override
8851            public int filterCountByG_F_S(long groupId, long folderId, int status) {
8852                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8853                            return countByG_F_S(groupId, folderId, status);
8854                    }
8855    
8856                    StringBundler query = new StringBundler(4);
8857    
8858                    query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
8859    
8860                    query.append(_FINDER_COLUMN_G_F_S_GROUPID_2);
8861    
8862                    query.append(_FINDER_COLUMN_G_F_S_FOLDERID_2);
8863    
8864                    query.append(_FINDER_COLUMN_G_F_S_STATUS_2);
8865    
8866                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8867                                    BookmarksEntry.class.getName(),
8868                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
8869                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
8870    
8871                    Session session = null;
8872    
8873                    try {
8874                            session = openSession();
8875    
8876                            Query q = session.createQuery(sql);
8877    
8878                            QueryPos qPos = QueryPos.getInstance(q);
8879    
8880                            qPos.add(groupId);
8881    
8882                            qPos.add(folderId);
8883    
8884                            qPos.add(status);
8885    
8886                            Long count = (Long)q.uniqueResult();
8887    
8888                            return count.intValue();
8889                    }
8890                    catch (Exception e) {
8891                            throw processException(e);
8892                    }
8893                    finally {
8894                            closeSession(session);
8895                    }
8896            }
8897    
8898            /**
8899             * Returns the number of bookmarks entries that the user has permission to view where groupId = &#63; and folderId = any &#63; and status = &#63;.
8900             *
8901             * @param groupId the group ID
8902             * @param folderIds the folder IDs
8903             * @param status the status
8904             * @return the number of matching bookmarks entries that the user has permission to view
8905             */
8906            @Override
8907            public int filterCountByG_F_S(long groupId, long[] folderIds, int status) {
8908                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8909                            return countByG_F_S(groupId, folderIds, status);
8910                    }
8911    
8912                    if (folderIds == null) {
8913                            folderIds = new long[0];
8914                    }
8915                    else {
8916                            folderIds = ArrayUtil.unique(folderIds);
8917                    }
8918    
8919                    StringBundler query = new StringBundler();
8920    
8921                    query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
8922    
8923                    query.append(_FINDER_COLUMN_G_F_S_GROUPID_2);
8924    
8925                    if (folderIds.length > 0) {
8926                            query.append(StringPool.OPEN_PARENTHESIS);
8927    
8928                            query.append(_FINDER_COLUMN_G_F_S_FOLDERID_7);
8929    
8930                            query.append(StringUtil.merge(folderIds));
8931    
8932                            query.append(StringPool.CLOSE_PARENTHESIS);
8933    
8934                            query.append(StringPool.CLOSE_PARENTHESIS);
8935    
8936                            query.append(WHERE_AND);
8937                    }
8938    
8939                    query.append(_FINDER_COLUMN_G_F_S_STATUS_2);
8940    
8941                    query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
8942                            query.index() - 1);
8943    
8944                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8945                                    BookmarksEntry.class.getName(),
8946                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
8947                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
8948    
8949                    Session session = null;
8950    
8951                    try {
8952                            session = openSession();
8953    
8954                            Query q = session.createQuery(sql);
8955    
8956                            QueryPos qPos = QueryPos.getInstance(q);
8957    
8958                            qPos.add(groupId);
8959    
8960                            qPos.add(status);
8961    
8962                            Long count = (Long)q.uniqueResult();
8963    
8964                            return count.intValue();
8965                    }
8966                    catch (Exception e) {
8967                            throw processException(e);
8968                    }
8969                    finally {
8970                            closeSession(session);
8971                    }
8972            }
8973    
8974            private static final String _FINDER_COLUMN_G_F_S_GROUPID_2 = "bookmarksEntry.groupId = ? AND ";
8975            private static final String _FINDER_COLUMN_G_F_S_FOLDERID_2 = "bookmarksEntry.folderId = ? AND ";
8976            private static final String _FINDER_COLUMN_G_F_S_FOLDERID_7 = "bookmarksEntry.folderId IN (";
8977            private static final String _FINDER_COLUMN_G_F_S_STATUS_2 = "bookmarksEntry.status = ?";
8978            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_NOTS = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
8979                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
8980                            BookmarksEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
8981                            "findByG_F_NotS",
8982                            new String[] {
8983                                    Long.class.getName(), Long.class.getName(),
8984                                    Integer.class.getName(),
8985                                    
8986                            Integer.class.getName(), Integer.class.getName(),
8987                                    OrderByComparator.class.getName()
8988                            });
8989            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_NOTS =
8990                    new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
8991                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
8992                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_F_NotS",
8993                            new String[] {
8994                                    Long.class.getName(), Long.class.getName(),
8995                                    Integer.class.getName()
8996                            });
8997    
8998            /**
8999             * Returns all the bookmarks entries where groupId = &#63; and folderId = &#63; and status &ne; &#63;.
9000             *
9001             * @param groupId the group ID
9002             * @param folderId the folder ID
9003             * @param status the status
9004             * @return the matching bookmarks entries
9005             */
9006            @Override
9007            public List<BookmarksEntry> findByG_F_NotS(long groupId, long folderId,
9008                    int status) {
9009                    return findByG_F_NotS(groupId, folderId, status, QueryUtil.ALL_POS,
9010                            QueryUtil.ALL_POS, null);
9011            }
9012    
9013            /**
9014             * Returns a range of all the bookmarks entries where groupId = &#63; and folderId = &#63; and status &ne; &#63;.
9015             *
9016             * <p>
9017             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.bookmarks.model.impl.BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9018             * </p>
9019             *
9020             * @param groupId the group ID
9021             * @param folderId the folder ID
9022             * @param status the status
9023             * @param start the lower bound of the range of bookmarks entries
9024             * @param end the upper bound of the range of bookmarks entries (not inclusive)
9025             * @return the range of matching bookmarks entries
9026             */
9027            @Override
9028            public List<BookmarksEntry> findByG_F_NotS(long groupId, long folderId,
9029                    int status, int start, int end) {
9030                    return findByG_F_NotS(groupId, folderId, status, start, end, null);
9031            }
9032    
9033            /**
9034             * Returns an ordered range of all the bookmarks entries where groupId = &#63; and folderId = &#63; and status &ne; &#63;.
9035             *
9036             * <p>
9037             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.bookmarks.model.impl.BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9038             * </p>
9039             *
9040             * @param groupId the group ID
9041             * @param folderId the folder ID
9042             * @param status the status
9043             * @param start the lower bound of the range of bookmarks entries
9044             * @param end the upper bound of the range of bookmarks entries (not inclusive)
9045             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9046             * @return the ordered range of matching bookmarks entries
9047             */
9048            @Override
9049            public List<BookmarksEntry> findByG_F_NotS(long groupId, long folderId,
9050                    int status, int start, int end,
9051                    OrderByComparator<BookmarksEntry> orderByComparator) {
9052                    boolean pagination = true;
9053                    FinderPath finderPath = null;
9054                    Object[] finderArgs = null;
9055    
9056                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_NOTS;
9057                    finderArgs = new Object[] {
9058                                    groupId, folderId, status,
9059                                    
9060                                    start, end, orderByComparator
9061                            };
9062    
9063                    List<BookmarksEntry> list = (List<BookmarksEntry>)FinderCacheUtil.getResult(finderPath,
9064                                    finderArgs, this);
9065    
9066                    if ((list != null) && !list.isEmpty()) {
9067                            for (BookmarksEntry bookmarksEntry : list) {
9068                                    if ((groupId != bookmarksEntry.getGroupId()) ||
9069                                                    (folderId != bookmarksEntry.getFolderId()) ||
9070                                                    (status == bookmarksEntry.getStatus())) {
9071                                            list = null;
9072    
9073                                            break;
9074                                    }
9075                            }
9076                    }
9077    
9078                    if (list == null) {
9079                            StringBundler query = null;
9080    
9081                            if (orderByComparator != null) {
9082                                    query = new StringBundler(5 +
9083                                                    (orderByComparator.getOrderByFields().length * 3));
9084                            }
9085                            else {
9086                                    query = new StringBundler(5);
9087                            }
9088    
9089                            query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
9090    
9091                            query.append(_FINDER_COLUMN_G_F_NOTS_GROUPID_2);
9092    
9093                            query.append(_FINDER_COLUMN_G_F_NOTS_FOLDERID_2);
9094    
9095                            query.append(_FINDER_COLUMN_G_F_NOTS_STATUS_2);
9096    
9097                            if (orderByComparator != null) {
9098                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9099                                            orderByComparator);
9100                            }
9101                            else
9102                             if (pagination) {
9103                                    query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
9104                            }
9105    
9106                            String sql = query.toString();
9107    
9108                            Session session = null;
9109    
9110                            try {
9111                                    session = openSession();
9112    
9113                                    Query q = session.createQuery(sql);
9114    
9115                                    QueryPos qPos = QueryPos.getInstance(q);
9116    
9117                                    qPos.add(groupId);
9118    
9119                                    qPos.add(folderId);
9120    
9121                                    qPos.add(status);
9122    
9123                                    if (!pagination) {
9124                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
9125                                                            getDialect(), start, end, false);
9126    
9127                                            Collections.sort(list);
9128    
9129                                            list = Collections.unmodifiableList(list);
9130                                    }
9131                                    else {
9132                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
9133                                                            getDialect(), start, end);
9134                                    }
9135    
9136                                    cacheResult(list);
9137    
9138                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
9139                            }
9140                            catch (Exception e) {
9141                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
9142    
9143                                    throw processException(e);
9144                            }
9145                            finally {
9146                                    closeSession(session);
9147                            }
9148                    }
9149    
9150                    return list;
9151            }
9152    
9153            /**
9154             * Returns the first bookmarks entry in the ordered set where groupId = &#63; and folderId = &#63; and status &ne; &#63;.
9155             *
9156             * @param groupId the group ID
9157             * @param folderId the folder ID
9158             * @param status the status
9159             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9160             * @return the first matching bookmarks entry
9161             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
9162             */
9163            @Override
9164            public BookmarksEntry findByG_F_NotS_First(long groupId, long folderId,
9165                    int status, OrderByComparator<BookmarksEntry> orderByComparator)
9166                    throws NoSuchEntryException {
9167                    BookmarksEntry bookmarksEntry = fetchByG_F_NotS_First(groupId,
9168                                    folderId, status, orderByComparator);
9169    
9170                    if (bookmarksEntry != null) {
9171                            return bookmarksEntry;
9172                    }
9173    
9174                    StringBundler msg = new StringBundler(8);
9175    
9176                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9177    
9178                    msg.append("groupId=");
9179                    msg.append(groupId);
9180    
9181                    msg.append(", folderId=");
9182                    msg.append(folderId);
9183    
9184                    msg.append(", status=");
9185                    msg.append(status);
9186    
9187                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9188    
9189                    throw new NoSuchEntryException(msg.toString());
9190            }
9191    
9192            /**
9193             * Returns the first bookmarks entry in the ordered set where groupId = &#63; and folderId = &#63; and status &ne; &#63;.
9194             *
9195             * @param groupId the group ID
9196             * @param folderId the folder ID
9197             * @param status the status
9198             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9199             * @return the first matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
9200             */
9201            @Override
9202            public BookmarksEntry fetchByG_F_NotS_First(long groupId, long folderId,
9203                    int status, OrderByComparator<BookmarksEntry> orderByComparator) {
9204                    List<BookmarksEntry> list = findByG_F_NotS(groupId, folderId, status,
9205                                    0, 1, orderByComparator);
9206    
9207                    if (!list.isEmpty()) {
9208                            return list.get(0);
9209                    }
9210    
9211                    return null;
9212            }
9213    
9214            /**
9215             * Returns the last bookmarks entry in the ordered set where groupId = &#63; and folderId = &#63; and status &ne; &#63;.
9216             *
9217             * @param groupId the group ID
9218             * @param folderId the folder ID
9219             * @param status the status
9220             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9221             * @return the last matching bookmarks entry
9222             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
9223             */
9224            @Override
9225            public BookmarksEntry findByG_F_NotS_Last(long groupId, long folderId,
9226                    int status, OrderByComparator<BookmarksEntry> orderByComparator)
9227                    throws NoSuchEntryException {
9228                    BookmarksEntry bookmarksEntry = fetchByG_F_NotS_Last(groupId, folderId,
9229                                    status, orderByComparator);
9230    
9231                    if (bookmarksEntry != null) {
9232                            return bookmarksEntry;
9233                    }
9234    
9235                    StringBundler msg = new StringBundler(8);
9236    
9237                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9238    
9239                    msg.append("groupId=");
9240                    msg.append(groupId);
9241    
9242                    msg.append(", folderId=");
9243                    msg.append(folderId);
9244    
9245                    msg.append(", status=");
9246                    msg.append(status);
9247    
9248                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9249    
9250                    throw new NoSuchEntryException(msg.toString());
9251            }
9252    
9253            /**
9254             * Returns the last bookmarks entry in the ordered set where groupId = &#63; and folderId = &#63; and status &ne; &#63;.
9255             *
9256             * @param groupId the group ID
9257             * @param folderId the folder ID
9258             * @param status the status
9259             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9260             * @return the last matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
9261             */
9262            @Override
9263            public BookmarksEntry fetchByG_F_NotS_Last(long groupId, long folderId,
9264                    int status, OrderByComparator<BookmarksEntry> orderByComparator) {
9265                    int count = countByG_F_NotS(groupId, folderId, status);
9266    
9267                    if (count == 0) {
9268                            return null;
9269                    }
9270    
9271                    List<BookmarksEntry> list = findByG_F_NotS(groupId, folderId, status,
9272                                    count - 1, count, orderByComparator);
9273    
9274                    if (!list.isEmpty()) {
9275                            return list.get(0);
9276                    }
9277    
9278                    return null;
9279            }
9280    
9281            /**
9282             * Returns the bookmarks entries before and after the current bookmarks entry in the ordered set where groupId = &#63; and folderId = &#63; and status &ne; &#63;.
9283             *
9284             * @param entryId the primary key of the current bookmarks entry
9285             * @param groupId the group ID
9286             * @param folderId the folder ID
9287             * @param status the status
9288             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9289             * @return the previous, current, and next bookmarks entry
9290             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
9291             */
9292            @Override
9293            public BookmarksEntry[] findByG_F_NotS_PrevAndNext(long entryId,
9294                    long groupId, long folderId, int status,
9295                    OrderByComparator<BookmarksEntry> orderByComparator)
9296                    throws NoSuchEntryException {
9297                    BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
9298    
9299                    Session session = null;
9300    
9301                    try {
9302                            session = openSession();
9303    
9304                            BookmarksEntry[] array = new BookmarksEntryImpl[3];
9305    
9306                            array[0] = getByG_F_NotS_PrevAndNext(session, bookmarksEntry,
9307                                            groupId, folderId, status, orderByComparator, true);
9308    
9309                            array[1] = bookmarksEntry;
9310    
9311                            array[2] = getByG_F_NotS_PrevAndNext(session, bookmarksEntry,
9312                                            groupId, folderId, status, orderByComparator, false);
9313    
9314                            return array;
9315                    }
9316                    catch (Exception e) {
9317                            throw processException(e);
9318                    }
9319                    finally {
9320                            closeSession(session);
9321                    }
9322            }
9323    
9324            protected BookmarksEntry getByG_F_NotS_PrevAndNext(Session session,
9325                    BookmarksEntry bookmarksEntry, long groupId, long folderId, int status,
9326                    OrderByComparator<BookmarksEntry> orderByComparator, boolean previous) {
9327                    StringBundler query = null;
9328    
9329                    if (orderByComparator != null) {
9330                            query = new StringBundler(6 +
9331                                            (orderByComparator.getOrderByFields().length * 6));
9332                    }
9333                    else {
9334                            query = new StringBundler(3);
9335                    }
9336    
9337                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
9338    
9339                    query.append(_FINDER_COLUMN_G_F_NOTS_GROUPID_2);
9340    
9341                    query.append(_FINDER_COLUMN_G_F_NOTS_FOLDERID_2);
9342    
9343                    query.append(_FINDER_COLUMN_G_F_NOTS_STATUS_2);
9344    
9345                    if (orderByComparator != null) {
9346                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9347    
9348                            if (orderByConditionFields.length > 0) {
9349                                    query.append(WHERE_AND);
9350                            }
9351    
9352                            for (int i = 0; i < orderByConditionFields.length; i++) {
9353                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9354                                    query.append(orderByConditionFields[i]);
9355    
9356                                    if ((i + 1) < orderByConditionFields.length) {
9357                                            if (orderByComparator.isAscending() ^ previous) {
9358                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9359                                            }
9360                                            else {
9361                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
9362                                            }
9363                                    }
9364                                    else {
9365                                            if (orderByComparator.isAscending() ^ previous) {
9366                                                    query.append(WHERE_GREATER_THAN);
9367                                            }
9368                                            else {
9369                                                    query.append(WHERE_LESSER_THAN);
9370                                            }
9371                                    }
9372                            }
9373    
9374                            query.append(ORDER_BY_CLAUSE);
9375    
9376                            String[] orderByFields = orderByComparator.getOrderByFields();
9377    
9378                            for (int i = 0; i < orderByFields.length; i++) {
9379                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9380                                    query.append(orderByFields[i]);
9381    
9382                                    if ((i + 1) < orderByFields.length) {
9383                                            if (orderByComparator.isAscending() ^ previous) {
9384                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
9385                                            }
9386                                            else {
9387                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
9388                                            }
9389                                    }
9390                                    else {
9391                                            if (orderByComparator.isAscending() ^ previous) {
9392                                                    query.append(ORDER_BY_ASC);
9393                                            }
9394                                            else {
9395                                                    query.append(ORDER_BY_DESC);
9396                                            }
9397                                    }
9398                            }
9399                    }
9400                    else {
9401                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
9402                    }
9403    
9404                    String sql = query.toString();
9405    
9406                    Query q = session.createQuery(sql);
9407    
9408                    q.setFirstResult(0);
9409                    q.setMaxResults(2);
9410    
9411                    QueryPos qPos = QueryPos.getInstance(q);
9412    
9413                    qPos.add(groupId);
9414    
9415                    qPos.add(folderId);
9416    
9417                    qPos.add(status);
9418    
9419                    if (orderByComparator != null) {
9420                            Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry);
9421    
9422                            for (Object value : values) {
9423                                    qPos.add(value);
9424                            }
9425                    }
9426    
9427                    List<BookmarksEntry> list = q.list();
9428    
9429                    if (list.size() == 2) {
9430                            return list.get(1);
9431                    }
9432                    else {
9433                            return null;
9434                    }
9435            }
9436    
9437            /**
9438             * Returns all the bookmarks entries that the user has permission to view where groupId = &#63; and folderId = &#63; and status &ne; &#63;.
9439             *
9440             * @param groupId the group ID
9441             * @param folderId the folder ID
9442             * @param status the status
9443             * @return the matching bookmarks entries that the user has permission to view
9444             */
9445            @Override
9446            public List<BookmarksEntry> filterFindByG_F_NotS(long groupId,
9447                    long folderId, int status) {
9448                    return filterFindByG_F_NotS(groupId, folderId, status,
9449                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
9450            }
9451    
9452            /**
9453             * Returns a range of all the bookmarks entries that the user has permission to view where groupId = &#63; and folderId = &#63; and status &ne; &#63;.
9454             *
9455             * <p>
9456             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.bookmarks.model.impl.BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9457             * </p>
9458             *
9459             * @param groupId the group ID
9460             * @param folderId the folder ID
9461             * @param status the status
9462             * @param start the lower bound of the range of bookmarks entries
9463             * @param end the upper bound of the range of bookmarks entries (not inclusive)
9464             * @return the range of matching bookmarks entries that the user has permission to view
9465             */
9466            @Override
9467            public List<BookmarksEntry> filterFindByG_F_NotS(long groupId,
9468                    long folderId, int status, int start, int end) {
9469                    return filterFindByG_F_NotS(groupId, folderId, status, start, end, null);
9470            }
9471    
9472            /**
9473             * Returns an ordered range of all the bookmarks entries that the user has permissions to view where groupId = &#63; and folderId = &#63; and status &ne; &#63;.
9474             *
9475             * <p>
9476             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.bookmarks.model.impl.BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9477             * </p>
9478             *
9479             * @param groupId the group ID
9480             * @param folderId the folder ID
9481             * @param status the status
9482             * @param start the lower bound of the range of bookmarks entries
9483             * @param end the upper bound of the range of bookmarks entries (not inclusive)
9484             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9485             * @return the ordered range of matching bookmarks entries that the user has permission to view
9486             */
9487            @Override
9488            public List<BookmarksEntry> filterFindByG_F_NotS(long groupId,
9489                    long folderId, int status, int start, int end,
9490                    OrderByComparator<BookmarksEntry> orderByComparator) {
9491                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9492                            return findByG_F_NotS(groupId, folderId, status, start, end,
9493                                    orderByComparator);
9494                    }
9495    
9496                    StringBundler query = null;
9497    
9498                    if (orderByComparator != null) {
9499                            query = new StringBundler(5 +
9500                                            (orderByComparator.getOrderByFields().length * 3));
9501                    }
9502                    else {
9503                            query = new StringBundler(5);
9504                    }
9505    
9506                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
9507    
9508                    query.append(_FINDER_COLUMN_G_F_NOTS_GROUPID_2);
9509    
9510                    query.append(_FINDER_COLUMN_G_F_NOTS_FOLDERID_2);
9511    
9512                    query.append(_FINDER_COLUMN_G_F_NOTS_STATUS_2);
9513    
9514                    if (orderByComparator != null) {
9515                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9516                                    orderByComparator);
9517                    }
9518                    else {
9519                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
9520                    }
9521    
9522                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9523                                    BookmarksEntry.class.getName(),
9524                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
9525                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
9526    
9527                    Session session = null;
9528    
9529                    try {
9530                            session = openSession();
9531    
9532                            Query q = session.createQuery(sql);
9533    
9534                            QueryPos qPos = QueryPos.getInstance(q);
9535    
9536                            qPos.add(groupId);
9537    
9538                            qPos.add(folderId);
9539    
9540                            qPos.add(status);
9541    
9542                            return (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start,
9543                                    end);
9544                    }
9545                    catch (Exception e) {
9546                            throw processException(e);
9547                    }
9548                    finally {
9549                            closeSession(session);
9550                    }
9551            }
9552    
9553            /**
9554             * Returns the bookmarks entries before and after the current bookmarks entry in the ordered set of bookmarks entries that the user has permission to view where groupId = &#63; and folderId = &#63; and status &ne; &#63;.
9555             *
9556             * @param entryId the primary key of the current bookmarks entry
9557             * @param groupId the group ID
9558             * @param folderId the folder ID
9559             * @param status the status
9560             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9561             * @return the previous, current, and next bookmarks entry
9562             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
9563             */
9564            @Override
9565            public BookmarksEntry[] filterFindByG_F_NotS_PrevAndNext(long entryId,
9566                    long groupId, long folderId, int status,
9567                    OrderByComparator<BookmarksEntry> orderByComparator)
9568                    throws NoSuchEntryException {
9569                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9570                            return findByG_F_NotS_PrevAndNext(entryId, groupId, folderId,
9571                                    status, orderByComparator);
9572                    }
9573    
9574                    BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
9575    
9576                    Session session = null;
9577    
9578                    try {
9579                            session = openSession();
9580    
9581                            BookmarksEntry[] array = new BookmarksEntryImpl[3];
9582    
9583                            array[0] = filterGetByG_F_NotS_PrevAndNext(session, bookmarksEntry,
9584                                            groupId, folderId, status, orderByComparator, true);
9585    
9586                            array[1] = bookmarksEntry;
9587    
9588                            array[2] = filterGetByG_F_NotS_PrevAndNext(session, bookmarksEntry,
9589                                            groupId, folderId, status, orderByComparator, false);
9590    
9591                            return array;
9592                    }
9593                    catch (Exception e) {
9594                            throw processException(e);
9595                    }
9596                    finally {
9597                            closeSession(session);
9598                    }
9599            }
9600    
9601            protected BookmarksEntry filterGetByG_F_NotS_PrevAndNext(Session session,
9602                    BookmarksEntry bookmarksEntry, long groupId, long folderId, int status,
9603                    OrderByComparator<BookmarksEntry> orderByComparator, boolean previous) {
9604                    StringBundler query = null;
9605    
9606                    if (orderByComparator != null) {
9607                            query = new StringBundler(6 +
9608                                            (orderByComparator.getOrderByFields().length * 6));
9609                    }
9610                    else {
9611                            query = new StringBundler(3);
9612                    }
9613    
9614                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
9615    
9616                    query.append(_FINDER_COLUMN_G_F_NOTS_GROUPID_2);
9617    
9618                    query.append(_FINDER_COLUMN_G_F_NOTS_FOLDERID_2);
9619    
9620                    query.append(_FINDER_COLUMN_G_F_NOTS_STATUS_2);
9621    
9622                    if (orderByComparator != null) {
9623                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9624    
9625                            if (orderByConditionFields.length > 0) {
9626                                    query.append(WHERE_AND);
9627                            }
9628    
9629                            for (int i = 0; i < orderByConditionFields.length; i++) {
9630                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9631                                    query.append(orderByConditionFields[i]);
9632    
9633                                    if ((i + 1) < orderByConditionFields.length) {
9634                                            if (orderByComparator.isAscending() ^ previous) {
9635                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9636                                            }
9637                                            else {
9638                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
9639                                            }
9640                                    }
9641                                    else {
9642                                            if (orderByComparator.isAscending() ^ previous) {
9643                                                    query.append(WHERE_GREATER_THAN);
9644                                            }
9645                                            else {
9646                                                    query.append(WHERE_LESSER_THAN);
9647                                            }
9648                                    }
9649                            }
9650    
9651                            query.append(ORDER_BY_CLAUSE);
9652    
9653                            String[] orderByFields = orderByComparator.getOrderByFields();
9654    
9655                            for (int i = 0; i < orderByFields.length; i++) {
9656                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9657                                    query.append(orderByFields[i]);
9658    
9659                                    if ((i + 1) < orderByFields.length) {
9660                                            if (orderByComparator.isAscending() ^ previous) {
9661                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
9662                                            }
9663                                            else {
9664                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
9665                                            }
9666                                    }
9667                                    else {
9668                                            if (orderByComparator.isAscending() ^ previous) {
9669                                                    query.append(ORDER_BY_ASC);
9670                                            }
9671                                            else {
9672                                                    query.append(ORDER_BY_DESC);
9673                                            }
9674                                    }
9675                            }
9676                    }
9677                    else {
9678                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
9679                    }
9680    
9681                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9682                                    BookmarksEntry.class.getName(),
9683                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
9684                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
9685    
9686                    Query q = session.createQuery(sql);
9687    
9688                    q.setFirstResult(0);
9689                    q.setMaxResults(2);
9690    
9691                    QueryPos qPos = QueryPos.getInstance(q);
9692    
9693                    qPos.add(groupId);
9694    
9695                    qPos.add(folderId);
9696    
9697                    qPos.add(status);
9698    
9699                    if (orderByComparator != null) {
9700                            Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry);
9701    
9702                            for (Object value : values) {
9703                                    qPos.add(value);
9704                            }
9705                    }
9706    
9707                    List<BookmarksEntry> list = q.list();
9708    
9709                    if (list.size() == 2) {
9710                            return list.get(1);
9711                    }
9712                    else {
9713                            return null;
9714                    }
9715            }
9716    
9717            /**
9718             * Returns all the bookmarks entries that the user has permission to view where groupId = &#63; and folderId = any &#63; and status &ne; &#63;.
9719             *
9720             * @param groupId the group ID
9721             * @param folderIds the folder IDs
9722             * @param status the status
9723             * @return the matching bookmarks entries that the user has permission to view
9724             */
9725            @Override
9726            public List<BookmarksEntry> filterFindByG_F_NotS(long groupId,
9727                    long[] folderIds, int status) {
9728                    return filterFindByG_F_NotS(groupId, folderIds, status,
9729                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
9730            }
9731    
9732            /**
9733             * Returns a range of all the bookmarks entries that the user has permission to view where groupId = &#63; and folderId = any &#63; and status &ne; &#63;.
9734             *
9735             * <p>
9736             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.bookmarks.model.impl.BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9737             * </p>
9738             *
9739             * @param groupId the group ID
9740             * @param folderIds the folder IDs
9741             * @param status the status
9742             * @param start the lower bound of the range of bookmarks entries
9743             * @param end the upper bound of the range of bookmarks entries (not inclusive)
9744             * @return the range of matching bookmarks entries that the user has permission to view
9745             */
9746            @Override
9747            public List<BookmarksEntry> filterFindByG_F_NotS(long groupId,
9748                    long[] folderIds, int status, int start, int end) {
9749                    return filterFindByG_F_NotS(groupId, folderIds, status, start, end, null);
9750            }
9751    
9752            /**
9753             * Returns an ordered range of all the bookmarks entries that the user has permission to view where groupId = &#63; and folderId = any &#63; and status &ne; &#63;.
9754             *
9755             * <p>
9756             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.bookmarks.model.impl.BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9757             * </p>
9758             *
9759             * @param groupId the group ID
9760             * @param folderIds the folder IDs
9761             * @param status the status
9762             * @param start the lower bound of the range of bookmarks entries
9763             * @param end the upper bound of the range of bookmarks entries (not inclusive)
9764             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9765             * @return the ordered range of matching bookmarks entries that the user has permission to view
9766             */
9767            @Override
9768            public List<BookmarksEntry> filterFindByG_F_NotS(long groupId,
9769                    long[] folderIds, int status, int start, int end,
9770                    OrderByComparator<BookmarksEntry> orderByComparator) {
9771                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9772                            return findByG_F_NotS(groupId, folderIds, status, start, end,
9773                                    orderByComparator);
9774                    }
9775    
9776                    if (folderIds == null) {
9777                            folderIds = new long[0];
9778                    }
9779                    else {
9780                            folderIds = ArrayUtil.unique(folderIds);
9781                    }
9782    
9783                    StringBundler query = new StringBundler();
9784    
9785                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
9786    
9787                    query.append(_FINDER_COLUMN_G_F_NOTS_GROUPID_2);
9788    
9789                    if (folderIds.length > 0) {
9790                            query.append(StringPool.OPEN_PARENTHESIS);
9791    
9792                            query.append(_FINDER_COLUMN_G_F_NOTS_FOLDERID_7);
9793    
9794                            query.append(StringUtil.merge(folderIds));
9795    
9796                            query.append(StringPool.CLOSE_PARENTHESIS);
9797    
9798                            query.append(StringPool.CLOSE_PARENTHESIS);
9799    
9800                            query.append(WHERE_AND);
9801                    }
9802    
9803                    query.append(_FINDER_COLUMN_G_F_NOTS_STATUS_2);
9804    
9805                    query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
9806                            query.index() - 1);
9807    
9808                    if (orderByComparator != null) {
9809                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9810                                    orderByComparator);
9811                    }
9812                    else {
9813                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
9814                    }
9815    
9816                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9817                                    BookmarksEntry.class.getName(),
9818                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
9819                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
9820    
9821                    Session session = null;
9822    
9823                    try {
9824                            session = openSession();
9825    
9826                            Query q = session.createQuery(sql);
9827    
9828                            QueryPos qPos = QueryPos.getInstance(q);
9829    
9830                            qPos.add(groupId);
9831    
9832                            qPos.add(status);
9833    
9834                            return (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start,
9835                                    end);
9836                    }
9837                    catch (Exception e) {
9838                            throw processException(e);
9839                    }
9840                    finally {
9841                            closeSession(session);
9842                    }
9843            }
9844    
9845            /**
9846             * Returns all the bookmarks entries where groupId = &#63; and folderId = any &#63; and status &ne; &#63;.
9847             *
9848             * <p>
9849             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.bookmarks.model.impl.BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9850             * </p>
9851             *
9852             * @param groupId the group ID
9853             * @param folderIds the folder IDs
9854             * @param status the status
9855             * @return the matching bookmarks entries
9856             */
9857            @Override
9858            public List<BookmarksEntry> findByG_F_NotS(long groupId, long[] folderIds,
9859                    int status) {
9860                    return findByG_F_NotS(groupId, folderIds, status, QueryUtil.ALL_POS,
9861                            QueryUtil.ALL_POS, null);
9862            }
9863    
9864            /**
9865             * Returns a range of all the bookmarks entries where groupId = &#63; and folderId = any &#63; and status &ne; &#63;.
9866             *
9867             * <p>
9868             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.bookmarks.model.impl.BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9869             * </p>
9870             *
9871             * @param groupId the group ID
9872             * @param folderIds the folder IDs
9873             * @param status the status
9874             * @param start the lower bound of the range of bookmarks entries
9875             * @param end the upper bound of the range of bookmarks entries (not inclusive)
9876             * @return the range of matching bookmarks entries
9877             */
9878            @Override
9879            public List<BookmarksEntry> findByG_F_NotS(long groupId, long[] folderIds,
9880                    int status, int start, int end) {
9881                    return findByG_F_NotS(groupId, folderIds, status, start, end, null);
9882            }
9883    
9884            /**
9885             * Returns an ordered range of all the bookmarks entries where groupId = &#63; and folderId = any &#63; and status &ne; &#63;.
9886             *
9887             * <p>
9888             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.bookmarks.model.impl.BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9889             * </p>
9890             *
9891             * @param groupId the group ID
9892             * @param folderIds the folder IDs
9893             * @param status the status
9894             * @param start the lower bound of the range of bookmarks entries
9895             * @param end the upper bound of the range of bookmarks entries (not inclusive)
9896             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9897             * @return the ordered range of matching bookmarks entries
9898             */
9899            @Override
9900            public List<BookmarksEntry> findByG_F_NotS(long groupId, long[] folderIds,
9901                    int status, int start, int end,
9902                    OrderByComparator<BookmarksEntry> orderByComparator) {
9903                    if (folderIds == null) {
9904                            folderIds = new long[0];
9905                    }
9906                    else {
9907                            folderIds = ArrayUtil.unique(folderIds);
9908                    }
9909    
9910                    if (folderIds.length == 1) {
9911                            return findByG_F_NotS(groupId, folderIds[0], status, start, end,
9912                                    orderByComparator);
9913                    }
9914    
9915                    boolean pagination = true;
9916                    Object[] finderArgs = null;
9917    
9918                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
9919                                    (orderByComparator == null)) {
9920                            pagination = false;
9921                            finderArgs = new Object[] {
9922                                            groupId, StringUtil.merge(folderIds), status
9923                                    };
9924                    }
9925                    else {
9926                            finderArgs = new Object[] {
9927                                            groupId, StringUtil.merge(folderIds), status,
9928                                            
9929                                            start, end, orderByComparator
9930                                    };
9931                    }
9932    
9933                    List<BookmarksEntry> list = (List<BookmarksEntry>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_NOTS,
9934                                    finderArgs, this);
9935    
9936                    if ((list != null) && !list.isEmpty()) {
9937                            for (BookmarksEntry bookmarksEntry : list) {
9938                                    if ((groupId != bookmarksEntry.getGroupId()) ||
9939                                                    !ArrayUtil.contains(folderIds,
9940                                                            bookmarksEntry.getFolderId()) ||
9941                                                    (status != bookmarksEntry.getStatus())) {
9942                                            list = null;
9943    
9944                                            break;
9945                                    }
9946                            }
9947                    }
9948    
9949                    if (list == null) {
9950                            StringBundler query = new StringBundler();
9951    
9952                            query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
9953    
9954                            query.append(_FINDER_COLUMN_G_F_NOTS_GROUPID_2);
9955    
9956                            if (folderIds.length > 0) {
9957                                    query.append(StringPool.OPEN_PARENTHESIS);
9958    
9959                                    query.append(_FINDER_COLUMN_G_F_NOTS_FOLDERID_7);
9960    
9961                                    query.append(StringUtil.merge(folderIds));
9962    
9963                                    query.append(StringPool.CLOSE_PARENTHESIS);
9964    
9965                                    query.append(StringPool.CLOSE_PARENTHESIS);
9966    
9967                                    query.append(WHERE_AND);
9968                            }
9969    
9970                            query.append(_FINDER_COLUMN_G_F_NOTS_STATUS_2);
9971    
9972                            query.setStringAt(removeConjunction(query.stringAt(query.index() -
9973                                                    1)), query.index() - 1);
9974    
9975                            if (orderByComparator != null) {
9976                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9977                                            orderByComparator);
9978                            }
9979                            else
9980                             if (pagination) {
9981                                    query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
9982                            }
9983    
9984                            String sql = query.toString();
9985    
9986                            Session session = null;
9987    
9988                            try {
9989                                    session = openSession();
9990    
9991                                    Query q = session.createQuery(sql);
9992    
9993                                    QueryPos qPos = QueryPos.getInstance(q);
9994    
9995                                    qPos.add(groupId);
9996    
9997                                    qPos.add(status);
9998    
9999                                    if (!pagination) {
10000                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
10001                                                            getDialect(), start, end, false);
10002    
10003                                            Collections.sort(list);
10004    
10005                                            list = Collections.unmodifiableList(list);
10006                                    }
10007                                    else {
10008                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
10009                                                            getDialect(), start, end);
10010                                    }
10011    
10012                                    cacheResult(list);
10013    
10014                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_NOTS,
10015                                            finderArgs, list);
10016                            }
10017                            catch (Exception e) {
10018                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_NOTS,
10019                                            finderArgs);
10020    
10021                                    throw processException(e);
10022                            }
10023                            finally {
10024                                    closeSession(session);
10025                            }
10026                    }
10027    
10028                    return list;
10029            }
10030    
10031            /**
10032             * Removes all the bookmarks entries where groupId = &#63; and folderId = &#63; and status &ne; &#63; from the database.
10033             *
10034             * @param groupId the group ID
10035             * @param folderId the folder ID
10036             * @param status the status
10037             */
10038            @Override
10039            public void removeByG_F_NotS(long groupId, long folderId, int status) {
10040                    for (BookmarksEntry bookmarksEntry : findByG_F_NotS(groupId, folderId,
10041                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
10042                            remove(bookmarksEntry);
10043                    }
10044            }
10045    
10046            /**
10047             * Returns the number of bookmarks entries where groupId = &#63; and folderId = &#63; and status &ne; &#63;.
10048             *
10049             * @param groupId the group ID
10050             * @param folderId the folder ID
10051             * @param status the status
10052             * @return the number of matching bookmarks entries
10053             */
10054            @Override
10055            public int countByG_F_NotS(long groupId, long folderId, int status) {
10056                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_NOTS;
10057    
10058                    Object[] finderArgs = new Object[] { groupId, folderId, status };
10059    
10060                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
10061                                    this);
10062    
10063                    if (count == null) {
10064                            StringBundler query = new StringBundler(4);
10065    
10066                            query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
10067    
10068                            query.append(_FINDER_COLUMN_G_F_NOTS_GROUPID_2);
10069    
10070                            query.append(_FINDER_COLUMN_G_F_NOTS_FOLDERID_2);
10071    
10072                            query.append(_FINDER_COLUMN_G_F_NOTS_STATUS_2);
10073    
10074                            String sql = query.toString();
10075    
10076                            Session session = null;
10077    
10078                            try {
10079                                    session = openSession();
10080    
10081                                    Query q = session.createQuery(sql);
10082    
10083                                    QueryPos qPos = QueryPos.getInstance(q);
10084    
10085                                    qPos.add(groupId);
10086    
10087                                    qPos.add(folderId);
10088    
10089                                    qPos.add(status);
10090    
10091                                    count = (Long)q.uniqueResult();
10092    
10093                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
10094                            }
10095                            catch (Exception e) {
10096                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
10097    
10098                                    throw processException(e);
10099                            }
10100                            finally {
10101                                    closeSession(session);
10102                            }
10103                    }
10104    
10105                    return count.intValue();
10106            }
10107    
10108            /**
10109             * Returns the number of bookmarks entries where groupId = &#63; and folderId = any &#63; and status &ne; &#63;.
10110             *
10111             * @param groupId the group ID
10112             * @param folderIds the folder IDs
10113             * @param status the status
10114             * @return the number of matching bookmarks entries
10115             */
10116            @Override
10117            public int countByG_F_NotS(long groupId, long[] folderIds, int status) {
10118                    if (folderIds == null) {
10119                            folderIds = new long[0];
10120                    }
10121                    else {
10122                            folderIds = ArrayUtil.unique(folderIds);
10123                    }
10124    
10125                    Object[] finderArgs = new Object[] {
10126                                    groupId, StringUtil.merge(folderIds), status
10127                            };
10128    
10129                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_NOTS,
10130                                    finderArgs, this);
10131    
10132                    if (count == null) {
10133                            StringBundler query = new StringBundler();
10134    
10135                            query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
10136    
10137                            query.append(_FINDER_COLUMN_G_F_NOTS_GROUPID_2);
10138    
10139                            if (folderIds.length > 0) {
10140                                    query.append(StringPool.OPEN_PARENTHESIS);
10141    
10142                                    query.append(_FINDER_COLUMN_G_F_NOTS_FOLDERID_7);
10143    
10144                                    query.append(StringUtil.merge(folderIds));
10145    
10146                                    query.append(StringPool.CLOSE_PARENTHESIS);
10147    
10148                                    query.append(StringPool.CLOSE_PARENTHESIS);
10149    
10150                                    query.append(WHERE_AND);
10151                            }
10152    
10153                            query.append(_FINDER_COLUMN_G_F_NOTS_STATUS_2);
10154    
10155                            query.setStringAt(removeConjunction(query.stringAt(query.index() -
10156                                                    1)), query.index() - 1);
10157    
10158                            String sql = query.toString();
10159    
10160                            Session session = null;
10161    
10162                            try {
10163                                    session = openSession();
10164    
10165                                    Query q = session.createQuery(sql);
10166    
10167                                    QueryPos qPos = QueryPos.getInstance(q);
10168    
10169                                    qPos.add(groupId);
10170    
10171                                    qPos.add(status);
10172    
10173                                    count = (Long)q.uniqueResult();
10174    
10175                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_NOTS,
10176                                            finderArgs, count);
10177                            }
10178                            catch (Exception e) {
10179                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_NOTS,
10180                                            finderArgs);
10181    
10182                                    throw processException(e);
10183                            }
10184                            finally {
10185                                    closeSession(session);
10186                            }
10187                    }
10188    
10189                    return count.intValue();
10190            }
10191    
10192            /**
10193             * Returns the number of bookmarks entries that the user has permission to view where groupId = &#63; and folderId = &#63; and status &ne; &#63;.
10194             *
10195             * @param groupId the group ID
10196             * @param folderId the folder ID
10197             * @param status the status
10198             * @return the number of matching bookmarks entries that the user has permission to view
10199             */
10200            @Override
10201            public int filterCountByG_F_NotS(long groupId, long folderId, int status) {
10202                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10203                            return countByG_F_NotS(groupId, folderId, status);
10204                    }
10205    
10206                    StringBundler query = new StringBundler(4);
10207    
10208                    query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
10209    
10210                    query.append(_FINDER_COLUMN_G_F_NOTS_GROUPID_2);
10211    
10212                    query.append(_FINDER_COLUMN_G_F_NOTS_FOLDERID_2);
10213    
10214                    query.append(_FINDER_COLUMN_G_F_NOTS_STATUS_2);
10215    
10216                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10217                                    BookmarksEntry.class.getName(),
10218                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
10219                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
10220    
10221                    Session session = null;
10222    
10223                    try {
10224                            session = openSession();
10225    
10226                            Query q = session.createQuery(sql);
10227    
10228                            QueryPos qPos = QueryPos.getInstance(q);
10229    
10230                            qPos.add(groupId);
10231    
10232                            qPos.add(folderId);
10233    
10234                            qPos.add(status);
10235    
10236                            Long count = (Long)q.uniqueResult();
10237    
10238                            return count.intValue();
10239                    }
10240                    catch (Exception e) {
10241                            throw processException(e);
10242                    }
10243                    finally {
10244                            closeSession(session);
10245                    }
10246            }
10247    
10248            /**
10249             * Returns the number of bookmarks entries that the user has permission to view where groupId = &#63; and folderId = any &#63; and status &ne; &#63;.
10250             *
10251             * @param groupId the group ID
10252             * @param folderIds the folder IDs
10253             * @param status the status
10254             * @return the number of matching bookmarks entries that the user has permission to view
10255             */
10256            @Override
10257            public int filterCountByG_F_NotS(long groupId, long[] folderIds, int status) {
10258                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10259                            return countByG_F_NotS(groupId, folderIds, status);
10260                    }
10261    
10262                    if (folderIds == null) {
10263                            folderIds = new long[0];
10264                    }
10265                    else {
10266                            folderIds = ArrayUtil.unique(folderIds);
10267                    }
10268    
10269                    StringBundler query = new StringBundler();
10270    
10271                    query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
10272    
10273                    query.append(_FINDER_COLUMN_G_F_NOTS_GROUPID_2);
10274    
10275                    if (folderIds.length > 0) {
10276                            query.append(StringPool.OPEN_PARENTHESIS);
10277    
10278                            query.append(_FINDER_COLUMN_G_F_NOTS_FOLDERID_7);
10279    
10280                            query.append(StringUtil.merge(folderIds));
10281    
10282                            query.append(StringPool.CLOSE_PARENTHESIS);
10283    
10284                            query.append(StringPool.CLOSE_PARENTHESIS);
10285    
10286                            query.append(WHERE_AND);
10287                    }
10288    
10289                    query.append(_FINDER_COLUMN_G_F_NOTS_STATUS_2);
10290    
10291                    query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
10292                            query.index() - 1);
10293    
10294                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10295                                    BookmarksEntry.class.getName(),
10296                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
10297                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
10298    
10299                    Session session = null;
10300    
10301                    try {
10302                            session = openSession();
10303    
10304                            Query q = session.createQuery(sql);
10305    
10306                            QueryPos qPos = QueryPos.getInstance(q);
10307    
10308                            qPos.add(groupId);
10309    
10310                            qPos.add(status);
10311    
10312                            Long count = (Long)q.uniqueResult();
10313    
10314                            return count.intValue();
10315                    }
10316                    catch (Exception e) {
10317                            throw processException(e);
10318                    }
10319                    finally {
10320                            closeSession(session);
10321                    }
10322            }
10323    
10324            private static final String _FINDER_COLUMN_G_F_NOTS_GROUPID_2 = "bookmarksEntry.groupId = ? AND ";
10325            private static final String _FINDER_COLUMN_G_F_NOTS_FOLDERID_2 = "bookmarksEntry.folderId = ? AND ";
10326            private static final String _FINDER_COLUMN_G_F_NOTS_FOLDERID_7 = "bookmarksEntry.folderId IN (";
10327            private static final String _FINDER_COLUMN_G_F_NOTS_STATUS_2 = "bookmarksEntry.status != ?";
10328            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_F_S = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
10329                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
10330                            BookmarksEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
10331                            "findByG_U_F_S",
10332                            new String[] {
10333                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
10334                                    Integer.class.getName(),
10335                                    
10336                            Integer.class.getName(), Integer.class.getName(),
10337                                    OrderByComparator.class.getName()
10338                            });
10339            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_F_S =
10340                    new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
10341                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
10342                            BookmarksEntryImpl.class,
10343                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U_F_S",
10344                            new String[] {
10345                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
10346                                    Integer.class.getName()
10347                            },
10348                            BookmarksEntryModelImpl.GROUPID_COLUMN_BITMASK |
10349                            BookmarksEntryModelImpl.USERID_COLUMN_BITMASK |
10350                            BookmarksEntryModelImpl.FOLDERID_COLUMN_BITMASK |
10351                            BookmarksEntryModelImpl.STATUS_COLUMN_BITMASK |
10352                            BookmarksEntryModelImpl.NAME_COLUMN_BITMASK);
10353            public static final FinderPath FINDER_PATH_COUNT_BY_G_U_F_S = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
10354                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
10355                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U_F_S",
10356                            new String[] {
10357                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
10358                                    Integer.class.getName()
10359                            });
10360            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_F_S = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
10361                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
10362                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_U_F_S",
10363                            new String[] {
10364                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
10365                                    Integer.class.getName()
10366                            });
10367    
10368            /**
10369             * Returns all the bookmarks entries where groupId = &#63; and userId = &#63; and folderId = &#63; and status = &#63;.
10370             *
10371             * @param groupId the group ID
10372             * @param userId the user ID
10373             * @param folderId the folder ID
10374             * @param status the status
10375             * @return the matching bookmarks entries
10376             */
10377            @Override
10378            public List<BookmarksEntry> findByG_U_F_S(long groupId, long userId,
10379                    long folderId, int status) {
10380                    return findByG_U_F_S(groupId, userId, folderId, status,
10381                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
10382            }
10383    
10384            /**
10385             * Returns a range of all the bookmarks entries where groupId = &#63; and userId = &#63; and folderId = &#63; and status = &#63;.
10386             *
10387             * <p>
10388             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.bookmarks.model.impl.BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10389             * </p>
10390             *
10391             * @param groupId the group ID
10392             * @param userId the user ID
10393             * @param folderId the folder ID
10394             * @param status the status
10395             * @param start the lower bound of the range of bookmarks entries
10396             * @param end the upper bound of the range of bookmarks entries (not inclusive)
10397             * @return the range of matching bookmarks entries
10398             */
10399            @Override
10400            public List<BookmarksEntry> findByG_U_F_S(long groupId, long userId,
10401                    long folderId, int status, int start, int end) {
10402                    return findByG_U_F_S(groupId, userId, folderId, status, start, end, null);
10403            }
10404    
10405            /**
10406             * Returns an ordered range of all the bookmarks entries where groupId = &#63; and userId = &#63; and folderId = &#63; and status = &#63;.
10407             *
10408             * <p>
10409             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.bookmarks.model.impl.BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10410             * </p>
10411             *
10412             * @param groupId the group ID
10413             * @param userId the user ID
10414             * @param folderId the folder ID
10415             * @param status the status
10416             * @param start the lower bound of the range of bookmarks entries
10417             * @param end the upper bound of the range of bookmarks entries (not inclusive)
10418             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10419             * @return the ordered range of matching bookmarks entries
10420             */
10421            @Override
10422            public List<BookmarksEntry> findByG_U_F_S(long groupId, long userId,
10423                    long folderId, int status, int start, int end,
10424                    OrderByComparator<BookmarksEntry> orderByComparator) {
10425                    boolean pagination = true;
10426                    FinderPath finderPath = null;
10427                    Object[] finderArgs = null;
10428    
10429                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
10430                                    (orderByComparator == null)) {
10431                            pagination = false;
10432                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_F_S;
10433                            finderArgs = new Object[] { groupId, userId, folderId, status };
10434                    }
10435                    else {
10436                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_F_S;
10437                            finderArgs = new Object[] {
10438                                            groupId, userId, folderId, status,
10439                                            
10440                                            start, end, orderByComparator
10441                                    };
10442                    }
10443    
10444                    List<BookmarksEntry> list = (List<BookmarksEntry>)FinderCacheUtil.getResult(finderPath,
10445                                    finderArgs, this);
10446    
10447                    if ((list != null) && !list.isEmpty()) {
10448                            for (BookmarksEntry bookmarksEntry : list) {
10449                                    if ((groupId != bookmarksEntry.getGroupId()) ||
10450                                                    (userId != bookmarksEntry.getUserId()) ||
10451                                                    (folderId != bookmarksEntry.getFolderId()) ||
10452                                                    (status != bookmarksEntry.getStatus())) {
10453                                            list = null;
10454    
10455                                            break;
10456                                    }
10457                            }
10458                    }
10459    
10460                    if (list == null) {
10461                            StringBundler query = null;
10462    
10463                            if (orderByComparator != null) {
10464                                    query = new StringBundler(6 +
10465                                                    (orderByComparator.getOrderByFields().length * 3));
10466                            }
10467                            else {
10468                                    query = new StringBundler(6);
10469                            }
10470    
10471                            query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
10472    
10473                            query.append(_FINDER_COLUMN_G_U_F_S_GROUPID_2);
10474    
10475                            query.append(_FINDER_COLUMN_G_U_F_S_USERID_2);
10476    
10477                            query.append(_FINDER_COLUMN_G_U_F_S_FOLDERID_2);
10478    
10479                            query.append(_FINDER_COLUMN_G_U_F_S_STATUS_2);
10480    
10481                            if (orderByComparator != null) {
10482                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10483                                            orderByComparator);
10484                            }
10485                            else
10486                             if (pagination) {
10487                                    query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
10488                            }
10489    
10490                            String sql = query.toString();
10491    
10492                            Session session = null;
10493    
10494                            try {
10495                                    session = openSession();
10496    
10497                                    Query q = session.createQuery(sql);
10498    
10499                                    QueryPos qPos = QueryPos.getInstance(q);
10500    
10501                                    qPos.add(groupId);
10502    
10503                                    qPos.add(userId);
10504    
10505                                    qPos.add(folderId);
10506    
10507                                    qPos.add(status);
10508    
10509                                    if (!pagination) {
10510                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
10511                                                            getDialect(), start, end, false);
10512    
10513                                            Collections.sort(list);
10514    
10515                                            list = Collections.unmodifiableList(list);
10516                                    }
10517                                    else {
10518                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
10519                                                            getDialect(), start, end);
10520                                    }
10521    
10522                                    cacheResult(list);
10523    
10524                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
10525                            }
10526                            catch (Exception e) {
10527                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
10528    
10529                                    throw processException(e);
10530                            }
10531                            finally {
10532                                    closeSession(session);
10533                            }
10534                    }
10535    
10536                    return list;
10537            }
10538    
10539            /**
10540             * Returns the first bookmarks entry in the ordered set where groupId = &#63; and userId = &#63; and folderId = &#63; and status = &#63;.
10541             *
10542             * @param groupId the group ID
10543             * @param userId the user ID
10544             * @param folderId the folder ID
10545             * @param status the status
10546             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10547             * @return the first matching bookmarks entry
10548             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
10549             */
10550            @Override
10551            public BookmarksEntry findByG_U_F_S_First(long groupId, long userId,
10552                    long folderId, int status,
10553                    OrderByComparator<BookmarksEntry> orderByComparator)
10554                    throws NoSuchEntryException {
10555                    BookmarksEntry bookmarksEntry = fetchByG_U_F_S_First(groupId, userId,
10556                                    folderId, status, orderByComparator);
10557    
10558                    if (bookmarksEntry != null) {
10559                            return bookmarksEntry;
10560                    }
10561    
10562                    StringBundler msg = new StringBundler(10);
10563    
10564                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10565    
10566                    msg.append("groupId=");
10567                    msg.append(groupId);
10568    
10569                    msg.append(", userId=");
10570                    msg.append(userId);
10571    
10572                    msg.append(", folderId=");
10573                    msg.append(folderId);
10574    
10575                    msg.append(", status=");
10576                    msg.append(status);
10577    
10578                    msg.append(StringPool.CLOSE_CURLY_BRACE);
10579    
10580                    throw new NoSuchEntryException(msg.toString());
10581            }
10582    
10583            /**
10584             * Returns the first bookmarks entry in the ordered set where groupId = &#63; and userId = &#63; and folderId = &#63; and status = &#63;.
10585             *
10586             * @param groupId the group ID
10587             * @param userId the user ID
10588             * @param folderId the folder ID
10589             * @param status the status
10590             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10591             * @return the first matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
10592             */
10593            @Override
10594            public BookmarksEntry fetchByG_U_F_S_First(long groupId, long userId,
10595                    long folderId, int status,
10596                    OrderByComparator<BookmarksEntry> orderByComparator) {
10597                    List<BookmarksEntry> list = findByG_U_F_S(groupId, userId, folderId,
10598                                    status, 0, 1, orderByComparator);
10599    
10600                    if (!list.isEmpty()) {
10601                            return list.get(0);
10602                    }
10603    
10604                    return null;
10605            }
10606    
10607            /**
10608             * Returns the last bookmarks entry in the ordered set where groupId = &#63; and userId = &#63; and folderId = &#63; and status = &#63;.
10609             *
10610             * @param groupId the group ID
10611             * @param userId the user ID
10612             * @param folderId the folder ID
10613             * @param status the status
10614             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10615             * @return the last matching bookmarks entry
10616             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
10617             */
10618            @Override
10619            public BookmarksEntry findByG_U_F_S_Last(long groupId, long userId,
10620                    long folderId, int status,
10621                    OrderByComparator<BookmarksEntry> orderByComparator)
10622                    throws NoSuchEntryException {
10623                    BookmarksEntry bookmarksEntry = fetchByG_U_F_S_Last(groupId, userId,
10624                                    folderId, status, orderByComparator);
10625    
10626                    if (bookmarksEntry != null) {
10627                            return bookmarksEntry;
10628                    }
10629    
10630                    StringBundler msg = new StringBundler(10);
10631    
10632                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10633    
10634                    msg.append("groupId=");
10635                    msg.append(groupId);
10636    
10637                    msg.append(", userId=");
10638                    msg.append(userId);
10639    
10640                    msg.append(", folderId=");
10641                    msg.append(folderId);
10642    
10643                    msg.append(", status=");
10644                    msg.append(status);
10645    
10646                    msg.append(StringPool.CLOSE_CURLY_BRACE);
10647    
10648                    throw new NoSuchEntryException(msg.toString());
10649            }
10650    
10651            /**
10652             * Returns the last bookmarks entry in the ordered set where groupId = &#63; and userId = &#63; and folderId = &#63; and status = &#63;.
10653             *
10654             * @param groupId the group ID
10655             * @param userId the user ID
10656             * @param folderId the folder ID
10657             * @param status the status
10658             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10659             * @return the last matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
10660             */
10661            @Override
10662            public BookmarksEntry fetchByG_U_F_S_Last(long groupId, long userId,
10663                    long folderId, int status,
10664                    OrderByComparator<BookmarksEntry> orderByComparator) {
10665                    int count = countByG_U_F_S(groupId, userId, folderId, status);
10666    
10667                    if (count == 0) {
10668                            return null;
10669                    }
10670    
10671                    List<BookmarksEntry> list = findByG_U_F_S(groupId, userId, folderId,
10672                                    status, count - 1, count, orderByComparator);
10673    
10674                    if (!list.isEmpty()) {
10675                            return list.get(0);
10676                    }
10677    
10678                    return null;
10679            }
10680    
10681            /**
10682             * Returns the bookmarks entries before and after the current bookmarks entry in the ordered set where groupId = &#63; and userId = &#63; and folderId = &#63; and status = &#63;.
10683             *
10684             * @param entryId the primary key of the current bookmarks entry
10685             * @param groupId the group ID
10686             * @param userId the user ID
10687             * @param folderId the folder ID
10688             * @param status the status
10689             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10690             * @return the previous, current, and next bookmarks entry
10691             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
10692             */
10693            @Override
10694            public BookmarksEntry[] findByG_U_F_S_PrevAndNext(long entryId,
10695                    long groupId, long userId, long folderId, int status,
10696                    OrderByComparator<BookmarksEntry> orderByComparator)
10697                    throws NoSuchEntryException {
10698                    BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
10699    
10700                    Session session = null;
10701    
10702                    try {
10703                            session = openSession();
10704    
10705                            BookmarksEntry[] array = new BookmarksEntryImpl[3];
10706    
10707                            array[0] = getByG_U_F_S_PrevAndNext(session, bookmarksEntry,
10708                                            groupId, userId, folderId, status, orderByComparator, true);
10709    
10710                            array[1] = bookmarksEntry;
10711    
10712                            array[2] = getByG_U_F_S_PrevAndNext(session, bookmarksEntry,
10713                                            groupId, userId, folderId, status, orderByComparator, false);
10714    
10715                            return array;
10716                    }
10717                    catch (Exception e) {
10718                            throw processException(e);
10719                    }
10720                    finally {
10721                            closeSession(session);
10722                    }
10723            }
10724    
10725            protected BookmarksEntry getByG_U_F_S_PrevAndNext(Session session,
10726                    BookmarksEntry bookmarksEntry, long groupId, long userId,
10727                    long folderId, int status,
10728                    OrderByComparator<BookmarksEntry> orderByComparator, boolean previous) {
10729                    StringBundler query = null;
10730    
10731                    if (orderByComparator != null) {
10732                            query = new StringBundler(6 +
10733                                            (orderByComparator.getOrderByFields().length * 6));
10734                    }
10735                    else {
10736                            query = new StringBundler(3);
10737                    }
10738    
10739                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
10740    
10741                    query.append(_FINDER_COLUMN_G_U_F_S_GROUPID_2);
10742    
10743                    query.append(_FINDER_COLUMN_G_U_F_S_USERID_2);
10744    
10745                    query.append(_FINDER_COLUMN_G_U_F_S_FOLDERID_2);
10746    
10747                    query.append(_FINDER_COLUMN_G_U_F_S_STATUS_2);
10748    
10749                    if (orderByComparator != null) {
10750                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10751    
10752                            if (orderByConditionFields.length > 0) {
10753                                    query.append(WHERE_AND);
10754                            }
10755    
10756                            for (int i = 0; i < orderByConditionFields.length; i++) {
10757                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10758                                    query.append(orderByConditionFields[i]);
10759    
10760                                    if ((i + 1) < orderByConditionFields.length) {
10761                                            if (orderByComparator.isAscending() ^ previous) {
10762                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10763                                            }
10764                                            else {
10765                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10766                                            }
10767                                    }
10768                                    else {
10769                                            if (orderByComparator.isAscending() ^ previous) {
10770                                                    query.append(WHERE_GREATER_THAN);
10771                                            }
10772                                            else {
10773                                                    query.append(WHERE_LESSER_THAN);
10774                                            }
10775                                    }
10776                            }
10777    
10778                            query.append(ORDER_BY_CLAUSE);
10779    
10780                            String[] orderByFields = orderByComparator.getOrderByFields();
10781    
10782                            for (int i = 0; i < orderByFields.length; i++) {
10783                                    query.append(_ORDER_BY_ENTITY_ALIAS);
10784                                    query.append(orderByFields[i]);
10785    
10786                                    if ((i + 1) < orderByFields.length) {
10787                                            if (orderByComparator.isAscending() ^ previous) {
10788                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10789                                            }
10790                                            else {
10791                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10792                                            }
10793                                    }
10794                                    else {
10795                                            if (orderByComparator.isAscending() ^ previous) {
10796                                                    query.append(ORDER_BY_ASC);
10797                                            }
10798                                            else {
10799                                                    query.append(ORDER_BY_DESC);
10800                                            }
10801                                    }
10802                            }
10803                    }
10804                    else {
10805                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
10806                    }
10807    
10808                    String sql = query.toString();
10809    
10810                    Query q = session.createQuery(sql);
10811    
10812                    q.setFirstResult(0);
10813                    q.setMaxResults(2);
10814    
10815                    QueryPos qPos = QueryPos.getInstance(q);
10816    
10817                    qPos.add(groupId);
10818    
10819                    qPos.add(userId);
10820    
10821                    qPos.add(folderId);
10822    
10823                    qPos.add(status);
10824    
10825                    if (orderByComparator != null) {
10826                            Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry);
10827    
10828                            for (Object value : values) {
10829                                    qPos.add(value);
10830                            }
10831                    }
10832    
10833                    List<BookmarksEntry> list = q.list();
10834    
10835                    if (list.size() == 2) {
10836                            return list.get(1);
10837                    }
10838                    else {
10839                            return null;
10840                    }
10841            }
10842    
10843            /**
10844             * Returns all the bookmarks entries that the user has permission to view where groupId = &#63; and userId = &#63; and folderId = &#63; and status = &#63;.
10845             *
10846             * @param groupId the group ID
10847             * @param userId the user ID
10848             * @param folderId the folder ID
10849             * @param status the status
10850             * @return the matching bookmarks entries that the user has permission to view
10851             */
10852            @Override
10853            public List<BookmarksEntry> filterFindByG_U_F_S(long groupId, long userId,
10854                    long folderId, int status) {
10855                    return filterFindByG_U_F_S(groupId, userId, folderId, status,
10856                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
10857            }
10858    
10859            /**
10860             * Returns a range of all the bookmarks entries that the user has permission to view where groupId = &#63; and userId = &#63; and folderId = &#63; and status = &#63;.
10861             *
10862             * <p>
10863             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.bookmarks.model.impl.BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10864             * </p>
10865             *
10866             * @param groupId the group ID
10867             * @param userId the user ID
10868             * @param folderId the folder ID
10869             * @param status the status
10870             * @param start the lower bound of the range of bookmarks entries
10871             * @param end the upper bound of the range of bookmarks entries (not inclusive)
10872             * @return the range of matching bookmarks entries that the user has permission to view
10873             */
10874            @Override
10875            public List<BookmarksEntry> filterFindByG_U_F_S(long groupId, long userId,
10876                    long folderId, int status, int start, int end) {
10877                    return filterFindByG_U_F_S(groupId, userId, folderId, status, start,
10878                            end, null);
10879            }
10880    
10881            /**
10882             * Returns an ordered range of all the bookmarks entries that the user has permissions to view where groupId = &#63; and userId = &#63; and folderId = &#63; and status = &#63;.
10883             *
10884             * <p>
10885             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.bookmarks.model.impl.BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
10886             * </p>
10887             *
10888             * @param groupId the group ID
10889             * @param userId the user ID
10890             * @param folderId the folder ID
10891             * @param status the status
10892             * @param start the lower bound of the range of bookmarks entries
10893             * @param end the upper bound of the range of bookmarks entries (not inclusive)
10894             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10895             * @return the ordered range of matching bookmarks entries that the user has permission to view
10896             */
10897            @Override
10898            public List<BookmarksEntry> filterFindByG_U_F_S(long groupId, long userId,
10899                    long folderId, int status, int start, int end,
10900                    OrderByComparator<BookmarksEntry> orderByComparator) {
10901                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10902                            return findByG_U_F_S(groupId, userId, folderId, status, start, end,
10903                                    orderByComparator);
10904                    }
10905    
10906                    StringBundler query = null;
10907    
10908                    if (orderByComparator != null) {
10909                            query = new StringBundler(6 +
10910                                            (orderByComparator.getOrderByFields().length * 3));
10911                    }
10912                    else {
10913                            query = new StringBundler(6);
10914                    }
10915    
10916                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
10917    
10918                    query.append(_FINDER_COLUMN_G_U_F_S_GROUPID_2);
10919    
10920                    query.append(_FINDER_COLUMN_G_U_F_S_USERID_2);
10921    
10922                    query.append(_FINDER_COLUMN_G_U_F_S_FOLDERID_2);
10923    
10924                    query.append(_FINDER_COLUMN_G_U_F_S_STATUS_2);
10925    
10926                    if (orderByComparator != null) {
10927                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10928                                    orderByComparator);
10929                    }
10930                    else {
10931                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
10932                    }
10933    
10934                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10935                                    BookmarksEntry.class.getName(),
10936                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
10937                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
10938    
10939                    Session session = null;
10940    
10941                    try {
10942                            session = openSession();
10943    
10944                            Query q = session.createQuery(sql);
10945    
10946                            QueryPos qPos = QueryPos.getInstance(q);
10947    
10948                            qPos.add(groupId);
10949    
10950                            qPos.add(userId);
10951    
10952                            qPos.add(folderId);
10953    
10954                            qPos.add(status);
10955    
10956                            return (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start,
10957                                    end);
10958                    }
10959                    catch (Exception e) {
10960                            throw processException(e);
10961                    }
10962                    finally {
10963                            closeSession(session);
10964                    }
10965            }
10966    
10967            /**
10968             * Returns the bookmarks entries before and after the current bookmarks entry in the ordered set of bookmarks entries that the user has permission to view where groupId = &#63; and userId = &#63; and folderId = &#63; and status = &#63;.
10969             *
10970             * @param entryId the primary key of the current bookmarks entry
10971             * @param groupId the group ID
10972             * @param userId the user ID
10973             * @param folderId the folder ID
10974             * @param status the status
10975             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10976             * @return the previous, current, and next bookmarks entry
10977             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
10978             */
10979            @Override
10980            public BookmarksEntry[] filterFindByG_U_F_S_PrevAndNext(long entryId,
10981                    long groupId, long userId, long folderId, int status,
10982                    OrderByComparator<BookmarksEntry> orderByComparator)
10983                    throws NoSuchEntryException {
10984                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10985                            return findByG_U_F_S_PrevAndNext(entryId, groupId, userId,
10986                                    folderId, status, orderByComparator);
10987                    }
10988    
10989                    BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
10990    
10991                    Session session = null;
10992    
10993                    try {
10994                            session = openSession();
10995    
10996                            BookmarksEntry[] array = new BookmarksEntryImpl[3];
10997    
10998                            array[0] = filterGetByG_U_F_S_PrevAndNext(session, bookmarksEntry,
10999                                            groupId, userId, folderId, status, orderByComparator, true);
11000    
11001                            array[1] = bookmarksEntry;
11002    
11003                            array[2] = filterGetByG_U_F_S_PrevAndNext(session, bookmarksEntry,
11004                                            groupId, userId, folderId, status, orderByComparator, false);
11005    
11006                            return array;
11007                    }
11008                    catch (Exception e) {
11009                            throw processException(e);
11010                    }
11011                    finally {
11012                            closeSession(session);
11013                    }
11014            }
11015    
11016            protected BookmarksEntry filterGetByG_U_F_S_PrevAndNext(Session session,
11017                    BookmarksEntry bookmarksEntry, long groupId, long userId,
11018                    long folderId, int status,
11019                    OrderByComparator<BookmarksEntry> orderByComparator, boolean previous) {
11020                    StringBundler query = null;
11021    
11022                    if (orderByComparator != null) {
11023                            query = new StringBundler(6 +
11024                                            (orderByComparator.getOrderByFields().length * 6));
11025                    }
11026                    else {
11027                            query = new StringBundler(3);
11028                    }
11029    
11030                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
11031    
11032                    query.append(_FINDER_COLUMN_G_U_F_S_GROUPID_2);
11033    
11034                    query.append(_FINDER_COLUMN_G_U_F_S_USERID_2);
11035    
11036                    query.append(_FINDER_COLUMN_G_U_F_S_FOLDERID_2);
11037    
11038                    query.append(_FINDER_COLUMN_G_U_F_S_STATUS_2);
11039    
11040                    if (orderByComparator != null) {
11041                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11042    
11043                            if (orderByConditionFields.length > 0) {
11044                                    query.append(WHERE_AND);
11045                            }
11046    
11047                            for (int i = 0; i < orderByConditionFields.length; i++) {
11048                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11049                                    query.append(orderByConditionFields[i]);
11050    
11051                                    if ((i + 1) < orderByConditionFields.length) {
11052                                            if (orderByComparator.isAscending() ^ previous) {
11053                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
11054                                            }
11055                                            else {
11056                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
11057                                            }
11058                                    }
11059                                    else {
11060                                            if (orderByComparator.isAscending() ^ previous) {
11061                                                    query.append(WHERE_GREATER_THAN);
11062                                            }
11063                                            else {
11064                                                    query.append(WHERE_LESSER_THAN);
11065                                            }
11066                                    }
11067                            }
11068    
11069                            query.append(ORDER_BY_CLAUSE);
11070    
11071                            String[] orderByFields = orderByComparator.getOrderByFields();
11072    
11073                            for (int i = 0; i < orderByFields.length; i++) {
11074                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11075                                    query.append(orderByFields[i]);
11076    
11077                                    if ((i + 1) < orderByFields.length) {
11078                                            if (orderByComparator.isAscending() ^ previous) {
11079                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
11080                                            }
11081                                            else {
11082                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
11083                                            }
11084                                    }
11085                                    else {
11086                                            if (orderByComparator.isAscending() ^ previous) {
11087                                                    query.append(ORDER_BY_ASC);
11088                                            }
11089                                            else {
11090                                                    query.append(ORDER_BY_DESC);
11091                                            }
11092                                    }
11093                            }
11094                    }
11095                    else {
11096                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
11097                    }
11098    
11099                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11100                                    BookmarksEntry.class.getName(),
11101                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
11102                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
11103    
11104                    Query q = session.createQuery(sql);
11105    
11106                    q.setFirstResult(0);
11107                    q.setMaxResults(2);
11108    
11109                    QueryPos qPos = QueryPos.getInstance(q);
11110    
11111                    qPos.add(groupId);
11112    
11113                    qPos.add(userId);
11114    
11115                    qPos.add(folderId);
11116    
11117                    qPos.add(status);
11118    
11119                    if (orderByComparator != null) {
11120                            Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry);
11121    
11122                            for (Object value : values) {
11123                                    qPos.add(value);
11124                            }
11125                    }
11126    
11127                    List<BookmarksEntry> list = q.list();
11128    
11129                    if (list.size() == 2) {
11130                            return list.get(1);
11131                    }
11132                    else {
11133                            return null;
11134                    }
11135            }
11136    
11137            /**
11138             * Returns all the bookmarks entries that the user has permission to view where groupId = &#63; and userId = &#63; and folderId = any &#63; and status = &#63;.
11139             *
11140             * @param groupId the group ID
11141             * @param userId the user ID
11142             * @param folderIds the folder IDs
11143             * @param status the status
11144             * @return the matching bookmarks entries that the user has permission to view
11145             */
11146            @Override
11147            public List<BookmarksEntry> filterFindByG_U_F_S(long groupId, long userId,
11148                    long[] folderIds, int status) {
11149                    return filterFindByG_U_F_S(groupId, userId, folderIds, status,
11150                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
11151            }
11152    
11153            /**
11154             * Returns a range of all the bookmarks entries that the user has permission to view where groupId = &#63; and userId = &#63; and folderId = any &#63; and status = &#63;.
11155             *
11156             * <p>
11157             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.bookmarks.model.impl.BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11158             * </p>
11159             *
11160             * @param groupId the group ID
11161             * @param userId the user ID
11162             * @param folderIds the folder IDs
11163             * @param status the status
11164             * @param start the lower bound of the range of bookmarks entries
11165             * @param end the upper bound of the range of bookmarks entries (not inclusive)
11166             * @return the range of matching bookmarks entries that the user has permission to view
11167             */
11168            @Override
11169            public List<BookmarksEntry> filterFindByG_U_F_S(long groupId, long userId,
11170                    long[] folderIds, int status, int start, int end) {
11171                    return filterFindByG_U_F_S(groupId, userId, folderIds, status, start,
11172                            end, null);
11173            }
11174    
11175            /**
11176             * Returns an ordered range of all the bookmarks entries that the user has permission to view where groupId = &#63; and userId = &#63; and folderId = any &#63; and status = &#63;.
11177             *
11178             * <p>
11179             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.bookmarks.model.impl.BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11180             * </p>
11181             *
11182             * @param groupId the group ID
11183             * @param userId the user ID
11184             * @param folderIds the folder IDs
11185             * @param status the status
11186             * @param start the lower bound of the range of bookmarks entries
11187             * @param end the upper bound of the range of bookmarks entries (not inclusive)
11188             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11189             * @return the ordered range of matching bookmarks entries that the user has permission to view
11190             */
11191            @Override
11192            public List<BookmarksEntry> filterFindByG_U_F_S(long groupId, long userId,
11193                    long[] folderIds, int status, int start, int end,
11194                    OrderByComparator<BookmarksEntry> orderByComparator) {
11195                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11196                            return findByG_U_F_S(groupId, userId, folderIds, status, start,
11197                                    end, orderByComparator);
11198                    }
11199    
11200                    if (folderIds == null) {
11201                            folderIds = new long[0];
11202                    }
11203                    else {
11204                            folderIds = ArrayUtil.unique(folderIds);
11205                    }
11206    
11207                    StringBundler query = new StringBundler();
11208    
11209                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
11210    
11211                    query.append(_FINDER_COLUMN_G_U_F_S_GROUPID_2);
11212    
11213                    query.append(_FINDER_COLUMN_G_U_F_S_USERID_2);
11214    
11215                    if (folderIds.length > 0) {
11216                            query.append(StringPool.OPEN_PARENTHESIS);
11217    
11218                            query.append(_FINDER_COLUMN_G_U_F_S_FOLDERID_7);
11219    
11220                            query.append(StringUtil.merge(folderIds));
11221    
11222                            query.append(StringPool.CLOSE_PARENTHESIS);
11223    
11224                            query.append(StringPool.CLOSE_PARENTHESIS);
11225    
11226                            query.append(WHERE_AND);
11227                    }
11228    
11229                    query.append(_FINDER_COLUMN_G_U_F_S_STATUS_2);
11230    
11231                    query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
11232                            query.index() - 1);
11233    
11234                    if (orderByComparator != null) {
11235                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11236                                    orderByComparator);
11237                    }
11238                    else {
11239                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
11240                    }
11241    
11242                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11243                                    BookmarksEntry.class.getName(),
11244                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
11245                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
11246    
11247                    Session session = null;
11248    
11249                    try {
11250                            session = openSession();
11251    
11252                            Query q = session.createQuery(sql);
11253    
11254                            QueryPos qPos = QueryPos.getInstance(q);
11255    
11256                            qPos.add(groupId);
11257    
11258                            qPos.add(userId);
11259    
11260                            qPos.add(status);
11261    
11262                            return (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start,
11263                                    end);
11264                    }
11265                    catch (Exception e) {
11266                            throw processException(e);
11267                    }
11268                    finally {
11269                            closeSession(session);
11270                    }
11271            }
11272    
11273            /**
11274             * Returns all the bookmarks entries where groupId = &#63; and userId = &#63; and folderId = any &#63; and status = &#63;.
11275             *
11276             * <p>
11277             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.bookmarks.model.impl.BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11278             * </p>
11279             *
11280             * @param groupId the group ID
11281             * @param userId the user ID
11282             * @param folderIds the folder IDs
11283             * @param status the status
11284             * @return the matching bookmarks entries
11285             */
11286            @Override
11287            public List<BookmarksEntry> findByG_U_F_S(long groupId, long userId,
11288                    long[] folderIds, int status) {
11289                    return findByG_U_F_S(groupId, userId, folderIds, status,
11290                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
11291            }
11292    
11293            /**
11294             * Returns a range of all the bookmarks entries where groupId = &#63; and userId = &#63; and folderId = any &#63; and status = &#63;.
11295             *
11296             * <p>
11297             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.bookmarks.model.impl.BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11298             * </p>
11299             *
11300             * @param groupId the group ID
11301             * @param userId the user ID
11302             * @param folderIds the folder IDs
11303             * @param status the status
11304             * @param start the lower bound of the range of bookmarks entries
11305             * @param end the upper bound of the range of bookmarks entries (not inclusive)
11306             * @return the range of matching bookmarks entries
11307             */
11308            @Override
11309            public List<BookmarksEntry> findByG_U_F_S(long groupId, long userId,
11310                    long[] folderIds, int status, int start, int end) {
11311                    return findByG_U_F_S(groupId, userId, folderIds, status, start, end,
11312                            null);
11313            }
11314    
11315            /**
11316             * Returns an ordered range of all the bookmarks entries where groupId = &#63; and userId = &#63; and folderId = any &#63; and status = &#63;.
11317             *
11318             * <p>
11319             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.bookmarks.model.impl.BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11320             * </p>
11321             *
11322             * @param groupId the group ID
11323             * @param userId the user ID
11324             * @param folderIds the folder IDs
11325             * @param status the status
11326             * @param start the lower bound of the range of bookmarks entries
11327             * @param end the upper bound of the range of bookmarks entries (not inclusive)
11328             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11329             * @return the ordered range of matching bookmarks entries
11330             */
11331            @Override
11332            public List<BookmarksEntry> findByG_U_F_S(long groupId, long userId,
11333                    long[] folderIds, int status, int start, int end,
11334                    OrderByComparator<BookmarksEntry> orderByComparator) {
11335                    if (folderIds == null) {
11336                            folderIds = new long[0];
11337                    }
11338                    else {
11339                            folderIds = ArrayUtil.unique(folderIds);
11340                    }
11341    
11342                    if (folderIds.length == 1) {
11343                            return findByG_U_F_S(groupId, userId, folderIds[0], status, start,
11344                                    end, orderByComparator);
11345                    }
11346    
11347                    boolean pagination = true;
11348                    Object[] finderArgs = null;
11349    
11350                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
11351                                    (orderByComparator == null)) {
11352                            pagination = false;
11353                            finderArgs = new Object[] {
11354                                            groupId, userId, StringUtil.merge(folderIds), status
11355                                    };
11356                    }
11357                    else {
11358                            finderArgs = new Object[] {
11359                                            groupId, userId, StringUtil.merge(folderIds), status,
11360                                            
11361                                            start, end, orderByComparator
11362                                    };
11363                    }
11364    
11365                    List<BookmarksEntry> list = (List<BookmarksEntry>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_F_S,
11366                                    finderArgs, this);
11367    
11368                    if ((list != null) && !list.isEmpty()) {
11369                            for (BookmarksEntry bookmarksEntry : list) {
11370                                    if ((groupId != bookmarksEntry.getGroupId()) ||
11371                                                    (userId != bookmarksEntry.getUserId()) ||
11372                                                    !ArrayUtil.contains(folderIds,
11373                                                            bookmarksEntry.getFolderId()) ||
11374                                                    (status != bookmarksEntry.getStatus())) {
11375                                            list = null;
11376    
11377                                            break;
11378                                    }
11379                            }
11380                    }
11381    
11382                    if (list == null) {
11383                            StringBundler query = new StringBundler();
11384    
11385                            query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
11386    
11387                            query.append(_FINDER_COLUMN_G_U_F_S_GROUPID_2);
11388    
11389                            query.append(_FINDER_COLUMN_G_U_F_S_USERID_2);
11390    
11391                            if (folderIds.length > 0) {
11392                                    query.append(StringPool.OPEN_PARENTHESIS);
11393    
11394                                    query.append(_FINDER_COLUMN_G_U_F_S_FOLDERID_7);
11395    
11396                                    query.append(StringUtil.merge(folderIds));
11397    
11398                                    query.append(StringPool.CLOSE_PARENTHESIS);
11399    
11400                                    query.append(StringPool.CLOSE_PARENTHESIS);
11401    
11402                                    query.append(WHERE_AND);
11403                            }
11404    
11405                            query.append(_FINDER_COLUMN_G_U_F_S_STATUS_2);
11406    
11407                            query.setStringAt(removeConjunction(query.stringAt(query.index() -
11408                                                    1)), query.index() - 1);
11409    
11410                            if (orderByComparator != null) {
11411                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11412                                            orderByComparator);
11413                            }
11414                            else
11415                             if (pagination) {
11416                                    query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
11417                            }
11418    
11419                            String sql = query.toString();
11420    
11421                            Session session = null;
11422    
11423                            try {
11424                                    session = openSession();
11425    
11426                                    Query q = session.createQuery(sql);
11427    
11428                                    QueryPos qPos = QueryPos.getInstance(q);
11429    
11430                                    qPos.add(groupId);
11431    
11432                                    qPos.add(userId);
11433    
11434                                    qPos.add(status);
11435    
11436                                    if (!pagination) {
11437                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
11438                                                            getDialect(), start, end, false);
11439    
11440                                            Collections.sort(list);
11441    
11442                                            list = Collections.unmodifiableList(list);
11443                                    }
11444                                    else {
11445                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
11446                                                            getDialect(), start, end);
11447                                    }
11448    
11449                                    cacheResult(list);
11450    
11451                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_F_S,
11452                                            finderArgs, list);
11453                            }
11454                            catch (Exception e) {
11455                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_F_S,
11456                                            finderArgs);
11457    
11458                                    throw processException(e);
11459                            }
11460                            finally {
11461                                    closeSession(session);
11462                            }
11463                    }
11464    
11465                    return list;
11466            }
11467    
11468            /**
11469             * Removes all the bookmarks entries where groupId = &#63; and userId = &#63; and folderId = &#63; and status = &#63; from the database.
11470             *
11471             * @param groupId the group ID
11472             * @param userId the user ID
11473             * @param folderId the folder ID
11474             * @param status the status
11475             */
11476            @Override
11477            public void removeByG_U_F_S(long groupId, long userId, long folderId,
11478                    int status) {
11479                    for (BookmarksEntry bookmarksEntry : findByG_U_F_S(groupId, userId,
11480                                    folderId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
11481                            remove(bookmarksEntry);
11482                    }
11483            }
11484    
11485            /**
11486             * Returns the number of bookmarks entries where groupId = &#63; and userId = &#63; and folderId = &#63; and status = &#63;.
11487             *
11488             * @param groupId the group ID
11489             * @param userId the user ID
11490             * @param folderId the folder ID
11491             * @param status the status
11492             * @return the number of matching bookmarks entries
11493             */
11494            @Override
11495            public int countByG_U_F_S(long groupId, long userId, long folderId,
11496                    int status) {
11497                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_U_F_S;
11498    
11499                    Object[] finderArgs = new Object[] { groupId, userId, folderId, status };
11500    
11501                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
11502                                    this);
11503    
11504                    if (count == null) {
11505                            StringBundler query = new StringBundler(5);
11506    
11507                            query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
11508    
11509                            query.append(_FINDER_COLUMN_G_U_F_S_GROUPID_2);
11510    
11511                            query.append(_FINDER_COLUMN_G_U_F_S_USERID_2);
11512    
11513                            query.append(_FINDER_COLUMN_G_U_F_S_FOLDERID_2);
11514    
11515                            query.append(_FINDER_COLUMN_G_U_F_S_STATUS_2);
11516    
11517                            String sql = query.toString();
11518    
11519                            Session session = null;
11520    
11521                            try {
11522                                    session = openSession();
11523    
11524                                    Query q = session.createQuery(sql);
11525    
11526                                    QueryPos qPos = QueryPos.getInstance(q);
11527    
11528                                    qPos.add(groupId);
11529    
11530                                    qPos.add(userId);
11531    
11532                                    qPos.add(folderId);
11533    
11534                                    qPos.add(status);
11535    
11536                                    count = (Long)q.uniqueResult();
11537    
11538                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
11539                            }
11540                            catch (Exception e) {
11541                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
11542    
11543                                    throw processException(e);
11544                            }
11545                            finally {
11546                                    closeSession(session);
11547                            }
11548                    }
11549    
11550                    return count.intValue();
11551            }
11552    
11553            /**
11554             * Returns the number of bookmarks entries where groupId = &#63; and userId = &#63; and folderId = any &#63; and status = &#63;.
11555             *
11556             * @param groupId the group ID
11557             * @param userId the user ID
11558             * @param folderIds the folder IDs
11559             * @param status the status
11560             * @return the number of matching bookmarks entries
11561             */
11562            @Override
11563            public int countByG_U_F_S(long groupId, long userId, long[] folderIds,
11564                    int status) {
11565                    if (folderIds == null) {
11566                            folderIds = new long[0];
11567                    }
11568                    else {
11569                            folderIds = ArrayUtil.unique(folderIds);
11570                    }
11571    
11572                    Object[] finderArgs = new Object[] {
11573                                    groupId, userId, StringUtil.merge(folderIds), status
11574                            };
11575    
11576                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_F_S,
11577                                    finderArgs, this);
11578    
11579                    if (count == null) {
11580                            StringBundler query = new StringBundler();
11581    
11582                            query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
11583    
11584                            query.append(_FINDER_COLUMN_G_U_F_S_GROUPID_2);
11585    
11586                            query.append(_FINDER_COLUMN_G_U_F_S_USERID_2);
11587    
11588                            if (folderIds.length > 0) {
11589                                    query.append(StringPool.OPEN_PARENTHESIS);
11590    
11591                                    query.append(_FINDER_COLUMN_G_U_F_S_FOLDERID_7);
11592    
11593                                    query.append(StringUtil.merge(folderIds));
11594    
11595                                    query.append(StringPool.CLOSE_PARENTHESIS);
11596    
11597                                    query.append(StringPool.CLOSE_PARENTHESIS);
11598    
11599                                    query.append(WHERE_AND);
11600                            }
11601    
11602                            query.append(_FINDER_COLUMN_G_U_F_S_STATUS_2);
11603    
11604                            query.setStringAt(removeConjunction(query.stringAt(query.index() -
11605                                                    1)), query.index() - 1);
11606    
11607                            String sql = query.toString();
11608    
11609                            Session session = null;
11610    
11611                            try {
11612                                    session = openSession();
11613    
11614                                    Query q = session.createQuery(sql);
11615    
11616                                    QueryPos qPos = QueryPos.getInstance(q);
11617    
11618                                    qPos.add(groupId);
11619    
11620                                    qPos.add(userId);
11621    
11622                                    qPos.add(status);
11623    
11624                                    count = (Long)q.uniqueResult();
11625    
11626                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_F_S,
11627                                            finderArgs, count);
11628                            }
11629                            catch (Exception e) {
11630                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_F_S,
11631                                            finderArgs);
11632    
11633                                    throw processException(e);
11634                            }
11635                            finally {
11636                                    closeSession(session);
11637                            }
11638                    }
11639    
11640                    return count.intValue();
11641            }
11642    
11643            /**
11644             * Returns the number of bookmarks entries that the user has permission to view where groupId = &#63; and userId = &#63; and folderId = &#63; and status = &#63;.
11645             *
11646             * @param groupId the group ID
11647             * @param userId the user ID
11648             * @param folderId the folder ID
11649             * @param status the status
11650             * @return the number of matching bookmarks entries that the user has permission to view
11651             */
11652            @Override
11653            public int filterCountByG_U_F_S(long groupId, long userId, long folderId,
11654                    int status) {
11655                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11656                            return countByG_U_F_S(groupId, userId, folderId, status);
11657                    }
11658    
11659                    StringBundler query = new StringBundler(5);
11660    
11661                    query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
11662    
11663                    query.append(_FINDER_COLUMN_G_U_F_S_GROUPID_2);
11664    
11665                    query.append(_FINDER_COLUMN_G_U_F_S_USERID_2);
11666    
11667                    query.append(_FINDER_COLUMN_G_U_F_S_FOLDERID_2);
11668    
11669                    query.append(_FINDER_COLUMN_G_U_F_S_STATUS_2);
11670    
11671                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11672                                    BookmarksEntry.class.getName(),
11673                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
11674                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
11675    
11676                    Session session = null;
11677    
11678                    try {
11679                            session = openSession();
11680    
11681                            Query q = session.createQuery(sql);
11682    
11683                            QueryPos qPos = QueryPos.getInstance(q);
11684    
11685                            qPos.add(groupId);
11686    
11687                            qPos.add(userId);
11688    
11689                            qPos.add(folderId);
11690    
11691                            qPos.add(status);
11692    
11693                            Long count = (Long)q.uniqueResult();
11694    
11695                            return count.intValue();
11696                    }
11697                    catch (Exception e) {
11698                            throw processException(e);
11699                    }
11700                    finally {
11701                            closeSession(session);
11702                    }
11703            }
11704    
11705            /**
11706             * Returns the number of bookmarks entries that the user has permission to view where groupId = &#63; and userId = &#63; and folderId = any &#63; and status = &#63;.
11707             *
11708             * @param groupId the group ID
11709             * @param userId the user ID
11710             * @param folderIds the folder IDs
11711             * @param status the status
11712             * @return the number of matching bookmarks entries that the user has permission to view
11713             */
11714            @Override
11715            public int filterCountByG_U_F_S(long groupId, long userId,
11716                    long[] folderIds, int status) {
11717                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11718                            return countByG_U_F_S(groupId, userId, folderIds, status);
11719                    }
11720    
11721                    if (folderIds == null) {
11722                            folderIds = new long[0];
11723                    }
11724                    else {
11725                            folderIds = ArrayUtil.unique(folderIds);
11726                    }
11727    
11728                    StringBundler query = new StringBundler();
11729    
11730                    query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
11731    
11732                    query.append(_FINDER_COLUMN_G_U_F_S_GROUPID_2);
11733    
11734                    query.append(_FINDER_COLUMN_G_U_F_S_USERID_2);
11735    
11736                    if (folderIds.length > 0) {
11737                            query.append(StringPool.OPEN_PARENTHESIS);
11738    
11739                            query.append(_FINDER_COLUMN_G_U_F_S_FOLDERID_7);
11740    
11741                            query.append(StringUtil.merge(folderIds));
11742    
11743                            query.append(StringPool.CLOSE_PARENTHESIS);
11744    
11745                            query.append(StringPool.CLOSE_PARENTHESIS);
11746    
11747                            query.append(WHERE_AND);
11748                    }
11749    
11750                    query.append(_FINDER_COLUMN_G_U_F_S_STATUS_2);
11751    
11752                    query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
11753                            query.index() - 1);
11754    
11755                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11756                                    BookmarksEntry.class.getName(),
11757                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
11758                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
11759    
11760                    Session session = null;
11761    
11762                    try {
11763                            session = openSession();
11764    
11765                            Query q = session.createQuery(sql);
11766    
11767                            QueryPos qPos = QueryPos.getInstance(q);
11768    
11769                            qPos.add(groupId);
11770    
11771                            qPos.add(userId);
11772    
11773                            qPos.add(status);
11774    
11775                            Long count = (Long)q.uniqueResult();
11776    
11777                            return count.intValue();
11778                    }
11779                    catch (Exception e) {
11780                            throw processException(e);
11781                    }
11782                    finally {
11783                            closeSession(session);
11784                    }
11785            }
11786    
11787            private static final String _FINDER_COLUMN_G_U_F_S_GROUPID_2 = "bookmarksEntry.groupId = ? AND ";
11788            private static final String _FINDER_COLUMN_G_U_F_S_USERID_2 = "bookmarksEntry.userId = ? AND ";
11789            private static final String _FINDER_COLUMN_G_U_F_S_FOLDERID_2 = "bookmarksEntry.folderId = ? AND ";
11790            private static final String _FINDER_COLUMN_G_U_F_S_FOLDERID_7 = "bookmarksEntry.folderId IN (";
11791            private static final String _FINDER_COLUMN_G_U_F_S_STATUS_2 = "bookmarksEntry.status = ?";
11792    
11793            public BookmarksEntryPersistenceImpl() {
11794                    setModelClass(BookmarksEntry.class);
11795            }
11796    
11797            /**
11798             * Caches the bookmarks entry in the entity cache if it is enabled.
11799             *
11800             * @param bookmarksEntry the bookmarks entry
11801             */
11802            @Override
11803            public void cacheResult(BookmarksEntry bookmarksEntry) {
11804                    EntityCacheUtil.putResult(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
11805                            BookmarksEntryImpl.class, bookmarksEntry.getPrimaryKey(),
11806                            bookmarksEntry);
11807    
11808                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
11809                            new Object[] { bookmarksEntry.getUuid(), bookmarksEntry.getGroupId() },
11810                            bookmarksEntry);
11811    
11812                    bookmarksEntry.resetOriginalValues();
11813            }
11814    
11815            /**
11816             * Caches the bookmarks entries in the entity cache if it is enabled.
11817             *
11818             * @param bookmarksEntries the bookmarks entries
11819             */
11820            @Override
11821            public void cacheResult(List<BookmarksEntry> bookmarksEntries) {
11822                    for (BookmarksEntry bookmarksEntry : bookmarksEntries) {
11823                            if (EntityCacheUtil.getResult(
11824                                                    BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
11825                                                    BookmarksEntryImpl.class, bookmarksEntry.getPrimaryKey()) == null) {
11826                                    cacheResult(bookmarksEntry);
11827                            }
11828                            else {
11829                                    bookmarksEntry.resetOriginalValues();
11830                            }
11831                    }
11832            }
11833    
11834            /**
11835             * Clears the cache for all bookmarks entries.
11836             *
11837             * <p>
11838             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
11839             * </p>
11840             */
11841            @Override
11842            public void clearCache() {
11843                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
11844                            CacheRegistryUtil.clear(BookmarksEntryImpl.class.getName());
11845                    }
11846    
11847                    EntityCacheUtil.clearCache(BookmarksEntryImpl.class);
11848    
11849                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
11850                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
11851                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
11852            }
11853    
11854            /**
11855             * Clears the cache for the bookmarks entry.
11856             *
11857             * <p>
11858             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
11859             * </p>
11860             */
11861            @Override
11862            public void clearCache(BookmarksEntry bookmarksEntry) {
11863                    EntityCacheUtil.removeResult(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
11864                            BookmarksEntryImpl.class, bookmarksEntry.getPrimaryKey());
11865    
11866                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
11867                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
11868    
11869                    clearUniqueFindersCache(bookmarksEntry);
11870            }
11871    
11872            @Override
11873            public void clearCache(List<BookmarksEntry> bookmarksEntries) {
11874                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
11875                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
11876    
11877                    for (BookmarksEntry bookmarksEntry : bookmarksEntries) {
11878                            EntityCacheUtil.removeResult(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
11879                                    BookmarksEntryImpl.class, bookmarksEntry.getPrimaryKey());
11880    
11881                            clearUniqueFindersCache(bookmarksEntry);
11882                    }
11883            }
11884    
11885            protected void cacheUniqueFindersCache(BookmarksEntry bookmarksEntry) {
11886                    if (bookmarksEntry.isNew()) {
11887                            Object[] args = new Object[] {
11888                                            bookmarksEntry.getUuid(), bookmarksEntry.getGroupId()
11889                                    };
11890    
11891                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
11892                                    Long.valueOf(1));
11893                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
11894                                    bookmarksEntry);
11895                    }
11896                    else {
11897                            BookmarksEntryModelImpl bookmarksEntryModelImpl = (BookmarksEntryModelImpl)bookmarksEntry;
11898    
11899                            if ((bookmarksEntryModelImpl.getColumnBitmask() &
11900                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
11901                                    Object[] args = new Object[] {
11902                                                    bookmarksEntry.getUuid(), bookmarksEntry.getGroupId()
11903                                            };
11904    
11905                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
11906                                            Long.valueOf(1));
11907                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
11908                                            bookmarksEntry);
11909                            }
11910                    }
11911            }
11912    
11913            protected void clearUniqueFindersCache(BookmarksEntry bookmarksEntry) {
11914                    BookmarksEntryModelImpl bookmarksEntryModelImpl = (BookmarksEntryModelImpl)bookmarksEntry;
11915    
11916                    Object[] args = new Object[] {
11917                                    bookmarksEntry.getUuid(), bookmarksEntry.getGroupId()
11918                            };
11919    
11920                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
11921                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
11922    
11923                    if ((bookmarksEntryModelImpl.getColumnBitmask() &
11924                                    FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
11925                            args = new Object[] {
11926                                            bookmarksEntryModelImpl.getOriginalUuid(),
11927                                            bookmarksEntryModelImpl.getOriginalGroupId()
11928                                    };
11929    
11930                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
11931                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
11932                    }
11933            }
11934    
11935            /**
11936             * Creates a new bookmarks entry with the primary key. Does not add the bookmarks entry to the database.
11937             *
11938             * @param entryId the primary key for the new bookmarks entry
11939             * @return the new bookmarks entry
11940             */
11941            @Override
11942            public BookmarksEntry create(long entryId) {
11943                    BookmarksEntry bookmarksEntry = new BookmarksEntryImpl();
11944    
11945                    bookmarksEntry.setNew(true);
11946                    bookmarksEntry.setPrimaryKey(entryId);
11947    
11948                    String uuid = PortalUUIDUtil.generate();
11949    
11950                    bookmarksEntry.setUuid(uuid);
11951    
11952                    return bookmarksEntry;
11953            }
11954    
11955            /**
11956             * Removes the bookmarks entry with the primary key from the database. Also notifies the appropriate model listeners.
11957             *
11958             * @param entryId the primary key of the bookmarks entry
11959             * @return the bookmarks entry that was removed
11960             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
11961             */
11962            @Override
11963            public BookmarksEntry remove(long entryId) throws NoSuchEntryException {
11964                    return remove((Serializable)entryId);
11965            }
11966    
11967            /**
11968             * Removes the bookmarks entry with the primary key from the database. Also notifies the appropriate model listeners.
11969             *
11970             * @param primaryKey the primary key of the bookmarks entry
11971             * @return the bookmarks entry that was removed
11972             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
11973             */
11974            @Override
11975            public BookmarksEntry remove(Serializable primaryKey)
11976                    throws NoSuchEntryException {
11977                    Session session = null;
11978    
11979                    try {
11980                            session = openSession();
11981    
11982                            BookmarksEntry bookmarksEntry = (BookmarksEntry)session.get(BookmarksEntryImpl.class,
11983                                            primaryKey);
11984    
11985                            if (bookmarksEntry == null) {
11986                                    if (_log.isWarnEnabled()) {
11987                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
11988                                    }
11989    
11990                                    throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
11991                                            primaryKey);
11992                            }
11993    
11994                            return remove(bookmarksEntry);
11995                    }
11996                    catch (NoSuchEntryException nsee) {
11997                            throw nsee;
11998                    }
11999                    catch (Exception e) {
12000                            throw processException(e);
12001                    }
12002                    finally {
12003                            closeSession(session);
12004                    }
12005            }
12006    
12007            @Override
12008            protected BookmarksEntry removeImpl(BookmarksEntry bookmarksEntry) {
12009                    bookmarksEntry = toUnwrappedModel(bookmarksEntry);
12010    
12011                    Session session = null;
12012    
12013                    try {
12014                            session = openSession();
12015    
12016                            if (!session.contains(bookmarksEntry)) {
12017                                    bookmarksEntry = (BookmarksEntry)session.get(BookmarksEntryImpl.class,
12018                                                    bookmarksEntry.getPrimaryKeyObj());
12019                            }
12020    
12021                            if (bookmarksEntry != null) {
12022                                    session.delete(bookmarksEntry);
12023                            }
12024                    }
12025                    catch (Exception e) {
12026                            throw processException(e);
12027                    }
12028                    finally {
12029                            closeSession(session);
12030                    }
12031    
12032                    if (bookmarksEntry != null) {
12033                            clearCache(bookmarksEntry);
12034                    }
12035    
12036                    return bookmarksEntry;
12037            }
12038    
12039            @Override
12040            public BookmarksEntry updateImpl(
12041                    com.liferay.portlet.bookmarks.model.BookmarksEntry bookmarksEntry) {
12042                    bookmarksEntry = toUnwrappedModel(bookmarksEntry);
12043    
12044                    boolean isNew = bookmarksEntry.isNew();
12045    
12046                    BookmarksEntryModelImpl bookmarksEntryModelImpl = (BookmarksEntryModelImpl)bookmarksEntry;
12047    
12048                    if (Validator.isNull(bookmarksEntry.getUuid())) {
12049                            String uuid = PortalUUIDUtil.generate();
12050    
12051                            bookmarksEntry.setUuid(uuid);
12052                    }
12053    
12054                    Session session = null;
12055    
12056                    try {
12057                            session = openSession();
12058    
12059                            if (bookmarksEntry.isNew()) {
12060                                    session.save(bookmarksEntry);
12061    
12062                                    bookmarksEntry.setNew(false);
12063                            }
12064                            else {
12065                                    session.merge(bookmarksEntry);
12066                            }
12067                    }
12068                    catch (Exception e) {
12069                            throw processException(e);
12070                    }
12071                    finally {
12072                            closeSession(session);
12073                    }
12074    
12075                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
12076    
12077                    if (isNew || !BookmarksEntryModelImpl.COLUMN_BITMASK_ENABLED) {
12078                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
12079                    }
12080    
12081                    else {
12082                            if ((bookmarksEntryModelImpl.getColumnBitmask() &
12083                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEBLOCKID.getColumnBitmask()) != 0) {
12084                                    Object[] args = new Object[] {
12085                                                    bookmarksEntryModelImpl.getOriginalResourceBlockId()
12086                                            };
12087    
12088                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RESOURCEBLOCKID,
12089                                            args);
12090                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEBLOCKID,
12091                                            args);
12092    
12093                                    args = new Object[] { bookmarksEntryModelImpl.getResourceBlockId() };
12094    
12095                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RESOURCEBLOCKID,
12096                                            args);
12097                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEBLOCKID,
12098                                            args);
12099                            }
12100    
12101                            if ((bookmarksEntryModelImpl.getColumnBitmask() &
12102                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
12103                                    Object[] args = new Object[] {
12104                                                    bookmarksEntryModelImpl.getOriginalUuid()
12105                                            };
12106    
12107                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
12108                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
12109                                            args);
12110    
12111                                    args = new Object[] { bookmarksEntryModelImpl.getUuid() };
12112    
12113                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
12114                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
12115                                            args);
12116                            }
12117    
12118                            if ((bookmarksEntryModelImpl.getColumnBitmask() &
12119                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
12120                                    Object[] args = new Object[] {
12121                                                    bookmarksEntryModelImpl.getOriginalUuid(),
12122                                                    bookmarksEntryModelImpl.getOriginalCompanyId()
12123                                            };
12124    
12125                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
12126                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
12127                                            args);
12128    
12129                                    args = new Object[] {
12130                                                    bookmarksEntryModelImpl.getUuid(),
12131                                                    bookmarksEntryModelImpl.getCompanyId()
12132                                            };
12133    
12134                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
12135                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
12136                                            args);
12137                            }
12138    
12139                            if ((bookmarksEntryModelImpl.getColumnBitmask() &
12140                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
12141                                    Object[] args = new Object[] {
12142                                                    bookmarksEntryModelImpl.getOriginalCompanyId()
12143                                            };
12144    
12145                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
12146                                            args);
12147                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
12148                                            args);
12149    
12150                                    args = new Object[] { bookmarksEntryModelImpl.getCompanyId() };
12151    
12152                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
12153                                            args);
12154                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
12155                                            args);
12156                            }
12157    
12158                            if ((bookmarksEntryModelImpl.getColumnBitmask() &
12159                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F.getColumnBitmask()) != 0) {
12160                                    Object[] args = new Object[] {
12161                                                    bookmarksEntryModelImpl.getOriginalGroupId(),
12162                                                    bookmarksEntryModelImpl.getOriginalFolderId()
12163                                            };
12164    
12165                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F, args);
12166                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F,
12167                                            args);
12168    
12169                                    args = new Object[] {
12170                                                    bookmarksEntryModelImpl.getGroupId(),
12171                                                    bookmarksEntryModelImpl.getFolderId()
12172                                            };
12173    
12174                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F, args);
12175                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F,
12176                                            args);
12177                            }
12178    
12179                            if ((bookmarksEntryModelImpl.getColumnBitmask() &
12180                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S.getColumnBitmask()) != 0) {
12181                                    Object[] args = new Object[] {
12182                                                    bookmarksEntryModelImpl.getOriginalGroupId(),
12183                                                    bookmarksEntryModelImpl.getOriginalStatus()
12184                                            };
12185    
12186                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
12187                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
12188                                            args);
12189    
12190                                    args = new Object[] {
12191                                                    bookmarksEntryModelImpl.getGroupId(),
12192                                                    bookmarksEntryModelImpl.getStatus()
12193                                            };
12194    
12195                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
12196                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
12197                                            args);
12198                            }
12199    
12200                            if ((bookmarksEntryModelImpl.getColumnBitmask() &
12201                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S.getColumnBitmask()) != 0) {
12202                                    Object[] args = new Object[] {
12203                                                    bookmarksEntryModelImpl.getOriginalGroupId(),
12204                                                    bookmarksEntryModelImpl.getOriginalUserId(),
12205                                                    bookmarksEntryModelImpl.getOriginalStatus()
12206                                            };
12207    
12208                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_S, args);
12209                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S,
12210                                            args);
12211    
12212                                    args = new Object[] {
12213                                                    bookmarksEntryModelImpl.getGroupId(),
12214                                                    bookmarksEntryModelImpl.getUserId(),
12215                                                    bookmarksEntryModelImpl.getStatus()
12216                                            };
12217    
12218                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_S, args);
12219                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S,
12220                                            args);
12221                            }
12222    
12223                            if ((bookmarksEntryModelImpl.getColumnBitmask() &
12224                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_S.getColumnBitmask()) != 0) {
12225                                    Object[] args = new Object[] {
12226                                                    bookmarksEntryModelImpl.getOriginalGroupId(),
12227                                                    bookmarksEntryModelImpl.getOriginalFolderId(),
12228                                                    bookmarksEntryModelImpl.getOriginalStatus()
12229                                            };
12230    
12231                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F_S, args);
12232                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_S,
12233                                            args);
12234    
12235                                    args = new Object[] {
12236                                                    bookmarksEntryModelImpl.getGroupId(),
12237                                                    bookmarksEntryModelImpl.getFolderId(),
12238                                                    bookmarksEntryModelImpl.getStatus()
12239                                            };
12240    
12241                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F_S, args);
12242                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_S,
12243                                            args);
12244                            }
12245    
12246                            if ((bookmarksEntryModelImpl.getColumnBitmask() &
12247                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_F_S.getColumnBitmask()) != 0) {
12248                                    Object[] args = new Object[] {
12249                                                    bookmarksEntryModelImpl.getOriginalGroupId(),
12250                                                    bookmarksEntryModelImpl.getOriginalUserId(),
12251                                                    bookmarksEntryModelImpl.getOriginalFolderId(),
12252                                                    bookmarksEntryModelImpl.getOriginalStatus()
12253                                            };
12254    
12255                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_F_S, args);
12256                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_F_S,
12257                                            args);
12258    
12259                                    args = new Object[] {
12260                                                    bookmarksEntryModelImpl.getGroupId(),
12261                                                    bookmarksEntryModelImpl.getUserId(),
12262                                                    bookmarksEntryModelImpl.getFolderId(),
12263                                                    bookmarksEntryModelImpl.getStatus()
12264                                            };
12265    
12266                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_F_S, args);
12267                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_F_S,
12268                                            args);
12269                            }
12270                    }
12271    
12272                    EntityCacheUtil.putResult(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
12273                            BookmarksEntryImpl.class, bookmarksEntry.getPrimaryKey(),
12274                            bookmarksEntry, false);
12275    
12276                    clearUniqueFindersCache(bookmarksEntry);
12277                    cacheUniqueFindersCache(bookmarksEntry);
12278    
12279                    bookmarksEntry.resetOriginalValues();
12280    
12281                    return bookmarksEntry;
12282            }
12283    
12284            protected BookmarksEntry toUnwrappedModel(BookmarksEntry bookmarksEntry) {
12285                    if (bookmarksEntry instanceof BookmarksEntryImpl) {
12286                            return bookmarksEntry;
12287                    }
12288    
12289                    BookmarksEntryImpl bookmarksEntryImpl = new BookmarksEntryImpl();
12290    
12291                    bookmarksEntryImpl.setNew(bookmarksEntry.isNew());
12292                    bookmarksEntryImpl.setPrimaryKey(bookmarksEntry.getPrimaryKey());
12293    
12294                    bookmarksEntryImpl.setUuid(bookmarksEntry.getUuid());
12295                    bookmarksEntryImpl.setEntryId(bookmarksEntry.getEntryId());
12296                    bookmarksEntryImpl.setGroupId(bookmarksEntry.getGroupId());
12297                    bookmarksEntryImpl.setCompanyId(bookmarksEntry.getCompanyId());
12298                    bookmarksEntryImpl.setUserId(bookmarksEntry.getUserId());
12299                    bookmarksEntryImpl.setUserName(bookmarksEntry.getUserName());
12300                    bookmarksEntryImpl.setCreateDate(bookmarksEntry.getCreateDate());
12301                    bookmarksEntryImpl.setModifiedDate(bookmarksEntry.getModifiedDate());
12302                    bookmarksEntryImpl.setResourceBlockId(bookmarksEntry.getResourceBlockId());
12303                    bookmarksEntryImpl.setFolderId(bookmarksEntry.getFolderId());
12304                    bookmarksEntryImpl.setTreePath(bookmarksEntry.getTreePath());
12305                    bookmarksEntryImpl.setName(bookmarksEntry.getName());
12306                    bookmarksEntryImpl.setUrl(bookmarksEntry.getUrl());
12307                    bookmarksEntryImpl.setDescription(bookmarksEntry.getDescription());
12308                    bookmarksEntryImpl.setVisits(bookmarksEntry.getVisits());
12309                    bookmarksEntryImpl.setPriority(bookmarksEntry.getPriority());
12310                    bookmarksEntryImpl.setStatus(bookmarksEntry.getStatus());
12311                    bookmarksEntryImpl.setStatusByUserId(bookmarksEntry.getStatusByUserId());
12312                    bookmarksEntryImpl.setStatusByUserName(bookmarksEntry.getStatusByUserName());
12313                    bookmarksEntryImpl.setStatusDate(bookmarksEntry.getStatusDate());
12314    
12315                    return bookmarksEntryImpl;
12316            }
12317    
12318            /**
12319             * Returns the bookmarks entry with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
12320             *
12321             * @param primaryKey the primary key of the bookmarks entry
12322             * @return the bookmarks entry
12323             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
12324             */
12325            @Override
12326            public BookmarksEntry findByPrimaryKey(Serializable primaryKey)
12327                    throws NoSuchEntryException {
12328                    BookmarksEntry bookmarksEntry = fetchByPrimaryKey(primaryKey);
12329    
12330                    if (bookmarksEntry == null) {
12331                            if (_log.isWarnEnabled()) {
12332                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
12333                            }
12334    
12335                            throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
12336                                    primaryKey);
12337                    }
12338    
12339                    return bookmarksEntry;
12340            }
12341    
12342            /**
12343             * Returns the bookmarks entry with the primary key or throws a {@link com.liferay.portlet.bookmarks.NoSuchEntryException} if it could not be found.
12344             *
12345             * @param entryId the primary key of the bookmarks entry
12346             * @return the bookmarks entry
12347             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
12348             */
12349            @Override
12350            public BookmarksEntry findByPrimaryKey(long entryId)
12351                    throws NoSuchEntryException {
12352                    return findByPrimaryKey((Serializable)entryId);
12353            }
12354    
12355            /**
12356             * Returns the bookmarks entry with the primary key or returns <code>null</code> if it could not be found.
12357             *
12358             * @param primaryKey the primary key of the bookmarks entry
12359             * @return the bookmarks entry, or <code>null</code> if a bookmarks entry with the primary key could not be found
12360             */
12361            @Override
12362            public BookmarksEntry fetchByPrimaryKey(Serializable primaryKey) {
12363                    BookmarksEntry bookmarksEntry = (BookmarksEntry)EntityCacheUtil.getResult(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
12364                                    BookmarksEntryImpl.class, primaryKey);
12365    
12366                    if (bookmarksEntry == _nullBookmarksEntry) {
12367                            return null;
12368                    }
12369    
12370                    if (bookmarksEntry == null) {
12371                            Session session = null;
12372    
12373                            try {
12374                                    session = openSession();
12375    
12376                                    bookmarksEntry = (BookmarksEntry)session.get(BookmarksEntryImpl.class,
12377                                                    primaryKey);
12378    
12379                                    if (bookmarksEntry != null) {
12380                                            cacheResult(bookmarksEntry);
12381                                    }
12382                                    else {
12383                                            EntityCacheUtil.putResult(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
12384                                                    BookmarksEntryImpl.class, primaryKey,
12385                                                    _nullBookmarksEntry);
12386                                    }
12387                            }
12388                            catch (Exception e) {
12389                                    EntityCacheUtil.removeResult(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
12390                                            BookmarksEntryImpl.class, primaryKey);
12391    
12392                                    throw processException(e);
12393                            }
12394                            finally {
12395                                    closeSession(session);
12396                            }
12397                    }
12398    
12399                    return bookmarksEntry;
12400            }
12401    
12402            /**
12403             * Returns the bookmarks entry with the primary key or returns <code>null</code> if it could not be found.
12404             *
12405             * @param entryId the primary key of the bookmarks entry
12406             * @return the bookmarks entry, or <code>null</code> if a bookmarks entry with the primary key could not be found
12407             */
12408            @Override
12409            public BookmarksEntry fetchByPrimaryKey(long entryId) {
12410                    return fetchByPrimaryKey((Serializable)entryId);
12411            }
12412    
12413            @Override
12414            public Map<Serializable, BookmarksEntry> fetchByPrimaryKeys(
12415                    Set<Serializable> primaryKeys) {
12416                    if (primaryKeys.isEmpty()) {
12417                            return Collections.emptyMap();
12418                    }
12419    
12420                    Map<Serializable, BookmarksEntry> map = new HashMap<Serializable, BookmarksEntry>();
12421    
12422                    if (primaryKeys.size() == 1) {
12423                            Iterator<Serializable> iterator = primaryKeys.iterator();
12424    
12425                            Serializable primaryKey = iterator.next();
12426    
12427                            BookmarksEntry bookmarksEntry = fetchByPrimaryKey(primaryKey);
12428    
12429                            if (bookmarksEntry != null) {
12430                                    map.put(primaryKey, bookmarksEntry);
12431                            }
12432    
12433                            return map;
12434                    }
12435    
12436                    Set<Serializable> uncachedPrimaryKeys = null;
12437    
12438                    for (Serializable primaryKey : primaryKeys) {
12439                            BookmarksEntry bookmarksEntry = (BookmarksEntry)EntityCacheUtil.getResult(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
12440                                            BookmarksEntryImpl.class, primaryKey);
12441    
12442                            if (bookmarksEntry == null) {
12443                                    if (uncachedPrimaryKeys == null) {
12444                                            uncachedPrimaryKeys = new HashSet<Serializable>();
12445                                    }
12446    
12447                                    uncachedPrimaryKeys.add(primaryKey);
12448                            }
12449                            else {
12450                                    map.put(primaryKey, bookmarksEntry);
12451                            }
12452                    }
12453    
12454                    if (uncachedPrimaryKeys == null) {
12455                            return map;
12456                    }
12457    
12458                    StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
12459                                    1);
12460    
12461                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE_PKS_IN);
12462    
12463                    for (Serializable primaryKey : uncachedPrimaryKeys) {
12464                            query.append(String.valueOf(primaryKey));
12465    
12466                            query.append(StringPool.COMMA);
12467                    }
12468    
12469                    query.setIndex(query.index() - 1);
12470    
12471                    query.append(StringPool.CLOSE_PARENTHESIS);
12472    
12473                    String sql = query.toString();
12474    
12475                    Session session = null;
12476    
12477                    try {
12478                            session = openSession();
12479    
12480                            Query q = session.createQuery(sql);
12481    
12482                            for (BookmarksEntry bookmarksEntry : (List<BookmarksEntry>)q.list()) {
12483                                    map.put(bookmarksEntry.getPrimaryKeyObj(), bookmarksEntry);
12484    
12485                                    cacheResult(bookmarksEntry);
12486    
12487                                    uncachedPrimaryKeys.remove(bookmarksEntry.getPrimaryKeyObj());
12488                            }
12489    
12490                            for (Serializable primaryKey : uncachedPrimaryKeys) {
12491                                    EntityCacheUtil.putResult(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
12492                                            BookmarksEntryImpl.class, primaryKey, _nullBookmarksEntry);
12493                            }
12494                    }
12495                    catch (Exception e) {
12496                            throw processException(e);
12497                    }
12498                    finally {
12499                            closeSession(session);
12500                    }
12501    
12502                    return map;
12503            }
12504    
12505            /**
12506             * Returns all the bookmarks entries.
12507             *
12508             * @return the bookmarks entries
12509             */
12510            @Override
12511            public List<BookmarksEntry> findAll() {
12512                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
12513            }
12514    
12515            /**
12516             * Returns a range of all the bookmarks entries.
12517             *
12518             * <p>
12519             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.bookmarks.model.impl.BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
12520             * </p>
12521             *
12522             * @param start the lower bound of the range of bookmarks entries
12523             * @param end the upper bound of the range of bookmarks entries (not inclusive)
12524             * @return the range of bookmarks entries
12525             */
12526            @Override
12527            public List<BookmarksEntry> findAll(int start, int end) {
12528                    return findAll(start, end, null);
12529            }
12530    
12531            /**
12532             * Returns an ordered range of all the bookmarks entries.
12533             *
12534             * <p>
12535             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.bookmarks.model.impl.BookmarksEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
12536             * </p>
12537             *
12538             * @param start the lower bound of the range of bookmarks entries
12539             * @param end the upper bound of the range of bookmarks entries (not inclusive)
12540             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12541             * @return the ordered range of bookmarks entries
12542             */
12543            @Override
12544            public List<BookmarksEntry> findAll(int start, int end,
12545                    OrderByComparator<BookmarksEntry> orderByComparator) {
12546                    boolean pagination = true;
12547                    FinderPath finderPath = null;
12548                    Object[] finderArgs = null;
12549    
12550                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
12551                                    (orderByComparator == null)) {
12552                            pagination = false;
12553                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
12554                            finderArgs = FINDER_ARGS_EMPTY;
12555                    }
12556                    else {
12557                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
12558                            finderArgs = new Object[] { start, end, orderByComparator };
12559                    }
12560    
12561                    List<BookmarksEntry> list = (List<BookmarksEntry>)FinderCacheUtil.getResult(finderPath,
12562                                    finderArgs, this);
12563    
12564                    if (list == null) {
12565                            StringBundler query = null;
12566                            String sql = null;
12567    
12568                            if (orderByComparator != null) {
12569                                    query = new StringBundler(2 +
12570                                                    (orderByComparator.getOrderByFields().length * 3));
12571    
12572                                    query.append(_SQL_SELECT_BOOKMARKSENTRY);
12573    
12574                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
12575                                            orderByComparator);
12576    
12577                                    sql = query.toString();
12578                            }
12579                            else {
12580                                    sql = _SQL_SELECT_BOOKMARKSENTRY;
12581    
12582                                    if (pagination) {
12583                                            sql = sql.concat(BookmarksEntryModelImpl.ORDER_BY_JPQL);
12584                                    }
12585                            }
12586    
12587                            Session session = null;
12588    
12589                            try {
12590                                    session = openSession();
12591    
12592                                    Query q = session.createQuery(sql);
12593    
12594                                    if (!pagination) {
12595                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
12596                                                            getDialect(), start, end, false);
12597    
12598                                            Collections.sort(list);
12599    
12600                                            list = Collections.unmodifiableList(list);
12601                                    }
12602                                    else {
12603                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
12604                                                            getDialect(), start, end);
12605                                    }
12606    
12607                                    cacheResult(list);
12608    
12609                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
12610                            }
12611                            catch (Exception e) {
12612                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
12613    
12614                                    throw processException(e);
12615                            }
12616                            finally {
12617                                    closeSession(session);
12618                            }
12619                    }
12620    
12621                    return list;
12622            }
12623    
12624            /**
12625             * Removes all the bookmarks entries from the database.
12626             *
12627             */
12628            @Override
12629            public void removeAll() {
12630                    for (BookmarksEntry bookmarksEntry : findAll()) {
12631                            remove(bookmarksEntry);
12632                    }
12633            }
12634    
12635            /**
12636             * Returns the number of bookmarks entries.
12637             *
12638             * @return the number of bookmarks entries
12639             */
12640            @Override
12641            public int countAll() {
12642                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
12643                                    FINDER_ARGS_EMPTY, this);
12644    
12645                    if (count == null) {
12646                            Session session = null;
12647    
12648                            try {
12649                                    session = openSession();
12650    
12651                                    Query q = session.createQuery(_SQL_COUNT_BOOKMARKSENTRY);
12652    
12653                                    count = (Long)q.uniqueResult();
12654    
12655                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
12656                                            FINDER_ARGS_EMPTY, count);
12657                            }
12658                            catch (Exception e) {
12659                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
12660                                            FINDER_ARGS_EMPTY);
12661    
12662                                    throw processException(e);
12663                            }
12664                            finally {
12665                                    closeSession(session);
12666                            }
12667                    }
12668    
12669                    return count.intValue();
12670            }
12671    
12672            @Override
12673            protected Set<String> getBadColumnNames() {
12674                    return _badColumnNames;
12675            }
12676    
12677            /**
12678             * Initializes the bookmarks entry persistence.
12679             */
12680            public void afterPropertiesSet() {
12681            }
12682    
12683            public void destroy() {
12684                    EntityCacheUtil.removeCache(BookmarksEntryImpl.class.getName());
12685                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
12686                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
12687                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
12688            }
12689    
12690            private static final String _SQL_SELECT_BOOKMARKSENTRY = "SELECT bookmarksEntry FROM BookmarksEntry bookmarksEntry";
12691            private static final String _SQL_SELECT_BOOKMARKSENTRY_WHERE_PKS_IN = "SELECT bookmarksEntry FROM BookmarksEntry bookmarksEntry WHERE entryId IN (";
12692            private static final String _SQL_SELECT_BOOKMARKSENTRY_WHERE = "SELECT bookmarksEntry FROM BookmarksEntry bookmarksEntry WHERE ";
12693            private static final String _SQL_COUNT_BOOKMARKSENTRY = "SELECT COUNT(bookmarksEntry) FROM BookmarksEntry bookmarksEntry";
12694            private static final String _SQL_COUNT_BOOKMARKSENTRY_WHERE = "SELECT COUNT(bookmarksEntry) FROM BookmarksEntry bookmarksEntry WHERE ";
12695            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "bookmarksEntry.entryId";
12696            private static final String _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN = "bookmarksEntry.userId";
12697            private static final String _ORDER_BY_ENTITY_ALIAS = "bookmarksEntry.";
12698            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No BookmarksEntry exists with the primary key ";
12699            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No BookmarksEntry exists with the key {";
12700            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
12701            private static final Log _log = LogFactoryUtil.getLog(BookmarksEntryPersistenceImpl.class);
12702            private static final Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
12703                                    "uuid"
12704                            });
12705            private static final BookmarksEntry _nullBookmarksEntry = new BookmarksEntryImpl() {
12706                            @Override
12707                            public Object clone() {
12708                                    return this;
12709                            }
12710    
12711                            @Override
12712                            public CacheModel<BookmarksEntry> toCacheModel() {
12713                                    return _nullBookmarksEntryCacheModel;
12714                            }
12715                    };
12716    
12717            private static final CacheModel<BookmarksEntry> _nullBookmarksEntryCacheModel =
12718                    new CacheModel<BookmarksEntry>() {
12719                            @Override
12720                            public BookmarksEntry toEntityModel() {
12721                                    return _nullBookmarksEntry;
12722                            }
12723                    };
12724    }