001    /**
002     * Copyright (c) 2000-2013 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;
016    
017    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
018    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
019    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
020    import com.liferay.portal.kernel.dao.orm.FinderPath;
021    import com.liferay.portal.kernel.dao.orm.Query;
022    import com.liferay.portal.kernel.dao.orm.QueryPos;
023    import com.liferay.portal.kernel.dao.orm.QueryUtil;
024    import com.liferay.portal.kernel.dao.orm.Session;
025    import com.liferay.portal.kernel.exception.SystemException;
026    import com.liferay.portal.kernel.log.Log;
027    import com.liferay.portal.kernel.log.LogFactoryUtil;
028    import com.liferay.portal.kernel.util.ArrayUtil;
029    import com.liferay.portal.kernel.util.GetterUtil;
030    import com.liferay.portal.kernel.util.InstanceFactory;
031    import com.liferay.portal.kernel.util.OrderByComparator;
032    import com.liferay.portal.kernel.util.SetUtil;
033    import com.liferay.portal.kernel.util.StringBundler;
034    import com.liferay.portal.kernel.util.StringPool;
035    import com.liferay.portal.kernel.util.StringUtil;
036    import com.liferay.portal.kernel.util.UnmodifiableList;
037    import com.liferay.portal.kernel.util.Validator;
038    import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
039    import com.liferay.portal.model.CacheModel;
040    import com.liferay.portal.model.ModelListener;
041    import com.liferay.portal.security.permission.InlineSQLHelperUtil;
042    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
043    
044    import com.liferay.portlet.bookmarks.NoSuchEntryException;
045    import com.liferay.portlet.bookmarks.model.BookmarksEntry;
046    import com.liferay.portlet.bookmarks.model.impl.BookmarksEntryImpl;
047    import com.liferay.portlet.bookmarks.model.impl.BookmarksEntryModelImpl;
048    
049    import java.io.Serializable;
050    
051    import java.util.ArrayList;
052    import java.util.Collections;
053    import java.util.List;
054    import java.util.Set;
055    
056    /**
057     * The persistence implementation for the bookmarks entry service.
058     *
059     * <p>
060     * Caching information and settings can be found in <code>portal.properties</code>
061     * </p>
062     *
063     * @author Brian Wing Shun Chan
064     * @see BookmarksEntryPersistence
065     * @see BookmarksEntryUtil
066     * @generated
067     */
068    public class BookmarksEntryPersistenceImpl extends BasePersistenceImpl<BookmarksEntry>
069            implements BookmarksEntryPersistence {
070            /*
071             * NOTE FOR DEVELOPERS:
072             *
073             * 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.
074             */
075            public static final String FINDER_CLASS_NAME_ENTITY = BookmarksEntryImpl.class.getName();
076            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
077                    ".List1";
078            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
079                    ".List2";
080            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
081                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
082                            BookmarksEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
083                            "findAll", new String[0]);
084            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
085                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
086                            BookmarksEntryImpl.class,
087                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
088            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
089                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
090                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
091            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_RESOURCEBLOCKID =
092                    new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
093                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
094                            BookmarksEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
095                            "findByResourceBlockId",
096                            new String[] {
097                                    Long.class.getName(),
098                                    
099                            Integer.class.getName(), Integer.class.getName(),
100                                    OrderByComparator.class.getName()
101                            });
102            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEBLOCKID =
103                    new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
104                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
105                            BookmarksEntryImpl.class,
106                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByResourceBlockId",
107                            new String[] { Long.class.getName() },
108                            BookmarksEntryModelImpl.RESOURCEBLOCKID_COLUMN_BITMASK |
109                            BookmarksEntryModelImpl.FOLDERID_COLUMN_BITMASK |
110                            BookmarksEntryModelImpl.NAME_COLUMN_BITMASK);
111            public static final FinderPath FINDER_PATH_COUNT_BY_RESOURCEBLOCKID = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
112                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
113                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
114                            "countByResourceBlockId", new String[] { Long.class.getName() });
115    
116            /**
117             * Returns all the bookmarks entries where resourceBlockId = &#63;.
118             *
119             * @param resourceBlockId the resource block ID
120             * @return the matching bookmarks entries
121             * @throws SystemException if a system exception occurred
122             */
123            @Override
124            public List<BookmarksEntry> findByResourceBlockId(long resourceBlockId)
125                    throws SystemException {
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             * @throws SystemException if a system exception occurred
142             */
143            @Override
144            public List<BookmarksEntry> findByResourceBlockId(long resourceBlockId,
145                    int start, int end) throws SystemException {
146                    return findByResourceBlockId(resourceBlockId, start, end, null);
147            }
148    
149            /**
150             * Returns an ordered range of all the bookmarks entries where resourceBlockId = &#63;.
151             *
152             * <p>
153             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
154             * </p>
155             *
156             * @param resourceBlockId the resource block ID
157             * @param start the lower bound of the range of bookmarks entries
158             * @param end the upper bound of the range of bookmarks entries (not inclusive)
159             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
160             * @return the ordered range of matching bookmarks entries
161             * @throws SystemException if a system exception occurred
162             */
163            @Override
164            public List<BookmarksEntry> findByResourceBlockId(long resourceBlockId,
165                    int start, int end, OrderByComparator orderByComparator)
166                    throws SystemException {
167                    boolean pagination = true;
168                    FinderPath finderPath = null;
169                    Object[] finderArgs = null;
170    
171                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
172                                    (orderByComparator == null)) {
173                            pagination = false;
174                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEBLOCKID;
175                            finderArgs = new Object[] { resourceBlockId };
176                    }
177                    else {
178                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_RESOURCEBLOCKID;
179                            finderArgs = new Object[] {
180                                            resourceBlockId,
181                                            
182                                            start, end, orderByComparator
183                                    };
184                    }
185    
186                    List<BookmarksEntry> list = (List<BookmarksEntry>)FinderCacheUtil.getResult(finderPath,
187                                    finderArgs, this);
188    
189                    if ((list != null) && !list.isEmpty()) {
190                            for (BookmarksEntry bookmarksEntry : list) {
191                                    if ((resourceBlockId != bookmarksEntry.getResourceBlockId())) {
192                                            list = null;
193    
194                                            break;
195                                    }
196                            }
197                    }
198    
199                    if (list == null) {
200                            StringBundler query = null;
201    
202                            if (orderByComparator != null) {
203                                    query = new StringBundler(3 +
204                                                    (orderByComparator.getOrderByFields().length * 3));
205                            }
206                            else {
207                                    query = new StringBundler(3);
208                            }
209    
210                            query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
211    
212                            query.append(_FINDER_COLUMN_RESOURCEBLOCKID_RESOURCEBLOCKID_2);
213    
214                            if (orderByComparator != null) {
215                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
216                                            orderByComparator);
217                            }
218                            else
219                             if (pagination) {
220                                    query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
221                            }
222    
223                            String sql = query.toString();
224    
225                            Session session = null;
226    
227                            try {
228                                    session = openSession();
229    
230                                    Query q = session.createQuery(sql);
231    
232                                    QueryPos qPos = QueryPos.getInstance(q);
233    
234                                    qPos.add(resourceBlockId);
235    
236                                    if (!pagination) {
237                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
238                                                            getDialect(), start, end, false);
239    
240                                            Collections.sort(list);
241    
242                                            list = new UnmodifiableList<BookmarksEntry>(list);
243                                    }
244                                    else {
245                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
246                                                            getDialect(), start, end);
247                                    }
248    
249                                    cacheResult(list);
250    
251                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
252                            }
253                            catch (Exception e) {
254                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
255    
256                                    throw processException(e);
257                            }
258                            finally {
259                                    closeSession(session);
260                            }
261                    }
262    
263                    return list;
264            }
265    
266            /**
267             * Returns the first bookmarks entry in the ordered set where resourceBlockId = &#63;.
268             *
269             * @param resourceBlockId the resource block ID
270             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
271             * @return the first matching bookmarks entry
272             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
273             * @throws SystemException if a system exception occurred
274             */
275            @Override
276            public BookmarksEntry findByResourceBlockId_First(long resourceBlockId,
277                    OrderByComparator orderByComparator)
278                    throws NoSuchEntryException, SystemException {
279                    BookmarksEntry bookmarksEntry = fetchByResourceBlockId_First(resourceBlockId,
280                                    orderByComparator);
281    
282                    if (bookmarksEntry != null) {
283                            return bookmarksEntry;
284                    }
285    
286                    StringBundler msg = new StringBundler(4);
287    
288                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
289    
290                    msg.append("resourceBlockId=");
291                    msg.append(resourceBlockId);
292    
293                    msg.append(StringPool.CLOSE_CURLY_BRACE);
294    
295                    throw new NoSuchEntryException(msg.toString());
296            }
297    
298            /**
299             * Returns the first bookmarks entry in the ordered set where resourceBlockId = &#63;.
300             *
301             * @param resourceBlockId the resource block ID
302             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
303             * @return the first matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
304             * @throws SystemException if a system exception occurred
305             */
306            @Override
307            public BookmarksEntry fetchByResourceBlockId_First(long resourceBlockId,
308                    OrderByComparator orderByComparator) throws SystemException {
309                    List<BookmarksEntry> list = findByResourceBlockId(resourceBlockId, 0,
310                                    1, orderByComparator);
311    
312                    if (!list.isEmpty()) {
313                            return list.get(0);
314                    }
315    
316                    return null;
317            }
318    
319            /**
320             * Returns the last bookmarks entry in the ordered set where resourceBlockId = &#63;.
321             *
322             * @param resourceBlockId the resource block ID
323             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
324             * @return the last matching bookmarks entry
325             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
326             * @throws SystemException if a system exception occurred
327             */
328            @Override
329            public BookmarksEntry findByResourceBlockId_Last(long resourceBlockId,
330                    OrderByComparator orderByComparator)
331                    throws NoSuchEntryException, SystemException {
332                    BookmarksEntry bookmarksEntry = fetchByResourceBlockId_Last(resourceBlockId,
333                                    orderByComparator);
334    
335                    if (bookmarksEntry != null) {
336                            return bookmarksEntry;
337                    }
338    
339                    StringBundler msg = new StringBundler(4);
340    
341                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
342    
343                    msg.append("resourceBlockId=");
344                    msg.append(resourceBlockId);
345    
346                    msg.append(StringPool.CLOSE_CURLY_BRACE);
347    
348                    throw new NoSuchEntryException(msg.toString());
349            }
350    
351            /**
352             * Returns the last bookmarks entry in the ordered set where resourceBlockId = &#63;.
353             *
354             * @param resourceBlockId the resource block ID
355             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
356             * @return the last matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
357             * @throws SystemException if a system exception occurred
358             */
359            @Override
360            public BookmarksEntry fetchByResourceBlockId_Last(long resourceBlockId,
361                    OrderByComparator orderByComparator) throws SystemException {
362                    int count = countByResourceBlockId(resourceBlockId);
363    
364                    if (count == 0) {
365                            return null;
366                    }
367    
368                    List<BookmarksEntry> list = findByResourceBlockId(resourceBlockId,
369                                    count - 1, count, orderByComparator);
370    
371                    if (!list.isEmpty()) {
372                            return list.get(0);
373                    }
374    
375                    return null;
376            }
377    
378            /**
379             * Returns the bookmarks entries before and after the current bookmarks entry in the ordered set where resourceBlockId = &#63;.
380             *
381             * @param entryId the primary key of the current bookmarks entry
382             * @param resourceBlockId the resource block ID
383             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
384             * @return the previous, current, and next bookmarks entry
385             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
386             * @throws SystemException if a system exception occurred
387             */
388            @Override
389            public BookmarksEntry[] findByResourceBlockId_PrevAndNext(long entryId,
390                    long resourceBlockId, OrderByComparator orderByComparator)
391                    throws NoSuchEntryException, SystemException {
392                    BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
393    
394                    Session session = null;
395    
396                    try {
397                            session = openSession();
398    
399                            BookmarksEntry[] array = new BookmarksEntryImpl[3];
400    
401                            array[0] = getByResourceBlockId_PrevAndNext(session,
402                                            bookmarksEntry, resourceBlockId, orderByComparator, true);
403    
404                            array[1] = bookmarksEntry;
405    
406                            array[2] = getByResourceBlockId_PrevAndNext(session,
407                                            bookmarksEntry, resourceBlockId, orderByComparator, false);
408    
409                            return array;
410                    }
411                    catch (Exception e) {
412                            throw processException(e);
413                    }
414                    finally {
415                            closeSession(session);
416                    }
417            }
418    
419            protected BookmarksEntry getByResourceBlockId_PrevAndNext(Session session,
420                    BookmarksEntry bookmarksEntry, long resourceBlockId,
421                    OrderByComparator orderByComparator, boolean previous) {
422                    StringBundler query = null;
423    
424                    if (orderByComparator != null) {
425                            query = new StringBundler(6 +
426                                            (orderByComparator.getOrderByFields().length * 6));
427                    }
428                    else {
429                            query = new StringBundler(3);
430                    }
431    
432                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
433    
434                    query.append(_FINDER_COLUMN_RESOURCEBLOCKID_RESOURCEBLOCKID_2);
435    
436                    if (orderByComparator != null) {
437                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
438    
439                            if (orderByConditionFields.length > 0) {
440                                    query.append(WHERE_AND);
441                            }
442    
443                            for (int i = 0; i < orderByConditionFields.length; i++) {
444                                    query.append(_ORDER_BY_ENTITY_ALIAS);
445                                    query.append(orderByConditionFields[i]);
446    
447                                    if ((i + 1) < orderByConditionFields.length) {
448                                            if (orderByComparator.isAscending() ^ previous) {
449                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
450                                            }
451                                            else {
452                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
453                                            }
454                                    }
455                                    else {
456                                            if (orderByComparator.isAscending() ^ previous) {
457                                                    query.append(WHERE_GREATER_THAN);
458                                            }
459                                            else {
460                                                    query.append(WHERE_LESSER_THAN);
461                                            }
462                                    }
463                            }
464    
465                            query.append(ORDER_BY_CLAUSE);
466    
467                            String[] orderByFields = orderByComparator.getOrderByFields();
468    
469                            for (int i = 0; i < orderByFields.length; i++) {
470                                    query.append(_ORDER_BY_ENTITY_ALIAS);
471                                    query.append(orderByFields[i]);
472    
473                                    if ((i + 1) < orderByFields.length) {
474                                            if (orderByComparator.isAscending() ^ previous) {
475                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
476                                            }
477                                            else {
478                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
479                                            }
480                                    }
481                                    else {
482                                            if (orderByComparator.isAscending() ^ previous) {
483                                                    query.append(ORDER_BY_ASC);
484                                            }
485                                            else {
486                                                    query.append(ORDER_BY_DESC);
487                                            }
488                                    }
489                            }
490                    }
491                    else {
492                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
493                    }
494    
495                    String sql = query.toString();
496    
497                    Query q = session.createQuery(sql);
498    
499                    q.setFirstResult(0);
500                    q.setMaxResults(2);
501    
502                    QueryPos qPos = QueryPos.getInstance(q);
503    
504                    qPos.add(resourceBlockId);
505    
506                    if (orderByComparator != null) {
507                            Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry);
508    
509                            for (Object value : values) {
510                                    qPos.add(value);
511                            }
512                    }
513    
514                    List<BookmarksEntry> list = q.list();
515    
516                    if (list.size() == 2) {
517                            return list.get(1);
518                    }
519                    else {
520                            return null;
521                    }
522            }
523    
524            /**
525             * Removes all the bookmarks entries where resourceBlockId = &#63; from the database.
526             *
527             * @param resourceBlockId the resource block ID
528             * @throws SystemException if a system exception occurred
529             */
530            @Override
531            public void removeByResourceBlockId(long resourceBlockId)
532                    throws SystemException {
533                    for (BookmarksEntry bookmarksEntry : findByResourceBlockId(
534                                    resourceBlockId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
535                            remove(bookmarksEntry);
536                    }
537            }
538    
539            /**
540             * Returns the number of bookmarks entries where resourceBlockId = &#63;.
541             *
542             * @param resourceBlockId the resource block ID
543             * @return the number of matching bookmarks entries
544             * @throws SystemException if a system exception occurred
545             */
546            @Override
547            public int countByResourceBlockId(long resourceBlockId)
548                    throws SystemException {
549                    FinderPath finderPath = FINDER_PATH_COUNT_BY_RESOURCEBLOCKID;
550    
551                    Object[] finderArgs = new Object[] { resourceBlockId };
552    
553                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
554                                    this);
555    
556                    if (count == null) {
557                            StringBundler query = new StringBundler(2);
558    
559                            query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
560    
561                            query.append(_FINDER_COLUMN_RESOURCEBLOCKID_RESOURCEBLOCKID_2);
562    
563                            String sql = query.toString();
564    
565                            Session session = null;
566    
567                            try {
568                                    session = openSession();
569    
570                                    Query q = session.createQuery(sql);
571    
572                                    QueryPos qPos = QueryPos.getInstance(q);
573    
574                                    qPos.add(resourceBlockId);
575    
576                                    count = (Long)q.uniqueResult();
577    
578                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
579                            }
580                            catch (Exception e) {
581                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
582    
583                                    throw processException(e);
584                            }
585                            finally {
586                                    closeSession(session);
587                            }
588                    }
589    
590                    return count.intValue();
591            }
592    
593            private static final String _FINDER_COLUMN_RESOURCEBLOCKID_RESOURCEBLOCKID_2 =
594                    "bookmarksEntry.resourceBlockId = ?";
595            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
596                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
597                            BookmarksEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
598                            "findByUuid",
599                            new String[] {
600                                    String.class.getName(),
601                                    
602                            Integer.class.getName(), Integer.class.getName(),
603                                    OrderByComparator.class.getName()
604                            });
605            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
606                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
607                            BookmarksEntryImpl.class,
608                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
609                            new String[] { String.class.getName() },
610                            BookmarksEntryModelImpl.UUID_COLUMN_BITMASK |
611                            BookmarksEntryModelImpl.FOLDERID_COLUMN_BITMASK |
612                            BookmarksEntryModelImpl.NAME_COLUMN_BITMASK);
613            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
614                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
615                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
616                            new String[] { String.class.getName() });
617    
618            /**
619             * Returns all the bookmarks entries where uuid = &#63;.
620             *
621             * @param uuid the uuid
622             * @return the matching bookmarks entries
623             * @throws SystemException if a system exception occurred
624             */
625            @Override
626            public List<BookmarksEntry> findByUuid(String uuid)
627                    throws SystemException {
628                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
629            }
630    
631            /**
632             * Returns a range of all the bookmarks entries where uuid = &#63;.
633             *
634             * <p>
635             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
636             * </p>
637             *
638             * @param uuid the uuid
639             * @param start the lower bound of the range of bookmarks entries
640             * @param end the upper bound of the range of bookmarks entries (not inclusive)
641             * @return the range of matching bookmarks entries
642             * @throws SystemException if a system exception occurred
643             */
644            @Override
645            public List<BookmarksEntry> findByUuid(String uuid, int start, int end)
646                    throws SystemException {
647                    return findByUuid(uuid, start, end, null);
648            }
649    
650            /**
651             * Returns an ordered range of all the bookmarks entries where uuid = &#63;.
652             *
653             * <p>
654             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
655             * </p>
656             *
657             * @param uuid the uuid
658             * @param start the lower bound of the range of bookmarks entries
659             * @param end the upper bound of the range of bookmarks entries (not inclusive)
660             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
661             * @return the ordered range of matching bookmarks entries
662             * @throws SystemException if a system exception occurred
663             */
664            @Override
665            public List<BookmarksEntry> findByUuid(String uuid, int start, int end,
666                    OrderByComparator orderByComparator) throws SystemException {
667                    boolean pagination = true;
668                    FinderPath finderPath = null;
669                    Object[] finderArgs = null;
670    
671                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
672                                    (orderByComparator == null)) {
673                            pagination = false;
674                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
675                            finderArgs = new Object[] { uuid };
676                    }
677                    else {
678                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
679                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
680                    }
681    
682                    List<BookmarksEntry> list = (List<BookmarksEntry>)FinderCacheUtil.getResult(finderPath,
683                                    finderArgs, this);
684    
685                    if ((list != null) && !list.isEmpty()) {
686                            for (BookmarksEntry bookmarksEntry : list) {
687                                    if (!Validator.equals(uuid, bookmarksEntry.getUuid())) {
688                                            list = null;
689    
690                                            break;
691                                    }
692                            }
693                    }
694    
695                    if (list == null) {
696                            StringBundler query = null;
697    
698                            if (orderByComparator != null) {
699                                    query = new StringBundler(3 +
700                                                    (orderByComparator.getOrderByFields().length * 3));
701                            }
702                            else {
703                                    query = new StringBundler(3);
704                            }
705    
706                            query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
707    
708                            boolean bindUuid = false;
709    
710                            if (uuid == null) {
711                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
712                            }
713                            else if (uuid.equals(StringPool.BLANK)) {
714                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
715                            }
716                            else {
717                                    bindUuid = true;
718    
719                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
720                            }
721    
722                            if (orderByComparator != null) {
723                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
724                                            orderByComparator);
725                            }
726                            else
727                             if (pagination) {
728                                    query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
729                            }
730    
731                            String sql = query.toString();
732    
733                            Session session = null;
734    
735                            try {
736                                    session = openSession();
737    
738                                    Query q = session.createQuery(sql);
739    
740                                    QueryPos qPos = QueryPos.getInstance(q);
741    
742                                    if (bindUuid) {
743                                            qPos.add(uuid);
744                                    }
745    
746                                    if (!pagination) {
747                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
748                                                            getDialect(), start, end, false);
749    
750                                            Collections.sort(list);
751    
752                                            list = new UnmodifiableList<BookmarksEntry>(list);
753                                    }
754                                    else {
755                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
756                                                            getDialect(), start, end);
757                                    }
758    
759                                    cacheResult(list);
760    
761                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
762                            }
763                            catch (Exception e) {
764                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
765    
766                                    throw processException(e);
767                            }
768                            finally {
769                                    closeSession(session);
770                            }
771                    }
772    
773                    return list;
774            }
775    
776            /**
777             * Returns the first bookmarks entry in the ordered set where uuid = &#63;.
778             *
779             * @param uuid the uuid
780             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
781             * @return the first matching bookmarks entry
782             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
783             * @throws SystemException if a system exception occurred
784             */
785            @Override
786            public BookmarksEntry findByUuid_First(String uuid,
787                    OrderByComparator orderByComparator)
788                    throws NoSuchEntryException, SystemException {
789                    BookmarksEntry bookmarksEntry = fetchByUuid_First(uuid,
790                                    orderByComparator);
791    
792                    if (bookmarksEntry != null) {
793                            return bookmarksEntry;
794                    }
795    
796                    StringBundler msg = new StringBundler(4);
797    
798                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
799    
800                    msg.append("uuid=");
801                    msg.append(uuid);
802    
803                    msg.append(StringPool.CLOSE_CURLY_BRACE);
804    
805                    throw new NoSuchEntryException(msg.toString());
806            }
807    
808            /**
809             * Returns the first bookmarks entry in the ordered set where uuid = &#63;.
810             *
811             * @param uuid the uuid
812             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
813             * @return the first matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
814             * @throws SystemException if a system exception occurred
815             */
816            @Override
817            public BookmarksEntry fetchByUuid_First(String uuid,
818                    OrderByComparator orderByComparator) throws SystemException {
819                    List<BookmarksEntry> list = findByUuid(uuid, 0, 1, orderByComparator);
820    
821                    if (!list.isEmpty()) {
822                            return list.get(0);
823                    }
824    
825                    return null;
826            }
827    
828            /**
829             * Returns the last bookmarks entry in the ordered set where uuid = &#63;.
830             *
831             * @param uuid the uuid
832             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
833             * @return the last matching bookmarks entry
834             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
835             * @throws SystemException if a system exception occurred
836             */
837            @Override
838            public BookmarksEntry findByUuid_Last(String uuid,
839                    OrderByComparator orderByComparator)
840                    throws NoSuchEntryException, SystemException {
841                    BookmarksEntry bookmarksEntry = fetchByUuid_Last(uuid, orderByComparator);
842    
843                    if (bookmarksEntry != null) {
844                            return bookmarksEntry;
845                    }
846    
847                    StringBundler msg = new StringBundler(4);
848    
849                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
850    
851                    msg.append("uuid=");
852                    msg.append(uuid);
853    
854                    msg.append(StringPool.CLOSE_CURLY_BRACE);
855    
856                    throw new NoSuchEntryException(msg.toString());
857            }
858    
859            /**
860             * Returns the last bookmarks entry in the ordered set where uuid = &#63;.
861             *
862             * @param uuid the uuid
863             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
864             * @return the last matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
865             * @throws SystemException if a system exception occurred
866             */
867            @Override
868            public BookmarksEntry fetchByUuid_Last(String uuid,
869                    OrderByComparator orderByComparator) throws SystemException {
870                    int count = countByUuid(uuid);
871    
872                    if (count == 0) {
873                            return null;
874                    }
875    
876                    List<BookmarksEntry> list = findByUuid(uuid, count - 1, count,
877                                    orderByComparator);
878    
879                    if (!list.isEmpty()) {
880                            return list.get(0);
881                    }
882    
883                    return null;
884            }
885    
886            /**
887             * Returns the bookmarks entries before and after the current bookmarks entry in the ordered set where uuid = &#63;.
888             *
889             * @param entryId the primary key of the current bookmarks entry
890             * @param uuid the uuid
891             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
892             * @return the previous, current, and next bookmarks entry
893             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
894             * @throws SystemException if a system exception occurred
895             */
896            @Override
897            public BookmarksEntry[] findByUuid_PrevAndNext(long entryId, String uuid,
898                    OrderByComparator orderByComparator)
899                    throws NoSuchEntryException, SystemException {
900                    BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
901    
902                    Session session = null;
903    
904                    try {
905                            session = openSession();
906    
907                            BookmarksEntry[] array = new BookmarksEntryImpl[3];
908    
909                            array[0] = getByUuid_PrevAndNext(session, bookmarksEntry, uuid,
910                                            orderByComparator, true);
911    
912                            array[1] = bookmarksEntry;
913    
914                            array[2] = getByUuid_PrevAndNext(session, bookmarksEntry, uuid,
915                                            orderByComparator, false);
916    
917                            return array;
918                    }
919                    catch (Exception e) {
920                            throw processException(e);
921                    }
922                    finally {
923                            closeSession(session);
924                    }
925            }
926    
927            protected BookmarksEntry getByUuid_PrevAndNext(Session session,
928                    BookmarksEntry bookmarksEntry, String uuid,
929                    OrderByComparator orderByComparator, boolean previous) {
930                    StringBundler query = null;
931    
932                    if (orderByComparator != null) {
933                            query = new StringBundler(6 +
934                                            (orderByComparator.getOrderByFields().length * 6));
935                    }
936                    else {
937                            query = new StringBundler(3);
938                    }
939    
940                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
941    
942                    boolean bindUuid = false;
943    
944                    if (uuid == null) {
945                            query.append(_FINDER_COLUMN_UUID_UUID_1);
946                    }
947                    else if (uuid.equals(StringPool.BLANK)) {
948                            query.append(_FINDER_COLUMN_UUID_UUID_3);
949                    }
950                    else {
951                            bindUuid = true;
952    
953                            query.append(_FINDER_COLUMN_UUID_UUID_2);
954                    }
955    
956                    if (orderByComparator != null) {
957                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
958    
959                            if (orderByConditionFields.length > 0) {
960                                    query.append(WHERE_AND);
961                            }
962    
963                            for (int i = 0; i < orderByConditionFields.length; i++) {
964                                    query.append(_ORDER_BY_ENTITY_ALIAS);
965                                    query.append(orderByConditionFields[i]);
966    
967                                    if ((i + 1) < orderByConditionFields.length) {
968                                            if (orderByComparator.isAscending() ^ previous) {
969                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
970                                            }
971                                            else {
972                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
973                                            }
974                                    }
975                                    else {
976                                            if (orderByComparator.isAscending() ^ previous) {
977                                                    query.append(WHERE_GREATER_THAN);
978                                            }
979                                            else {
980                                                    query.append(WHERE_LESSER_THAN);
981                                            }
982                                    }
983                            }
984    
985                            query.append(ORDER_BY_CLAUSE);
986    
987                            String[] orderByFields = orderByComparator.getOrderByFields();
988    
989                            for (int i = 0; i < orderByFields.length; i++) {
990                                    query.append(_ORDER_BY_ENTITY_ALIAS);
991                                    query.append(orderByFields[i]);
992    
993                                    if ((i + 1) < orderByFields.length) {
994                                            if (orderByComparator.isAscending() ^ previous) {
995                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
996                                            }
997                                            else {
998                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
999                                            }
1000                                    }
1001                                    else {
1002                                            if (orderByComparator.isAscending() ^ previous) {
1003                                                    query.append(ORDER_BY_ASC);
1004                                            }
1005                                            else {
1006                                                    query.append(ORDER_BY_DESC);
1007                                            }
1008                                    }
1009                            }
1010                    }
1011                    else {
1012                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
1013                    }
1014    
1015                    String sql = query.toString();
1016    
1017                    Query q = session.createQuery(sql);
1018    
1019                    q.setFirstResult(0);
1020                    q.setMaxResults(2);
1021    
1022                    QueryPos qPos = QueryPos.getInstance(q);
1023    
1024                    if (bindUuid) {
1025                            qPos.add(uuid);
1026                    }
1027    
1028                    if (orderByComparator != null) {
1029                            Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry);
1030    
1031                            for (Object value : values) {
1032                                    qPos.add(value);
1033                            }
1034                    }
1035    
1036                    List<BookmarksEntry> list = q.list();
1037    
1038                    if (list.size() == 2) {
1039                            return list.get(1);
1040                    }
1041                    else {
1042                            return null;
1043                    }
1044            }
1045    
1046            /**
1047             * Removes all the bookmarks entries where uuid = &#63; from the database.
1048             *
1049             * @param uuid the uuid
1050             * @throws SystemException if a system exception occurred
1051             */
1052            @Override
1053            public void removeByUuid(String uuid) throws SystemException {
1054                    for (BookmarksEntry bookmarksEntry : findByUuid(uuid,
1055                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1056                            remove(bookmarksEntry);
1057                    }
1058            }
1059    
1060            /**
1061             * Returns the number of bookmarks entries where uuid = &#63;.
1062             *
1063             * @param uuid the uuid
1064             * @return the number of matching bookmarks entries
1065             * @throws SystemException if a system exception occurred
1066             */
1067            @Override
1068            public int countByUuid(String uuid) throws SystemException {
1069                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
1070    
1071                    Object[] finderArgs = new Object[] { uuid };
1072    
1073                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1074                                    this);
1075    
1076                    if (count == null) {
1077                            StringBundler query = new StringBundler(2);
1078    
1079                            query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
1080    
1081                            boolean bindUuid = false;
1082    
1083                            if (uuid == null) {
1084                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
1085                            }
1086                            else if (uuid.equals(StringPool.BLANK)) {
1087                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
1088                            }
1089                            else {
1090                                    bindUuid = true;
1091    
1092                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
1093                            }
1094    
1095                            String sql = query.toString();
1096    
1097                            Session session = null;
1098    
1099                            try {
1100                                    session = openSession();
1101    
1102                                    Query q = session.createQuery(sql);
1103    
1104                                    QueryPos qPos = QueryPos.getInstance(q);
1105    
1106                                    if (bindUuid) {
1107                                            qPos.add(uuid);
1108                                    }
1109    
1110                                    count = (Long)q.uniqueResult();
1111    
1112                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
1113                            }
1114                            catch (Exception e) {
1115                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1116    
1117                                    throw processException(e);
1118                            }
1119                            finally {
1120                                    closeSession(session);
1121                            }
1122                    }
1123    
1124                    return count.intValue();
1125            }
1126    
1127            private static final String _FINDER_COLUMN_UUID_UUID_1 = "bookmarksEntry.uuid IS NULL";
1128            private static final String _FINDER_COLUMN_UUID_UUID_2 = "bookmarksEntry.uuid = ?";
1129            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(bookmarksEntry.uuid IS NULL OR bookmarksEntry.uuid = '')";
1130            public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
1131                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
1132                            BookmarksEntryImpl.class, FINDER_CLASS_NAME_ENTITY,
1133                            "fetchByUUID_G",
1134                            new String[] { String.class.getName(), Long.class.getName() },
1135                            BookmarksEntryModelImpl.UUID_COLUMN_BITMASK |
1136                            BookmarksEntryModelImpl.GROUPID_COLUMN_BITMASK);
1137            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
1138                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
1139                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
1140                            new String[] { String.class.getName(), Long.class.getName() });
1141    
1142            /**
1143             * 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.
1144             *
1145             * @param uuid the uuid
1146             * @param groupId the group ID
1147             * @return the matching bookmarks entry
1148             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
1149             * @throws SystemException if a system exception occurred
1150             */
1151            @Override
1152            public BookmarksEntry findByUUID_G(String uuid, long groupId)
1153                    throws NoSuchEntryException, SystemException {
1154                    BookmarksEntry bookmarksEntry = fetchByUUID_G(uuid, groupId);
1155    
1156                    if (bookmarksEntry == null) {
1157                            StringBundler msg = new StringBundler(6);
1158    
1159                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1160    
1161                            msg.append("uuid=");
1162                            msg.append(uuid);
1163    
1164                            msg.append(", groupId=");
1165                            msg.append(groupId);
1166    
1167                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1168    
1169                            if (_log.isWarnEnabled()) {
1170                                    _log.warn(msg.toString());
1171                            }
1172    
1173                            throw new NoSuchEntryException(msg.toString());
1174                    }
1175    
1176                    return bookmarksEntry;
1177            }
1178    
1179            /**
1180             * 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.
1181             *
1182             * @param uuid the uuid
1183             * @param groupId the group ID
1184             * @return the matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
1185             * @throws SystemException if a system exception occurred
1186             */
1187            @Override
1188            public BookmarksEntry fetchByUUID_G(String uuid, long groupId)
1189                    throws SystemException {
1190                    return fetchByUUID_G(uuid, groupId, true);
1191            }
1192    
1193            /**
1194             * 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.
1195             *
1196             * @param uuid the uuid
1197             * @param groupId the group ID
1198             * @param retrieveFromCache whether to use the finder cache
1199             * @return the matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
1200             * @throws SystemException if a system exception occurred
1201             */
1202            @Override
1203            public BookmarksEntry fetchByUUID_G(String uuid, long groupId,
1204                    boolean retrieveFromCache) throws SystemException {
1205                    Object[] finderArgs = new Object[] { uuid, groupId };
1206    
1207                    Object result = null;
1208    
1209                    if (retrieveFromCache) {
1210                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
1211                                            finderArgs, this);
1212                    }
1213    
1214                    if (result instanceof BookmarksEntry) {
1215                            BookmarksEntry bookmarksEntry = (BookmarksEntry)result;
1216    
1217                            if (!Validator.equals(uuid, bookmarksEntry.getUuid()) ||
1218                                            (groupId != bookmarksEntry.getGroupId())) {
1219                                    result = null;
1220                            }
1221                    }
1222    
1223                    if (result == null) {
1224                            StringBundler query = new StringBundler(4);
1225    
1226                            query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
1227    
1228                            boolean bindUuid = false;
1229    
1230                            if (uuid == null) {
1231                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1232                            }
1233                            else if (uuid.equals(StringPool.BLANK)) {
1234                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1235                            }
1236                            else {
1237                                    bindUuid = true;
1238    
1239                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1240                            }
1241    
1242                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1243    
1244                            String sql = query.toString();
1245    
1246                            Session session = null;
1247    
1248                            try {
1249                                    session = openSession();
1250    
1251                                    Query q = session.createQuery(sql);
1252    
1253                                    QueryPos qPos = QueryPos.getInstance(q);
1254    
1255                                    if (bindUuid) {
1256                                            qPos.add(uuid);
1257                                    }
1258    
1259                                    qPos.add(groupId);
1260    
1261                                    List<BookmarksEntry> list = q.list();
1262    
1263                                    if (list.isEmpty()) {
1264                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1265                                                    finderArgs, list);
1266                                    }
1267                                    else {
1268                                            BookmarksEntry bookmarksEntry = list.get(0);
1269    
1270                                            result = bookmarksEntry;
1271    
1272                                            cacheResult(bookmarksEntry);
1273    
1274                                            if ((bookmarksEntry.getUuid() == null) ||
1275                                                            !bookmarksEntry.getUuid().equals(uuid) ||
1276                                                            (bookmarksEntry.getGroupId() != groupId)) {
1277                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1278                                                            finderArgs, bookmarksEntry);
1279                                            }
1280                                    }
1281                            }
1282                            catch (Exception e) {
1283                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
1284                                            finderArgs);
1285    
1286                                    throw processException(e);
1287                            }
1288                            finally {
1289                                    closeSession(session);
1290                            }
1291                    }
1292    
1293                    if (result instanceof List<?>) {
1294                            return null;
1295                    }
1296                    else {
1297                            return (BookmarksEntry)result;
1298                    }
1299            }
1300    
1301            /**
1302             * Removes the bookmarks entry where uuid = &#63; and groupId = &#63; from the database.
1303             *
1304             * @param uuid the uuid
1305             * @param groupId the group ID
1306             * @return the bookmarks entry that was removed
1307             * @throws SystemException if a system exception occurred
1308             */
1309            @Override
1310            public BookmarksEntry removeByUUID_G(String uuid, long groupId)
1311                    throws NoSuchEntryException, SystemException {
1312                    BookmarksEntry bookmarksEntry = findByUUID_G(uuid, groupId);
1313    
1314                    return remove(bookmarksEntry);
1315            }
1316    
1317            /**
1318             * Returns the number of bookmarks entries where uuid = &#63; and groupId = &#63;.
1319             *
1320             * @param uuid the uuid
1321             * @param groupId the group ID
1322             * @return the number of matching bookmarks entries
1323             * @throws SystemException if a system exception occurred
1324             */
1325            @Override
1326            public int countByUUID_G(String uuid, long groupId)
1327                    throws SystemException {
1328                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_G;
1329    
1330                    Object[] finderArgs = new Object[] { uuid, groupId };
1331    
1332                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1333                                    this);
1334    
1335                    if (count == null) {
1336                            StringBundler query = new StringBundler(3);
1337    
1338                            query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
1339    
1340                            boolean bindUuid = false;
1341    
1342                            if (uuid == null) {
1343                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1344                            }
1345                            else if (uuid.equals(StringPool.BLANK)) {
1346                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1347                            }
1348                            else {
1349                                    bindUuid = true;
1350    
1351                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1352                            }
1353    
1354                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1355    
1356                            String sql = query.toString();
1357    
1358                            Session session = null;
1359    
1360                            try {
1361                                    session = openSession();
1362    
1363                                    Query q = session.createQuery(sql);
1364    
1365                                    QueryPos qPos = QueryPos.getInstance(q);
1366    
1367                                    if (bindUuid) {
1368                                            qPos.add(uuid);
1369                                    }
1370    
1371                                    qPos.add(groupId);
1372    
1373                                    count = (Long)q.uniqueResult();
1374    
1375                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
1376                            }
1377                            catch (Exception e) {
1378                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1379    
1380                                    throw processException(e);
1381                            }
1382                            finally {
1383                                    closeSession(session);
1384                            }
1385                    }
1386    
1387                    return count.intValue();
1388            }
1389    
1390            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "bookmarksEntry.uuid IS NULL AND ";
1391            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "bookmarksEntry.uuid = ? AND ";
1392            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(bookmarksEntry.uuid IS NULL OR bookmarksEntry.uuid = '') AND ";
1393            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "bookmarksEntry.groupId = ?";
1394            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
1395                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
1396                            BookmarksEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
1397                            "findByUuid_C",
1398                            new String[] {
1399                                    String.class.getName(), Long.class.getName(),
1400                                    
1401                            Integer.class.getName(), Integer.class.getName(),
1402                                    OrderByComparator.class.getName()
1403                            });
1404            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
1405                    new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
1406                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
1407                            BookmarksEntryImpl.class,
1408                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
1409                            new String[] { String.class.getName(), Long.class.getName() },
1410                            BookmarksEntryModelImpl.UUID_COLUMN_BITMASK |
1411                            BookmarksEntryModelImpl.COMPANYID_COLUMN_BITMASK |
1412                            BookmarksEntryModelImpl.FOLDERID_COLUMN_BITMASK |
1413                            BookmarksEntryModelImpl.NAME_COLUMN_BITMASK);
1414            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
1415                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
1416                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
1417                            new String[] { String.class.getName(), Long.class.getName() });
1418    
1419            /**
1420             * Returns all the bookmarks entries where uuid = &#63; and companyId = &#63;.
1421             *
1422             * @param uuid the uuid
1423             * @param companyId the company ID
1424             * @return the matching bookmarks entries
1425             * @throws SystemException if a system exception occurred
1426             */
1427            @Override
1428            public List<BookmarksEntry> findByUuid_C(String uuid, long companyId)
1429                    throws SystemException {
1430                    return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
1431                            QueryUtil.ALL_POS, null);
1432            }
1433    
1434            /**
1435             * Returns a range of all the bookmarks entries where uuid = &#63; and companyId = &#63;.
1436             *
1437             * <p>
1438             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
1439             * </p>
1440             *
1441             * @param uuid the uuid
1442             * @param companyId the company ID
1443             * @param start the lower bound of the range of bookmarks entries
1444             * @param end the upper bound of the range of bookmarks entries (not inclusive)
1445             * @return the range of matching bookmarks entries
1446             * @throws SystemException if a system exception occurred
1447             */
1448            @Override
1449            public List<BookmarksEntry> findByUuid_C(String uuid, long companyId,
1450                    int start, int end) throws SystemException {
1451                    return findByUuid_C(uuid, companyId, start, end, null);
1452            }
1453    
1454            /**
1455             * Returns an ordered range of all the bookmarks entries where uuid = &#63; and companyId = &#63;.
1456             *
1457             * <p>
1458             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
1459             * </p>
1460             *
1461             * @param uuid the uuid
1462             * @param companyId the company ID
1463             * @param start the lower bound of the range of bookmarks entries
1464             * @param end the upper bound of the range of bookmarks entries (not inclusive)
1465             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1466             * @return the ordered range of matching bookmarks entries
1467             * @throws SystemException if a system exception occurred
1468             */
1469            @Override
1470            public List<BookmarksEntry> findByUuid_C(String uuid, long companyId,
1471                    int start, int end, OrderByComparator orderByComparator)
1472                    throws SystemException {
1473                    boolean pagination = true;
1474                    FinderPath finderPath = null;
1475                    Object[] finderArgs = null;
1476    
1477                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1478                                    (orderByComparator == null)) {
1479                            pagination = false;
1480                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
1481                            finderArgs = new Object[] { uuid, companyId };
1482                    }
1483                    else {
1484                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
1485                            finderArgs = new Object[] {
1486                                            uuid, companyId,
1487                                            
1488                                            start, end, orderByComparator
1489                                    };
1490                    }
1491    
1492                    List<BookmarksEntry> list = (List<BookmarksEntry>)FinderCacheUtil.getResult(finderPath,
1493                                    finderArgs, this);
1494    
1495                    if ((list != null) && !list.isEmpty()) {
1496                            for (BookmarksEntry bookmarksEntry : list) {
1497                                    if (!Validator.equals(uuid, bookmarksEntry.getUuid()) ||
1498                                                    (companyId != bookmarksEntry.getCompanyId())) {
1499                                            list = null;
1500    
1501                                            break;
1502                                    }
1503                            }
1504                    }
1505    
1506                    if (list == null) {
1507                            StringBundler query = null;
1508    
1509                            if (orderByComparator != null) {
1510                                    query = new StringBundler(4 +
1511                                                    (orderByComparator.getOrderByFields().length * 3));
1512                            }
1513                            else {
1514                                    query = new StringBundler(4);
1515                            }
1516    
1517                            query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
1518    
1519                            boolean bindUuid = false;
1520    
1521                            if (uuid == null) {
1522                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1523                            }
1524                            else if (uuid.equals(StringPool.BLANK)) {
1525                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1526                            }
1527                            else {
1528                                    bindUuid = true;
1529    
1530                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1531                            }
1532    
1533                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1534    
1535                            if (orderByComparator != null) {
1536                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1537                                            orderByComparator);
1538                            }
1539                            else
1540                             if (pagination) {
1541                                    query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
1542                            }
1543    
1544                            String sql = query.toString();
1545    
1546                            Session session = null;
1547    
1548                            try {
1549                                    session = openSession();
1550    
1551                                    Query q = session.createQuery(sql);
1552    
1553                                    QueryPos qPos = QueryPos.getInstance(q);
1554    
1555                                    if (bindUuid) {
1556                                            qPos.add(uuid);
1557                                    }
1558    
1559                                    qPos.add(companyId);
1560    
1561                                    if (!pagination) {
1562                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
1563                                                            getDialect(), start, end, false);
1564    
1565                                            Collections.sort(list);
1566    
1567                                            list = new UnmodifiableList<BookmarksEntry>(list);
1568                                    }
1569                                    else {
1570                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
1571                                                            getDialect(), start, end);
1572                                    }
1573    
1574                                    cacheResult(list);
1575    
1576                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1577                            }
1578                            catch (Exception e) {
1579                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1580    
1581                                    throw processException(e);
1582                            }
1583                            finally {
1584                                    closeSession(session);
1585                            }
1586                    }
1587    
1588                    return list;
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
1598             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
1599             * @throws SystemException if a system exception occurred
1600             */
1601            @Override
1602            public BookmarksEntry findByUuid_C_First(String uuid, long companyId,
1603                    OrderByComparator orderByComparator)
1604                    throws NoSuchEntryException, SystemException {
1605                    BookmarksEntry bookmarksEntry = fetchByUuid_C_First(uuid, companyId,
1606                                    orderByComparator);
1607    
1608                    if (bookmarksEntry != null) {
1609                            return bookmarksEntry;
1610                    }
1611    
1612                    StringBundler msg = new StringBundler(6);
1613    
1614                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1615    
1616                    msg.append("uuid=");
1617                    msg.append(uuid);
1618    
1619                    msg.append(", companyId=");
1620                    msg.append(companyId);
1621    
1622                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1623    
1624                    throw new NoSuchEntryException(msg.toString());
1625            }
1626    
1627            /**
1628             * Returns the first bookmarks entry in the ordered set where uuid = &#63; and companyId = &#63;.
1629             *
1630             * @param uuid the uuid
1631             * @param companyId the company ID
1632             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1633             * @return the first matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
1634             * @throws SystemException if a system exception occurred
1635             */
1636            @Override
1637            public BookmarksEntry fetchByUuid_C_First(String uuid, long companyId,
1638                    OrderByComparator orderByComparator) throws SystemException {
1639                    List<BookmarksEntry> list = findByUuid_C(uuid, companyId, 0, 1,
1640                                    orderByComparator);
1641    
1642                    if (!list.isEmpty()) {
1643                            return list.get(0);
1644                    }
1645    
1646                    return null;
1647            }
1648    
1649            /**
1650             * Returns the last bookmarks entry in the ordered set where uuid = &#63; and companyId = &#63;.
1651             *
1652             * @param uuid the uuid
1653             * @param companyId the company ID
1654             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1655             * @return the last matching bookmarks entry
1656             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
1657             * @throws SystemException if a system exception occurred
1658             */
1659            @Override
1660            public BookmarksEntry findByUuid_C_Last(String uuid, long companyId,
1661                    OrderByComparator orderByComparator)
1662                    throws NoSuchEntryException, SystemException {
1663                    BookmarksEntry bookmarksEntry = fetchByUuid_C_Last(uuid, companyId,
1664                                    orderByComparator);
1665    
1666                    if (bookmarksEntry != null) {
1667                            return bookmarksEntry;
1668                    }
1669    
1670                    StringBundler msg = new StringBundler(6);
1671    
1672                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1673    
1674                    msg.append("uuid=");
1675                    msg.append(uuid);
1676    
1677                    msg.append(", companyId=");
1678                    msg.append(companyId);
1679    
1680                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1681    
1682                    throw new NoSuchEntryException(msg.toString());
1683            }
1684    
1685            /**
1686             * Returns the last bookmarks entry in the ordered set where uuid = &#63; and companyId = &#63;.
1687             *
1688             * @param uuid the uuid
1689             * @param companyId the company ID
1690             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1691             * @return the last matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
1692             * @throws SystemException if a system exception occurred
1693             */
1694            @Override
1695            public BookmarksEntry fetchByUuid_C_Last(String uuid, long companyId,
1696                    OrderByComparator orderByComparator) throws SystemException {
1697                    int count = countByUuid_C(uuid, companyId);
1698    
1699                    if (count == 0) {
1700                            return null;
1701                    }
1702    
1703                    List<BookmarksEntry> list = findByUuid_C(uuid, companyId, count - 1,
1704                                    count, orderByComparator);
1705    
1706                    if (!list.isEmpty()) {
1707                            return list.get(0);
1708                    }
1709    
1710                    return null;
1711            }
1712    
1713            /**
1714             * Returns the bookmarks entries before and after the current bookmarks entry in the ordered set where uuid = &#63; and companyId = &#63;.
1715             *
1716             * @param entryId the primary key of the current bookmarks entry
1717             * @param uuid the uuid
1718             * @param companyId the company ID
1719             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1720             * @return the previous, current, and next bookmarks entry
1721             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
1722             * @throws SystemException if a system exception occurred
1723             */
1724            @Override
1725            public BookmarksEntry[] findByUuid_C_PrevAndNext(long entryId, String uuid,
1726                    long companyId, OrderByComparator orderByComparator)
1727                    throws NoSuchEntryException, SystemException {
1728                    BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
1729    
1730                    Session session = null;
1731    
1732                    try {
1733                            session = openSession();
1734    
1735                            BookmarksEntry[] array = new BookmarksEntryImpl[3];
1736    
1737                            array[0] = getByUuid_C_PrevAndNext(session, bookmarksEntry, uuid,
1738                                            companyId, orderByComparator, true);
1739    
1740                            array[1] = bookmarksEntry;
1741    
1742                            array[2] = getByUuid_C_PrevAndNext(session, bookmarksEntry, uuid,
1743                                            companyId, orderByComparator, false);
1744    
1745                            return array;
1746                    }
1747                    catch (Exception e) {
1748                            throw processException(e);
1749                    }
1750                    finally {
1751                            closeSession(session);
1752                    }
1753            }
1754    
1755            protected BookmarksEntry getByUuid_C_PrevAndNext(Session session,
1756                    BookmarksEntry bookmarksEntry, String uuid, long companyId,
1757                    OrderByComparator orderByComparator, boolean previous) {
1758                    StringBundler query = null;
1759    
1760                    if (orderByComparator != null) {
1761                            query = new StringBundler(6 +
1762                                            (orderByComparator.getOrderByFields().length * 6));
1763                    }
1764                    else {
1765                            query = new StringBundler(3);
1766                    }
1767    
1768                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
1769    
1770                    boolean bindUuid = false;
1771    
1772                    if (uuid == null) {
1773                            query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1774                    }
1775                    else if (uuid.equals(StringPool.BLANK)) {
1776                            query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1777                    }
1778                    else {
1779                            bindUuid = true;
1780    
1781                            query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1782                    }
1783    
1784                    query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1785    
1786                    if (orderByComparator != null) {
1787                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1788    
1789                            if (orderByConditionFields.length > 0) {
1790                                    query.append(WHERE_AND);
1791                            }
1792    
1793                            for (int i = 0; i < orderByConditionFields.length; i++) {
1794                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1795                                    query.append(orderByConditionFields[i]);
1796    
1797                                    if ((i + 1) < orderByConditionFields.length) {
1798                                            if (orderByComparator.isAscending() ^ previous) {
1799                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1800                                            }
1801                                            else {
1802                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1803                                            }
1804                                    }
1805                                    else {
1806                                            if (orderByComparator.isAscending() ^ previous) {
1807                                                    query.append(WHERE_GREATER_THAN);
1808                                            }
1809                                            else {
1810                                                    query.append(WHERE_LESSER_THAN);
1811                                            }
1812                                    }
1813                            }
1814    
1815                            query.append(ORDER_BY_CLAUSE);
1816    
1817                            String[] orderByFields = orderByComparator.getOrderByFields();
1818    
1819                            for (int i = 0; i < orderByFields.length; i++) {
1820                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1821                                    query.append(orderByFields[i]);
1822    
1823                                    if ((i + 1) < orderByFields.length) {
1824                                            if (orderByComparator.isAscending() ^ previous) {
1825                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1826                                            }
1827                                            else {
1828                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1829                                            }
1830                                    }
1831                                    else {
1832                                            if (orderByComparator.isAscending() ^ previous) {
1833                                                    query.append(ORDER_BY_ASC);
1834                                            }
1835                                            else {
1836                                                    query.append(ORDER_BY_DESC);
1837                                            }
1838                                    }
1839                            }
1840                    }
1841                    else {
1842                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
1843                    }
1844    
1845                    String sql = query.toString();
1846    
1847                    Query q = session.createQuery(sql);
1848    
1849                    q.setFirstResult(0);
1850                    q.setMaxResults(2);
1851    
1852                    QueryPos qPos = QueryPos.getInstance(q);
1853    
1854                    if (bindUuid) {
1855                            qPos.add(uuid);
1856                    }
1857    
1858                    qPos.add(companyId);
1859    
1860                    if (orderByComparator != null) {
1861                            Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry);
1862    
1863                            for (Object value : values) {
1864                                    qPos.add(value);
1865                            }
1866                    }
1867    
1868                    List<BookmarksEntry> list = q.list();
1869    
1870                    if (list.size() == 2) {
1871                            return list.get(1);
1872                    }
1873                    else {
1874                            return null;
1875                    }
1876            }
1877    
1878            /**
1879             * Removes all the bookmarks entries where uuid = &#63; and companyId = &#63; from the database.
1880             *
1881             * @param uuid the uuid
1882             * @param companyId the company ID
1883             * @throws SystemException if a system exception occurred
1884             */
1885            @Override
1886            public void removeByUuid_C(String uuid, long companyId)
1887                    throws SystemException {
1888                    for (BookmarksEntry bookmarksEntry : findByUuid_C(uuid, companyId,
1889                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1890                            remove(bookmarksEntry);
1891                    }
1892            }
1893    
1894            /**
1895             * Returns the number of bookmarks entries where uuid = &#63; and companyId = &#63;.
1896             *
1897             * @param uuid the uuid
1898             * @param companyId the company ID
1899             * @return the number of matching bookmarks entries
1900             * @throws SystemException if a system exception occurred
1901             */
1902            @Override
1903            public int countByUuid_C(String uuid, long companyId)
1904                    throws SystemException {
1905                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1906    
1907                    Object[] finderArgs = new Object[] { uuid, companyId };
1908    
1909                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1910                                    this);
1911    
1912                    if (count == null) {
1913                            StringBundler query = new StringBundler(3);
1914    
1915                            query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
1916    
1917                            boolean bindUuid = false;
1918    
1919                            if (uuid == null) {
1920                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1921                            }
1922                            else if (uuid.equals(StringPool.BLANK)) {
1923                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1924                            }
1925                            else {
1926                                    bindUuid = true;
1927    
1928                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1929                            }
1930    
1931                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1932    
1933                            String sql = query.toString();
1934    
1935                            Session session = null;
1936    
1937                            try {
1938                                    session = openSession();
1939    
1940                                    Query q = session.createQuery(sql);
1941    
1942                                    QueryPos qPos = QueryPos.getInstance(q);
1943    
1944                                    if (bindUuid) {
1945                                            qPos.add(uuid);
1946                                    }
1947    
1948                                    qPos.add(companyId);
1949    
1950                                    count = (Long)q.uniqueResult();
1951    
1952                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
1953                            }
1954                            catch (Exception e) {
1955                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1956    
1957                                    throw processException(e);
1958                            }
1959                            finally {
1960                                    closeSession(session);
1961                            }
1962                    }
1963    
1964                    return count.intValue();
1965            }
1966    
1967            private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "bookmarksEntry.uuid IS NULL AND ";
1968            private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "bookmarksEntry.uuid = ? AND ";
1969            private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(bookmarksEntry.uuid IS NULL OR bookmarksEntry.uuid = '') AND ";
1970            private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "bookmarksEntry.companyId = ?";
1971            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
1972                    new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
1973                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
1974                            BookmarksEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
1975                            "findByCompanyId",
1976                            new String[] {
1977                                    Long.class.getName(),
1978                                    
1979                            Integer.class.getName(), Integer.class.getName(),
1980                                    OrderByComparator.class.getName()
1981                            });
1982            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
1983                    new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
1984                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
1985                            BookmarksEntryImpl.class,
1986                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
1987                            new String[] { Long.class.getName() },
1988                            BookmarksEntryModelImpl.COMPANYID_COLUMN_BITMASK |
1989                            BookmarksEntryModelImpl.FOLDERID_COLUMN_BITMASK |
1990                            BookmarksEntryModelImpl.NAME_COLUMN_BITMASK);
1991            public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
1992                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
1993                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
1994                            new String[] { Long.class.getName() });
1995    
1996            /**
1997             * Returns all the bookmarks entries where companyId = &#63;.
1998             *
1999             * @param companyId the company ID
2000             * @return the matching bookmarks entries
2001             * @throws SystemException if a system exception occurred
2002             */
2003            @Override
2004            public List<BookmarksEntry> findByCompanyId(long companyId)
2005                    throws SystemException {
2006                    return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2007                            null);
2008            }
2009    
2010            /**
2011             * Returns a range of all the bookmarks entries where companyId = &#63;.
2012             *
2013             * <p>
2014             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
2015             * </p>
2016             *
2017             * @param companyId the company ID
2018             * @param start the lower bound of the range of bookmarks entries
2019             * @param end the upper bound of the range of bookmarks entries (not inclusive)
2020             * @return the range of matching bookmarks entries
2021             * @throws SystemException if a system exception occurred
2022             */
2023            @Override
2024            public List<BookmarksEntry> findByCompanyId(long companyId, int start,
2025                    int end) throws SystemException {
2026                    return findByCompanyId(companyId, start, end, null);
2027            }
2028    
2029            /**
2030             * Returns an ordered range of all the bookmarks entries where companyId = &#63;.
2031             *
2032             * <p>
2033             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
2034             * </p>
2035             *
2036             * @param companyId the company ID
2037             * @param start the lower bound of the range of bookmarks entries
2038             * @param end the upper bound of the range of bookmarks entries (not inclusive)
2039             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2040             * @return the ordered range of matching bookmarks entries
2041             * @throws SystemException if a system exception occurred
2042             */
2043            @Override
2044            public List<BookmarksEntry> findByCompanyId(long companyId, int start,
2045                    int end, OrderByComparator orderByComparator) throws SystemException {
2046                    boolean pagination = true;
2047                    FinderPath finderPath = null;
2048                    Object[] finderArgs = null;
2049    
2050                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2051                                    (orderByComparator == null)) {
2052                            pagination = false;
2053                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
2054                            finderArgs = new Object[] { companyId };
2055                    }
2056                    else {
2057                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
2058                            finderArgs = new Object[] { companyId, start, end, orderByComparator };
2059                    }
2060    
2061                    List<BookmarksEntry> list = (List<BookmarksEntry>)FinderCacheUtil.getResult(finderPath,
2062                                    finderArgs, this);
2063    
2064                    if ((list != null) && !list.isEmpty()) {
2065                            for (BookmarksEntry bookmarksEntry : list) {
2066                                    if ((companyId != bookmarksEntry.getCompanyId())) {
2067                                            list = null;
2068    
2069                                            break;
2070                                    }
2071                            }
2072                    }
2073    
2074                    if (list == null) {
2075                            StringBundler query = null;
2076    
2077                            if (orderByComparator != null) {
2078                                    query = new StringBundler(3 +
2079                                                    (orderByComparator.getOrderByFields().length * 3));
2080                            }
2081                            else {
2082                                    query = new StringBundler(3);
2083                            }
2084    
2085                            query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
2086    
2087                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2088    
2089                            if (orderByComparator != null) {
2090                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2091                                            orderByComparator);
2092                            }
2093                            else
2094                             if (pagination) {
2095                                    query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
2096                            }
2097    
2098                            String sql = query.toString();
2099    
2100                            Session session = null;
2101    
2102                            try {
2103                                    session = openSession();
2104    
2105                                    Query q = session.createQuery(sql);
2106    
2107                                    QueryPos qPos = QueryPos.getInstance(q);
2108    
2109                                    qPos.add(companyId);
2110    
2111                                    if (!pagination) {
2112                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
2113                                                            getDialect(), start, end, false);
2114    
2115                                            Collections.sort(list);
2116    
2117                                            list = new UnmodifiableList<BookmarksEntry>(list);
2118                                    }
2119                                    else {
2120                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
2121                                                            getDialect(), start, end);
2122                                    }
2123    
2124                                    cacheResult(list);
2125    
2126                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
2127                            }
2128                            catch (Exception e) {
2129                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2130    
2131                                    throw processException(e);
2132                            }
2133                            finally {
2134                                    closeSession(session);
2135                            }
2136                    }
2137    
2138                    return list;
2139            }
2140    
2141            /**
2142             * Returns the first bookmarks entry in the ordered set where companyId = &#63;.
2143             *
2144             * @param companyId the company ID
2145             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2146             * @return the first matching bookmarks entry
2147             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
2148             * @throws SystemException if a system exception occurred
2149             */
2150            @Override
2151            public BookmarksEntry findByCompanyId_First(long companyId,
2152                    OrderByComparator orderByComparator)
2153                    throws NoSuchEntryException, SystemException {
2154                    BookmarksEntry bookmarksEntry = fetchByCompanyId_First(companyId,
2155                                    orderByComparator);
2156    
2157                    if (bookmarksEntry != null) {
2158                            return bookmarksEntry;
2159                    }
2160    
2161                    StringBundler msg = new StringBundler(4);
2162    
2163                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2164    
2165                    msg.append("companyId=");
2166                    msg.append(companyId);
2167    
2168                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2169    
2170                    throw new NoSuchEntryException(msg.toString());
2171            }
2172    
2173            /**
2174             * Returns the first bookmarks entry in the ordered set where companyId = &#63;.
2175             *
2176             * @param companyId the company ID
2177             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2178             * @return the first matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
2179             * @throws SystemException if a system exception occurred
2180             */
2181            @Override
2182            public BookmarksEntry fetchByCompanyId_First(long companyId,
2183                    OrderByComparator orderByComparator) throws SystemException {
2184                    List<BookmarksEntry> list = findByCompanyId(companyId, 0, 1,
2185                                    orderByComparator);
2186    
2187                    if (!list.isEmpty()) {
2188                            return list.get(0);
2189                    }
2190    
2191                    return null;
2192            }
2193    
2194            /**
2195             * Returns the last bookmarks entry in the ordered set where companyId = &#63;.
2196             *
2197             * @param companyId the company ID
2198             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2199             * @return the last matching bookmarks entry
2200             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
2201             * @throws SystemException if a system exception occurred
2202             */
2203            @Override
2204            public BookmarksEntry findByCompanyId_Last(long companyId,
2205                    OrderByComparator orderByComparator)
2206                    throws NoSuchEntryException, SystemException {
2207                    BookmarksEntry bookmarksEntry = fetchByCompanyId_Last(companyId,
2208                                    orderByComparator);
2209    
2210                    if (bookmarksEntry != null) {
2211                            return bookmarksEntry;
2212                    }
2213    
2214                    StringBundler msg = new StringBundler(4);
2215    
2216                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2217    
2218                    msg.append("companyId=");
2219                    msg.append(companyId);
2220    
2221                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2222    
2223                    throw new NoSuchEntryException(msg.toString());
2224            }
2225    
2226            /**
2227             * Returns the last bookmarks entry in the ordered set where companyId = &#63;.
2228             *
2229             * @param companyId the company ID
2230             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2231             * @return the last matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
2232             * @throws SystemException if a system exception occurred
2233             */
2234            @Override
2235            public BookmarksEntry fetchByCompanyId_Last(long companyId,
2236                    OrderByComparator orderByComparator) throws SystemException {
2237                    int count = countByCompanyId(companyId);
2238    
2239                    if (count == 0) {
2240                            return null;
2241                    }
2242    
2243                    List<BookmarksEntry> list = findByCompanyId(companyId, count - 1,
2244                                    count, orderByComparator);
2245    
2246                    if (!list.isEmpty()) {
2247                            return list.get(0);
2248                    }
2249    
2250                    return null;
2251            }
2252    
2253            /**
2254             * Returns the bookmarks entries before and after the current bookmarks entry in the ordered set where companyId = &#63;.
2255             *
2256             * @param entryId the primary key of the current bookmarks entry
2257             * @param companyId the company ID
2258             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2259             * @return the previous, current, and next bookmarks entry
2260             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
2261             * @throws SystemException if a system exception occurred
2262             */
2263            @Override
2264            public BookmarksEntry[] findByCompanyId_PrevAndNext(long entryId,
2265                    long companyId, OrderByComparator orderByComparator)
2266                    throws NoSuchEntryException, SystemException {
2267                    BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
2268    
2269                    Session session = null;
2270    
2271                    try {
2272                            session = openSession();
2273    
2274                            BookmarksEntry[] array = new BookmarksEntryImpl[3];
2275    
2276                            array[0] = getByCompanyId_PrevAndNext(session, bookmarksEntry,
2277                                            companyId, orderByComparator, true);
2278    
2279                            array[1] = bookmarksEntry;
2280    
2281                            array[2] = getByCompanyId_PrevAndNext(session, bookmarksEntry,
2282                                            companyId, orderByComparator, false);
2283    
2284                            return array;
2285                    }
2286                    catch (Exception e) {
2287                            throw processException(e);
2288                    }
2289                    finally {
2290                            closeSession(session);
2291                    }
2292            }
2293    
2294            protected BookmarksEntry getByCompanyId_PrevAndNext(Session session,
2295                    BookmarksEntry bookmarksEntry, long companyId,
2296                    OrderByComparator orderByComparator, boolean previous) {
2297                    StringBundler query = null;
2298    
2299                    if (orderByComparator != null) {
2300                            query = new StringBundler(6 +
2301                                            (orderByComparator.getOrderByFields().length * 6));
2302                    }
2303                    else {
2304                            query = new StringBundler(3);
2305                    }
2306    
2307                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
2308    
2309                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2310    
2311                    if (orderByComparator != null) {
2312                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2313    
2314                            if (orderByConditionFields.length > 0) {
2315                                    query.append(WHERE_AND);
2316                            }
2317    
2318                            for (int i = 0; i < orderByConditionFields.length; i++) {
2319                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2320                                    query.append(orderByConditionFields[i]);
2321    
2322                                    if ((i + 1) < orderByConditionFields.length) {
2323                                            if (orderByComparator.isAscending() ^ previous) {
2324                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2325                                            }
2326                                            else {
2327                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2328                                            }
2329                                    }
2330                                    else {
2331                                            if (orderByComparator.isAscending() ^ previous) {
2332                                                    query.append(WHERE_GREATER_THAN);
2333                                            }
2334                                            else {
2335                                                    query.append(WHERE_LESSER_THAN);
2336                                            }
2337                                    }
2338                            }
2339    
2340                            query.append(ORDER_BY_CLAUSE);
2341    
2342                            String[] orderByFields = orderByComparator.getOrderByFields();
2343    
2344                            for (int i = 0; i < orderByFields.length; i++) {
2345                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2346                                    query.append(orderByFields[i]);
2347    
2348                                    if ((i + 1) < orderByFields.length) {
2349                                            if (orderByComparator.isAscending() ^ previous) {
2350                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2351                                            }
2352                                            else {
2353                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2354                                            }
2355                                    }
2356                                    else {
2357                                            if (orderByComparator.isAscending() ^ previous) {
2358                                                    query.append(ORDER_BY_ASC);
2359                                            }
2360                                            else {
2361                                                    query.append(ORDER_BY_DESC);
2362                                            }
2363                                    }
2364                            }
2365                    }
2366                    else {
2367                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
2368                    }
2369    
2370                    String sql = query.toString();
2371    
2372                    Query q = session.createQuery(sql);
2373    
2374                    q.setFirstResult(0);
2375                    q.setMaxResults(2);
2376    
2377                    QueryPos qPos = QueryPos.getInstance(q);
2378    
2379                    qPos.add(companyId);
2380    
2381                    if (orderByComparator != null) {
2382                            Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry);
2383    
2384                            for (Object value : values) {
2385                                    qPos.add(value);
2386                            }
2387                    }
2388    
2389                    List<BookmarksEntry> list = q.list();
2390    
2391                    if (list.size() == 2) {
2392                            return list.get(1);
2393                    }
2394                    else {
2395                            return null;
2396                    }
2397            }
2398    
2399            /**
2400             * Removes all the bookmarks entries where companyId = &#63; from the database.
2401             *
2402             * @param companyId the company ID
2403             * @throws SystemException if a system exception occurred
2404             */
2405            @Override
2406            public void removeByCompanyId(long companyId) throws SystemException {
2407                    for (BookmarksEntry bookmarksEntry : findByCompanyId(companyId,
2408                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2409                            remove(bookmarksEntry);
2410                    }
2411            }
2412    
2413            /**
2414             * Returns the number of bookmarks entries where companyId = &#63;.
2415             *
2416             * @param companyId the company ID
2417             * @return the number of matching bookmarks entries
2418             * @throws SystemException if a system exception occurred
2419             */
2420            @Override
2421            public int countByCompanyId(long companyId) throws SystemException {
2422                    FinderPath finderPath = FINDER_PATH_COUNT_BY_COMPANYID;
2423    
2424                    Object[] finderArgs = new Object[] { companyId };
2425    
2426                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2427                                    this);
2428    
2429                    if (count == null) {
2430                            StringBundler query = new StringBundler(2);
2431    
2432                            query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
2433    
2434                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2435    
2436                            String sql = query.toString();
2437    
2438                            Session session = null;
2439    
2440                            try {
2441                                    session = openSession();
2442    
2443                                    Query q = session.createQuery(sql);
2444    
2445                                    QueryPos qPos = QueryPos.getInstance(q);
2446    
2447                                    qPos.add(companyId);
2448    
2449                                    count = (Long)q.uniqueResult();
2450    
2451                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
2452                            }
2453                            catch (Exception e) {
2454                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2455    
2456                                    throw processException(e);
2457                            }
2458                            finally {
2459                                    closeSession(session);
2460                            }
2461                    }
2462    
2463                    return count.intValue();
2464            }
2465    
2466            private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "bookmarksEntry.companyId = ?";
2467            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
2468                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
2469                            BookmarksEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
2470                            "findByG_F",
2471                            new String[] {
2472                                    Long.class.getName(), Long.class.getName(),
2473                                    
2474                            Integer.class.getName(), Integer.class.getName(),
2475                                    OrderByComparator.class.getName()
2476                            });
2477            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
2478                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
2479                            BookmarksEntryImpl.class,
2480                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_F",
2481                            new String[] { Long.class.getName(), Long.class.getName() },
2482                            BookmarksEntryModelImpl.GROUPID_COLUMN_BITMASK |
2483                            BookmarksEntryModelImpl.FOLDERID_COLUMN_BITMASK |
2484                            BookmarksEntryModelImpl.NAME_COLUMN_BITMASK);
2485            public static final FinderPath FINDER_PATH_COUNT_BY_G_F = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
2486                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
2487                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_F",
2488                            new String[] { Long.class.getName(), Long.class.getName() });
2489            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
2490                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
2491                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_F",
2492                            new String[] { Long.class.getName(), Long.class.getName() });
2493    
2494            /**
2495             * Returns all the bookmarks entries where groupId = &#63; and folderId = &#63;.
2496             *
2497             * @param groupId the group ID
2498             * @param folderId the folder ID
2499             * @return the matching bookmarks entries
2500             * @throws SystemException if a system exception occurred
2501             */
2502            @Override
2503            public List<BookmarksEntry> findByG_F(long groupId, long folderId)
2504                    throws SystemException {
2505                    return findByG_F(groupId, folderId, QueryUtil.ALL_POS,
2506                            QueryUtil.ALL_POS, null);
2507            }
2508    
2509            /**
2510             * Returns a range of all the bookmarks entries where groupId = &#63; and folderId = &#63;.
2511             *
2512             * <p>
2513             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
2514             * </p>
2515             *
2516             * @param groupId the group ID
2517             * @param folderId the folder ID
2518             * @param start the lower bound of the range of bookmarks entries
2519             * @param end the upper bound of the range of bookmarks entries (not inclusive)
2520             * @return the range of matching bookmarks entries
2521             * @throws SystemException if a system exception occurred
2522             */
2523            @Override
2524            public List<BookmarksEntry> findByG_F(long groupId, long folderId,
2525                    int start, int end) throws SystemException {
2526                    return findByG_F(groupId, folderId, start, end, null);
2527            }
2528    
2529            /**
2530             * Returns an ordered range of all the bookmarks entries where groupId = &#63; and folderId = &#63;.
2531             *
2532             * <p>
2533             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
2534             * </p>
2535             *
2536             * @param groupId the group ID
2537             * @param folderId the folder ID
2538             * @param start the lower bound of the range of bookmarks entries
2539             * @param end the upper bound of the range of bookmarks entries (not inclusive)
2540             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2541             * @return the ordered range of matching bookmarks entries
2542             * @throws SystemException if a system exception occurred
2543             */
2544            @Override
2545            public List<BookmarksEntry> findByG_F(long groupId, long folderId,
2546                    int start, int end, OrderByComparator orderByComparator)
2547                    throws SystemException {
2548                    boolean pagination = true;
2549                    FinderPath finderPath = null;
2550                    Object[] finderArgs = null;
2551    
2552                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2553                                    (orderByComparator == null)) {
2554                            pagination = false;
2555                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F;
2556                            finderArgs = new Object[] { groupId, folderId };
2557                    }
2558                    else {
2559                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F;
2560                            finderArgs = new Object[] {
2561                                            groupId, folderId,
2562                                            
2563                                            start, end, orderByComparator
2564                                    };
2565                    }
2566    
2567                    List<BookmarksEntry> list = (List<BookmarksEntry>)FinderCacheUtil.getResult(finderPath,
2568                                    finderArgs, this);
2569    
2570                    if ((list != null) && !list.isEmpty()) {
2571                            for (BookmarksEntry bookmarksEntry : list) {
2572                                    if ((groupId != bookmarksEntry.getGroupId()) ||
2573                                                    (folderId != bookmarksEntry.getFolderId())) {
2574                                            list = null;
2575    
2576                                            break;
2577                                    }
2578                            }
2579                    }
2580    
2581                    if (list == null) {
2582                            StringBundler query = null;
2583    
2584                            if (orderByComparator != null) {
2585                                    query = new StringBundler(4 +
2586                                                    (orderByComparator.getOrderByFields().length * 3));
2587                            }
2588                            else {
2589                                    query = new StringBundler(4);
2590                            }
2591    
2592                            query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
2593    
2594                            query.append(_FINDER_COLUMN_G_F_GROUPID_2);
2595    
2596                            query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
2597    
2598                            if (orderByComparator != null) {
2599                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2600                                            orderByComparator);
2601                            }
2602                            else
2603                             if (pagination) {
2604                                    query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
2605                            }
2606    
2607                            String sql = query.toString();
2608    
2609                            Session session = null;
2610    
2611                            try {
2612                                    session = openSession();
2613    
2614                                    Query q = session.createQuery(sql);
2615    
2616                                    QueryPos qPos = QueryPos.getInstance(q);
2617    
2618                                    qPos.add(groupId);
2619    
2620                                    qPos.add(folderId);
2621    
2622                                    if (!pagination) {
2623                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
2624                                                            getDialect(), start, end, false);
2625    
2626                                            Collections.sort(list);
2627    
2628                                            list = new UnmodifiableList<BookmarksEntry>(list);
2629                                    }
2630                                    else {
2631                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
2632                                                            getDialect(), start, end);
2633                                    }
2634    
2635                                    cacheResult(list);
2636    
2637                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
2638                            }
2639                            catch (Exception e) {
2640                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2641    
2642                                    throw processException(e);
2643                            }
2644                            finally {
2645                                    closeSession(session);
2646                            }
2647                    }
2648    
2649                    return list;
2650            }
2651    
2652            /**
2653             * Returns the first bookmarks entry in the ordered set where groupId = &#63; and folderId = &#63;.
2654             *
2655             * @param groupId the group ID
2656             * @param folderId the folder ID
2657             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2658             * @return the first matching bookmarks entry
2659             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
2660             * @throws SystemException if a system exception occurred
2661             */
2662            @Override
2663            public BookmarksEntry findByG_F_First(long groupId, long folderId,
2664                    OrderByComparator orderByComparator)
2665                    throws NoSuchEntryException, SystemException {
2666                    BookmarksEntry bookmarksEntry = fetchByG_F_First(groupId, folderId,
2667                                    orderByComparator);
2668    
2669                    if (bookmarksEntry != null) {
2670                            return bookmarksEntry;
2671                    }
2672    
2673                    StringBundler msg = new StringBundler(6);
2674    
2675                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2676    
2677                    msg.append("groupId=");
2678                    msg.append(groupId);
2679    
2680                    msg.append(", folderId=");
2681                    msg.append(folderId);
2682    
2683                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2684    
2685                    throw new NoSuchEntryException(msg.toString());
2686            }
2687    
2688            /**
2689             * Returns the first bookmarks entry in the ordered set where groupId = &#63; and folderId = &#63;.
2690             *
2691             * @param groupId the group ID
2692             * @param folderId the folder ID
2693             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2694             * @return the first matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
2695             * @throws SystemException if a system exception occurred
2696             */
2697            @Override
2698            public BookmarksEntry fetchByG_F_First(long groupId, long folderId,
2699                    OrderByComparator orderByComparator) throws SystemException {
2700                    List<BookmarksEntry> list = findByG_F(groupId, folderId, 0, 1,
2701                                    orderByComparator);
2702    
2703                    if (!list.isEmpty()) {
2704                            return list.get(0);
2705                    }
2706    
2707                    return null;
2708            }
2709    
2710            /**
2711             * Returns the last bookmarks entry in the ordered set where groupId = &#63; and folderId = &#63;.
2712             *
2713             * @param groupId the group ID
2714             * @param folderId the folder ID
2715             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2716             * @return the last matching bookmarks entry
2717             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
2718             * @throws SystemException if a system exception occurred
2719             */
2720            @Override
2721            public BookmarksEntry findByG_F_Last(long groupId, long folderId,
2722                    OrderByComparator orderByComparator)
2723                    throws NoSuchEntryException, SystemException {
2724                    BookmarksEntry bookmarksEntry = fetchByG_F_Last(groupId, folderId,
2725                                    orderByComparator);
2726    
2727                    if (bookmarksEntry != null) {
2728                            return bookmarksEntry;
2729                    }
2730    
2731                    StringBundler msg = new StringBundler(6);
2732    
2733                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2734    
2735                    msg.append("groupId=");
2736                    msg.append(groupId);
2737    
2738                    msg.append(", folderId=");
2739                    msg.append(folderId);
2740    
2741                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2742    
2743                    throw new NoSuchEntryException(msg.toString());
2744            }
2745    
2746            /**
2747             * Returns the last bookmarks entry in the ordered set where groupId = &#63; and folderId = &#63;.
2748             *
2749             * @param groupId the group ID
2750             * @param folderId the folder ID
2751             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2752             * @return the last matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
2753             * @throws SystemException if a system exception occurred
2754             */
2755            @Override
2756            public BookmarksEntry fetchByG_F_Last(long groupId, long folderId,
2757                    OrderByComparator orderByComparator) throws SystemException {
2758                    int count = countByG_F(groupId, folderId);
2759    
2760                    if (count == 0) {
2761                            return null;
2762                    }
2763    
2764                    List<BookmarksEntry> list = findByG_F(groupId, folderId, count - 1,
2765                                    count, orderByComparator);
2766    
2767                    if (!list.isEmpty()) {
2768                            return list.get(0);
2769                    }
2770    
2771                    return null;
2772            }
2773    
2774            /**
2775             * Returns the bookmarks entries before and after the current bookmarks entry in the ordered set where groupId = &#63; and folderId = &#63;.
2776             *
2777             * @param entryId the primary key of the current bookmarks entry
2778             * @param groupId the group ID
2779             * @param folderId the folder ID
2780             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2781             * @return the previous, current, and next bookmarks entry
2782             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
2783             * @throws SystemException if a system exception occurred
2784             */
2785            @Override
2786            public BookmarksEntry[] findByG_F_PrevAndNext(long entryId, long groupId,
2787                    long folderId, OrderByComparator orderByComparator)
2788                    throws NoSuchEntryException, SystemException {
2789                    BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
2790    
2791                    Session session = null;
2792    
2793                    try {
2794                            session = openSession();
2795    
2796                            BookmarksEntry[] array = new BookmarksEntryImpl[3];
2797    
2798                            array[0] = getByG_F_PrevAndNext(session, bookmarksEntry, groupId,
2799                                            folderId, orderByComparator, true);
2800    
2801                            array[1] = bookmarksEntry;
2802    
2803                            array[2] = getByG_F_PrevAndNext(session, bookmarksEntry, groupId,
2804                                            folderId, orderByComparator, false);
2805    
2806                            return array;
2807                    }
2808                    catch (Exception e) {
2809                            throw processException(e);
2810                    }
2811                    finally {
2812                            closeSession(session);
2813                    }
2814            }
2815    
2816            protected BookmarksEntry getByG_F_PrevAndNext(Session session,
2817                    BookmarksEntry bookmarksEntry, long groupId, long folderId,
2818                    OrderByComparator orderByComparator, boolean previous) {
2819                    StringBundler query = null;
2820    
2821                    if (orderByComparator != null) {
2822                            query = new StringBundler(6 +
2823                                            (orderByComparator.getOrderByFields().length * 6));
2824                    }
2825                    else {
2826                            query = new StringBundler(3);
2827                    }
2828    
2829                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
2830    
2831                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
2832    
2833                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
2834    
2835                    if (orderByComparator != null) {
2836                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2837    
2838                            if (orderByConditionFields.length > 0) {
2839                                    query.append(WHERE_AND);
2840                            }
2841    
2842                            for (int i = 0; i < orderByConditionFields.length; i++) {
2843                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2844                                    query.append(orderByConditionFields[i]);
2845    
2846                                    if ((i + 1) < orderByConditionFields.length) {
2847                                            if (orderByComparator.isAscending() ^ previous) {
2848                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2849                                            }
2850                                            else {
2851                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2852                                            }
2853                                    }
2854                                    else {
2855                                            if (orderByComparator.isAscending() ^ previous) {
2856                                                    query.append(WHERE_GREATER_THAN);
2857                                            }
2858                                            else {
2859                                                    query.append(WHERE_LESSER_THAN);
2860                                            }
2861                                    }
2862                            }
2863    
2864                            query.append(ORDER_BY_CLAUSE);
2865    
2866                            String[] orderByFields = orderByComparator.getOrderByFields();
2867    
2868                            for (int i = 0; i < orderByFields.length; i++) {
2869                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2870                                    query.append(orderByFields[i]);
2871    
2872                                    if ((i + 1) < orderByFields.length) {
2873                                            if (orderByComparator.isAscending() ^ previous) {
2874                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2875                                            }
2876                                            else {
2877                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2878                                            }
2879                                    }
2880                                    else {
2881                                            if (orderByComparator.isAscending() ^ previous) {
2882                                                    query.append(ORDER_BY_ASC);
2883                                            }
2884                                            else {
2885                                                    query.append(ORDER_BY_DESC);
2886                                            }
2887                                    }
2888                            }
2889                    }
2890                    else {
2891                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
2892                    }
2893    
2894                    String sql = query.toString();
2895    
2896                    Query q = session.createQuery(sql);
2897    
2898                    q.setFirstResult(0);
2899                    q.setMaxResults(2);
2900    
2901                    QueryPos qPos = QueryPos.getInstance(q);
2902    
2903                    qPos.add(groupId);
2904    
2905                    qPos.add(folderId);
2906    
2907                    if (orderByComparator != null) {
2908                            Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry);
2909    
2910                            for (Object value : values) {
2911                                    qPos.add(value);
2912                            }
2913                    }
2914    
2915                    List<BookmarksEntry> list = q.list();
2916    
2917                    if (list.size() == 2) {
2918                            return list.get(1);
2919                    }
2920                    else {
2921                            return null;
2922                    }
2923            }
2924    
2925            /**
2926             * Returns all the bookmarks entries that the user has permission to view where groupId = &#63; and folderId = &#63;.
2927             *
2928             * @param groupId the group ID
2929             * @param folderId the folder ID
2930             * @return the matching bookmarks entries that the user has permission to view
2931             * @throws SystemException if a system exception occurred
2932             */
2933            @Override
2934            public List<BookmarksEntry> filterFindByG_F(long groupId, long folderId)
2935                    throws SystemException {
2936                    return filterFindByG_F(groupId, folderId, QueryUtil.ALL_POS,
2937                            QueryUtil.ALL_POS, null);
2938            }
2939    
2940            /**
2941             * Returns a range of all the bookmarks entries that the user has permission to view where groupId = &#63; and folderId = &#63;.
2942             *
2943             * <p>
2944             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
2945             * </p>
2946             *
2947             * @param groupId the group ID
2948             * @param folderId the folder ID
2949             * @param start the lower bound of the range of bookmarks entries
2950             * @param end the upper bound of the range of bookmarks entries (not inclusive)
2951             * @return the range of matching bookmarks entries that the user has permission to view
2952             * @throws SystemException if a system exception occurred
2953             */
2954            @Override
2955            public List<BookmarksEntry> filterFindByG_F(long groupId, long folderId,
2956                    int start, int end) throws SystemException {
2957                    return filterFindByG_F(groupId, folderId, start, end, null);
2958            }
2959    
2960            /**
2961             * Returns an ordered range of all the bookmarks entries that the user has permissions to view where groupId = &#63; and folderId = &#63;.
2962             *
2963             * <p>
2964             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
2965             * </p>
2966             *
2967             * @param groupId the group ID
2968             * @param folderId the folder ID
2969             * @param start the lower bound of the range of bookmarks entries
2970             * @param end the upper bound of the range of bookmarks entries (not inclusive)
2971             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2972             * @return the ordered range of matching bookmarks entries that the user has permission to view
2973             * @throws SystemException if a system exception occurred
2974             */
2975            @Override
2976            public List<BookmarksEntry> filterFindByG_F(long groupId, long folderId,
2977                    int start, int end, OrderByComparator orderByComparator)
2978                    throws SystemException {
2979                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2980                            return findByG_F(groupId, folderId, start, end, orderByComparator);
2981                    }
2982    
2983                    StringBundler query = null;
2984    
2985                    if (orderByComparator != null) {
2986                            query = new StringBundler(4 +
2987                                            (orderByComparator.getOrderByFields().length * 3));
2988                    }
2989                    else {
2990                            query = new StringBundler(4);
2991                    }
2992    
2993                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
2994    
2995                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
2996    
2997                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
2998    
2999                    if (orderByComparator != null) {
3000                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3001                                    orderByComparator);
3002                    }
3003                    else {
3004                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
3005                    }
3006    
3007                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3008                                    BookmarksEntry.class.getName(),
3009                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
3010                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
3011    
3012                    Session session = null;
3013    
3014                    try {
3015                            session = openSession();
3016    
3017                            Query q = session.createQuery(sql);
3018    
3019                            QueryPos qPos = QueryPos.getInstance(q);
3020    
3021                            qPos.add(groupId);
3022    
3023                            qPos.add(folderId);
3024    
3025                            return (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start,
3026                                    end);
3027                    }
3028                    catch (Exception e) {
3029                            throw processException(e);
3030                    }
3031                    finally {
3032                            closeSession(session);
3033                    }
3034            }
3035    
3036            /**
3037             * 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;.
3038             *
3039             * @param entryId the primary key of the current bookmarks entry
3040             * @param groupId the group ID
3041             * @param folderId the folder ID
3042             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3043             * @return the previous, current, and next bookmarks entry
3044             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
3045             * @throws SystemException if a system exception occurred
3046             */
3047            @Override
3048            public BookmarksEntry[] filterFindByG_F_PrevAndNext(long entryId,
3049                    long groupId, long folderId, OrderByComparator orderByComparator)
3050                    throws NoSuchEntryException, SystemException {
3051                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3052                            return findByG_F_PrevAndNext(entryId, groupId, folderId,
3053                                    orderByComparator);
3054                    }
3055    
3056                    BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
3057    
3058                    Session session = null;
3059    
3060                    try {
3061                            session = openSession();
3062    
3063                            BookmarksEntry[] array = new BookmarksEntryImpl[3];
3064    
3065                            array[0] = filterGetByG_F_PrevAndNext(session, bookmarksEntry,
3066                                            groupId, folderId, orderByComparator, true);
3067    
3068                            array[1] = bookmarksEntry;
3069    
3070                            array[2] = filterGetByG_F_PrevAndNext(session, bookmarksEntry,
3071                                            groupId, folderId, orderByComparator, false);
3072    
3073                            return array;
3074                    }
3075                    catch (Exception e) {
3076                            throw processException(e);
3077                    }
3078                    finally {
3079                            closeSession(session);
3080                    }
3081            }
3082    
3083            protected BookmarksEntry filterGetByG_F_PrevAndNext(Session session,
3084                    BookmarksEntry bookmarksEntry, long groupId, long folderId,
3085                    OrderByComparator orderByComparator, boolean previous) {
3086                    StringBundler query = null;
3087    
3088                    if (orderByComparator != null) {
3089                            query = new StringBundler(6 +
3090                                            (orderByComparator.getOrderByFields().length * 6));
3091                    }
3092                    else {
3093                            query = new StringBundler(3);
3094                    }
3095    
3096                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
3097    
3098                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
3099    
3100                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
3101    
3102                    if (orderByComparator != null) {
3103                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3104    
3105                            if (orderByConditionFields.length > 0) {
3106                                    query.append(WHERE_AND);
3107                            }
3108    
3109                            for (int i = 0; i < orderByConditionFields.length; i++) {
3110                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3111                                    query.append(orderByConditionFields[i]);
3112    
3113                                    if ((i + 1) < orderByConditionFields.length) {
3114                                            if (orderByComparator.isAscending() ^ previous) {
3115                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3116                                            }
3117                                            else {
3118                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3119                                            }
3120                                    }
3121                                    else {
3122                                            if (orderByComparator.isAscending() ^ previous) {
3123                                                    query.append(WHERE_GREATER_THAN);
3124                                            }
3125                                            else {
3126                                                    query.append(WHERE_LESSER_THAN);
3127                                            }
3128                                    }
3129                            }
3130    
3131                            query.append(ORDER_BY_CLAUSE);
3132    
3133                            String[] orderByFields = orderByComparator.getOrderByFields();
3134    
3135                            for (int i = 0; i < orderByFields.length; i++) {
3136                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3137                                    query.append(orderByFields[i]);
3138    
3139                                    if ((i + 1) < orderByFields.length) {
3140                                            if (orderByComparator.isAscending() ^ previous) {
3141                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3142                                            }
3143                                            else {
3144                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3145                                            }
3146                                    }
3147                                    else {
3148                                            if (orderByComparator.isAscending() ^ previous) {
3149                                                    query.append(ORDER_BY_ASC);
3150                                            }
3151                                            else {
3152                                                    query.append(ORDER_BY_DESC);
3153                                            }
3154                                    }
3155                            }
3156                    }
3157                    else {
3158                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
3159                    }
3160    
3161                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3162                                    BookmarksEntry.class.getName(),
3163                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
3164                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
3165    
3166                    Query q = session.createQuery(sql);
3167    
3168                    q.setFirstResult(0);
3169                    q.setMaxResults(2);
3170    
3171                    QueryPos qPos = QueryPos.getInstance(q);
3172    
3173                    qPos.add(groupId);
3174    
3175                    qPos.add(folderId);
3176    
3177                    if (orderByComparator != null) {
3178                            Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry);
3179    
3180                            for (Object value : values) {
3181                                    qPos.add(value);
3182                            }
3183                    }
3184    
3185                    List<BookmarksEntry> list = q.list();
3186    
3187                    if (list.size() == 2) {
3188                            return list.get(1);
3189                    }
3190                    else {
3191                            return null;
3192                    }
3193            }
3194    
3195            /**
3196             * Returns all the bookmarks entries that the user has permission to view where groupId = &#63; and folderId = any &#63;.
3197             *
3198             * @param groupId the group ID
3199             * @param folderIds the folder IDs
3200             * @return the matching bookmarks entries that the user has permission to view
3201             * @throws SystemException if a system exception occurred
3202             */
3203            @Override
3204            public List<BookmarksEntry> filterFindByG_F(long groupId, long[] folderIds)
3205                    throws SystemException {
3206                    return filterFindByG_F(groupId, folderIds, QueryUtil.ALL_POS,
3207                            QueryUtil.ALL_POS, null);
3208            }
3209    
3210            /**
3211             * Returns a range of all the bookmarks entries that the user has permission to view where groupId = &#63; and folderId = any &#63;.
3212             *
3213             * <p>
3214             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
3215             * </p>
3216             *
3217             * @param groupId the group ID
3218             * @param folderIds the folder IDs
3219             * @param start the lower bound of the range of bookmarks entries
3220             * @param end the upper bound of the range of bookmarks entries (not inclusive)
3221             * @return the range of matching bookmarks entries that the user has permission to view
3222             * @throws SystemException if a system exception occurred
3223             */
3224            @Override
3225            public List<BookmarksEntry> filterFindByG_F(long groupId, long[] folderIds,
3226                    int start, int end) throws SystemException {
3227                    return filterFindByG_F(groupId, folderIds, start, end, null);
3228            }
3229    
3230            /**
3231             * Returns an ordered range of all the bookmarks entries that the user has permission to view where groupId = &#63; and folderId = any &#63;.
3232             *
3233             * <p>
3234             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
3235             * </p>
3236             *
3237             * @param groupId the group ID
3238             * @param folderIds the folder IDs
3239             * @param start the lower bound of the range of bookmarks entries
3240             * @param end the upper bound of the range of bookmarks entries (not inclusive)
3241             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3242             * @return the ordered range of matching bookmarks entries that the user has permission to view
3243             * @throws SystemException if a system exception occurred
3244             */
3245            @Override
3246            public List<BookmarksEntry> filterFindByG_F(long groupId, long[] folderIds,
3247                    int start, int end, OrderByComparator orderByComparator)
3248                    throws SystemException {
3249                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3250                            return findByG_F(groupId, folderIds, start, end, orderByComparator);
3251                    }
3252    
3253                    StringBundler query = new StringBundler();
3254    
3255                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
3256    
3257                    boolean conjunctionable = false;
3258    
3259                    if (conjunctionable) {
3260                            query.append(WHERE_AND);
3261                    }
3262    
3263                    query.append(_FINDER_COLUMN_G_F_GROUPID_5);
3264    
3265                    conjunctionable = true;
3266    
3267                    if ((folderIds == null) || (folderIds.length > 0)) {
3268                            if (conjunctionable) {
3269                                    query.append(WHERE_AND);
3270                            }
3271    
3272                            query.append(StringPool.OPEN_PARENTHESIS);
3273    
3274                            for (int i = 0; i < folderIds.length; i++) {
3275                                    query.append(_FINDER_COLUMN_G_F_FOLDERID_5);
3276    
3277                                    if ((i + 1) < folderIds.length) {
3278                                            query.append(WHERE_OR);
3279                                    }
3280                            }
3281    
3282                            query.append(StringPool.CLOSE_PARENTHESIS);
3283    
3284                            conjunctionable = true;
3285                    }
3286    
3287                    if (orderByComparator != null) {
3288                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3289                                    orderByComparator);
3290                    }
3291                    else {
3292                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
3293                    }
3294    
3295                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3296                                    BookmarksEntry.class.getName(),
3297                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
3298                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
3299    
3300                    Session session = null;
3301    
3302                    try {
3303                            session = openSession();
3304    
3305                            Query q = session.createQuery(sql);
3306    
3307                            QueryPos qPos = QueryPos.getInstance(q);
3308    
3309                            qPos.add(groupId);
3310    
3311                            if (folderIds != null) {
3312                                    qPos.add(folderIds);
3313                            }
3314    
3315                            return (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start,
3316                                    end);
3317                    }
3318                    catch (Exception e) {
3319                            throw processException(e);
3320                    }
3321                    finally {
3322                            closeSession(session);
3323                    }
3324            }
3325    
3326            /**
3327             * Returns all the bookmarks entries where groupId = &#63; and folderId = any &#63;.
3328             *
3329             * <p>
3330             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
3331             * </p>
3332             *
3333             * @param groupId the group ID
3334             * @param folderIds the folder IDs
3335             * @return the matching bookmarks entries
3336             * @throws SystemException if a system exception occurred
3337             */
3338            @Override
3339            public List<BookmarksEntry> findByG_F(long groupId, long[] folderIds)
3340                    throws SystemException {
3341                    return findByG_F(groupId, folderIds, QueryUtil.ALL_POS,
3342                            QueryUtil.ALL_POS, null);
3343            }
3344    
3345            /**
3346             * Returns a range of all the bookmarks entries where groupId = &#63; and folderId = any &#63;.
3347             *
3348             * <p>
3349             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
3350             * </p>
3351             *
3352             * @param groupId the group ID
3353             * @param folderIds the folder IDs
3354             * @param start the lower bound of the range of bookmarks entries
3355             * @param end the upper bound of the range of bookmarks entries (not inclusive)
3356             * @return the range of matching bookmarks entries
3357             * @throws SystemException if a system exception occurred
3358             */
3359            @Override
3360            public List<BookmarksEntry> findByG_F(long groupId, long[] folderIds,
3361                    int start, int end) throws SystemException {
3362                    return findByG_F(groupId, folderIds, start, end, null);
3363            }
3364    
3365            /**
3366             * Returns an ordered range of all the bookmarks entries where groupId = &#63; and folderId = any &#63;.
3367             *
3368             * <p>
3369             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
3370             * </p>
3371             *
3372             * @param groupId the group ID
3373             * @param folderIds the folder IDs
3374             * @param start the lower bound of the range of bookmarks entries
3375             * @param end the upper bound of the range of bookmarks entries (not inclusive)
3376             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3377             * @return the ordered range of matching bookmarks entries
3378             * @throws SystemException if a system exception occurred
3379             */
3380            @Override
3381            public List<BookmarksEntry> findByG_F(long groupId, long[] folderIds,
3382                    int start, int end, OrderByComparator orderByComparator)
3383                    throws SystemException {
3384                    if ((folderIds != null) && (folderIds.length == 1)) {
3385                            return findByG_F(groupId, folderIds[0], start, end,
3386                                    orderByComparator);
3387                    }
3388    
3389                    boolean pagination = true;
3390                    Object[] finderArgs = null;
3391    
3392                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3393                                    (orderByComparator == null)) {
3394                            pagination = false;
3395                            finderArgs = new Object[] { groupId, StringUtil.merge(folderIds) };
3396                    }
3397                    else {
3398                            finderArgs = new Object[] {
3399                                            groupId, StringUtil.merge(folderIds),
3400                                            
3401                                            start, end, orderByComparator
3402                                    };
3403                    }
3404    
3405                    List<BookmarksEntry> list = (List<BookmarksEntry>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F,
3406                                    finderArgs, this);
3407    
3408                    if ((list != null) && !list.isEmpty()) {
3409                            for (BookmarksEntry bookmarksEntry : list) {
3410                                    if ((groupId != bookmarksEntry.getGroupId()) ||
3411                                                    !ArrayUtil.contains(folderIds,
3412                                                            bookmarksEntry.getFolderId())) {
3413                                            list = null;
3414    
3415                                            break;
3416                                    }
3417                            }
3418                    }
3419    
3420                    if (list == null) {
3421                            StringBundler query = new StringBundler();
3422    
3423                            query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
3424    
3425                            boolean conjunctionable = false;
3426    
3427                            if (conjunctionable) {
3428                                    query.append(WHERE_AND);
3429                            }
3430    
3431                            query.append(_FINDER_COLUMN_G_F_GROUPID_5);
3432    
3433                            conjunctionable = true;
3434    
3435                            if ((folderIds == null) || (folderIds.length > 0)) {
3436                                    if (conjunctionable) {
3437                                            query.append(WHERE_AND);
3438                                    }
3439    
3440                                    query.append(StringPool.OPEN_PARENTHESIS);
3441    
3442                                    for (int i = 0; i < folderIds.length; i++) {
3443                                            query.append(_FINDER_COLUMN_G_F_FOLDERID_5);
3444    
3445                                            if ((i + 1) < folderIds.length) {
3446                                                    query.append(WHERE_OR);
3447                                            }
3448                                    }
3449    
3450                                    query.append(StringPool.CLOSE_PARENTHESIS);
3451    
3452                                    conjunctionable = true;
3453                            }
3454    
3455                            if (orderByComparator != null) {
3456                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3457                                            orderByComparator);
3458                            }
3459                            else
3460                             if (pagination) {
3461                                    query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
3462                            }
3463    
3464                            String sql = query.toString();
3465    
3466                            Session session = null;
3467    
3468                            try {
3469                                    session = openSession();
3470    
3471                                    Query q = session.createQuery(sql);
3472    
3473                                    QueryPos qPos = QueryPos.getInstance(q);
3474    
3475                                    qPos.add(groupId);
3476    
3477                                    if (folderIds != null) {
3478                                            qPos.add(folderIds);
3479                                    }
3480    
3481                                    if (!pagination) {
3482                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
3483                                                            getDialect(), start, end, false);
3484    
3485                                            Collections.sort(list);
3486    
3487                                            list = new UnmodifiableList<BookmarksEntry>(list);
3488                                    }
3489                                    else {
3490                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
3491                                                            getDialect(), start, end);
3492                                    }
3493    
3494                                    cacheResult(list);
3495    
3496                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F,
3497                                            finderArgs, list);
3498                            }
3499                            catch (Exception e) {
3500                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F,
3501                                            finderArgs);
3502    
3503                                    throw processException(e);
3504                            }
3505                            finally {
3506                                    closeSession(session);
3507                            }
3508                    }
3509    
3510                    return list;
3511            }
3512    
3513            /**
3514             * Removes all the bookmarks entries where groupId = &#63; and folderId = &#63; from the database.
3515             *
3516             * @param groupId the group ID
3517             * @param folderId the folder ID
3518             * @throws SystemException if a system exception occurred
3519             */
3520            @Override
3521            public void removeByG_F(long groupId, long folderId)
3522                    throws SystemException {
3523                    for (BookmarksEntry bookmarksEntry : findByG_F(groupId, folderId,
3524                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3525                            remove(bookmarksEntry);
3526                    }
3527            }
3528    
3529            /**
3530             * Returns the number of bookmarks entries where groupId = &#63; and folderId = &#63;.
3531             *
3532             * @param groupId the group ID
3533             * @param folderId the folder ID
3534             * @return the number of matching bookmarks entries
3535             * @throws SystemException if a system exception occurred
3536             */
3537            @Override
3538            public int countByG_F(long groupId, long folderId)
3539                    throws SystemException {
3540                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_F;
3541    
3542                    Object[] finderArgs = new Object[] { groupId, folderId };
3543    
3544                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3545                                    this);
3546    
3547                    if (count == null) {
3548                            StringBundler query = new StringBundler(3);
3549    
3550                            query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
3551    
3552                            query.append(_FINDER_COLUMN_G_F_GROUPID_2);
3553    
3554                            query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
3555    
3556                            String sql = query.toString();
3557    
3558                            Session session = null;
3559    
3560                            try {
3561                                    session = openSession();
3562    
3563                                    Query q = session.createQuery(sql);
3564    
3565                                    QueryPos qPos = QueryPos.getInstance(q);
3566    
3567                                    qPos.add(groupId);
3568    
3569                                    qPos.add(folderId);
3570    
3571                                    count = (Long)q.uniqueResult();
3572    
3573                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
3574                            }
3575                            catch (Exception e) {
3576                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3577    
3578                                    throw processException(e);
3579                            }
3580                            finally {
3581                                    closeSession(session);
3582                            }
3583                    }
3584    
3585                    return count.intValue();
3586            }
3587    
3588            /**
3589             * Returns the number of bookmarks entries where groupId = &#63; and folderId = any &#63;.
3590             *
3591             * @param groupId the group ID
3592             * @param folderIds the folder IDs
3593             * @return the number of matching bookmarks entries
3594             * @throws SystemException if a system exception occurred
3595             */
3596            @Override
3597            public int countByG_F(long groupId, long[] folderIds)
3598                    throws SystemException {
3599                    Object[] finderArgs = new Object[] { groupId, StringUtil.merge(folderIds) };
3600    
3601                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F,
3602                                    finderArgs, this);
3603    
3604                    if (count == null) {
3605                            StringBundler query = new StringBundler();
3606    
3607                            query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
3608    
3609                            boolean conjunctionable = false;
3610    
3611                            if (conjunctionable) {
3612                                    query.append(WHERE_AND);
3613                            }
3614    
3615                            query.append(_FINDER_COLUMN_G_F_GROUPID_5);
3616    
3617                            conjunctionable = true;
3618    
3619                            if ((folderIds == null) || (folderIds.length > 0)) {
3620                                    if (conjunctionable) {
3621                                            query.append(WHERE_AND);
3622                                    }
3623    
3624                                    query.append(StringPool.OPEN_PARENTHESIS);
3625    
3626                                    for (int i = 0; i < folderIds.length; i++) {
3627                                            query.append(_FINDER_COLUMN_G_F_FOLDERID_5);
3628    
3629                                            if ((i + 1) < folderIds.length) {
3630                                                    query.append(WHERE_OR);
3631                                            }
3632                                    }
3633    
3634                                    query.append(StringPool.CLOSE_PARENTHESIS);
3635    
3636                                    conjunctionable = true;
3637                            }
3638    
3639                            String sql = query.toString();
3640    
3641                            Session session = null;
3642    
3643                            try {
3644                                    session = openSession();
3645    
3646                                    Query q = session.createQuery(sql);
3647    
3648                                    QueryPos qPos = QueryPos.getInstance(q);
3649    
3650                                    qPos.add(groupId);
3651    
3652                                    if (folderIds != null) {
3653                                            qPos.add(folderIds);
3654                                    }
3655    
3656                                    count = (Long)q.uniqueResult();
3657    
3658                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F,
3659                                            finderArgs, count);
3660                            }
3661                            catch (Exception e) {
3662                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F,
3663                                            finderArgs);
3664    
3665                                    throw processException(e);
3666                            }
3667                            finally {
3668                                    closeSession(session);
3669                            }
3670                    }
3671    
3672                    return count.intValue();
3673            }
3674    
3675            /**
3676             * Returns the number of bookmarks entries that the user has permission to view where groupId = &#63; and folderId = &#63;.
3677             *
3678             * @param groupId the group ID
3679             * @param folderId the folder ID
3680             * @return the number of matching bookmarks entries that the user has permission to view
3681             * @throws SystemException if a system exception occurred
3682             */
3683            @Override
3684            public int filterCountByG_F(long groupId, long folderId)
3685                    throws SystemException {
3686                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3687                            return countByG_F(groupId, folderId);
3688                    }
3689    
3690                    StringBundler query = new StringBundler(3);
3691    
3692                    query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
3693    
3694                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
3695    
3696                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
3697    
3698                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3699                                    BookmarksEntry.class.getName(),
3700                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
3701                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
3702    
3703                    Session session = null;
3704    
3705                    try {
3706                            session = openSession();
3707    
3708                            Query q = session.createQuery(sql);
3709    
3710                            QueryPos qPos = QueryPos.getInstance(q);
3711    
3712                            qPos.add(groupId);
3713    
3714                            qPos.add(folderId);
3715    
3716                            Long count = (Long)q.uniqueResult();
3717    
3718                            return count.intValue();
3719                    }
3720                    catch (Exception e) {
3721                            throw processException(e);
3722                    }
3723                    finally {
3724                            closeSession(session);
3725                    }
3726            }
3727    
3728            /**
3729             * Returns the number of bookmarks entries that the user has permission to view where groupId = &#63; and folderId = any &#63;.
3730             *
3731             * @param groupId the group ID
3732             * @param folderIds the folder IDs
3733             * @return the number of matching bookmarks entries that the user has permission to view
3734             * @throws SystemException if a system exception occurred
3735             */
3736            @Override
3737            public int filterCountByG_F(long groupId, long[] folderIds)
3738                    throws SystemException {
3739                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3740                            return countByG_F(groupId, folderIds);
3741                    }
3742    
3743                    StringBundler query = new StringBundler();
3744    
3745                    query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
3746    
3747                    boolean conjunctionable = false;
3748    
3749                    if (conjunctionable) {
3750                            query.append(WHERE_AND);
3751                    }
3752    
3753                    query.append(_FINDER_COLUMN_G_F_GROUPID_5);
3754    
3755                    conjunctionable = true;
3756    
3757                    if ((folderIds == null) || (folderIds.length > 0)) {
3758                            if (conjunctionable) {
3759                                    query.append(WHERE_AND);
3760                            }
3761    
3762                            query.append(StringPool.OPEN_PARENTHESIS);
3763    
3764                            for (int i = 0; i < folderIds.length; i++) {
3765                                    query.append(_FINDER_COLUMN_G_F_FOLDERID_5);
3766    
3767                                    if ((i + 1) < folderIds.length) {
3768                                            query.append(WHERE_OR);
3769                                    }
3770                            }
3771    
3772                            query.append(StringPool.CLOSE_PARENTHESIS);
3773    
3774                            conjunctionable = true;
3775                    }
3776    
3777                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3778                                    BookmarksEntry.class.getName(),
3779                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
3780                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
3781    
3782                    Session session = null;
3783    
3784                    try {
3785                            session = openSession();
3786    
3787                            Query q = session.createQuery(sql);
3788    
3789                            QueryPos qPos = QueryPos.getInstance(q);
3790    
3791                            qPos.add(groupId);
3792    
3793                            if (folderIds != null) {
3794                                    qPos.add(folderIds);
3795                            }
3796    
3797                            Long count = (Long)q.uniqueResult();
3798    
3799                            return count.intValue();
3800                    }
3801                    catch (Exception e) {
3802                            throw processException(e);
3803                    }
3804                    finally {
3805                            closeSession(session);
3806                    }
3807            }
3808    
3809            private static final String _FINDER_COLUMN_G_F_GROUPID_2 = "bookmarksEntry.groupId = ? AND ";
3810            private static final String _FINDER_COLUMN_G_F_GROUPID_5 = "(" +
3811                    removeConjunction(_FINDER_COLUMN_G_F_GROUPID_2) + ")";
3812            private static final String _FINDER_COLUMN_G_F_FOLDERID_2 = "bookmarksEntry.folderId = ?";
3813            private static final String _FINDER_COLUMN_G_F_FOLDERID_5 = "(" +
3814                    removeConjunction(_FINDER_COLUMN_G_F_FOLDERID_2) + ")";
3815            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
3816                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
3817                            BookmarksEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
3818                            "findByG_S",
3819                            new String[] {
3820                                    Long.class.getName(), Integer.class.getName(),
3821                                    
3822                            Integer.class.getName(), Integer.class.getName(),
3823                                    OrderByComparator.class.getName()
3824                            });
3825            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
3826                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
3827                            BookmarksEntryImpl.class,
3828                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_S",
3829                            new String[] { Long.class.getName(), Integer.class.getName() },
3830                            BookmarksEntryModelImpl.GROUPID_COLUMN_BITMASK |
3831                            BookmarksEntryModelImpl.STATUS_COLUMN_BITMASK |
3832                            BookmarksEntryModelImpl.FOLDERID_COLUMN_BITMASK |
3833                            BookmarksEntryModelImpl.NAME_COLUMN_BITMASK);
3834            public static final FinderPath FINDER_PATH_COUNT_BY_G_S = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
3835                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
3836                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_S",
3837                            new String[] { Long.class.getName(), Integer.class.getName() });
3838    
3839            /**
3840             * Returns all the bookmarks entries where groupId = &#63; and status = &#63;.
3841             *
3842             * @param groupId the group ID
3843             * @param status the status
3844             * @return the matching bookmarks entries
3845             * @throws SystemException if a system exception occurred
3846             */
3847            @Override
3848            public List<BookmarksEntry> findByG_S(long groupId, int status)
3849                    throws SystemException {
3850                    return findByG_S(groupId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
3851                            null);
3852            }
3853    
3854            /**
3855             * Returns a range of all the bookmarks entries where groupId = &#63; and status = &#63;.
3856             *
3857             * <p>
3858             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
3859             * </p>
3860             *
3861             * @param groupId the group ID
3862             * @param status the status
3863             * @param start the lower bound of the range of bookmarks entries
3864             * @param end the upper bound of the range of bookmarks entries (not inclusive)
3865             * @return the range of matching bookmarks entries
3866             * @throws SystemException if a system exception occurred
3867             */
3868            @Override
3869            public List<BookmarksEntry> findByG_S(long groupId, int status, int start,
3870                    int end) throws SystemException {
3871                    return findByG_S(groupId, status, start, end, null);
3872            }
3873    
3874            /**
3875             * Returns an ordered range of all the bookmarks entries where groupId = &#63; and status = &#63;.
3876             *
3877             * <p>
3878             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
3879             * </p>
3880             *
3881             * @param groupId the group ID
3882             * @param status the status
3883             * @param start the lower bound of the range of bookmarks entries
3884             * @param end the upper bound of the range of bookmarks entries (not inclusive)
3885             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3886             * @return the ordered range of matching bookmarks entries
3887             * @throws SystemException if a system exception occurred
3888             */
3889            @Override
3890            public List<BookmarksEntry> findByG_S(long groupId, int status, int start,
3891                    int end, OrderByComparator orderByComparator) throws SystemException {
3892                    boolean pagination = true;
3893                    FinderPath finderPath = null;
3894                    Object[] finderArgs = null;
3895    
3896                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3897                                    (orderByComparator == null)) {
3898                            pagination = false;
3899                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S;
3900                            finderArgs = new Object[] { groupId, status };
3901                    }
3902                    else {
3903                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S;
3904                            finderArgs = new Object[] {
3905                                            groupId, status,
3906                                            
3907                                            start, end, orderByComparator
3908                                    };
3909                    }
3910    
3911                    List<BookmarksEntry> list = (List<BookmarksEntry>)FinderCacheUtil.getResult(finderPath,
3912                                    finderArgs, this);
3913    
3914                    if ((list != null) && !list.isEmpty()) {
3915                            for (BookmarksEntry bookmarksEntry : list) {
3916                                    if ((groupId != bookmarksEntry.getGroupId()) ||
3917                                                    (status != bookmarksEntry.getStatus())) {
3918                                            list = null;
3919    
3920                                            break;
3921                                    }
3922                            }
3923                    }
3924    
3925                    if (list == null) {
3926                            StringBundler query = null;
3927    
3928                            if (orderByComparator != null) {
3929                                    query = new StringBundler(4 +
3930                                                    (orderByComparator.getOrderByFields().length * 3));
3931                            }
3932                            else {
3933                                    query = new StringBundler(4);
3934                            }
3935    
3936                            query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
3937    
3938                            query.append(_FINDER_COLUMN_G_S_GROUPID_2);
3939    
3940                            query.append(_FINDER_COLUMN_G_S_STATUS_2);
3941    
3942                            if (orderByComparator != null) {
3943                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3944                                            orderByComparator);
3945                            }
3946                            else
3947                             if (pagination) {
3948                                    query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
3949                            }
3950    
3951                            String sql = query.toString();
3952    
3953                            Session session = null;
3954    
3955                            try {
3956                                    session = openSession();
3957    
3958                                    Query q = session.createQuery(sql);
3959    
3960                                    QueryPos qPos = QueryPos.getInstance(q);
3961    
3962                                    qPos.add(groupId);
3963    
3964                                    qPos.add(status);
3965    
3966                                    if (!pagination) {
3967                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
3968                                                            getDialect(), start, end, false);
3969    
3970                                            Collections.sort(list);
3971    
3972                                            list = new UnmodifiableList<BookmarksEntry>(list);
3973                                    }
3974                                    else {
3975                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
3976                                                            getDialect(), start, end);
3977                                    }
3978    
3979                                    cacheResult(list);
3980    
3981                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
3982                            }
3983                            catch (Exception e) {
3984                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3985    
3986                                    throw processException(e);
3987                            }
3988                            finally {
3989                                    closeSession(session);
3990                            }
3991                    }
3992    
3993                    return list;
3994            }
3995    
3996            /**
3997             * Returns the first bookmarks entry in the ordered set where groupId = &#63; and status = &#63;.
3998             *
3999             * @param groupId the group ID
4000             * @param status the status
4001             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4002             * @return the first matching bookmarks entry
4003             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
4004             * @throws SystemException if a system exception occurred
4005             */
4006            @Override
4007            public BookmarksEntry findByG_S_First(long groupId, int status,
4008                    OrderByComparator orderByComparator)
4009                    throws NoSuchEntryException, SystemException {
4010                    BookmarksEntry bookmarksEntry = fetchByG_S_First(groupId, status,
4011                                    orderByComparator);
4012    
4013                    if (bookmarksEntry != null) {
4014                            return bookmarksEntry;
4015                    }
4016    
4017                    StringBundler msg = new StringBundler(6);
4018    
4019                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4020    
4021                    msg.append("groupId=");
4022                    msg.append(groupId);
4023    
4024                    msg.append(", status=");
4025                    msg.append(status);
4026    
4027                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4028    
4029                    throw new NoSuchEntryException(msg.toString());
4030            }
4031    
4032            /**
4033             * Returns the first bookmarks entry in the ordered set where groupId = &#63; and status = &#63;.
4034             *
4035             * @param groupId the group ID
4036             * @param status the status
4037             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4038             * @return the first matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
4039             * @throws SystemException if a system exception occurred
4040             */
4041            @Override
4042            public BookmarksEntry fetchByG_S_First(long groupId, int status,
4043                    OrderByComparator orderByComparator) throws SystemException {
4044                    List<BookmarksEntry> list = findByG_S(groupId, status, 0, 1,
4045                                    orderByComparator);
4046    
4047                    if (!list.isEmpty()) {
4048                            return list.get(0);
4049                    }
4050    
4051                    return null;
4052            }
4053    
4054            /**
4055             * Returns the last bookmarks entry in the ordered set where groupId = &#63; and status = &#63;.
4056             *
4057             * @param groupId the group ID
4058             * @param status the status
4059             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4060             * @return the last matching bookmarks entry
4061             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
4062             * @throws SystemException if a system exception occurred
4063             */
4064            @Override
4065            public BookmarksEntry findByG_S_Last(long groupId, int status,
4066                    OrderByComparator orderByComparator)
4067                    throws NoSuchEntryException, SystemException {
4068                    BookmarksEntry bookmarksEntry = fetchByG_S_Last(groupId, status,
4069                                    orderByComparator);
4070    
4071                    if (bookmarksEntry != null) {
4072                            return bookmarksEntry;
4073                    }
4074    
4075                    StringBundler msg = new StringBundler(6);
4076    
4077                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4078    
4079                    msg.append("groupId=");
4080                    msg.append(groupId);
4081    
4082                    msg.append(", status=");
4083                    msg.append(status);
4084    
4085                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4086    
4087                    throw new NoSuchEntryException(msg.toString());
4088            }
4089    
4090            /**
4091             * Returns the last bookmarks entry in the ordered set where groupId = &#63; and status = &#63;.
4092             *
4093             * @param groupId the group ID
4094             * @param status the status
4095             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4096             * @return the last matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
4097             * @throws SystemException if a system exception occurred
4098             */
4099            @Override
4100            public BookmarksEntry fetchByG_S_Last(long groupId, int status,
4101                    OrderByComparator orderByComparator) throws SystemException {
4102                    int count = countByG_S(groupId, status);
4103    
4104                    if (count == 0) {
4105                            return null;
4106                    }
4107    
4108                    List<BookmarksEntry> list = findByG_S(groupId, status, count - 1,
4109                                    count, orderByComparator);
4110    
4111                    if (!list.isEmpty()) {
4112                            return list.get(0);
4113                    }
4114    
4115                    return null;
4116            }
4117    
4118            /**
4119             * Returns the bookmarks entries before and after the current bookmarks entry in the ordered set where groupId = &#63; and status = &#63;.
4120             *
4121             * @param entryId the primary key of the current bookmarks entry
4122             * @param groupId the group ID
4123             * @param status the status
4124             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4125             * @return the previous, current, and next bookmarks entry
4126             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
4127             * @throws SystemException if a system exception occurred
4128             */
4129            @Override
4130            public BookmarksEntry[] findByG_S_PrevAndNext(long entryId, long groupId,
4131                    int status, OrderByComparator orderByComparator)
4132                    throws NoSuchEntryException, SystemException {
4133                    BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
4134    
4135                    Session session = null;
4136    
4137                    try {
4138                            session = openSession();
4139    
4140                            BookmarksEntry[] array = new BookmarksEntryImpl[3];
4141    
4142                            array[0] = getByG_S_PrevAndNext(session, bookmarksEntry, groupId,
4143                                            status, orderByComparator, true);
4144    
4145                            array[1] = bookmarksEntry;
4146    
4147                            array[2] = getByG_S_PrevAndNext(session, bookmarksEntry, groupId,
4148                                            status, orderByComparator, false);
4149    
4150                            return array;
4151                    }
4152                    catch (Exception e) {
4153                            throw processException(e);
4154                    }
4155                    finally {
4156                            closeSession(session);
4157                    }
4158            }
4159    
4160            protected BookmarksEntry getByG_S_PrevAndNext(Session session,
4161                    BookmarksEntry bookmarksEntry, long groupId, int status,
4162                    OrderByComparator orderByComparator, boolean previous) {
4163                    StringBundler query = null;
4164    
4165                    if (orderByComparator != null) {
4166                            query = new StringBundler(6 +
4167                                            (orderByComparator.getOrderByFields().length * 6));
4168                    }
4169                    else {
4170                            query = new StringBundler(3);
4171                    }
4172    
4173                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
4174    
4175                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4176    
4177                    query.append(_FINDER_COLUMN_G_S_STATUS_2);
4178    
4179                    if (orderByComparator != null) {
4180                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4181    
4182                            if (orderByConditionFields.length > 0) {
4183                                    query.append(WHERE_AND);
4184                            }
4185    
4186                            for (int i = 0; i < orderByConditionFields.length; i++) {
4187                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4188                                    query.append(orderByConditionFields[i]);
4189    
4190                                    if ((i + 1) < orderByConditionFields.length) {
4191                                            if (orderByComparator.isAscending() ^ previous) {
4192                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4193                                            }
4194                                            else {
4195                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4196                                            }
4197                                    }
4198                                    else {
4199                                            if (orderByComparator.isAscending() ^ previous) {
4200                                                    query.append(WHERE_GREATER_THAN);
4201                                            }
4202                                            else {
4203                                                    query.append(WHERE_LESSER_THAN);
4204                                            }
4205                                    }
4206                            }
4207    
4208                            query.append(ORDER_BY_CLAUSE);
4209    
4210                            String[] orderByFields = orderByComparator.getOrderByFields();
4211    
4212                            for (int i = 0; i < orderByFields.length; i++) {
4213                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4214                                    query.append(orderByFields[i]);
4215    
4216                                    if ((i + 1) < orderByFields.length) {
4217                                            if (orderByComparator.isAscending() ^ previous) {
4218                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4219                                            }
4220                                            else {
4221                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4222                                            }
4223                                    }
4224                                    else {
4225                                            if (orderByComparator.isAscending() ^ previous) {
4226                                                    query.append(ORDER_BY_ASC);
4227                                            }
4228                                            else {
4229                                                    query.append(ORDER_BY_DESC);
4230                                            }
4231                                    }
4232                            }
4233                    }
4234                    else {
4235                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
4236                    }
4237    
4238                    String sql = query.toString();
4239    
4240                    Query q = session.createQuery(sql);
4241    
4242                    q.setFirstResult(0);
4243                    q.setMaxResults(2);
4244    
4245                    QueryPos qPos = QueryPos.getInstance(q);
4246    
4247                    qPos.add(groupId);
4248    
4249                    qPos.add(status);
4250    
4251                    if (orderByComparator != null) {
4252                            Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry);
4253    
4254                            for (Object value : values) {
4255                                    qPos.add(value);
4256                            }
4257                    }
4258    
4259                    List<BookmarksEntry> list = q.list();
4260    
4261                    if (list.size() == 2) {
4262                            return list.get(1);
4263                    }
4264                    else {
4265                            return null;
4266                    }
4267            }
4268    
4269            /**
4270             * Returns all the bookmarks entries that the user has permission to view where groupId = &#63; and status = &#63;.
4271             *
4272             * @param groupId the group ID
4273             * @param status the status
4274             * @return the matching bookmarks entries that the user has permission to view
4275             * @throws SystemException if a system exception occurred
4276             */
4277            @Override
4278            public List<BookmarksEntry> filterFindByG_S(long groupId, int status)
4279                    throws SystemException {
4280                    return filterFindByG_S(groupId, status, QueryUtil.ALL_POS,
4281                            QueryUtil.ALL_POS, null);
4282            }
4283    
4284            /**
4285             * Returns a range of all the bookmarks entries that the user has permission to view where groupId = &#63; and status = &#63;.
4286             *
4287             * <p>
4288             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
4289             * </p>
4290             *
4291             * @param groupId the group ID
4292             * @param status the status
4293             * @param start the lower bound of the range of bookmarks entries
4294             * @param end the upper bound of the range of bookmarks entries (not inclusive)
4295             * @return the range of matching bookmarks entries that the user has permission to view
4296             * @throws SystemException if a system exception occurred
4297             */
4298            @Override
4299            public List<BookmarksEntry> filterFindByG_S(long groupId, int status,
4300                    int start, int end) throws SystemException {
4301                    return filterFindByG_S(groupId, status, start, end, null);
4302            }
4303    
4304            /**
4305             * Returns an ordered range of all the bookmarks entries that the user has permissions to view where groupId = &#63; and status = &#63;.
4306             *
4307             * <p>
4308             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
4309             * </p>
4310             *
4311             * @param groupId the group ID
4312             * @param status the status
4313             * @param start the lower bound of the range of bookmarks entries
4314             * @param end the upper bound of the range of bookmarks entries (not inclusive)
4315             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4316             * @return the ordered range of matching bookmarks entries that the user has permission to view
4317             * @throws SystemException if a system exception occurred
4318             */
4319            @Override
4320            public List<BookmarksEntry> filterFindByG_S(long groupId, int status,
4321                    int start, int end, OrderByComparator orderByComparator)
4322                    throws SystemException {
4323                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4324                            return findByG_S(groupId, status, start, end, orderByComparator);
4325                    }
4326    
4327                    StringBundler query = null;
4328    
4329                    if (orderByComparator != null) {
4330                            query = new StringBundler(4 +
4331                                            (orderByComparator.getOrderByFields().length * 3));
4332                    }
4333                    else {
4334                            query = new StringBundler(4);
4335                    }
4336    
4337                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
4338    
4339                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4340    
4341                    query.append(_FINDER_COLUMN_G_S_STATUS_2);
4342    
4343                    if (orderByComparator != null) {
4344                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4345                                    orderByComparator);
4346                    }
4347                    else {
4348                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
4349                    }
4350    
4351                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4352                                    BookmarksEntry.class.getName(),
4353                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
4354                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
4355    
4356                    Session session = null;
4357    
4358                    try {
4359                            session = openSession();
4360    
4361                            Query q = session.createQuery(sql);
4362    
4363                            QueryPos qPos = QueryPos.getInstance(q);
4364    
4365                            qPos.add(groupId);
4366    
4367                            qPos.add(status);
4368    
4369                            return (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start,
4370                                    end);
4371                    }
4372                    catch (Exception e) {
4373                            throw processException(e);
4374                    }
4375                    finally {
4376                            closeSession(session);
4377                    }
4378            }
4379    
4380            /**
4381             * 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;.
4382             *
4383             * @param entryId the primary key of the current bookmarks entry
4384             * @param groupId the group ID
4385             * @param status the status
4386             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4387             * @return the previous, current, and next bookmarks entry
4388             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
4389             * @throws SystemException if a system exception occurred
4390             */
4391            @Override
4392            public BookmarksEntry[] filterFindByG_S_PrevAndNext(long entryId,
4393                    long groupId, int status, OrderByComparator orderByComparator)
4394                    throws NoSuchEntryException, SystemException {
4395                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4396                            return findByG_S_PrevAndNext(entryId, groupId, status,
4397                                    orderByComparator);
4398                    }
4399    
4400                    BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
4401    
4402                    Session session = null;
4403    
4404                    try {
4405                            session = openSession();
4406    
4407                            BookmarksEntry[] array = new BookmarksEntryImpl[3];
4408    
4409                            array[0] = filterGetByG_S_PrevAndNext(session, bookmarksEntry,
4410                                            groupId, status, orderByComparator, true);
4411    
4412                            array[1] = bookmarksEntry;
4413    
4414                            array[2] = filterGetByG_S_PrevAndNext(session, bookmarksEntry,
4415                                            groupId, status, orderByComparator, false);
4416    
4417                            return array;
4418                    }
4419                    catch (Exception e) {
4420                            throw processException(e);
4421                    }
4422                    finally {
4423                            closeSession(session);
4424                    }
4425            }
4426    
4427            protected BookmarksEntry filterGetByG_S_PrevAndNext(Session session,
4428                    BookmarksEntry bookmarksEntry, long groupId, int status,
4429                    OrderByComparator orderByComparator, boolean previous) {
4430                    StringBundler query = null;
4431    
4432                    if (orderByComparator != null) {
4433                            query = new StringBundler(6 +
4434                                            (orderByComparator.getOrderByFields().length * 6));
4435                    }
4436                    else {
4437                            query = new StringBundler(3);
4438                    }
4439    
4440                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
4441    
4442                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4443    
4444                    query.append(_FINDER_COLUMN_G_S_STATUS_2);
4445    
4446                    if (orderByComparator != null) {
4447                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4448    
4449                            if (orderByConditionFields.length > 0) {
4450                                    query.append(WHERE_AND);
4451                            }
4452    
4453                            for (int i = 0; i < orderByConditionFields.length; i++) {
4454                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4455                                    query.append(orderByConditionFields[i]);
4456    
4457                                    if ((i + 1) < orderByConditionFields.length) {
4458                                            if (orderByComparator.isAscending() ^ previous) {
4459                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4460                                            }
4461                                            else {
4462                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4463                                            }
4464                                    }
4465                                    else {
4466                                            if (orderByComparator.isAscending() ^ previous) {
4467                                                    query.append(WHERE_GREATER_THAN);
4468                                            }
4469                                            else {
4470                                                    query.append(WHERE_LESSER_THAN);
4471                                            }
4472                                    }
4473                            }
4474    
4475                            query.append(ORDER_BY_CLAUSE);
4476    
4477                            String[] orderByFields = orderByComparator.getOrderByFields();
4478    
4479                            for (int i = 0; i < orderByFields.length; i++) {
4480                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4481                                    query.append(orderByFields[i]);
4482    
4483                                    if ((i + 1) < orderByFields.length) {
4484                                            if (orderByComparator.isAscending() ^ previous) {
4485                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4486                                            }
4487                                            else {
4488                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4489                                            }
4490                                    }
4491                                    else {
4492                                            if (orderByComparator.isAscending() ^ previous) {
4493                                                    query.append(ORDER_BY_ASC);
4494                                            }
4495                                            else {
4496                                                    query.append(ORDER_BY_DESC);
4497                                            }
4498                                    }
4499                            }
4500                    }
4501                    else {
4502                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
4503                    }
4504    
4505                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4506                                    BookmarksEntry.class.getName(),
4507                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
4508                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
4509    
4510                    Query q = session.createQuery(sql);
4511    
4512                    q.setFirstResult(0);
4513                    q.setMaxResults(2);
4514    
4515                    QueryPos qPos = QueryPos.getInstance(q);
4516    
4517                    qPos.add(groupId);
4518    
4519                    qPos.add(status);
4520    
4521                    if (orderByComparator != null) {
4522                            Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry);
4523    
4524                            for (Object value : values) {
4525                                    qPos.add(value);
4526                            }
4527                    }
4528    
4529                    List<BookmarksEntry> list = q.list();
4530    
4531                    if (list.size() == 2) {
4532                            return list.get(1);
4533                    }
4534                    else {
4535                            return null;
4536                    }
4537            }
4538    
4539            /**
4540             * Removes all the bookmarks entries where groupId = &#63; and status = &#63; from the database.
4541             *
4542             * @param groupId the group ID
4543             * @param status the status
4544             * @throws SystemException if a system exception occurred
4545             */
4546            @Override
4547            public void removeByG_S(long groupId, int status) throws SystemException {
4548                    for (BookmarksEntry bookmarksEntry : findByG_S(groupId, status,
4549                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
4550                            remove(bookmarksEntry);
4551                    }
4552            }
4553    
4554            /**
4555             * Returns the number of bookmarks entries where groupId = &#63; and status = &#63;.
4556             *
4557             * @param groupId the group ID
4558             * @param status the status
4559             * @return the number of matching bookmarks entries
4560             * @throws SystemException if a system exception occurred
4561             */
4562            @Override
4563            public int countByG_S(long groupId, int status) throws SystemException {
4564                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_S;
4565    
4566                    Object[] finderArgs = new Object[] { groupId, status };
4567    
4568                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
4569                                    this);
4570    
4571                    if (count == null) {
4572                            StringBundler query = new StringBundler(3);
4573    
4574                            query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
4575    
4576                            query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4577    
4578                            query.append(_FINDER_COLUMN_G_S_STATUS_2);
4579    
4580                            String sql = query.toString();
4581    
4582                            Session session = null;
4583    
4584                            try {
4585                                    session = openSession();
4586    
4587                                    Query q = session.createQuery(sql);
4588    
4589                                    QueryPos qPos = QueryPos.getInstance(q);
4590    
4591                                    qPos.add(groupId);
4592    
4593                                    qPos.add(status);
4594    
4595                                    count = (Long)q.uniqueResult();
4596    
4597                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
4598                            }
4599                            catch (Exception e) {
4600                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4601    
4602                                    throw processException(e);
4603                            }
4604                            finally {
4605                                    closeSession(session);
4606                            }
4607                    }
4608    
4609                    return count.intValue();
4610            }
4611    
4612            /**
4613             * Returns the number of bookmarks entries that the user has permission to view where groupId = &#63; and status = &#63;.
4614             *
4615             * @param groupId the group ID
4616             * @param status the status
4617             * @return the number of matching bookmarks entries that the user has permission to view
4618             * @throws SystemException if a system exception occurred
4619             */
4620            @Override
4621            public int filterCountByG_S(long groupId, int status)
4622                    throws SystemException {
4623                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4624                            return countByG_S(groupId, status);
4625                    }
4626    
4627                    StringBundler query = new StringBundler(3);
4628    
4629                    query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
4630    
4631                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4632    
4633                    query.append(_FINDER_COLUMN_G_S_STATUS_2);
4634    
4635                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4636                                    BookmarksEntry.class.getName(),
4637                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
4638                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
4639    
4640                    Session session = null;
4641    
4642                    try {
4643                            session = openSession();
4644    
4645                            Query q = session.createQuery(sql);
4646    
4647                            QueryPos qPos = QueryPos.getInstance(q);
4648    
4649                            qPos.add(groupId);
4650    
4651                            qPos.add(status);
4652    
4653                            Long count = (Long)q.uniqueResult();
4654    
4655                            return count.intValue();
4656                    }
4657                    catch (Exception e) {
4658                            throw processException(e);
4659                    }
4660                    finally {
4661                            closeSession(session);
4662                    }
4663            }
4664    
4665            private static final String _FINDER_COLUMN_G_S_GROUPID_2 = "bookmarksEntry.groupId = ? AND ";
4666            private static final String _FINDER_COLUMN_G_S_STATUS_2 = "bookmarksEntry.status = ?";
4667            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_NOTS = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
4668                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
4669                            BookmarksEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
4670                            "findByG_NotS",
4671                            new String[] {
4672                                    Long.class.getName(), Integer.class.getName(),
4673                                    
4674                            Integer.class.getName(), Integer.class.getName(),
4675                                    OrderByComparator.class.getName()
4676                            });
4677            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_NOTS = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
4678                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
4679                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_NotS",
4680                            new String[] { Long.class.getName(), Integer.class.getName() });
4681    
4682            /**
4683             * Returns all the bookmarks entries where groupId = &#63; and status &ne; &#63;.
4684             *
4685             * @param groupId the group ID
4686             * @param status the status
4687             * @return the matching bookmarks entries
4688             * @throws SystemException if a system exception occurred
4689             */
4690            @Override
4691            public List<BookmarksEntry> findByG_NotS(long groupId, int status)
4692                    throws SystemException {
4693                    return findByG_NotS(groupId, status, QueryUtil.ALL_POS,
4694                            QueryUtil.ALL_POS, null);
4695            }
4696    
4697            /**
4698             * Returns a range of all the bookmarks entries where groupId = &#63; and status &ne; &#63;.
4699             *
4700             * <p>
4701             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
4702             * </p>
4703             *
4704             * @param groupId the group ID
4705             * @param status the status
4706             * @param start the lower bound of the range of bookmarks entries
4707             * @param end the upper bound of the range of bookmarks entries (not inclusive)
4708             * @return the range of matching bookmarks entries
4709             * @throws SystemException if a system exception occurred
4710             */
4711            @Override
4712            public List<BookmarksEntry> findByG_NotS(long groupId, int status,
4713                    int start, int end) throws SystemException {
4714                    return findByG_NotS(groupId, status, start, end, null);
4715            }
4716    
4717            /**
4718             * Returns an ordered range of all the bookmarks entries where groupId = &#63; and status &ne; &#63;.
4719             *
4720             * <p>
4721             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
4722             * </p>
4723             *
4724             * @param groupId the group ID
4725             * @param status the status
4726             * @param start the lower bound of the range of bookmarks entries
4727             * @param end the upper bound of the range of bookmarks entries (not inclusive)
4728             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4729             * @return the ordered range of matching bookmarks entries
4730             * @throws SystemException if a system exception occurred
4731             */
4732            @Override
4733            public List<BookmarksEntry> findByG_NotS(long groupId, int status,
4734                    int start, int end, OrderByComparator orderByComparator)
4735                    throws SystemException {
4736                    boolean pagination = true;
4737                    FinderPath finderPath = null;
4738                    Object[] finderArgs = null;
4739    
4740                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_NOTS;
4741                    finderArgs = new Object[] { groupId, status, start, end, orderByComparator };
4742    
4743                    List<BookmarksEntry> list = (List<BookmarksEntry>)FinderCacheUtil.getResult(finderPath,
4744                                    finderArgs, this);
4745    
4746                    if ((list != null) && !list.isEmpty()) {
4747                            for (BookmarksEntry bookmarksEntry : list) {
4748                                    if ((groupId != bookmarksEntry.getGroupId()) ||
4749                                                    (status != bookmarksEntry.getStatus())) {
4750                                            list = null;
4751    
4752                                            break;
4753                                    }
4754                            }
4755                    }
4756    
4757                    if (list == null) {
4758                            StringBundler query = null;
4759    
4760                            if (orderByComparator != null) {
4761                                    query = new StringBundler(4 +
4762                                                    (orderByComparator.getOrderByFields().length * 3));
4763                            }
4764                            else {
4765                                    query = new StringBundler(4);
4766                            }
4767    
4768                            query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
4769    
4770                            query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
4771    
4772                            query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
4773    
4774                            if (orderByComparator != null) {
4775                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4776                                            orderByComparator);
4777                            }
4778                            else
4779                             if (pagination) {
4780                                    query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
4781                            }
4782    
4783                            String sql = query.toString();
4784    
4785                            Session session = null;
4786    
4787                            try {
4788                                    session = openSession();
4789    
4790                                    Query q = session.createQuery(sql);
4791    
4792                                    QueryPos qPos = QueryPos.getInstance(q);
4793    
4794                                    qPos.add(groupId);
4795    
4796                                    qPos.add(status);
4797    
4798                                    if (!pagination) {
4799                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
4800                                                            getDialect(), start, end, false);
4801    
4802                                            Collections.sort(list);
4803    
4804                                            list = new UnmodifiableList<BookmarksEntry>(list);
4805                                    }
4806                                    else {
4807                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
4808                                                            getDialect(), start, end);
4809                                    }
4810    
4811                                    cacheResult(list);
4812    
4813                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
4814                            }
4815                            catch (Exception e) {
4816                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4817    
4818                                    throw processException(e);
4819                            }
4820                            finally {
4821                                    closeSession(session);
4822                            }
4823                    }
4824    
4825                    return list;
4826            }
4827    
4828            /**
4829             * Returns the first bookmarks entry in the ordered set where groupId = &#63; and status &ne; &#63;.
4830             *
4831             * @param groupId the group ID
4832             * @param status the status
4833             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4834             * @return the first matching bookmarks entry
4835             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
4836             * @throws SystemException if a system exception occurred
4837             */
4838            @Override
4839            public BookmarksEntry findByG_NotS_First(long groupId, int status,
4840                    OrderByComparator orderByComparator)
4841                    throws NoSuchEntryException, SystemException {
4842                    BookmarksEntry bookmarksEntry = fetchByG_NotS_First(groupId, status,
4843                                    orderByComparator);
4844    
4845                    if (bookmarksEntry != null) {
4846                            return bookmarksEntry;
4847                    }
4848    
4849                    StringBundler msg = new StringBundler(6);
4850    
4851                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4852    
4853                    msg.append("groupId=");
4854                    msg.append(groupId);
4855    
4856                    msg.append(", status=");
4857                    msg.append(status);
4858    
4859                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4860    
4861                    throw new NoSuchEntryException(msg.toString());
4862            }
4863    
4864            /**
4865             * Returns the first bookmarks entry in the ordered set where groupId = &#63; and status &ne; &#63;.
4866             *
4867             * @param groupId the group ID
4868             * @param status the status
4869             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4870             * @return the first matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
4871             * @throws SystemException if a system exception occurred
4872             */
4873            @Override
4874            public BookmarksEntry fetchByG_NotS_First(long groupId, int status,
4875                    OrderByComparator orderByComparator) throws SystemException {
4876                    List<BookmarksEntry> list = findByG_NotS(groupId, status, 0, 1,
4877                                    orderByComparator);
4878    
4879                    if (!list.isEmpty()) {
4880                            return list.get(0);
4881                    }
4882    
4883                    return null;
4884            }
4885    
4886            /**
4887             * Returns the last bookmarks entry in the ordered set where groupId = &#63; and status &ne; &#63;.
4888             *
4889             * @param groupId the group ID
4890             * @param status the status
4891             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4892             * @return the last matching bookmarks entry
4893             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
4894             * @throws SystemException if a system exception occurred
4895             */
4896            @Override
4897            public BookmarksEntry findByG_NotS_Last(long groupId, int status,
4898                    OrderByComparator orderByComparator)
4899                    throws NoSuchEntryException, SystemException {
4900                    BookmarksEntry bookmarksEntry = fetchByG_NotS_Last(groupId, status,
4901                                    orderByComparator);
4902    
4903                    if (bookmarksEntry != null) {
4904                            return bookmarksEntry;
4905                    }
4906    
4907                    StringBundler msg = new StringBundler(6);
4908    
4909                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4910    
4911                    msg.append("groupId=");
4912                    msg.append(groupId);
4913    
4914                    msg.append(", status=");
4915                    msg.append(status);
4916    
4917                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4918    
4919                    throw new NoSuchEntryException(msg.toString());
4920            }
4921    
4922            /**
4923             * Returns the last bookmarks entry in the ordered set where groupId = &#63; and status &ne; &#63;.
4924             *
4925             * @param groupId the group ID
4926             * @param status the status
4927             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4928             * @return the last matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
4929             * @throws SystemException if a system exception occurred
4930             */
4931            @Override
4932            public BookmarksEntry fetchByG_NotS_Last(long groupId, int status,
4933                    OrderByComparator orderByComparator) throws SystemException {
4934                    int count = countByG_NotS(groupId, status);
4935    
4936                    if (count == 0) {
4937                            return null;
4938                    }
4939    
4940                    List<BookmarksEntry> list = findByG_NotS(groupId, status, count - 1,
4941                                    count, orderByComparator);
4942    
4943                    if (!list.isEmpty()) {
4944                            return list.get(0);
4945                    }
4946    
4947                    return null;
4948            }
4949    
4950            /**
4951             * Returns the bookmarks entries before and after the current bookmarks entry in the ordered set where groupId = &#63; and status &ne; &#63;.
4952             *
4953             * @param entryId the primary key of the current bookmarks entry
4954             * @param groupId the group ID
4955             * @param status the status
4956             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4957             * @return the previous, current, and next bookmarks entry
4958             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
4959             * @throws SystemException if a system exception occurred
4960             */
4961            @Override
4962            public BookmarksEntry[] findByG_NotS_PrevAndNext(long entryId,
4963                    long groupId, int status, OrderByComparator orderByComparator)
4964                    throws NoSuchEntryException, SystemException {
4965                    BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
4966    
4967                    Session session = null;
4968    
4969                    try {
4970                            session = openSession();
4971    
4972                            BookmarksEntry[] array = new BookmarksEntryImpl[3];
4973    
4974                            array[0] = getByG_NotS_PrevAndNext(session, bookmarksEntry,
4975                                            groupId, status, orderByComparator, true);
4976    
4977                            array[1] = bookmarksEntry;
4978    
4979                            array[2] = getByG_NotS_PrevAndNext(session, bookmarksEntry,
4980                                            groupId, status, orderByComparator, false);
4981    
4982                            return array;
4983                    }
4984                    catch (Exception e) {
4985                            throw processException(e);
4986                    }
4987                    finally {
4988                            closeSession(session);
4989                    }
4990            }
4991    
4992            protected BookmarksEntry getByG_NotS_PrevAndNext(Session session,
4993                    BookmarksEntry bookmarksEntry, long groupId, int status,
4994                    OrderByComparator orderByComparator, boolean previous) {
4995                    StringBundler query = null;
4996    
4997                    if (orderByComparator != null) {
4998                            query = new StringBundler(6 +
4999                                            (orderByComparator.getOrderByFields().length * 6));
5000                    }
5001                    else {
5002                            query = new StringBundler(3);
5003                    }
5004    
5005                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
5006    
5007                    query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
5008    
5009                    query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
5010    
5011                    if (orderByComparator != null) {
5012                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5013    
5014                            if (orderByConditionFields.length > 0) {
5015                                    query.append(WHERE_AND);
5016                            }
5017    
5018                            for (int i = 0; i < orderByConditionFields.length; i++) {
5019                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5020                                    query.append(orderByConditionFields[i]);
5021    
5022                                    if ((i + 1) < orderByConditionFields.length) {
5023                                            if (orderByComparator.isAscending() ^ previous) {
5024                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5025                                            }
5026                                            else {
5027                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5028                                            }
5029                                    }
5030                                    else {
5031                                            if (orderByComparator.isAscending() ^ previous) {
5032                                                    query.append(WHERE_GREATER_THAN);
5033                                            }
5034                                            else {
5035                                                    query.append(WHERE_LESSER_THAN);
5036                                            }
5037                                    }
5038                            }
5039    
5040                            query.append(ORDER_BY_CLAUSE);
5041    
5042                            String[] orderByFields = orderByComparator.getOrderByFields();
5043    
5044                            for (int i = 0; i < orderByFields.length; i++) {
5045                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5046                                    query.append(orderByFields[i]);
5047    
5048                                    if ((i + 1) < orderByFields.length) {
5049                                            if (orderByComparator.isAscending() ^ previous) {
5050                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5051                                            }
5052                                            else {
5053                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5054                                            }
5055                                    }
5056                                    else {
5057                                            if (orderByComparator.isAscending() ^ previous) {
5058                                                    query.append(ORDER_BY_ASC);
5059                                            }
5060                                            else {
5061                                                    query.append(ORDER_BY_DESC);
5062                                            }
5063                                    }
5064                            }
5065                    }
5066                    else {
5067                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
5068                    }
5069    
5070                    String sql = query.toString();
5071    
5072                    Query q = session.createQuery(sql);
5073    
5074                    q.setFirstResult(0);
5075                    q.setMaxResults(2);
5076    
5077                    QueryPos qPos = QueryPos.getInstance(q);
5078    
5079                    qPos.add(groupId);
5080    
5081                    qPos.add(status);
5082    
5083                    if (orderByComparator != null) {
5084                            Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry);
5085    
5086                            for (Object value : values) {
5087                                    qPos.add(value);
5088                            }
5089                    }
5090    
5091                    List<BookmarksEntry> list = q.list();
5092    
5093                    if (list.size() == 2) {
5094                            return list.get(1);
5095                    }
5096                    else {
5097                            return null;
5098                    }
5099            }
5100    
5101            /**
5102             * Returns all the bookmarks entries that the user has permission to view where groupId = &#63; and status &ne; &#63;.
5103             *
5104             * @param groupId the group ID
5105             * @param status the status
5106             * @return the matching bookmarks entries that the user has permission to view
5107             * @throws SystemException if a system exception occurred
5108             */
5109            @Override
5110            public List<BookmarksEntry> filterFindByG_NotS(long groupId, int status)
5111                    throws SystemException {
5112                    return filterFindByG_NotS(groupId, status, QueryUtil.ALL_POS,
5113                            QueryUtil.ALL_POS, null);
5114            }
5115    
5116            /**
5117             * Returns a range of all the bookmarks entries that the user has permission to view where groupId = &#63; and status &ne; &#63;.
5118             *
5119             * <p>
5120             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
5121             * </p>
5122             *
5123             * @param groupId the group ID
5124             * @param status the status
5125             * @param start the lower bound of the range of bookmarks entries
5126             * @param end the upper bound of the range of bookmarks entries (not inclusive)
5127             * @return the range of matching bookmarks entries that the user has permission to view
5128             * @throws SystemException if a system exception occurred
5129             */
5130            @Override
5131            public List<BookmarksEntry> filterFindByG_NotS(long groupId, int status,
5132                    int start, int end) throws SystemException {
5133                    return filterFindByG_NotS(groupId, status, start, end, null);
5134            }
5135    
5136            /**
5137             * Returns an ordered range of all the bookmarks entries that the user has permissions to view where groupId = &#63; and status &ne; &#63;.
5138             *
5139             * <p>
5140             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
5141             * </p>
5142             *
5143             * @param groupId the group ID
5144             * @param status the status
5145             * @param start the lower bound of the range of bookmarks entries
5146             * @param end the upper bound of the range of bookmarks entries (not inclusive)
5147             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5148             * @return the ordered range of matching bookmarks entries that the user has permission to view
5149             * @throws SystemException if a system exception occurred
5150             */
5151            @Override
5152            public List<BookmarksEntry> filterFindByG_NotS(long groupId, int status,
5153                    int start, int end, OrderByComparator orderByComparator)
5154                    throws SystemException {
5155                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5156                            return findByG_NotS(groupId, status, start, end, orderByComparator);
5157                    }
5158    
5159                    StringBundler query = null;
5160    
5161                    if (orderByComparator != null) {
5162                            query = new StringBundler(4 +
5163                                            (orderByComparator.getOrderByFields().length * 3));
5164                    }
5165                    else {
5166                            query = new StringBundler(4);
5167                    }
5168    
5169                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
5170    
5171                    query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
5172    
5173                    query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
5174    
5175                    if (orderByComparator != null) {
5176                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5177                                    orderByComparator);
5178                    }
5179                    else {
5180                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
5181                    }
5182    
5183                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5184                                    BookmarksEntry.class.getName(),
5185                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
5186                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
5187    
5188                    Session session = null;
5189    
5190                    try {
5191                            session = openSession();
5192    
5193                            Query q = session.createQuery(sql);
5194    
5195                            QueryPos qPos = QueryPos.getInstance(q);
5196    
5197                            qPos.add(groupId);
5198    
5199                            qPos.add(status);
5200    
5201                            return (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start,
5202                                    end);
5203                    }
5204                    catch (Exception e) {
5205                            throw processException(e);
5206                    }
5207                    finally {
5208                            closeSession(session);
5209                    }
5210            }
5211    
5212            /**
5213             * 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;.
5214             *
5215             * @param entryId the primary key of the current bookmarks entry
5216             * @param groupId the group ID
5217             * @param status the status
5218             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5219             * @return the previous, current, and next bookmarks entry
5220             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
5221             * @throws SystemException if a system exception occurred
5222             */
5223            @Override
5224            public BookmarksEntry[] filterFindByG_NotS_PrevAndNext(long entryId,
5225                    long groupId, int status, OrderByComparator orderByComparator)
5226                    throws NoSuchEntryException, SystemException {
5227                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5228                            return findByG_NotS_PrevAndNext(entryId, groupId, status,
5229                                    orderByComparator);
5230                    }
5231    
5232                    BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
5233    
5234                    Session session = null;
5235    
5236                    try {
5237                            session = openSession();
5238    
5239                            BookmarksEntry[] array = new BookmarksEntryImpl[3];
5240    
5241                            array[0] = filterGetByG_NotS_PrevAndNext(session, bookmarksEntry,
5242                                            groupId, status, orderByComparator, true);
5243    
5244                            array[1] = bookmarksEntry;
5245    
5246                            array[2] = filterGetByG_NotS_PrevAndNext(session, bookmarksEntry,
5247                                            groupId, status, orderByComparator, false);
5248    
5249                            return array;
5250                    }
5251                    catch (Exception e) {
5252                            throw processException(e);
5253                    }
5254                    finally {
5255                            closeSession(session);
5256                    }
5257            }
5258    
5259            protected BookmarksEntry filterGetByG_NotS_PrevAndNext(Session session,
5260                    BookmarksEntry bookmarksEntry, long groupId, int status,
5261                    OrderByComparator orderByComparator, boolean previous) {
5262                    StringBundler query = null;
5263    
5264                    if (orderByComparator != null) {
5265                            query = new StringBundler(6 +
5266                                            (orderByComparator.getOrderByFields().length * 6));
5267                    }
5268                    else {
5269                            query = new StringBundler(3);
5270                    }
5271    
5272                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
5273    
5274                    query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
5275    
5276                    query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
5277    
5278                    if (orderByComparator != null) {
5279                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5280    
5281                            if (orderByConditionFields.length > 0) {
5282                                    query.append(WHERE_AND);
5283                            }
5284    
5285                            for (int i = 0; i < orderByConditionFields.length; i++) {
5286                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5287                                    query.append(orderByConditionFields[i]);
5288    
5289                                    if ((i + 1) < orderByConditionFields.length) {
5290                                            if (orderByComparator.isAscending() ^ previous) {
5291                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5292                                            }
5293                                            else {
5294                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5295                                            }
5296                                    }
5297                                    else {
5298                                            if (orderByComparator.isAscending() ^ previous) {
5299                                                    query.append(WHERE_GREATER_THAN);
5300                                            }
5301                                            else {
5302                                                    query.append(WHERE_LESSER_THAN);
5303                                            }
5304                                    }
5305                            }
5306    
5307                            query.append(ORDER_BY_CLAUSE);
5308    
5309                            String[] orderByFields = orderByComparator.getOrderByFields();
5310    
5311                            for (int i = 0; i < orderByFields.length; i++) {
5312                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5313                                    query.append(orderByFields[i]);
5314    
5315                                    if ((i + 1) < orderByFields.length) {
5316                                            if (orderByComparator.isAscending() ^ previous) {
5317                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5318                                            }
5319                                            else {
5320                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5321                                            }
5322                                    }
5323                                    else {
5324                                            if (orderByComparator.isAscending() ^ previous) {
5325                                                    query.append(ORDER_BY_ASC);
5326                                            }
5327                                            else {
5328                                                    query.append(ORDER_BY_DESC);
5329                                            }
5330                                    }
5331                            }
5332                    }
5333                    else {
5334                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
5335                    }
5336    
5337                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5338                                    BookmarksEntry.class.getName(),
5339                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
5340                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
5341    
5342                    Query q = session.createQuery(sql);
5343    
5344                    q.setFirstResult(0);
5345                    q.setMaxResults(2);
5346    
5347                    QueryPos qPos = QueryPos.getInstance(q);
5348    
5349                    qPos.add(groupId);
5350    
5351                    qPos.add(status);
5352    
5353                    if (orderByComparator != null) {
5354                            Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry);
5355    
5356                            for (Object value : values) {
5357                                    qPos.add(value);
5358                            }
5359                    }
5360    
5361                    List<BookmarksEntry> list = q.list();
5362    
5363                    if (list.size() == 2) {
5364                            return list.get(1);
5365                    }
5366                    else {
5367                            return null;
5368                    }
5369            }
5370    
5371            /**
5372             * Removes all the bookmarks entries where groupId = &#63; and status &ne; &#63; from the database.
5373             *
5374             * @param groupId the group ID
5375             * @param status the status
5376             * @throws SystemException if a system exception occurred
5377             */
5378            @Override
5379            public void removeByG_NotS(long groupId, int status)
5380                    throws SystemException {
5381                    for (BookmarksEntry bookmarksEntry : findByG_NotS(groupId, status,
5382                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
5383                            remove(bookmarksEntry);
5384                    }
5385            }
5386    
5387            /**
5388             * Returns the number of bookmarks entries where groupId = &#63; and status &ne; &#63;.
5389             *
5390             * @param groupId the group ID
5391             * @param status the status
5392             * @return the number of matching bookmarks entries
5393             * @throws SystemException if a system exception occurred
5394             */
5395            @Override
5396            public int countByG_NotS(long groupId, int status)
5397                    throws SystemException {
5398                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_NOTS;
5399    
5400                    Object[] finderArgs = new Object[] { groupId, status };
5401    
5402                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
5403                                    this);
5404    
5405                    if (count == null) {
5406                            StringBundler query = new StringBundler(3);
5407    
5408                            query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
5409    
5410                            query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
5411    
5412                            query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
5413    
5414                            String sql = query.toString();
5415    
5416                            Session session = null;
5417    
5418                            try {
5419                                    session = openSession();
5420    
5421                                    Query q = session.createQuery(sql);
5422    
5423                                    QueryPos qPos = QueryPos.getInstance(q);
5424    
5425                                    qPos.add(groupId);
5426    
5427                                    qPos.add(status);
5428    
5429                                    count = (Long)q.uniqueResult();
5430    
5431                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
5432                            }
5433                            catch (Exception e) {
5434                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5435    
5436                                    throw processException(e);
5437                            }
5438                            finally {
5439                                    closeSession(session);
5440                            }
5441                    }
5442    
5443                    return count.intValue();
5444            }
5445    
5446            /**
5447             * Returns the number of bookmarks entries that the user has permission to view where groupId = &#63; and status &ne; &#63;.
5448             *
5449             * @param groupId the group ID
5450             * @param status the status
5451             * @return the number of matching bookmarks entries that the user has permission to view
5452             * @throws SystemException if a system exception occurred
5453             */
5454            @Override
5455            public int filterCountByG_NotS(long groupId, int status)
5456                    throws SystemException {
5457                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5458                            return countByG_NotS(groupId, status);
5459                    }
5460    
5461                    StringBundler query = new StringBundler(3);
5462    
5463                    query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
5464    
5465                    query.append(_FINDER_COLUMN_G_NOTS_GROUPID_2);
5466    
5467                    query.append(_FINDER_COLUMN_G_NOTS_STATUS_2);
5468    
5469                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5470                                    BookmarksEntry.class.getName(),
5471                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
5472                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
5473    
5474                    Session session = null;
5475    
5476                    try {
5477                            session = openSession();
5478    
5479                            Query q = session.createQuery(sql);
5480    
5481                            QueryPos qPos = QueryPos.getInstance(q);
5482    
5483                            qPos.add(groupId);
5484    
5485                            qPos.add(status);
5486    
5487                            Long count = (Long)q.uniqueResult();
5488    
5489                            return count.intValue();
5490                    }
5491                    catch (Exception e) {
5492                            throw processException(e);
5493                    }
5494                    finally {
5495                            closeSession(session);
5496                    }
5497            }
5498    
5499            private static final String _FINDER_COLUMN_G_NOTS_GROUPID_2 = "bookmarksEntry.groupId = ? AND ";
5500            private static final String _FINDER_COLUMN_G_NOTS_STATUS_2 = "bookmarksEntry.status != ?";
5501            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_NOTS = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
5502                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
5503                            BookmarksEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
5504                            "findByC_NotS",
5505                            new String[] {
5506                                    Long.class.getName(), Integer.class.getName(),
5507                                    
5508                            Integer.class.getName(), Integer.class.getName(),
5509                                    OrderByComparator.class.getName()
5510                            });
5511            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_NOTS = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
5512                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
5513                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByC_NotS",
5514                            new String[] { Long.class.getName(), Integer.class.getName() });
5515    
5516            /**
5517             * Returns all the bookmarks entries where companyId = &#63; and status &ne; &#63;.
5518             *
5519             * @param companyId the company ID
5520             * @param status the status
5521             * @return the matching bookmarks entries
5522             * @throws SystemException if a system exception occurred
5523             */
5524            @Override
5525            public List<BookmarksEntry> findByC_NotS(long companyId, int status)
5526                    throws SystemException {
5527                    return findByC_NotS(companyId, status, QueryUtil.ALL_POS,
5528                            QueryUtil.ALL_POS, null);
5529            }
5530    
5531            /**
5532             * Returns a range of all the bookmarks entries where companyId = &#63; and status &ne; &#63;.
5533             *
5534             * <p>
5535             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
5536             * </p>
5537             *
5538             * @param companyId the company ID
5539             * @param status the status
5540             * @param start the lower bound of the range of bookmarks entries
5541             * @param end the upper bound of the range of bookmarks entries (not inclusive)
5542             * @return the range of matching bookmarks entries
5543             * @throws SystemException if a system exception occurred
5544             */
5545            @Override
5546            public List<BookmarksEntry> findByC_NotS(long companyId, int status,
5547                    int start, int end) throws SystemException {
5548                    return findByC_NotS(companyId, status, start, end, null);
5549            }
5550    
5551            /**
5552             * Returns an ordered range of all the bookmarks entries where companyId = &#63; and status &ne; &#63;.
5553             *
5554             * <p>
5555             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
5556             * </p>
5557             *
5558             * @param companyId the company ID
5559             * @param status the status
5560             * @param start the lower bound of the range of bookmarks entries
5561             * @param end the upper bound of the range of bookmarks entries (not inclusive)
5562             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5563             * @return the ordered range of matching bookmarks entries
5564             * @throws SystemException if a system exception occurred
5565             */
5566            @Override
5567            public List<BookmarksEntry> findByC_NotS(long companyId, int status,
5568                    int start, int end, OrderByComparator orderByComparator)
5569                    throws SystemException {
5570                    boolean pagination = true;
5571                    FinderPath finderPath = null;
5572                    Object[] finderArgs = null;
5573    
5574                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_NOTS;
5575                    finderArgs = new Object[] {
5576                                    companyId, status,
5577                                    
5578                                    start, end, orderByComparator
5579                            };
5580    
5581                    List<BookmarksEntry> list = (List<BookmarksEntry>)FinderCacheUtil.getResult(finderPath,
5582                                    finderArgs, this);
5583    
5584                    if ((list != null) && !list.isEmpty()) {
5585                            for (BookmarksEntry bookmarksEntry : list) {
5586                                    if ((companyId != bookmarksEntry.getCompanyId()) ||
5587                                                    (status != bookmarksEntry.getStatus())) {
5588                                            list = null;
5589    
5590                                            break;
5591                                    }
5592                            }
5593                    }
5594    
5595                    if (list == null) {
5596                            StringBundler query = null;
5597    
5598                            if (orderByComparator != null) {
5599                                    query = new StringBundler(4 +
5600                                                    (orderByComparator.getOrderByFields().length * 3));
5601                            }
5602                            else {
5603                                    query = new StringBundler(4);
5604                            }
5605    
5606                            query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
5607    
5608                            query.append(_FINDER_COLUMN_C_NOTS_COMPANYID_2);
5609    
5610                            query.append(_FINDER_COLUMN_C_NOTS_STATUS_2);
5611    
5612                            if (orderByComparator != null) {
5613                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5614                                            orderByComparator);
5615                            }
5616                            else
5617                             if (pagination) {
5618                                    query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
5619                            }
5620    
5621                            String sql = query.toString();
5622    
5623                            Session session = null;
5624    
5625                            try {
5626                                    session = openSession();
5627    
5628                                    Query q = session.createQuery(sql);
5629    
5630                                    QueryPos qPos = QueryPos.getInstance(q);
5631    
5632                                    qPos.add(companyId);
5633    
5634                                    qPos.add(status);
5635    
5636                                    if (!pagination) {
5637                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
5638                                                            getDialect(), start, end, false);
5639    
5640                                            Collections.sort(list);
5641    
5642                                            list = new UnmodifiableList<BookmarksEntry>(list);
5643                                    }
5644                                    else {
5645                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
5646                                                            getDialect(), start, end);
5647                                    }
5648    
5649                                    cacheResult(list);
5650    
5651                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
5652                            }
5653                            catch (Exception e) {
5654                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5655    
5656                                    throw processException(e);
5657                            }
5658                            finally {
5659                                    closeSession(session);
5660                            }
5661                    }
5662    
5663                    return list;
5664            }
5665    
5666            /**
5667             * Returns the first bookmarks entry in the ordered set where companyId = &#63; and status &ne; &#63;.
5668             *
5669             * @param companyId the company ID
5670             * @param status the status
5671             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5672             * @return the first matching bookmarks entry
5673             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
5674             * @throws SystemException if a system exception occurred
5675             */
5676            @Override
5677            public BookmarksEntry findByC_NotS_First(long companyId, int status,
5678                    OrderByComparator orderByComparator)
5679                    throws NoSuchEntryException, SystemException {
5680                    BookmarksEntry bookmarksEntry = fetchByC_NotS_First(companyId, status,
5681                                    orderByComparator);
5682    
5683                    if (bookmarksEntry != null) {
5684                            return bookmarksEntry;
5685                    }
5686    
5687                    StringBundler msg = new StringBundler(6);
5688    
5689                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5690    
5691                    msg.append("companyId=");
5692                    msg.append(companyId);
5693    
5694                    msg.append(", status=");
5695                    msg.append(status);
5696    
5697                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5698    
5699                    throw new NoSuchEntryException(msg.toString());
5700            }
5701    
5702            /**
5703             * Returns the first bookmarks entry in the ordered set where companyId = &#63; and status &ne; &#63;.
5704             *
5705             * @param companyId the company ID
5706             * @param status the status
5707             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5708             * @return the first matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
5709             * @throws SystemException if a system exception occurred
5710             */
5711            @Override
5712            public BookmarksEntry fetchByC_NotS_First(long companyId, int status,
5713                    OrderByComparator orderByComparator) throws SystemException {
5714                    List<BookmarksEntry> list = findByC_NotS(companyId, status, 0, 1,
5715                                    orderByComparator);
5716    
5717                    if (!list.isEmpty()) {
5718                            return list.get(0);
5719                    }
5720    
5721                    return null;
5722            }
5723    
5724            /**
5725             * Returns the last bookmarks entry in the ordered set where companyId = &#63; and status &ne; &#63;.
5726             *
5727             * @param companyId the company ID
5728             * @param status the status
5729             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5730             * @return the last matching bookmarks entry
5731             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
5732             * @throws SystemException if a system exception occurred
5733             */
5734            @Override
5735            public BookmarksEntry findByC_NotS_Last(long companyId, int status,
5736                    OrderByComparator orderByComparator)
5737                    throws NoSuchEntryException, SystemException {
5738                    BookmarksEntry bookmarksEntry = fetchByC_NotS_Last(companyId, status,
5739                                    orderByComparator);
5740    
5741                    if (bookmarksEntry != null) {
5742                            return bookmarksEntry;
5743                    }
5744    
5745                    StringBundler msg = new StringBundler(6);
5746    
5747                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5748    
5749                    msg.append("companyId=");
5750                    msg.append(companyId);
5751    
5752                    msg.append(", status=");
5753                    msg.append(status);
5754    
5755                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5756    
5757                    throw new NoSuchEntryException(msg.toString());
5758            }
5759    
5760            /**
5761             * Returns the last bookmarks entry in the ordered set where companyId = &#63; and status &ne; &#63;.
5762             *
5763             * @param companyId the company ID
5764             * @param status the status
5765             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5766             * @return the last matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
5767             * @throws SystemException if a system exception occurred
5768             */
5769            @Override
5770            public BookmarksEntry fetchByC_NotS_Last(long companyId, int status,
5771                    OrderByComparator orderByComparator) throws SystemException {
5772                    int count = countByC_NotS(companyId, status);
5773    
5774                    if (count == 0) {
5775                            return null;
5776                    }
5777    
5778                    List<BookmarksEntry> list = findByC_NotS(companyId, status, count - 1,
5779                                    count, orderByComparator);
5780    
5781                    if (!list.isEmpty()) {
5782                            return list.get(0);
5783                    }
5784    
5785                    return null;
5786            }
5787    
5788            /**
5789             * Returns the bookmarks entries before and after the current bookmarks entry in the ordered set where companyId = &#63; and status &ne; &#63;.
5790             *
5791             * @param entryId the primary key of the current bookmarks entry
5792             * @param companyId the company ID
5793             * @param status the status
5794             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5795             * @return the previous, current, and next bookmarks entry
5796             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
5797             * @throws SystemException if a system exception occurred
5798             */
5799            @Override
5800            public BookmarksEntry[] findByC_NotS_PrevAndNext(long entryId,
5801                    long companyId, int status, OrderByComparator orderByComparator)
5802                    throws NoSuchEntryException, SystemException {
5803                    BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
5804    
5805                    Session session = null;
5806    
5807                    try {
5808                            session = openSession();
5809    
5810                            BookmarksEntry[] array = new BookmarksEntryImpl[3];
5811    
5812                            array[0] = getByC_NotS_PrevAndNext(session, bookmarksEntry,
5813                                            companyId, status, orderByComparator, true);
5814    
5815                            array[1] = bookmarksEntry;
5816    
5817                            array[2] = getByC_NotS_PrevAndNext(session, bookmarksEntry,
5818                                            companyId, status, orderByComparator, false);
5819    
5820                            return array;
5821                    }
5822                    catch (Exception e) {
5823                            throw processException(e);
5824                    }
5825                    finally {
5826                            closeSession(session);
5827                    }
5828            }
5829    
5830            protected BookmarksEntry getByC_NotS_PrevAndNext(Session session,
5831                    BookmarksEntry bookmarksEntry, long companyId, int status,
5832                    OrderByComparator orderByComparator, boolean previous) {
5833                    StringBundler query = null;
5834    
5835                    if (orderByComparator != null) {
5836                            query = new StringBundler(6 +
5837                                            (orderByComparator.getOrderByFields().length * 6));
5838                    }
5839                    else {
5840                            query = new StringBundler(3);
5841                    }
5842    
5843                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
5844    
5845                    query.append(_FINDER_COLUMN_C_NOTS_COMPANYID_2);
5846    
5847                    query.append(_FINDER_COLUMN_C_NOTS_STATUS_2);
5848    
5849                    if (orderByComparator != null) {
5850                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5851    
5852                            if (orderByConditionFields.length > 0) {
5853                                    query.append(WHERE_AND);
5854                            }
5855    
5856                            for (int i = 0; i < orderByConditionFields.length; i++) {
5857                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5858                                    query.append(orderByConditionFields[i]);
5859    
5860                                    if ((i + 1) < orderByConditionFields.length) {
5861                                            if (orderByComparator.isAscending() ^ previous) {
5862                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5863                                            }
5864                                            else {
5865                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5866                                            }
5867                                    }
5868                                    else {
5869                                            if (orderByComparator.isAscending() ^ previous) {
5870                                                    query.append(WHERE_GREATER_THAN);
5871                                            }
5872                                            else {
5873                                                    query.append(WHERE_LESSER_THAN);
5874                                            }
5875                                    }
5876                            }
5877    
5878                            query.append(ORDER_BY_CLAUSE);
5879    
5880                            String[] orderByFields = orderByComparator.getOrderByFields();
5881    
5882                            for (int i = 0; i < orderByFields.length; i++) {
5883                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5884                                    query.append(orderByFields[i]);
5885    
5886                                    if ((i + 1) < orderByFields.length) {
5887                                            if (orderByComparator.isAscending() ^ previous) {
5888                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5889                                            }
5890                                            else {
5891                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5892                                            }
5893                                    }
5894                                    else {
5895                                            if (orderByComparator.isAscending() ^ previous) {
5896                                                    query.append(ORDER_BY_ASC);
5897                                            }
5898                                            else {
5899                                                    query.append(ORDER_BY_DESC);
5900                                            }
5901                                    }
5902                            }
5903                    }
5904                    else {
5905                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
5906                    }
5907    
5908                    String sql = query.toString();
5909    
5910                    Query q = session.createQuery(sql);
5911    
5912                    q.setFirstResult(0);
5913                    q.setMaxResults(2);
5914    
5915                    QueryPos qPos = QueryPos.getInstance(q);
5916    
5917                    qPos.add(companyId);
5918    
5919                    qPos.add(status);
5920    
5921                    if (orderByComparator != null) {
5922                            Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry);
5923    
5924                            for (Object value : values) {
5925                                    qPos.add(value);
5926                            }
5927                    }
5928    
5929                    List<BookmarksEntry> list = q.list();
5930    
5931                    if (list.size() == 2) {
5932                            return list.get(1);
5933                    }
5934                    else {
5935                            return null;
5936                    }
5937            }
5938    
5939            /**
5940             * Removes all the bookmarks entries where companyId = &#63; and status &ne; &#63; from the database.
5941             *
5942             * @param companyId the company ID
5943             * @param status the status
5944             * @throws SystemException if a system exception occurred
5945             */
5946            @Override
5947            public void removeByC_NotS(long companyId, int status)
5948                    throws SystemException {
5949                    for (BookmarksEntry bookmarksEntry : findByC_NotS(companyId, status,
5950                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
5951                            remove(bookmarksEntry);
5952                    }
5953            }
5954    
5955            /**
5956             * Returns the number of bookmarks entries where companyId = &#63; and status &ne; &#63;.
5957             *
5958             * @param companyId the company ID
5959             * @param status the status
5960             * @return the number of matching bookmarks entries
5961             * @throws SystemException if a system exception occurred
5962             */
5963            @Override
5964            public int countByC_NotS(long companyId, int status)
5965                    throws SystemException {
5966                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_NOTS;
5967    
5968                    Object[] finderArgs = new Object[] { companyId, status };
5969    
5970                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
5971                                    this);
5972    
5973                    if (count == null) {
5974                            StringBundler query = new StringBundler(3);
5975    
5976                            query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
5977    
5978                            query.append(_FINDER_COLUMN_C_NOTS_COMPANYID_2);
5979    
5980                            query.append(_FINDER_COLUMN_C_NOTS_STATUS_2);
5981    
5982                            String sql = query.toString();
5983    
5984                            Session session = null;
5985    
5986                            try {
5987                                    session = openSession();
5988    
5989                                    Query q = session.createQuery(sql);
5990    
5991                                    QueryPos qPos = QueryPos.getInstance(q);
5992    
5993                                    qPos.add(companyId);
5994    
5995                                    qPos.add(status);
5996    
5997                                    count = (Long)q.uniqueResult();
5998    
5999                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
6000                            }
6001                            catch (Exception e) {
6002                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6003    
6004                                    throw processException(e);
6005                            }
6006                            finally {
6007                                    closeSession(session);
6008                            }
6009                    }
6010    
6011                    return count.intValue();
6012            }
6013    
6014            private static final String _FINDER_COLUMN_C_NOTS_COMPANYID_2 = "bookmarksEntry.companyId = ? AND ";
6015            private static final String _FINDER_COLUMN_C_NOTS_STATUS_2 = "bookmarksEntry.status != ?";
6016            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_S = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
6017                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
6018                            BookmarksEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
6019                            "findByG_U_S",
6020                            new String[] {
6021                                    Long.class.getName(), Long.class.getName(),
6022                                    Integer.class.getName(),
6023                                    
6024                            Integer.class.getName(), Integer.class.getName(),
6025                                    OrderByComparator.class.getName()
6026                            });
6027            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
6028                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
6029                            BookmarksEntryImpl.class,
6030                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U_S",
6031                            new String[] {
6032                                    Long.class.getName(), Long.class.getName(),
6033                                    Integer.class.getName()
6034                            },
6035                            BookmarksEntryModelImpl.GROUPID_COLUMN_BITMASK |
6036                            BookmarksEntryModelImpl.USERID_COLUMN_BITMASK |
6037                            BookmarksEntryModelImpl.STATUS_COLUMN_BITMASK |
6038                            BookmarksEntryModelImpl.FOLDERID_COLUMN_BITMASK |
6039                            BookmarksEntryModelImpl.NAME_COLUMN_BITMASK);
6040            public static final FinderPath FINDER_PATH_COUNT_BY_G_U_S = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
6041                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
6042                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U_S",
6043                            new String[] {
6044                                    Long.class.getName(), Long.class.getName(),
6045                                    Integer.class.getName()
6046                            });
6047    
6048            /**
6049             * Returns all the bookmarks entries where groupId = &#63; and userId = &#63; and status = &#63;.
6050             *
6051             * @param groupId the group ID
6052             * @param userId the user ID
6053             * @param status the status
6054             * @return the matching bookmarks entries
6055             * @throws SystemException if a system exception occurred
6056             */
6057            @Override
6058            public List<BookmarksEntry> findByG_U_S(long groupId, long userId,
6059                    int status) throws SystemException {
6060                    return findByG_U_S(groupId, userId, status, QueryUtil.ALL_POS,
6061                            QueryUtil.ALL_POS, null);
6062            }
6063    
6064            /**
6065             * Returns a range of all the bookmarks entries where groupId = &#63; and userId = &#63; and status = &#63;.
6066             *
6067             * <p>
6068             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
6069             * </p>
6070             *
6071             * @param groupId the group ID
6072             * @param userId the user ID
6073             * @param status the status
6074             * @param start the lower bound of the range of bookmarks entries
6075             * @param end the upper bound of the range of bookmarks entries (not inclusive)
6076             * @return the range of matching bookmarks entries
6077             * @throws SystemException if a system exception occurred
6078             */
6079            @Override
6080            public List<BookmarksEntry> findByG_U_S(long groupId, long userId,
6081                    int status, int start, int end) throws SystemException {
6082                    return findByG_U_S(groupId, userId, status, start, end, null);
6083            }
6084    
6085            /**
6086             * Returns an ordered range of all the bookmarks entries where groupId = &#63; and userId = &#63; and status = &#63;.
6087             *
6088             * <p>
6089             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
6090             * </p>
6091             *
6092             * @param groupId the group ID
6093             * @param userId the user ID
6094             * @param status the status
6095             * @param start the lower bound of the range of bookmarks entries
6096             * @param end the upper bound of the range of bookmarks entries (not inclusive)
6097             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6098             * @return the ordered range of matching bookmarks entries
6099             * @throws SystemException if a system exception occurred
6100             */
6101            @Override
6102            public List<BookmarksEntry> findByG_U_S(long groupId, long userId,
6103                    int status, int start, int end, OrderByComparator orderByComparator)
6104                    throws SystemException {
6105                    boolean pagination = true;
6106                    FinderPath finderPath = null;
6107                    Object[] finderArgs = null;
6108    
6109                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6110                                    (orderByComparator == null)) {
6111                            pagination = false;
6112                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S;
6113                            finderArgs = new Object[] { groupId, userId, status };
6114                    }
6115                    else {
6116                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_S;
6117                            finderArgs = new Object[] {
6118                                            groupId, userId, status,
6119                                            
6120                                            start, end, orderByComparator
6121                                    };
6122                    }
6123    
6124                    List<BookmarksEntry> list = (List<BookmarksEntry>)FinderCacheUtil.getResult(finderPath,
6125                                    finderArgs, this);
6126    
6127                    if ((list != null) && !list.isEmpty()) {
6128                            for (BookmarksEntry bookmarksEntry : list) {
6129                                    if ((groupId != bookmarksEntry.getGroupId()) ||
6130                                                    (userId != bookmarksEntry.getUserId()) ||
6131                                                    (status != bookmarksEntry.getStatus())) {
6132                                            list = null;
6133    
6134                                            break;
6135                                    }
6136                            }
6137                    }
6138    
6139                    if (list == null) {
6140                            StringBundler query = null;
6141    
6142                            if (orderByComparator != null) {
6143                                    query = new StringBundler(5 +
6144                                                    (orderByComparator.getOrderByFields().length * 3));
6145                            }
6146                            else {
6147                                    query = new StringBundler(5);
6148                            }
6149    
6150                            query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
6151    
6152                            query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
6153    
6154                            query.append(_FINDER_COLUMN_G_U_S_USERID_2);
6155    
6156                            query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
6157    
6158                            if (orderByComparator != null) {
6159                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6160                                            orderByComparator);
6161                            }
6162                            else
6163                             if (pagination) {
6164                                    query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
6165                            }
6166    
6167                            String sql = query.toString();
6168    
6169                            Session session = null;
6170    
6171                            try {
6172                                    session = openSession();
6173    
6174                                    Query q = session.createQuery(sql);
6175    
6176                                    QueryPos qPos = QueryPos.getInstance(q);
6177    
6178                                    qPos.add(groupId);
6179    
6180                                    qPos.add(userId);
6181    
6182                                    qPos.add(status);
6183    
6184                                    if (!pagination) {
6185                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
6186                                                            getDialect(), start, end, false);
6187    
6188                                            Collections.sort(list);
6189    
6190                                            list = new UnmodifiableList<BookmarksEntry>(list);
6191                                    }
6192                                    else {
6193                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
6194                                                            getDialect(), start, end);
6195                                    }
6196    
6197                                    cacheResult(list);
6198    
6199                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
6200                            }
6201                            catch (Exception e) {
6202                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6203    
6204                                    throw processException(e);
6205                            }
6206                            finally {
6207                                    closeSession(session);
6208                            }
6209                    }
6210    
6211                    return list;
6212            }
6213    
6214            /**
6215             * Returns the first bookmarks entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
6216             *
6217             * @param groupId the group ID
6218             * @param userId the user ID
6219             * @param status the status
6220             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6221             * @return the first matching bookmarks entry
6222             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
6223             * @throws SystemException if a system exception occurred
6224             */
6225            @Override
6226            public BookmarksEntry findByG_U_S_First(long groupId, long userId,
6227                    int status, OrderByComparator orderByComparator)
6228                    throws NoSuchEntryException, SystemException {
6229                    BookmarksEntry bookmarksEntry = fetchByG_U_S_First(groupId, userId,
6230                                    status, orderByComparator);
6231    
6232                    if (bookmarksEntry != null) {
6233                            return bookmarksEntry;
6234                    }
6235    
6236                    StringBundler msg = new StringBundler(8);
6237    
6238                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6239    
6240                    msg.append("groupId=");
6241                    msg.append(groupId);
6242    
6243                    msg.append(", userId=");
6244                    msg.append(userId);
6245    
6246                    msg.append(", status=");
6247                    msg.append(status);
6248    
6249                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6250    
6251                    throw new NoSuchEntryException(msg.toString());
6252            }
6253    
6254            /**
6255             * Returns the first bookmarks entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
6256             *
6257             * @param groupId the group ID
6258             * @param userId the user ID
6259             * @param status the status
6260             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6261             * @return the first matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
6262             * @throws SystemException if a system exception occurred
6263             */
6264            @Override
6265            public BookmarksEntry fetchByG_U_S_First(long groupId, long userId,
6266                    int status, OrderByComparator orderByComparator)
6267                    throws SystemException {
6268                    List<BookmarksEntry> list = findByG_U_S(groupId, userId, status, 0, 1,
6269                                    orderByComparator);
6270    
6271                    if (!list.isEmpty()) {
6272                            return list.get(0);
6273                    }
6274    
6275                    return null;
6276            }
6277    
6278            /**
6279             * Returns the last bookmarks entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
6280             *
6281             * @param groupId the group ID
6282             * @param userId the user ID
6283             * @param status the status
6284             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6285             * @return the last matching bookmarks entry
6286             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
6287             * @throws SystemException if a system exception occurred
6288             */
6289            @Override
6290            public BookmarksEntry findByG_U_S_Last(long groupId, long userId,
6291                    int status, OrderByComparator orderByComparator)
6292                    throws NoSuchEntryException, SystemException {
6293                    BookmarksEntry bookmarksEntry = fetchByG_U_S_Last(groupId, userId,
6294                                    status, orderByComparator);
6295    
6296                    if (bookmarksEntry != null) {
6297                            return bookmarksEntry;
6298                    }
6299    
6300                    StringBundler msg = new StringBundler(8);
6301    
6302                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6303    
6304                    msg.append("groupId=");
6305                    msg.append(groupId);
6306    
6307                    msg.append(", userId=");
6308                    msg.append(userId);
6309    
6310                    msg.append(", status=");
6311                    msg.append(status);
6312    
6313                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6314    
6315                    throw new NoSuchEntryException(msg.toString());
6316            }
6317    
6318            /**
6319             * Returns the last bookmarks entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
6320             *
6321             * @param groupId the group ID
6322             * @param userId the user ID
6323             * @param status the status
6324             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6325             * @return the last matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
6326             * @throws SystemException if a system exception occurred
6327             */
6328            @Override
6329            public BookmarksEntry fetchByG_U_S_Last(long groupId, long userId,
6330                    int status, OrderByComparator orderByComparator)
6331                    throws SystemException {
6332                    int count = countByG_U_S(groupId, userId, status);
6333    
6334                    if (count == 0) {
6335                            return null;
6336                    }
6337    
6338                    List<BookmarksEntry> list = findByG_U_S(groupId, userId, status,
6339                                    count - 1, count, orderByComparator);
6340    
6341                    if (!list.isEmpty()) {
6342                            return list.get(0);
6343                    }
6344    
6345                    return null;
6346            }
6347    
6348            /**
6349             * Returns the bookmarks entries before and after the current bookmarks entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
6350             *
6351             * @param entryId the primary key of the current bookmarks entry
6352             * @param groupId the group ID
6353             * @param userId the user ID
6354             * @param status the status
6355             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6356             * @return the previous, current, and next bookmarks entry
6357             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
6358             * @throws SystemException if a system exception occurred
6359             */
6360            @Override
6361            public BookmarksEntry[] findByG_U_S_PrevAndNext(long entryId, long groupId,
6362                    long userId, int status, OrderByComparator orderByComparator)
6363                    throws NoSuchEntryException, SystemException {
6364                    BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
6365    
6366                    Session session = null;
6367    
6368                    try {
6369                            session = openSession();
6370    
6371                            BookmarksEntry[] array = new BookmarksEntryImpl[3];
6372    
6373                            array[0] = getByG_U_S_PrevAndNext(session, bookmarksEntry, groupId,
6374                                            userId, status, orderByComparator, true);
6375    
6376                            array[1] = bookmarksEntry;
6377    
6378                            array[2] = getByG_U_S_PrevAndNext(session, bookmarksEntry, groupId,
6379                                            userId, status, orderByComparator, false);
6380    
6381                            return array;
6382                    }
6383                    catch (Exception e) {
6384                            throw processException(e);
6385                    }
6386                    finally {
6387                            closeSession(session);
6388                    }
6389            }
6390    
6391            protected BookmarksEntry getByG_U_S_PrevAndNext(Session session,
6392                    BookmarksEntry bookmarksEntry, long groupId, long userId, int status,
6393                    OrderByComparator orderByComparator, boolean previous) {
6394                    StringBundler query = null;
6395    
6396                    if (orderByComparator != null) {
6397                            query = new StringBundler(6 +
6398                                            (orderByComparator.getOrderByFields().length * 6));
6399                    }
6400                    else {
6401                            query = new StringBundler(3);
6402                    }
6403    
6404                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
6405    
6406                    query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
6407    
6408                    query.append(_FINDER_COLUMN_G_U_S_USERID_2);
6409    
6410                    query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
6411    
6412                    if (orderByComparator != null) {
6413                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6414    
6415                            if (orderByConditionFields.length > 0) {
6416                                    query.append(WHERE_AND);
6417                            }
6418    
6419                            for (int i = 0; i < orderByConditionFields.length; i++) {
6420                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6421                                    query.append(orderByConditionFields[i]);
6422    
6423                                    if ((i + 1) < orderByConditionFields.length) {
6424                                            if (orderByComparator.isAscending() ^ previous) {
6425                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6426                                            }
6427                                            else {
6428                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6429                                            }
6430                                    }
6431                                    else {
6432                                            if (orderByComparator.isAscending() ^ previous) {
6433                                                    query.append(WHERE_GREATER_THAN);
6434                                            }
6435                                            else {
6436                                                    query.append(WHERE_LESSER_THAN);
6437                                            }
6438                                    }
6439                            }
6440    
6441                            query.append(ORDER_BY_CLAUSE);
6442    
6443                            String[] orderByFields = orderByComparator.getOrderByFields();
6444    
6445                            for (int i = 0; i < orderByFields.length; i++) {
6446                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6447                                    query.append(orderByFields[i]);
6448    
6449                                    if ((i + 1) < orderByFields.length) {
6450                                            if (orderByComparator.isAscending() ^ previous) {
6451                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6452                                            }
6453                                            else {
6454                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6455                                            }
6456                                    }
6457                                    else {
6458                                            if (orderByComparator.isAscending() ^ previous) {
6459                                                    query.append(ORDER_BY_ASC);
6460                                            }
6461                                            else {
6462                                                    query.append(ORDER_BY_DESC);
6463                                            }
6464                                    }
6465                            }
6466                    }
6467                    else {
6468                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
6469                    }
6470    
6471                    String sql = query.toString();
6472    
6473                    Query q = session.createQuery(sql);
6474    
6475                    q.setFirstResult(0);
6476                    q.setMaxResults(2);
6477    
6478                    QueryPos qPos = QueryPos.getInstance(q);
6479    
6480                    qPos.add(groupId);
6481    
6482                    qPos.add(userId);
6483    
6484                    qPos.add(status);
6485    
6486                    if (orderByComparator != null) {
6487                            Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry);
6488    
6489                            for (Object value : values) {
6490                                    qPos.add(value);
6491                            }
6492                    }
6493    
6494                    List<BookmarksEntry> list = q.list();
6495    
6496                    if (list.size() == 2) {
6497                            return list.get(1);
6498                    }
6499                    else {
6500                            return null;
6501                    }
6502            }
6503    
6504            /**
6505             * Returns all the bookmarks entries that the user has permission to view where groupId = &#63; and userId = &#63; and status = &#63;.
6506             *
6507             * @param groupId the group ID
6508             * @param userId the user ID
6509             * @param status the status
6510             * @return the matching bookmarks entries that the user has permission to view
6511             * @throws SystemException if a system exception occurred
6512             */
6513            @Override
6514            public List<BookmarksEntry> filterFindByG_U_S(long groupId, long userId,
6515                    int status) throws SystemException {
6516                    return filterFindByG_U_S(groupId, userId, status, QueryUtil.ALL_POS,
6517                            QueryUtil.ALL_POS, null);
6518            }
6519    
6520            /**
6521             * Returns a range of all the bookmarks entries that the user has permission to view where groupId = &#63; and userId = &#63; and status = &#63;.
6522             *
6523             * <p>
6524             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
6525             * </p>
6526             *
6527             * @param groupId the group ID
6528             * @param userId the user ID
6529             * @param status the status
6530             * @param start the lower bound of the range of bookmarks entries
6531             * @param end the upper bound of the range of bookmarks entries (not inclusive)
6532             * @return the range of matching bookmarks entries that the user has permission to view
6533             * @throws SystemException if a system exception occurred
6534             */
6535            @Override
6536            public List<BookmarksEntry> filterFindByG_U_S(long groupId, long userId,
6537                    int status, int start, int end) throws SystemException {
6538                    return filterFindByG_U_S(groupId, userId, status, start, end, null);
6539            }
6540    
6541            /**
6542             * 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;.
6543             *
6544             * <p>
6545             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
6546             * </p>
6547             *
6548             * @param groupId the group ID
6549             * @param userId the user ID
6550             * @param status the status
6551             * @param start the lower bound of the range of bookmarks entries
6552             * @param end the upper bound of the range of bookmarks entries (not inclusive)
6553             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6554             * @return the ordered range of matching bookmarks entries that the user has permission to view
6555             * @throws SystemException if a system exception occurred
6556             */
6557            @Override
6558            public List<BookmarksEntry> filterFindByG_U_S(long groupId, long userId,
6559                    int status, int start, int end, OrderByComparator orderByComparator)
6560                    throws SystemException {
6561                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6562                            return findByG_U_S(groupId, userId, status, start, end,
6563                                    orderByComparator);
6564                    }
6565    
6566                    StringBundler query = null;
6567    
6568                    if (orderByComparator != null) {
6569                            query = new StringBundler(5 +
6570                                            (orderByComparator.getOrderByFields().length * 3));
6571                    }
6572                    else {
6573                            query = new StringBundler(5);
6574                    }
6575    
6576                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
6577    
6578                    query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
6579    
6580                    query.append(_FINDER_COLUMN_G_U_S_USERID_2);
6581    
6582                    query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
6583    
6584                    if (orderByComparator != null) {
6585                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6586                                    orderByComparator);
6587                    }
6588                    else {
6589                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
6590                    }
6591    
6592                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6593                                    BookmarksEntry.class.getName(),
6594                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
6595                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
6596    
6597                    Session session = null;
6598    
6599                    try {
6600                            session = openSession();
6601    
6602                            Query q = session.createQuery(sql);
6603    
6604                            QueryPos qPos = QueryPos.getInstance(q);
6605    
6606                            qPos.add(groupId);
6607    
6608                            qPos.add(userId);
6609    
6610                            qPos.add(status);
6611    
6612                            return (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start,
6613                                    end);
6614                    }
6615                    catch (Exception e) {
6616                            throw processException(e);
6617                    }
6618                    finally {
6619                            closeSession(session);
6620                    }
6621            }
6622    
6623            /**
6624             * 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;.
6625             *
6626             * @param entryId the primary key of the current bookmarks entry
6627             * @param groupId the group ID
6628             * @param userId the user ID
6629             * @param status the status
6630             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6631             * @return the previous, current, and next bookmarks entry
6632             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
6633             * @throws SystemException if a system exception occurred
6634             */
6635            @Override
6636            public BookmarksEntry[] filterFindByG_U_S_PrevAndNext(long entryId,
6637                    long groupId, long userId, int status,
6638                    OrderByComparator orderByComparator)
6639                    throws NoSuchEntryException, SystemException {
6640                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6641                            return findByG_U_S_PrevAndNext(entryId, groupId, userId, status,
6642                                    orderByComparator);
6643                    }
6644    
6645                    BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
6646    
6647                    Session session = null;
6648    
6649                    try {
6650                            session = openSession();
6651    
6652                            BookmarksEntry[] array = new BookmarksEntryImpl[3];
6653    
6654                            array[0] = filterGetByG_U_S_PrevAndNext(session, bookmarksEntry,
6655                                            groupId, userId, status, orderByComparator, true);
6656    
6657                            array[1] = bookmarksEntry;
6658    
6659                            array[2] = filterGetByG_U_S_PrevAndNext(session, bookmarksEntry,
6660                                            groupId, userId, status, orderByComparator, false);
6661    
6662                            return array;
6663                    }
6664                    catch (Exception e) {
6665                            throw processException(e);
6666                    }
6667                    finally {
6668                            closeSession(session);
6669                    }
6670            }
6671    
6672            protected BookmarksEntry filterGetByG_U_S_PrevAndNext(Session session,
6673                    BookmarksEntry bookmarksEntry, long groupId, long userId, int status,
6674                    OrderByComparator orderByComparator, boolean previous) {
6675                    StringBundler query = null;
6676    
6677                    if (orderByComparator != null) {
6678                            query = new StringBundler(6 +
6679                                            (orderByComparator.getOrderByFields().length * 6));
6680                    }
6681                    else {
6682                            query = new StringBundler(3);
6683                    }
6684    
6685                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
6686    
6687                    query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
6688    
6689                    query.append(_FINDER_COLUMN_G_U_S_USERID_2);
6690    
6691                    query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
6692    
6693                    if (orderByComparator != null) {
6694                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6695    
6696                            if (orderByConditionFields.length > 0) {
6697                                    query.append(WHERE_AND);
6698                            }
6699    
6700                            for (int i = 0; i < orderByConditionFields.length; i++) {
6701                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6702                                    query.append(orderByConditionFields[i]);
6703    
6704                                    if ((i + 1) < orderByConditionFields.length) {
6705                                            if (orderByComparator.isAscending() ^ previous) {
6706                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6707                                            }
6708                                            else {
6709                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6710                                            }
6711                                    }
6712                                    else {
6713                                            if (orderByComparator.isAscending() ^ previous) {
6714                                                    query.append(WHERE_GREATER_THAN);
6715                                            }
6716                                            else {
6717                                                    query.append(WHERE_LESSER_THAN);
6718                                            }
6719                                    }
6720                            }
6721    
6722                            query.append(ORDER_BY_CLAUSE);
6723    
6724                            String[] orderByFields = orderByComparator.getOrderByFields();
6725    
6726                            for (int i = 0; i < orderByFields.length; i++) {
6727                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6728                                    query.append(orderByFields[i]);
6729    
6730                                    if ((i + 1) < orderByFields.length) {
6731                                            if (orderByComparator.isAscending() ^ previous) {
6732                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6733                                            }
6734                                            else {
6735                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6736                                            }
6737                                    }
6738                                    else {
6739                                            if (orderByComparator.isAscending() ^ previous) {
6740                                                    query.append(ORDER_BY_ASC);
6741                                            }
6742                                            else {
6743                                                    query.append(ORDER_BY_DESC);
6744                                            }
6745                                    }
6746                            }
6747                    }
6748                    else {
6749                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
6750                    }
6751    
6752                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6753                                    BookmarksEntry.class.getName(),
6754                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
6755                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
6756    
6757                    Query q = session.createQuery(sql);
6758    
6759                    q.setFirstResult(0);
6760                    q.setMaxResults(2);
6761    
6762                    QueryPos qPos = QueryPos.getInstance(q);
6763    
6764                    qPos.add(groupId);
6765    
6766                    qPos.add(userId);
6767    
6768                    qPos.add(status);
6769    
6770                    if (orderByComparator != null) {
6771                            Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry);
6772    
6773                            for (Object value : values) {
6774                                    qPos.add(value);
6775                            }
6776                    }
6777    
6778                    List<BookmarksEntry> list = q.list();
6779    
6780                    if (list.size() == 2) {
6781                            return list.get(1);
6782                    }
6783                    else {
6784                            return null;
6785                    }
6786            }
6787    
6788            /**
6789             * Removes all the bookmarks entries where groupId = &#63; and userId = &#63; and status = &#63; from the database.
6790             *
6791             * @param groupId the group ID
6792             * @param userId the user ID
6793             * @param status the status
6794             * @throws SystemException if a system exception occurred
6795             */
6796            @Override
6797            public void removeByG_U_S(long groupId, long userId, int status)
6798                    throws SystemException {
6799                    for (BookmarksEntry bookmarksEntry : findByG_U_S(groupId, userId,
6800                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
6801                            remove(bookmarksEntry);
6802                    }
6803            }
6804    
6805            /**
6806             * Returns the number of bookmarks entries where groupId = &#63; and userId = &#63; and status = &#63;.
6807             *
6808             * @param groupId the group ID
6809             * @param userId the user ID
6810             * @param status the status
6811             * @return the number of matching bookmarks entries
6812             * @throws SystemException if a system exception occurred
6813             */
6814            @Override
6815            public int countByG_U_S(long groupId, long userId, int status)
6816                    throws SystemException {
6817                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_U_S;
6818    
6819                    Object[] finderArgs = new Object[] { groupId, userId, status };
6820    
6821                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
6822                                    this);
6823    
6824                    if (count == null) {
6825                            StringBundler query = new StringBundler(4);
6826    
6827                            query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
6828    
6829                            query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
6830    
6831                            query.append(_FINDER_COLUMN_G_U_S_USERID_2);
6832    
6833                            query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
6834    
6835                            String sql = query.toString();
6836    
6837                            Session session = null;
6838    
6839                            try {
6840                                    session = openSession();
6841    
6842                                    Query q = session.createQuery(sql);
6843    
6844                                    QueryPos qPos = QueryPos.getInstance(q);
6845    
6846                                    qPos.add(groupId);
6847    
6848                                    qPos.add(userId);
6849    
6850                                    qPos.add(status);
6851    
6852                                    count = (Long)q.uniqueResult();
6853    
6854                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
6855                            }
6856                            catch (Exception e) {
6857                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6858    
6859                                    throw processException(e);
6860                            }
6861                            finally {
6862                                    closeSession(session);
6863                            }
6864                    }
6865    
6866                    return count.intValue();
6867            }
6868    
6869            /**
6870             * Returns the number of bookmarks entries that the user has permission to view where groupId = &#63; and userId = &#63; and status = &#63;.
6871             *
6872             * @param groupId the group ID
6873             * @param userId the user ID
6874             * @param status the status
6875             * @return the number of matching bookmarks entries that the user has permission to view
6876             * @throws SystemException if a system exception occurred
6877             */
6878            @Override
6879            public int filterCountByG_U_S(long groupId, long userId, int status)
6880                    throws SystemException {
6881                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6882                            return countByG_U_S(groupId, userId, status);
6883                    }
6884    
6885                    StringBundler query = new StringBundler(4);
6886    
6887                    query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
6888    
6889                    query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
6890    
6891                    query.append(_FINDER_COLUMN_G_U_S_USERID_2);
6892    
6893                    query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
6894    
6895                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6896                                    BookmarksEntry.class.getName(),
6897                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
6898                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
6899    
6900                    Session session = null;
6901    
6902                    try {
6903                            session = openSession();
6904    
6905                            Query q = session.createQuery(sql);
6906    
6907                            QueryPos qPos = QueryPos.getInstance(q);
6908    
6909                            qPos.add(groupId);
6910    
6911                            qPos.add(userId);
6912    
6913                            qPos.add(status);
6914    
6915                            Long count = (Long)q.uniqueResult();
6916    
6917                            return count.intValue();
6918                    }
6919                    catch (Exception e) {
6920                            throw processException(e);
6921                    }
6922                    finally {
6923                            closeSession(session);
6924                    }
6925            }
6926    
6927            private static final String _FINDER_COLUMN_G_U_S_GROUPID_2 = "bookmarksEntry.groupId = ? AND ";
6928            private static final String _FINDER_COLUMN_G_U_S_USERID_2 = "bookmarksEntry.userId = ? AND ";
6929            private static final String _FINDER_COLUMN_G_U_S_STATUS_2 = "bookmarksEntry.status = ?";
6930            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_NOTS = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
6931                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
6932                            BookmarksEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
6933                            "findByG_U_NotS",
6934                            new String[] {
6935                                    Long.class.getName(), Long.class.getName(),
6936                                    Integer.class.getName(),
6937                                    
6938                            Integer.class.getName(), Integer.class.getName(),
6939                                    OrderByComparator.class.getName()
6940                            });
6941            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_NOTS =
6942                    new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
6943                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
6944                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_U_NotS",
6945                            new String[] {
6946                                    Long.class.getName(), Long.class.getName(),
6947                                    Integer.class.getName()
6948                            });
6949    
6950            /**
6951             * Returns all the bookmarks entries where groupId = &#63; and userId = &#63; and status &ne; &#63;.
6952             *
6953             * @param groupId the group ID
6954             * @param userId the user ID
6955             * @param status the status
6956             * @return the matching bookmarks entries
6957             * @throws SystemException if a system exception occurred
6958             */
6959            @Override
6960            public List<BookmarksEntry> findByG_U_NotS(long groupId, long userId,
6961                    int status) throws SystemException {
6962                    return findByG_U_NotS(groupId, userId, status, QueryUtil.ALL_POS,
6963                            QueryUtil.ALL_POS, null);
6964            }
6965    
6966            /**
6967             * Returns a range of all the bookmarks entries where groupId = &#63; and userId = &#63; and status &ne; &#63;.
6968             *
6969             * <p>
6970             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
6971             * </p>
6972             *
6973             * @param groupId the group ID
6974             * @param userId the user ID
6975             * @param status the status
6976             * @param start the lower bound of the range of bookmarks entries
6977             * @param end the upper bound of the range of bookmarks entries (not inclusive)
6978             * @return the range of matching bookmarks entries
6979             * @throws SystemException if a system exception occurred
6980             */
6981            @Override
6982            public List<BookmarksEntry> findByG_U_NotS(long groupId, long userId,
6983                    int status, int start, int end) throws SystemException {
6984                    return findByG_U_NotS(groupId, userId, status, start, end, null);
6985            }
6986    
6987            /**
6988             * Returns an ordered range of all the bookmarks entries where groupId = &#63; and userId = &#63; and status &ne; &#63;.
6989             *
6990             * <p>
6991             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
6992             * </p>
6993             *
6994             * @param groupId the group ID
6995             * @param userId the user ID
6996             * @param status the status
6997             * @param start the lower bound of the range of bookmarks entries
6998             * @param end the upper bound of the range of bookmarks entries (not inclusive)
6999             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7000             * @return the ordered range of matching bookmarks entries
7001             * @throws SystemException if a system exception occurred
7002             */
7003            @Override
7004            public List<BookmarksEntry> findByG_U_NotS(long groupId, long userId,
7005                    int status, int start, int end, OrderByComparator orderByComparator)
7006                    throws SystemException {
7007                    boolean pagination = true;
7008                    FinderPath finderPath = null;
7009                    Object[] finderArgs = null;
7010    
7011                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_NOTS;
7012                    finderArgs = new Object[] {
7013                                    groupId, userId, status,
7014                                    
7015                                    start, end, orderByComparator
7016                            };
7017    
7018                    List<BookmarksEntry> list = (List<BookmarksEntry>)FinderCacheUtil.getResult(finderPath,
7019                                    finderArgs, this);
7020    
7021                    if ((list != null) && !list.isEmpty()) {
7022                            for (BookmarksEntry bookmarksEntry : list) {
7023                                    if ((groupId != bookmarksEntry.getGroupId()) ||
7024                                                    (userId != bookmarksEntry.getUserId()) ||
7025                                                    (status != bookmarksEntry.getStatus())) {
7026                                            list = null;
7027    
7028                                            break;
7029                                    }
7030                            }
7031                    }
7032    
7033                    if (list == null) {
7034                            StringBundler query = null;
7035    
7036                            if (orderByComparator != null) {
7037                                    query = new StringBundler(5 +
7038                                                    (orderByComparator.getOrderByFields().length * 3));
7039                            }
7040                            else {
7041                                    query = new StringBundler(5);
7042                            }
7043    
7044                            query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
7045    
7046                            query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
7047    
7048                            query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
7049    
7050                            query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
7051    
7052                            if (orderByComparator != null) {
7053                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7054                                            orderByComparator);
7055                            }
7056                            else
7057                             if (pagination) {
7058                                    query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
7059                            }
7060    
7061                            String sql = query.toString();
7062    
7063                            Session session = null;
7064    
7065                            try {
7066                                    session = openSession();
7067    
7068                                    Query q = session.createQuery(sql);
7069    
7070                                    QueryPos qPos = QueryPos.getInstance(q);
7071    
7072                                    qPos.add(groupId);
7073    
7074                                    qPos.add(userId);
7075    
7076                                    qPos.add(status);
7077    
7078                                    if (!pagination) {
7079                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
7080                                                            getDialect(), start, end, false);
7081    
7082                                            Collections.sort(list);
7083    
7084                                            list = new UnmodifiableList<BookmarksEntry>(list);
7085                                    }
7086                                    else {
7087                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
7088                                                            getDialect(), start, end);
7089                                    }
7090    
7091                                    cacheResult(list);
7092    
7093                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
7094                            }
7095                            catch (Exception e) {
7096                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
7097    
7098                                    throw processException(e);
7099                            }
7100                            finally {
7101                                    closeSession(session);
7102                            }
7103                    }
7104    
7105                    return list;
7106            }
7107    
7108            /**
7109             * Returns the first bookmarks entry in the ordered set where groupId = &#63; and userId = &#63; and status &ne; &#63;.
7110             *
7111             * @param groupId the group ID
7112             * @param userId the user ID
7113             * @param status the status
7114             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7115             * @return the first matching bookmarks entry
7116             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
7117             * @throws SystemException if a system exception occurred
7118             */
7119            @Override
7120            public BookmarksEntry findByG_U_NotS_First(long groupId, long userId,
7121                    int status, OrderByComparator orderByComparator)
7122                    throws NoSuchEntryException, SystemException {
7123                    BookmarksEntry bookmarksEntry = fetchByG_U_NotS_First(groupId, userId,
7124                                    status, orderByComparator);
7125    
7126                    if (bookmarksEntry != null) {
7127                            return bookmarksEntry;
7128                    }
7129    
7130                    StringBundler msg = new StringBundler(8);
7131    
7132                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7133    
7134                    msg.append("groupId=");
7135                    msg.append(groupId);
7136    
7137                    msg.append(", userId=");
7138                    msg.append(userId);
7139    
7140                    msg.append(", status=");
7141                    msg.append(status);
7142    
7143                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7144    
7145                    throw new NoSuchEntryException(msg.toString());
7146            }
7147    
7148            /**
7149             * Returns the first bookmarks entry in the ordered set where groupId = &#63; and userId = &#63; and status &ne; &#63;.
7150             *
7151             * @param groupId the group ID
7152             * @param userId the user ID
7153             * @param status the status
7154             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7155             * @return the first matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
7156             * @throws SystemException if a system exception occurred
7157             */
7158            @Override
7159            public BookmarksEntry fetchByG_U_NotS_First(long groupId, long userId,
7160                    int status, OrderByComparator orderByComparator)
7161                    throws SystemException {
7162                    List<BookmarksEntry> list = findByG_U_NotS(groupId, userId, status, 0,
7163                                    1, orderByComparator);
7164    
7165                    if (!list.isEmpty()) {
7166                            return list.get(0);
7167                    }
7168    
7169                    return null;
7170            }
7171    
7172            /**
7173             * Returns the last bookmarks entry in the ordered set where groupId = &#63; and userId = &#63; and status &ne; &#63;.
7174             *
7175             * @param groupId the group ID
7176             * @param userId the user ID
7177             * @param status the status
7178             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7179             * @return the last matching bookmarks entry
7180             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
7181             * @throws SystemException if a system exception occurred
7182             */
7183            @Override
7184            public BookmarksEntry findByG_U_NotS_Last(long groupId, long userId,
7185                    int status, OrderByComparator orderByComparator)
7186                    throws NoSuchEntryException, SystemException {
7187                    BookmarksEntry bookmarksEntry = fetchByG_U_NotS_Last(groupId, userId,
7188                                    status, orderByComparator);
7189    
7190                    if (bookmarksEntry != null) {
7191                            return bookmarksEntry;
7192                    }
7193    
7194                    StringBundler msg = new StringBundler(8);
7195    
7196                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7197    
7198                    msg.append("groupId=");
7199                    msg.append(groupId);
7200    
7201                    msg.append(", userId=");
7202                    msg.append(userId);
7203    
7204                    msg.append(", status=");
7205                    msg.append(status);
7206    
7207                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7208    
7209                    throw new NoSuchEntryException(msg.toString());
7210            }
7211    
7212            /**
7213             * Returns the last bookmarks entry in the ordered set where groupId = &#63; and userId = &#63; and status &ne; &#63;.
7214             *
7215             * @param groupId the group ID
7216             * @param userId the user ID
7217             * @param status the status
7218             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7219             * @return the last matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
7220             * @throws SystemException if a system exception occurred
7221             */
7222            @Override
7223            public BookmarksEntry fetchByG_U_NotS_Last(long groupId, long userId,
7224                    int status, OrderByComparator orderByComparator)
7225                    throws SystemException {
7226                    int count = countByG_U_NotS(groupId, userId, status);
7227    
7228                    if (count == 0) {
7229                            return null;
7230                    }
7231    
7232                    List<BookmarksEntry> list = findByG_U_NotS(groupId, userId, status,
7233                                    count - 1, count, orderByComparator);
7234    
7235                    if (!list.isEmpty()) {
7236                            return list.get(0);
7237                    }
7238    
7239                    return null;
7240            }
7241    
7242            /**
7243             * 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;.
7244             *
7245             * @param entryId the primary key of the current bookmarks entry
7246             * @param groupId the group ID
7247             * @param userId the user ID
7248             * @param status the status
7249             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7250             * @return the previous, current, and next bookmarks entry
7251             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
7252             * @throws SystemException if a system exception occurred
7253             */
7254            @Override
7255            public BookmarksEntry[] findByG_U_NotS_PrevAndNext(long entryId,
7256                    long groupId, long userId, int status,
7257                    OrderByComparator orderByComparator)
7258                    throws NoSuchEntryException, SystemException {
7259                    BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
7260    
7261                    Session session = null;
7262    
7263                    try {
7264                            session = openSession();
7265    
7266                            BookmarksEntry[] array = new BookmarksEntryImpl[3];
7267    
7268                            array[0] = getByG_U_NotS_PrevAndNext(session, bookmarksEntry,
7269                                            groupId, userId, status, orderByComparator, true);
7270    
7271                            array[1] = bookmarksEntry;
7272    
7273                            array[2] = getByG_U_NotS_PrevAndNext(session, bookmarksEntry,
7274                                            groupId, userId, status, orderByComparator, false);
7275    
7276                            return array;
7277                    }
7278                    catch (Exception e) {
7279                            throw processException(e);
7280                    }
7281                    finally {
7282                            closeSession(session);
7283                    }
7284            }
7285    
7286            protected BookmarksEntry getByG_U_NotS_PrevAndNext(Session session,
7287                    BookmarksEntry bookmarksEntry, long groupId, long userId, int status,
7288                    OrderByComparator orderByComparator, boolean previous) {
7289                    StringBundler query = null;
7290    
7291                    if (orderByComparator != null) {
7292                            query = new StringBundler(6 +
7293                                            (orderByComparator.getOrderByFields().length * 6));
7294                    }
7295                    else {
7296                            query = new StringBundler(3);
7297                    }
7298    
7299                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
7300    
7301                    query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
7302    
7303                    query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
7304    
7305                    query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
7306    
7307                    if (orderByComparator != null) {
7308                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7309    
7310                            if (orderByConditionFields.length > 0) {
7311                                    query.append(WHERE_AND);
7312                            }
7313    
7314                            for (int i = 0; i < orderByConditionFields.length; i++) {
7315                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7316                                    query.append(orderByConditionFields[i]);
7317    
7318                                    if ((i + 1) < orderByConditionFields.length) {
7319                                            if (orderByComparator.isAscending() ^ previous) {
7320                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7321                                            }
7322                                            else {
7323                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7324                                            }
7325                                    }
7326                                    else {
7327                                            if (orderByComparator.isAscending() ^ previous) {
7328                                                    query.append(WHERE_GREATER_THAN);
7329                                            }
7330                                            else {
7331                                                    query.append(WHERE_LESSER_THAN);
7332                                            }
7333                                    }
7334                            }
7335    
7336                            query.append(ORDER_BY_CLAUSE);
7337    
7338                            String[] orderByFields = orderByComparator.getOrderByFields();
7339    
7340                            for (int i = 0; i < orderByFields.length; i++) {
7341                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7342                                    query.append(orderByFields[i]);
7343    
7344                                    if ((i + 1) < orderByFields.length) {
7345                                            if (orderByComparator.isAscending() ^ previous) {
7346                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7347                                            }
7348                                            else {
7349                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7350                                            }
7351                                    }
7352                                    else {
7353                                            if (orderByComparator.isAscending() ^ previous) {
7354                                                    query.append(ORDER_BY_ASC);
7355                                            }
7356                                            else {
7357                                                    query.append(ORDER_BY_DESC);
7358                                            }
7359                                    }
7360                            }
7361                    }
7362                    else {
7363                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
7364                    }
7365    
7366                    String sql = query.toString();
7367    
7368                    Query q = session.createQuery(sql);
7369    
7370                    q.setFirstResult(0);
7371                    q.setMaxResults(2);
7372    
7373                    QueryPos qPos = QueryPos.getInstance(q);
7374    
7375                    qPos.add(groupId);
7376    
7377                    qPos.add(userId);
7378    
7379                    qPos.add(status);
7380    
7381                    if (orderByComparator != null) {
7382                            Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry);
7383    
7384                            for (Object value : values) {
7385                                    qPos.add(value);
7386                            }
7387                    }
7388    
7389                    List<BookmarksEntry> list = q.list();
7390    
7391                    if (list.size() == 2) {
7392                            return list.get(1);
7393                    }
7394                    else {
7395                            return null;
7396                    }
7397            }
7398    
7399            /**
7400             * Returns all the bookmarks entries that the user has permission to view where groupId = &#63; and userId = &#63; and status &ne; &#63;.
7401             *
7402             * @param groupId the group ID
7403             * @param userId the user ID
7404             * @param status the status
7405             * @return the matching bookmarks entries that the user has permission to view
7406             * @throws SystemException if a system exception occurred
7407             */
7408            @Override
7409            public List<BookmarksEntry> filterFindByG_U_NotS(long groupId, long userId,
7410                    int status) throws SystemException {
7411                    return filterFindByG_U_NotS(groupId, userId, status, QueryUtil.ALL_POS,
7412                            QueryUtil.ALL_POS, null);
7413            }
7414    
7415            /**
7416             * 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;.
7417             *
7418             * <p>
7419             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
7420             * </p>
7421             *
7422             * @param groupId the group ID
7423             * @param userId the user ID
7424             * @param status the status
7425             * @param start the lower bound of the range of bookmarks entries
7426             * @param end the upper bound of the range of bookmarks entries (not inclusive)
7427             * @return the range of matching bookmarks entries that the user has permission to view
7428             * @throws SystemException if a system exception occurred
7429             */
7430            @Override
7431            public List<BookmarksEntry> filterFindByG_U_NotS(long groupId, long userId,
7432                    int status, int start, int end) throws SystemException {
7433                    return filterFindByG_U_NotS(groupId, userId, status, start, end, null);
7434            }
7435    
7436            /**
7437             * 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;.
7438             *
7439             * <p>
7440             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
7441             * </p>
7442             *
7443             * @param groupId the group ID
7444             * @param userId the user ID
7445             * @param status the status
7446             * @param start the lower bound of the range of bookmarks entries
7447             * @param end the upper bound of the range of bookmarks entries (not inclusive)
7448             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7449             * @return the ordered range of matching bookmarks entries that the user has permission to view
7450             * @throws SystemException if a system exception occurred
7451             */
7452            @Override
7453            public List<BookmarksEntry> filterFindByG_U_NotS(long groupId, long userId,
7454                    int status, int start, int end, OrderByComparator orderByComparator)
7455                    throws SystemException {
7456                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7457                            return findByG_U_NotS(groupId, userId, status, start, end,
7458                                    orderByComparator);
7459                    }
7460    
7461                    StringBundler query = null;
7462    
7463                    if (orderByComparator != null) {
7464                            query = new StringBundler(5 +
7465                                            (orderByComparator.getOrderByFields().length * 3));
7466                    }
7467                    else {
7468                            query = new StringBundler(5);
7469                    }
7470    
7471                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
7472    
7473                    query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
7474    
7475                    query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
7476    
7477                    query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
7478    
7479                    if (orderByComparator != null) {
7480                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7481                                    orderByComparator);
7482                    }
7483                    else {
7484                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
7485                    }
7486    
7487                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7488                                    BookmarksEntry.class.getName(),
7489                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
7490                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
7491    
7492                    Session session = null;
7493    
7494                    try {
7495                            session = openSession();
7496    
7497                            Query q = session.createQuery(sql);
7498    
7499                            QueryPos qPos = QueryPos.getInstance(q);
7500    
7501                            qPos.add(groupId);
7502    
7503                            qPos.add(userId);
7504    
7505                            qPos.add(status);
7506    
7507                            return (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start,
7508                                    end);
7509                    }
7510                    catch (Exception e) {
7511                            throw processException(e);
7512                    }
7513                    finally {
7514                            closeSession(session);
7515                    }
7516            }
7517    
7518            /**
7519             * 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;.
7520             *
7521             * @param entryId the primary key of the current bookmarks entry
7522             * @param groupId the group ID
7523             * @param userId the user ID
7524             * @param status the status
7525             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7526             * @return the previous, current, and next bookmarks entry
7527             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
7528             * @throws SystemException if a system exception occurred
7529             */
7530            @Override
7531            public BookmarksEntry[] filterFindByG_U_NotS_PrevAndNext(long entryId,
7532                    long groupId, long userId, int status,
7533                    OrderByComparator orderByComparator)
7534                    throws NoSuchEntryException, SystemException {
7535                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7536                            return findByG_U_NotS_PrevAndNext(entryId, groupId, userId, status,
7537                                    orderByComparator);
7538                    }
7539    
7540                    BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
7541    
7542                    Session session = null;
7543    
7544                    try {
7545                            session = openSession();
7546    
7547                            BookmarksEntry[] array = new BookmarksEntryImpl[3];
7548    
7549                            array[0] = filterGetByG_U_NotS_PrevAndNext(session, bookmarksEntry,
7550                                            groupId, userId, status, orderByComparator, true);
7551    
7552                            array[1] = bookmarksEntry;
7553    
7554                            array[2] = filterGetByG_U_NotS_PrevAndNext(session, bookmarksEntry,
7555                                            groupId, userId, status, orderByComparator, false);
7556    
7557                            return array;
7558                    }
7559                    catch (Exception e) {
7560                            throw processException(e);
7561                    }
7562                    finally {
7563                            closeSession(session);
7564                    }
7565            }
7566    
7567            protected BookmarksEntry filterGetByG_U_NotS_PrevAndNext(Session session,
7568                    BookmarksEntry bookmarksEntry, long groupId, long userId, int status,
7569                    OrderByComparator orderByComparator, boolean previous) {
7570                    StringBundler query = null;
7571    
7572                    if (orderByComparator != null) {
7573                            query = new StringBundler(6 +
7574                                            (orderByComparator.getOrderByFields().length * 6));
7575                    }
7576                    else {
7577                            query = new StringBundler(3);
7578                    }
7579    
7580                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
7581    
7582                    query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
7583    
7584                    query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
7585    
7586                    query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
7587    
7588                    if (orderByComparator != null) {
7589                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7590    
7591                            if (orderByConditionFields.length > 0) {
7592                                    query.append(WHERE_AND);
7593                            }
7594    
7595                            for (int i = 0; i < orderByConditionFields.length; i++) {
7596                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7597                                    query.append(orderByConditionFields[i]);
7598    
7599                                    if ((i + 1) < orderByConditionFields.length) {
7600                                            if (orderByComparator.isAscending() ^ previous) {
7601                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7602                                            }
7603                                            else {
7604                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7605                                            }
7606                                    }
7607                                    else {
7608                                            if (orderByComparator.isAscending() ^ previous) {
7609                                                    query.append(WHERE_GREATER_THAN);
7610                                            }
7611                                            else {
7612                                                    query.append(WHERE_LESSER_THAN);
7613                                            }
7614                                    }
7615                            }
7616    
7617                            query.append(ORDER_BY_CLAUSE);
7618    
7619                            String[] orderByFields = orderByComparator.getOrderByFields();
7620    
7621                            for (int i = 0; i < orderByFields.length; i++) {
7622                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7623                                    query.append(orderByFields[i]);
7624    
7625                                    if ((i + 1) < orderByFields.length) {
7626                                            if (orderByComparator.isAscending() ^ previous) {
7627                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7628                                            }
7629                                            else {
7630                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7631                                            }
7632                                    }
7633                                    else {
7634                                            if (orderByComparator.isAscending() ^ previous) {
7635                                                    query.append(ORDER_BY_ASC);
7636                                            }
7637                                            else {
7638                                                    query.append(ORDER_BY_DESC);
7639                                            }
7640                                    }
7641                            }
7642                    }
7643                    else {
7644                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
7645                    }
7646    
7647                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7648                                    BookmarksEntry.class.getName(),
7649                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
7650                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
7651    
7652                    Query q = session.createQuery(sql);
7653    
7654                    q.setFirstResult(0);
7655                    q.setMaxResults(2);
7656    
7657                    QueryPos qPos = QueryPos.getInstance(q);
7658    
7659                    qPos.add(groupId);
7660    
7661                    qPos.add(userId);
7662    
7663                    qPos.add(status);
7664    
7665                    if (orderByComparator != null) {
7666                            Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry);
7667    
7668                            for (Object value : values) {
7669                                    qPos.add(value);
7670                            }
7671                    }
7672    
7673                    List<BookmarksEntry> list = q.list();
7674    
7675                    if (list.size() == 2) {
7676                            return list.get(1);
7677                    }
7678                    else {
7679                            return null;
7680                    }
7681            }
7682    
7683            /**
7684             * Removes all the bookmarks entries where groupId = &#63; and userId = &#63; and status &ne; &#63; from the database.
7685             *
7686             * @param groupId the group ID
7687             * @param userId the user ID
7688             * @param status the status
7689             * @throws SystemException if a system exception occurred
7690             */
7691            @Override
7692            public void removeByG_U_NotS(long groupId, long userId, int status)
7693                    throws SystemException {
7694                    for (BookmarksEntry bookmarksEntry : findByG_U_NotS(groupId, userId,
7695                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
7696                            remove(bookmarksEntry);
7697                    }
7698            }
7699    
7700            /**
7701             * Returns the number of bookmarks entries where groupId = &#63; and userId = &#63; and status &ne; &#63;.
7702             *
7703             * @param groupId the group ID
7704             * @param userId the user ID
7705             * @param status the status
7706             * @return the number of matching bookmarks entries
7707             * @throws SystemException if a system exception occurred
7708             */
7709            @Override
7710            public int countByG_U_NotS(long groupId, long userId, int status)
7711                    throws SystemException {
7712                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_NOTS;
7713    
7714                    Object[] finderArgs = new Object[] { groupId, userId, status };
7715    
7716                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
7717                                    this);
7718    
7719                    if (count == null) {
7720                            StringBundler query = new StringBundler(4);
7721    
7722                            query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
7723    
7724                            query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
7725    
7726                            query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
7727    
7728                            query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
7729    
7730                            String sql = query.toString();
7731    
7732                            Session session = null;
7733    
7734                            try {
7735                                    session = openSession();
7736    
7737                                    Query q = session.createQuery(sql);
7738    
7739                                    QueryPos qPos = QueryPos.getInstance(q);
7740    
7741                                    qPos.add(groupId);
7742    
7743                                    qPos.add(userId);
7744    
7745                                    qPos.add(status);
7746    
7747                                    count = (Long)q.uniqueResult();
7748    
7749                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
7750                            }
7751                            catch (Exception e) {
7752                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
7753    
7754                                    throw processException(e);
7755                            }
7756                            finally {
7757                                    closeSession(session);
7758                            }
7759                    }
7760    
7761                    return count.intValue();
7762            }
7763    
7764            /**
7765             * Returns the number of bookmarks entries that the user has permission to view where groupId = &#63; and userId = &#63; and status &ne; &#63;.
7766             *
7767             * @param groupId the group ID
7768             * @param userId the user ID
7769             * @param status the status
7770             * @return the number of matching bookmarks entries that the user has permission to view
7771             * @throws SystemException if a system exception occurred
7772             */
7773            @Override
7774            public int filterCountByG_U_NotS(long groupId, long userId, int status)
7775                    throws SystemException {
7776                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7777                            return countByG_U_NotS(groupId, userId, status);
7778                    }
7779    
7780                    StringBundler query = new StringBundler(4);
7781    
7782                    query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
7783    
7784                    query.append(_FINDER_COLUMN_G_U_NOTS_GROUPID_2);
7785    
7786                    query.append(_FINDER_COLUMN_G_U_NOTS_USERID_2);
7787    
7788                    query.append(_FINDER_COLUMN_G_U_NOTS_STATUS_2);
7789    
7790                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7791                                    BookmarksEntry.class.getName(),
7792                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
7793                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
7794    
7795                    Session session = null;
7796    
7797                    try {
7798                            session = openSession();
7799    
7800                            Query q = session.createQuery(sql);
7801    
7802                            QueryPos qPos = QueryPos.getInstance(q);
7803    
7804                            qPos.add(groupId);
7805    
7806                            qPos.add(userId);
7807    
7808                            qPos.add(status);
7809    
7810                            Long count = (Long)q.uniqueResult();
7811    
7812                            return count.intValue();
7813                    }
7814                    catch (Exception e) {
7815                            throw processException(e);
7816                    }
7817                    finally {
7818                            closeSession(session);
7819                    }
7820            }
7821    
7822            private static final String _FINDER_COLUMN_G_U_NOTS_GROUPID_2 = "bookmarksEntry.groupId = ? AND ";
7823            private static final String _FINDER_COLUMN_G_U_NOTS_USERID_2 = "bookmarksEntry.userId = ? AND ";
7824            private static final String _FINDER_COLUMN_G_U_NOTS_STATUS_2 = "bookmarksEntry.status != ?";
7825            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_S = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
7826                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
7827                            BookmarksEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
7828                            "findByG_F_S",
7829                            new String[] {
7830                                    Long.class.getName(), Long.class.getName(),
7831                                    Integer.class.getName(),
7832                                    
7833                            Integer.class.getName(), Integer.class.getName(),
7834                                    OrderByComparator.class.getName()
7835                            });
7836            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_S = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
7837                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
7838                            BookmarksEntryImpl.class,
7839                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_F_S",
7840                            new String[] {
7841                                    Long.class.getName(), Long.class.getName(),
7842                                    Integer.class.getName()
7843                            },
7844                            BookmarksEntryModelImpl.GROUPID_COLUMN_BITMASK |
7845                            BookmarksEntryModelImpl.FOLDERID_COLUMN_BITMASK |
7846                            BookmarksEntryModelImpl.STATUS_COLUMN_BITMASK |
7847                            BookmarksEntryModelImpl.NAME_COLUMN_BITMASK);
7848            public static final FinderPath FINDER_PATH_COUNT_BY_G_F_S = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
7849                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
7850                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_F_S",
7851                            new String[] {
7852                                    Long.class.getName(), Long.class.getName(),
7853                                    Integer.class.getName()
7854                            });
7855            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_S = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
7856                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
7857                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_F_S",
7858                            new String[] {
7859                                    Long.class.getName(), Long.class.getName(),
7860                                    Integer.class.getName()
7861                            });
7862    
7863            /**
7864             * Returns all the bookmarks entries where groupId = &#63; and folderId = &#63; and status = &#63;.
7865             *
7866             * @param groupId the group ID
7867             * @param folderId the folder ID
7868             * @param status the status
7869             * @return the matching bookmarks entries
7870             * @throws SystemException if a system exception occurred
7871             */
7872            @Override
7873            public List<BookmarksEntry> findByG_F_S(long groupId, long folderId,
7874                    int status) throws SystemException {
7875                    return findByG_F_S(groupId, folderId, status, QueryUtil.ALL_POS,
7876                            QueryUtil.ALL_POS, null);
7877            }
7878    
7879            /**
7880             * Returns a range of all the bookmarks entries where groupId = &#63; and folderId = &#63; and status = &#63;.
7881             *
7882             * <p>
7883             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
7884             * </p>
7885             *
7886             * @param groupId the group ID
7887             * @param folderId the folder ID
7888             * @param status the status
7889             * @param start the lower bound of the range of bookmarks entries
7890             * @param end the upper bound of the range of bookmarks entries (not inclusive)
7891             * @return the range of matching bookmarks entries
7892             * @throws SystemException if a system exception occurred
7893             */
7894            @Override
7895            public List<BookmarksEntry> findByG_F_S(long groupId, long folderId,
7896                    int status, int start, int end) throws SystemException {
7897                    return findByG_F_S(groupId, folderId, status, start, end, null);
7898            }
7899    
7900            /**
7901             * Returns an ordered range of all the bookmarks entries where groupId = &#63; and folderId = &#63; and status = &#63;.
7902             *
7903             * <p>
7904             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
7905             * </p>
7906             *
7907             * @param groupId the group ID
7908             * @param folderId the folder ID
7909             * @param status the status
7910             * @param start the lower bound of the range of bookmarks entries
7911             * @param end the upper bound of the range of bookmarks entries (not inclusive)
7912             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7913             * @return the ordered range of matching bookmarks entries
7914             * @throws SystemException if a system exception occurred
7915             */
7916            @Override
7917            public List<BookmarksEntry> findByG_F_S(long groupId, long folderId,
7918                    int status, int start, int end, OrderByComparator orderByComparator)
7919                    throws SystemException {
7920                    boolean pagination = true;
7921                    FinderPath finderPath = null;
7922                    Object[] finderArgs = null;
7923    
7924                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
7925                                    (orderByComparator == null)) {
7926                            pagination = false;
7927                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_S;
7928                            finderArgs = new Object[] { groupId, folderId, status };
7929                    }
7930                    else {
7931                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_S;
7932                            finderArgs = new Object[] {
7933                                            groupId, folderId, status,
7934                                            
7935                                            start, end, orderByComparator
7936                                    };
7937                    }
7938    
7939                    List<BookmarksEntry> list = (List<BookmarksEntry>)FinderCacheUtil.getResult(finderPath,
7940                                    finderArgs, this);
7941    
7942                    if ((list != null) && !list.isEmpty()) {
7943                            for (BookmarksEntry bookmarksEntry : list) {
7944                                    if ((groupId != bookmarksEntry.getGroupId()) ||
7945                                                    (folderId != bookmarksEntry.getFolderId()) ||
7946                                                    (status != bookmarksEntry.getStatus())) {
7947                                            list = null;
7948    
7949                                            break;
7950                                    }
7951                            }
7952                    }
7953    
7954                    if (list == null) {
7955                            StringBundler query = null;
7956    
7957                            if (orderByComparator != null) {
7958                                    query = new StringBundler(5 +
7959                                                    (orderByComparator.getOrderByFields().length * 3));
7960                            }
7961                            else {
7962                                    query = new StringBundler(5);
7963                            }
7964    
7965                            query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
7966    
7967                            query.append(_FINDER_COLUMN_G_F_S_GROUPID_2);
7968    
7969                            query.append(_FINDER_COLUMN_G_F_S_FOLDERID_2);
7970    
7971                            query.append(_FINDER_COLUMN_G_F_S_STATUS_2);
7972    
7973                            if (orderByComparator != null) {
7974                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7975                                            orderByComparator);
7976                            }
7977                            else
7978                             if (pagination) {
7979                                    query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
7980                            }
7981    
7982                            String sql = query.toString();
7983    
7984                            Session session = null;
7985    
7986                            try {
7987                                    session = openSession();
7988    
7989                                    Query q = session.createQuery(sql);
7990    
7991                                    QueryPos qPos = QueryPos.getInstance(q);
7992    
7993                                    qPos.add(groupId);
7994    
7995                                    qPos.add(folderId);
7996    
7997                                    qPos.add(status);
7998    
7999                                    if (!pagination) {
8000                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
8001                                                            getDialect(), start, end, false);
8002    
8003                                            Collections.sort(list);
8004    
8005                                            list = new UnmodifiableList<BookmarksEntry>(list);
8006                                    }
8007                                    else {
8008                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
8009                                                            getDialect(), start, end);
8010                                    }
8011    
8012                                    cacheResult(list);
8013    
8014                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
8015                            }
8016                            catch (Exception e) {
8017                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
8018    
8019                                    throw processException(e);
8020                            }
8021                            finally {
8022                                    closeSession(session);
8023                            }
8024                    }
8025    
8026                    return list;
8027            }
8028    
8029            /**
8030             * Returns the first bookmarks entry in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
8031             *
8032             * @param groupId the group ID
8033             * @param folderId the folder ID
8034             * @param status the status
8035             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8036             * @return the first matching bookmarks entry
8037             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
8038             * @throws SystemException if a system exception occurred
8039             */
8040            @Override
8041            public BookmarksEntry findByG_F_S_First(long groupId, long folderId,
8042                    int status, OrderByComparator orderByComparator)
8043                    throws NoSuchEntryException, SystemException {
8044                    BookmarksEntry bookmarksEntry = fetchByG_F_S_First(groupId, folderId,
8045                                    status, orderByComparator);
8046    
8047                    if (bookmarksEntry != null) {
8048                            return bookmarksEntry;
8049                    }
8050    
8051                    StringBundler msg = new StringBundler(8);
8052    
8053                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8054    
8055                    msg.append("groupId=");
8056                    msg.append(groupId);
8057    
8058                    msg.append(", folderId=");
8059                    msg.append(folderId);
8060    
8061                    msg.append(", status=");
8062                    msg.append(status);
8063    
8064                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8065    
8066                    throw new NoSuchEntryException(msg.toString());
8067            }
8068    
8069            /**
8070             * Returns the first bookmarks entry in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
8071             *
8072             * @param groupId the group ID
8073             * @param folderId the folder ID
8074             * @param status the status
8075             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8076             * @return the first matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
8077             * @throws SystemException if a system exception occurred
8078             */
8079            @Override
8080            public BookmarksEntry fetchByG_F_S_First(long groupId, long folderId,
8081                    int status, OrderByComparator orderByComparator)
8082                    throws SystemException {
8083                    List<BookmarksEntry> list = findByG_F_S(groupId, folderId, status, 0,
8084                                    1, orderByComparator);
8085    
8086                    if (!list.isEmpty()) {
8087                            return list.get(0);
8088                    }
8089    
8090                    return null;
8091            }
8092    
8093            /**
8094             * Returns the last bookmarks entry in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
8095             *
8096             * @param groupId the group ID
8097             * @param folderId the folder ID
8098             * @param status the status
8099             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8100             * @return the last matching bookmarks entry
8101             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
8102             * @throws SystemException if a system exception occurred
8103             */
8104            @Override
8105            public BookmarksEntry findByG_F_S_Last(long groupId, long folderId,
8106                    int status, OrderByComparator orderByComparator)
8107                    throws NoSuchEntryException, SystemException {
8108                    BookmarksEntry bookmarksEntry = fetchByG_F_S_Last(groupId, folderId,
8109                                    status, orderByComparator);
8110    
8111                    if (bookmarksEntry != null) {
8112                            return bookmarksEntry;
8113                    }
8114    
8115                    StringBundler msg = new StringBundler(8);
8116    
8117                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
8118    
8119                    msg.append("groupId=");
8120                    msg.append(groupId);
8121    
8122                    msg.append(", folderId=");
8123                    msg.append(folderId);
8124    
8125                    msg.append(", status=");
8126                    msg.append(status);
8127    
8128                    msg.append(StringPool.CLOSE_CURLY_BRACE);
8129    
8130                    throw new NoSuchEntryException(msg.toString());
8131            }
8132    
8133            /**
8134             * Returns the last bookmarks entry in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
8135             *
8136             * @param groupId the group ID
8137             * @param folderId the folder ID
8138             * @param status the status
8139             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8140             * @return the last matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
8141             * @throws SystemException if a system exception occurred
8142             */
8143            @Override
8144            public BookmarksEntry fetchByG_F_S_Last(long groupId, long folderId,
8145                    int status, OrderByComparator orderByComparator)
8146                    throws SystemException {
8147                    int count = countByG_F_S(groupId, folderId, status);
8148    
8149                    if (count == 0) {
8150                            return null;
8151                    }
8152    
8153                    List<BookmarksEntry> list = findByG_F_S(groupId, folderId, status,
8154                                    count - 1, count, orderByComparator);
8155    
8156                    if (!list.isEmpty()) {
8157                            return list.get(0);
8158                    }
8159    
8160                    return null;
8161            }
8162    
8163            /**
8164             * Returns the bookmarks entries before and after the current bookmarks entry in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
8165             *
8166             * @param entryId the primary key of the current bookmarks entry
8167             * @param groupId the group ID
8168             * @param folderId the folder ID
8169             * @param status the status
8170             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8171             * @return the previous, current, and next bookmarks entry
8172             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
8173             * @throws SystemException if a system exception occurred
8174             */
8175            @Override
8176            public BookmarksEntry[] findByG_F_S_PrevAndNext(long entryId, long groupId,
8177                    long folderId, int status, OrderByComparator orderByComparator)
8178                    throws NoSuchEntryException, SystemException {
8179                    BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
8180    
8181                    Session session = null;
8182    
8183                    try {
8184                            session = openSession();
8185    
8186                            BookmarksEntry[] array = new BookmarksEntryImpl[3];
8187    
8188                            array[0] = getByG_F_S_PrevAndNext(session, bookmarksEntry, groupId,
8189                                            folderId, status, orderByComparator, true);
8190    
8191                            array[1] = bookmarksEntry;
8192    
8193                            array[2] = getByG_F_S_PrevAndNext(session, bookmarksEntry, groupId,
8194                                            folderId, status, orderByComparator, false);
8195    
8196                            return array;
8197                    }
8198                    catch (Exception e) {
8199                            throw processException(e);
8200                    }
8201                    finally {
8202                            closeSession(session);
8203                    }
8204            }
8205    
8206            protected BookmarksEntry getByG_F_S_PrevAndNext(Session session,
8207                    BookmarksEntry bookmarksEntry, long groupId, long folderId, int status,
8208                    OrderByComparator orderByComparator, boolean previous) {
8209                    StringBundler query = null;
8210    
8211                    if (orderByComparator != null) {
8212                            query = new StringBundler(6 +
8213                                            (orderByComparator.getOrderByFields().length * 6));
8214                    }
8215                    else {
8216                            query = new StringBundler(3);
8217                    }
8218    
8219                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
8220    
8221                    query.append(_FINDER_COLUMN_G_F_S_GROUPID_2);
8222    
8223                    query.append(_FINDER_COLUMN_G_F_S_FOLDERID_2);
8224    
8225                    query.append(_FINDER_COLUMN_G_F_S_STATUS_2);
8226    
8227                    if (orderByComparator != null) {
8228                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8229    
8230                            if (orderByConditionFields.length > 0) {
8231                                    query.append(WHERE_AND);
8232                            }
8233    
8234                            for (int i = 0; i < orderByConditionFields.length; i++) {
8235                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8236                                    query.append(orderByConditionFields[i]);
8237    
8238                                    if ((i + 1) < orderByConditionFields.length) {
8239                                            if (orderByComparator.isAscending() ^ previous) {
8240                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8241                                            }
8242                                            else {
8243                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8244                                            }
8245                                    }
8246                                    else {
8247                                            if (orderByComparator.isAscending() ^ previous) {
8248                                                    query.append(WHERE_GREATER_THAN);
8249                                            }
8250                                            else {
8251                                                    query.append(WHERE_LESSER_THAN);
8252                                            }
8253                                    }
8254                            }
8255    
8256                            query.append(ORDER_BY_CLAUSE);
8257    
8258                            String[] orderByFields = orderByComparator.getOrderByFields();
8259    
8260                            for (int i = 0; i < orderByFields.length; i++) {
8261                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8262                                    query.append(orderByFields[i]);
8263    
8264                                    if ((i + 1) < orderByFields.length) {
8265                                            if (orderByComparator.isAscending() ^ previous) {
8266                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8267                                            }
8268                                            else {
8269                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8270                                            }
8271                                    }
8272                                    else {
8273                                            if (orderByComparator.isAscending() ^ previous) {
8274                                                    query.append(ORDER_BY_ASC);
8275                                            }
8276                                            else {
8277                                                    query.append(ORDER_BY_DESC);
8278                                            }
8279                                    }
8280                            }
8281                    }
8282                    else {
8283                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
8284                    }
8285    
8286                    String sql = query.toString();
8287    
8288                    Query q = session.createQuery(sql);
8289    
8290                    q.setFirstResult(0);
8291                    q.setMaxResults(2);
8292    
8293                    QueryPos qPos = QueryPos.getInstance(q);
8294    
8295                    qPos.add(groupId);
8296    
8297                    qPos.add(folderId);
8298    
8299                    qPos.add(status);
8300    
8301                    if (orderByComparator != null) {
8302                            Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry);
8303    
8304                            for (Object value : values) {
8305                                    qPos.add(value);
8306                            }
8307                    }
8308    
8309                    List<BookmarksEntry> list = q.list();
8310    
8311                    if (list.size() == 2) {
8312                            return list.get(1);
8313                    }
8314                    else {
8315                            return null;
8316                    }
8317            }
8318    
8319            /**
8320             * Returns all the bookmarks entries that the user has permission to view where groupId = &#63; and folderId = &#63; and status = &#63;.
8321             *
8322             * @param groupId the group ID
8323             * @param folderId the folder ID
8324             * @param status the status
8325             * @return the matching bookmarks entries that the user has permission to view
8326             * @throws SystemException if a system exception occurred
8327             */
8328            @Override
8329            public List<BookmarksEntry> filterFindByG_F_S(long groupId, long folderId,
8330                    int status) throws SystemException {
8331                    return filterFindByG_F_S(groupId, folderId, status, QueryUtil.ALL_POS,
8332                            QueryUtil.ALL_POS, null);
8333            }
8334    
8335            /**
8336             * Returns a range of all the bookmarks entries that the user has permission to view where groupId = &#63; and folderId = &#63; and status = &#63;.
8337             *
8338             * <p>
8339             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
8340             * </p>
8341             *
8342             * @param groupId the group ID
8343             * @param folderId the folder ID
8344             * @param status the status
8345             * @param start the lower bound of the range of bookmarks entries
8346             * @param end the upper bound of the range of bookmarks entries (not inclusive)
8347             * @return the range of matching bookmarks entries that the user has permission to view
8348             * @throws SystemException if a system exception occurred
8349             */
8350            @Override
8351            public List<BookmarksEntry> filterFindByG_F_S(long groupId, long folderId,
8352                    int status, int start, int end) throws SystemException {
8353                    return filterFindByG_F_S(groupId, folderId, status, start, end, null);
8354            }
8355    
8356            /**
8357             * 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;.
8358             *
8359             * <p>
8360             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
8361             * </p>
8362             *
8363             * @param groupId the group ID
8364             * @param folderId the folder ID
8365             * @param status the status
8366             * @param start the lower bound of the range of bookmarks entries
8367             * @param end the upper bound of the range of bookmarks entries (not inclusive)
8368             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8369             * @return the ordered range of matching bookmarks entries that the user has permission to view
8370             * @throws SystemException if a system exception occurred
8371             */
8372            @Override
8373            public List<BookmarksEntry> filterFindByG_F_S(long groupId, long folderId,
8374                    int status, int start, int end, OrderByComparator orderByComparator)
8375                    throws SystemException {
8376                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8377                            return findByG_F_S(groupId, folderId, status, start, end,
8378                                    orderByComparator);
8379                    }
8380    
8381                    StringBundler query = null;
8382    
8383                    if (orderByComparator != null) {
8384                            query = new StringBundler(5 +
8385                                            (orderByComparator.getOrderByFields().length * 3));
8386                    }
8387                    else {
8388                            query = new StringBundler(5);
8389                    }
8390    
8391                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
8392    
8393                    query.append(_FINDER_COLUMN_G_F_S_GROUPID_2);
8394    
8395                    query.append(_FINDER_COLUMN_G_F_S_FOLDERID_2);
8396    
8397                    query.append(_FINDER_COLUMN_G_F_S_STATUS_2);
8398    
8399                    if (orderByComparator != null) {
8400                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8401                                    orderByComparator);
8402                    }
8403                    else {
8404                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
8405                    }
8406    
8407                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8408                                    BookmarksEntry.class.getName(),
8409                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
8410                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
8411    
8412                    Session session = null;
8413    
8414                    try {
8415                            session = openSession();
8416    
8417                            Query q = session.createQuery(sql);
8418    
8419                            QueryPos qPos = QueryPos.getInstance(q);
8420    
8421                            qPos.add(groupId);
8422    
8423                            qPos.add(folderId);
8424    
8425                            qPos.add(status);
8426    
8427                            return (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start,
8428                                    end);
8429                    }
8430                    catch (Exception e) {
8431                            throw processException(e);
8432                    }
8433                    finally {
8434                            closeSession(session);
8435                    }
8436            }
8437    
8438            /**
8439             * 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;.
8440             *
8441             * @param entryId the primary key of the current bookmarks entry
8442             * @param groupId the group ID
8443             * @param folderId the folder ID
8444             * @param status the status
8445             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8446             * @return the previous, current, and next bookmarks entry
8447             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
8448             * @throws SystemException if a system exception occurred
8449             */
8450            @Override
8451            public BookmarksEntry[] filterFindByG_F_S_PrevAndNext(long entryId,
8452                    long groupId, long folderId, int status,
8453                    OrderByComparator orderByComparator)
8454                    throws NoSuchEntryException, SystemException {
8455                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8456                            return findByG_F_S_PrevAndNext(entryId, groupId, folderId, status,
8457                                    orderByComparator);
8458                    }
8459    
8460                    BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
8461    
8462                    Session session = null;
8463    
8464                    try {
8465                            session = openSession();
8466    
8467                            BookmarksEntry[] array = new BookmarksEntryImpl[3];
8468    
8469                            array[0] = filterGetByG_F_S_PrevAndNext(session, bookmarksEntry,
8470                                            groupId, folderId, status, orderByComparator, true);
8471    
8472                            array[1] = bookmarksEntry;
8473    
8474                            array[2] = filterGetByG_F_S_PrevAndNext(session, bookmarksEntry,
8475                                            groupId, folderId, status, orderByComparator, false);
8476    
8477                            return array;
8478                    }
8479                    catch (Exception e) {
8480                            throw processException(e);
8481                    }
8482                    finally {
8483                            closeSession(session);
8484                    }
8485            }
8486    
8487            protected BookmarksEntry filterGetByG_F_S_PrevAndNext(Session session,
8488                    BookmarksEntry bookmarksEntry, long groupId, long folderId, int status,
8489                    OrderByComparator orderByComparator, boolean previous) {
8490                    StringBundler query = null;
8491    
8492                    if (orderByComparator != null) {
8493                            query = new StringBundler(6 +
8494                                            (orderByComparator.getOrderByFields().length * 6));
8495                    }
8496                    else {
8497                            query = new StringBundler(3);
8498                    }
8499    
8500                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
8501    
8502                    query.append(_FINDER_COLUMN_G_F_S_GROUPID_2);
8503    
8504                    query.append(_FINDER_COLUMN_G_F_S_FOLDERID_2);
8505    
8506                    query.append(_FINDER_COLUMN_G_F_S_STATUS_2);
8507    
8508                    if (orderByComparator != null) {
8509                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8510    
8511                            if (orderByConditionFields.length > 0) {
8512                                    query.append(WHERE_AND);
8513                            }
8514    
8515                            for (int i = 0; i < orderByConditionFields.length; i++) {
8516                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8517                                    query.append(orderByConditionFields[i]);
8518    
8519                                    if ((i + 1) < orderByConditionFields.length) {
8520                                            if (orderByComparator.isAscending() ^ previous) {
8521                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8522                                            }
8523                                            else {
8524                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8525                                            }
8526                                    }
8527                                    else {
8528                                            if (orderByComparator.isAscending() ^ previous) {
8529                                                    query.append(WHERE_GREATER_THAN);
8530                                            }
8531                                            else {
8532                                                    query.append(WHERE_LESSER_THAN);
8533                                            }
8534                                    }
8535                            }
8536    
8537                            query.append(ORDER_BY_CLAUSE);
8538    
8539                            String[] orderByFields = orderByComparator.getOrderByFields();
8540    
8541                            for (int i = 0; i < orderByFields.length; i++) {
8542                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8543                                    query.append(orderByFields[i]);
8544    
8545                                    if ((i + 1) < orderByFields.length) {
8546                                            if (orderByComparator.isAscending() ^ previous) {
8547                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8548                                            }
8549                                            else {
8550                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8551                                            }
8552                                    }
8553                                    else {
8554                                            if (orderByComparator.isAscending() ^ previous) {
8555                                                    query.append(ORDER_BY_ASC);
8556                                            }
8557                                            else {
8558                                                    query.append(ORDER_BY_DESC);
8559                                            }
8560                                    }
8561                            }
8562                    }
8563                    else {
8564                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
8565                    }
8566    
8567                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8568                                    BookmarksEntry.class.getName(),
8569                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
8570                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
8571    
8572                    Query q = session.createQuery(sql);
8573    
8574                    q.setFirstResult(0);
8575                    q.setMaxResults(2);
8576    
8577                    QueryPos qPos = QueryPos.getInstance(q);
8578    
8579                    qPos.add(groupId);
8580    
8581                    qPos.add(folderId);
8582    
8583                    qPos.add(status);
8584    
8585                    if (orderByComparator != null) {
8586                            Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry);
8587    
8588                            for (Object value : values) {
8589                                    qPos.add(value);
8590                            }
8591                    }
8592    
8593                    List<BookmarksEntry> list = q.list();
8594    
8595                    if (list.size() == 2) {
8596                            return list.get(1);
8597                    }
8598                    else {
8599                            return null;
8600                    }
8601            }
8602    
8603            /**
8604             * Returns all the bookmarks entries that the user has permission to view where groupId = &#63; and folderId = any &#63; and status = &#63;.
8605             *
8606             * @param groupId the group ID
8607             * @param folderIds the folder IDs
8608             * @param status the status
8609             * @return the matching bookmarks entries that the user has permission to view
8610             * @throws SystemException if a system exception occurred
8611             */
8612            @Override
8613            public List<BookmarksEntry> filterFindByG_F_S(long groupId,
8614                    long[] folderIds, int status) throws SystemException {
8615                    return filterFindByG_F_S(groupId, folderIds, status, QueryUtil.ALL_POS,
8616                            QueryUtil.ALL_POS, null);
8617            }
8618    
8619            /**
8620             * 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;.
8621             *
8622             * <p>
8623             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
8624             * </p>
8625             *
8626             * @param groupId the group ID
8627             * @param folderIds the folder IDs
8628             * @param status the status
8629             * @param start the lower bound of the range of bookmarks entries
8630             * @param end the upper bound of the range of bookmarks entries (not inclusive)
8631             * @return the range of matching bookmarks entries that the user has permission to view
8632             * @throws SystemException if a system exception occurred
8633             */
8634            @Override
8635            public List<BookmarksEntry> filterFindByG_F_S(long groupId,
8636                    long[] folderIds, int status, int start, int end)
8637                    throws SystemException {
8638                    return filterFindByG_F_S(groupId, folderIds, status, start, end, null);
8639            }
8640    
8641            /**
8642             * 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;.
8643             *
8644             * <p>
8645             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
8646             * </p>
8647             *
8648             * @param groupId the group ID
8649             * @param folderIds the folder IDs
8650             * @param status the status
8651             * @param start the lower bound of the range of bookmarks entries
8652             * @param end the upper bound of the range of bookmarks entries (not inclusive)
8653             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8654             * @return the ordered range of matching bookmarks entries that the user has permission to view
8655             * @throws SystemException if a system exception occurred
8656             */
8657            @Override
8658            public List<BookmarksEntry> filterFindByG_F_S(long groupId,
8659                    long[] folderIds, int status, int start, int end,
8660                    OrderByComparator orderByComparator) throws SystemException {
8661                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8662                            return findByG_F_S(groupId, folderIds, status, start, end,
8663                                    orderByComparator);
8664                    }
8665    
8666                    StringBundler query = new StringBundler();
8667    
8668                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
8669    
8670                    boolean conjunctionable = false;
8671    
8672                    if (conjunctionable) {
8673                            query.append(WHERE_AND);
8674                    }
8675    
8676                    query.append(_FINDER_COLUMN_G_F_S_GROUPID_5);
8677    
8678                    conjunctionable = true;
8679    
8680                    if ((folderIds == null) || (folderIds.length > 0)) {
8681                            if (conjunctionable) {
8682                                    query.append(WHERE_AND);
8683                            }
8684    
8685                            query.append(StringPool.OPEN_PARENTHESIS);
8686    
8687                            for (int i = 0; i < folderIds.length; i++) {
8688                                    query.append(_FINDER_COLUMN_G_F_S_FOLDERID_5);
8689    
8690                                    if ((i + 1) < folderIds.length) {
8691                                            query.append(WHERE_OR);
8692                                    }
8693                            }
8694    
8695                            query.append(StringPool.CLOSE_PARENTHESIS);
8696    
8697                            conjunctionable = true;
8698                    }
8699    
8700                    if (conjunctionable) {
8701                            query.append(WHERE_AND);
8702                    }
8703    
8704                    query.append(_FINDER_COLUMN_G_F_S_STATUS_5);
8705    
8706                    conjunctionable = true;
8707    
8708                    if (orderByComparator != null) {
8709                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8710                                    orderByComparator);
8711                    }
8712                    else {
8713                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
8714                    }
8715    
8716                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8717                                    BookmarksEntry.class.getName(),
8718                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
8719                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
8720    
8721                    Session session = null;
8722    
8723                    try {
8724                            session = openSession();
8725    
8726                            Query q = session.createQuery(sql);
8727    
8728                            QueryPos qPos = QueryPos.getInstance(q);
8729    
8730                            qPos.add(groupId);
8731    
8732                            if (folderIds != null) {
8733                                    qPos.add(folderIds);
8734                            }
8735    
8736                            qPos.add(status);
8737    
8738                            return (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start,
8739                                    end);
8740                    }
8741                    catch (Exception e) {
8742                            throw processException(e);
8743                    }
8744                    finally {
8745                            closeSession(session);
8746                    }
8747            }
8748    
8749            /**
8750             * Returns all the bookmarks entries where groupId = &#63; and folderId = any &#63; and status = &#63;.
8751             *
8752             * <p>
8753             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
8754             * </p>
8755             *
8756             * @param groupId the group ID
8757             * @param folderIds the folder IDs
8758             * @param status the status
8759             * @return the matching bookmarks entries
8760             * @throws SystemException if a system exception occurred
8761             */
8762            @Override
8763            public List<BookmarksEntry> findByG_F_S(long groupId, long[] folderIds,
8764                    int status) throws SystemException {
8765                    return findByG_F_S(groupId, folderIds, status, QueryUtil.ALL_POS,
8766                            QueryUtil.ALL_POS, null);
8767            }
8768    
8769            /**
8770             * Returns a range of all the bookmarks entries where groupId = &#63; and folderId = any &#63; and status = &#63;.
8771             *
8772             * <p>
8773             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
8774             * </p>
8775             *
8776             * @param groupId the group ID
8777             * @param folderIds the folder IDs
8778             * @param status the status
8779             * @param start the lower bound of the range of bookmarks entries
8780             * @param end the upper bound of the range of bookmarks entries (not inclusive)
8781             * @return the range of matching bookmarks entries
8782             * @throws SystemException if a system exception occurred
8783             */
8784            @Override
8785            public List<BookmarksEntry> findByG_F_S(long groupId, long[] folderIds,
8786                    int status, int start, int end) throws SystemException {
8787                    return findByG_F_S(groupId, folderIds, status, start, end, null);
8788            }
8789    
8790            /**
8791             * Returns an ordered range of all the bookmarks entries where groupId = &#63; and folderId = any &#63; and status = &#63;.
8792             *
8793             * <p>
8794             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
8795             * </p>
8796             *
8797             * @param groupId the group ID
8798             * @param folderIds the folder IDs
8799             * @param status the status
8800             * @param start the lower bound of the range of bookmarks entries
8801             * @param end the upper bound of the range of bookmarks entries (not inclusive)
8802             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8803             * @return the ordered range of matching bookmarks entries
8804             * @throws SystemException if a system exception occurred
8805             */
8806            @Override
8807            public List<BookmarksEntry> findByG_F_S(long groupId, long[] folderIds,
8808                    int status, int start, int end, OrderByComparator orderByComparator)
8809                    throws SystemException {
8810                    if ((folderIds != null) && (folderIds.length == 1)) {
8811                            return findByG_F_S(groupId, folderIds[0], status, start, end,
8812                                    orderByComparator);
8813                    }
8814    
8815                    boolean pagination = true;
8816                    Object[] finderArgs = null;
8817    
8818                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
8819                                    (orderByComparator == null)) {
8820                            pagination = false;
8821                            finderArgs = new Object[] {
8822                                            groupId, StringUtil.merge(folderIds), status
8823                                    };
8824                    }
8825                    else {
8826                            finderArgs = new Object[] {
8827                                            groupId, StringUtil.merge(folderIds), status,
8828                                            
8829                                            start, end, orderByComparator
8830                                    };
8831                    }
8832    
8833                    List<BookmarksEntry> list = (List<BookmarksEntry>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_S,
8834                                    finderArgs, this);
8835    
8836                    if ((list != null) && !list.isEmpty()) {
8837                            for (BookmarksEntry bookmarksEntry : list) {
8838                                    if ((groupId != bookmarksEntry.getGroupId()) ||
8839                                                    !ArrayUtil.contains(folderIds,
8840                                                            bookmarksEntry.getFolderId()) ||
8841                                                    (status != bookmarksEntry.getStatus())) {
8842                                            list = null;
8843    
8844                                            break;
8845                                    }
8846                            }
8847                    }
8848    
8849                    if (list == null) {
8850                            StringBundler query = new StringBundler();
8851    
8852                            query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
8853    
8854                            boolean conjunctionable = false;
8855    
8856                            if (conjunctionable) {
8857                                    query.append(WHERE_AND);
8858                            }
8859    
8860                            query.append(_FINDER_COLUMN_G_F_S_GROUPID_5);
8861    
8862                            conjunctionable = true;
8863    
8864                            if ((folderIds == null) || (folderIds.length > 0)) {
8865                                    if (conjunctionable) {
8866                                            query.append(WHERE_AND);
8867                                    }
8868    
8869                                    query.append(StringPool.OPEN_PARENTHESIS);
8870    
8871                                    for (int i = 0; i < folderIds.length; i++) {
8872                                            query.append(_FINDER_COLUMN_G_F_S_FOLDERID_5);
8873    
8874                                            if ((i + 1) < folderIds.length) {
8875                                                    query.append(WHERE_OR);
8876                                            }
8877                                    }
8878    
8879                                    query.append(StringPool.CLOSE_PARENTHESIS);
8880    
8881                                    conjunctionable = true;
8882                            }
8883    
8884                            if (conjunctionable) {
8885                                    query.append(WHERE_AND);
8886                            }
8887    
8888                            query.append(_FINDER_COLUMN_G_F_S_STATUS_5);
8889    
8890                            conjunctionable = true;
8891    
8892                            if (orderByComparator != null) {
8893                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8894                                            orderByComparator);
8895                            }
8896                            else
8897                             if (pagination) {
8898                                    query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
8899                            }
8900    
8901                            String sql = query.toString();
8902    
8903                            Session session = null;
8904    
8905                            try {
8906                                    session = openSession();
8907    
8908                                    Query q = session.createQuery(sql);
8909    
8910                                    QueryPos qPos = QueryPos.getInstance(q);
8911    
8912                                    qPos.add(groupId);
8913    
8914                                    if (folderIds != null) {
8915                                            qPos.add(folderIds);
8916                                    }
8917    
8918                                    qPos.add(status);
8919    
8920                                    if (!pagination) {
8921                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
8922                                                            getDialect(), start, end, false);
8923    
8924                                            Collections.sort(list);
8925    
8926                                            list = new UnmodifiableList<BookmarksEntry>(list);
8927                                    }
8928                                    else {
8929                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
8930                                                            getDialect(), start, end);
8931                                    }
8932    
8933                                    cacheResult(list);
8934    
8935                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_S,
8936                                            finderArgs, list);
8937                            }
8938                            catch (Exception e) {
8939                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_S,
8940                                            finderArgs);
8941    
8942                                    throw processException(e);
8943                            }
8944                            finally {
8945                                    closeSession(session);
8946                            }
8947                    }
8948    
8949                    return list;
8950            }
8951    
8952            /**
8953             * Removes all the bookmarks entries where groupId = &#63; and folderId = &#63; and status = &#63; from the database.
8954             *
8955             * @param groupId the group ID
8956             * @param folderId the folder ID
8957             * @param status the status
8958             * @throws SystemException if a system exception occurred
8959             */
8960            @Override
8961            public void removeByG_F_S(long groupId, long folderId, int status)
8962                    throws SystemException {
8963                    for (BookmarksEntry bookmarksEntry : findByG_F_S(groupId, folderId,
8964                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
8965                            remove(bookmarksEntry);
8966                    }
8967            }
8968    
8969            /**
8970             * Returns the number of bookmarks entries where groupId = &#63; and folderId = &#63; and status = &#63;.
8971             *
8972             * @param groupId the group ID
8973             * @param folderId the folder ID
8974             * @param status the status
8975             * @return the number of matching bookmarks entries
8976             * @throws SystemException if a system exception occurred
8977             */
8978            @Override
8979            public int countByG_F_S(long groupId, long folderId, int status)
8980                    throws SystemException {
8981                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_F_S;
8982    
8983                    Object[] finderArgs = new Object[] { groupId, folderId, status };
8984    
8985                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
8986                                    this);
8987    
8988                    if (count == null) {
8989                            StringBundler query = new StringBundler(4);
8990    
8991                            query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
8992    
8993                            query.append(_FINDER_COLUMN_G_F_S_GROUPID_2);
8994    
8995                            query.append(_FINDER_COLUMN_G_F_S_FOLDERID_2);
8996    
8997                            query.append(_FINDER_COLUMN_G_F_S_STATUS_2);
8998    
8999                            String sql = query.toString();
9000    
9001                            Session session = null;
9002    
9003                            try {
9004                                    session = openSession();
9005    
9006                                    Query q = session.createQuery(sql);
9007    
9008                                    QueryPos qPos = QueryPos.getInstance(q);
9009    
9010                                    qPos.add(groupId);
9011    
9012                                    qPos.add(folderId);
9013    
9014                                    qPos.add(status);
9015    
9016                                    count = (Long)q.uniqueResult();
9017    
9018                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
9019                            }
9020                            catch (Exception e) {
9021                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
9022    
9023                                    throw processException(e);
9024                            }
9025                            finally {
9026                                    closeSession(session);
9027                            }
9028                    }
9029    
9030                    return count.intValue();
9031            }
9032    
9033            /**
9034             * Returns the number of bookmarks entries where groupId = &#63; and folderId = any &#63; and status = &#63;.
9035             *
9036             * @param groupId the group ID
9037             * @param folderIds the folder IDs
9038             * @param status the status
9039             * @return the number of matching bookmarks entries
9040             * @throws SystemException if a system exception occurred
9041             */
9042            @Override
9043            public int countByG_F_S(long groupId, long[] folderIds, int status)
9044                    throws SystemException {
9045                    Object[] finderArgs = new Object[] {
9046                                    groupId, StringUtil.merge(folderIds), status
9047                            };
9048    
9049                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_S,
9050                                    finderArgs, this);
9051    
9052                    if (count == null) {
9053                            StringBundler query = new StringBundler();
9054    
9055                            query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
9056    
9057                            boolean conjunctionable = false;
9058    
9059                            if (conjunctionable) {
9060                                    query.append(WHERE_AND);
9061                            }
9062    
9063                            query.append(_FINDER_COLUMN_G_F_S_GROUPID_5);
9064    
9065                            conjunctionable = true;
9066    
9067                            if ((folderIds == null) || (folderIds.length > 0)) {
9068                                    if (conjunctionable) {
9069                                            query.append(WHERE_AND);
9070                                    }
9071    
9072                                    query.append(StringPool.OPEN_PARENTHESIS);
9073    
9074                                    for (int i = 0; i < folderIds.length; i++) {
9075                                            query.append(_FINDER_COLUMN_G_F_S_FOLDERID_5);
9076    
9077                                            if ((i + 1) < folderIds.length) {
9078                                                    query.append(WHERE_OR);
9079                                            }
9080                                    }
9081    
9082                                    query.append(StringPool.CLOSE_PARENTHESIS);
9083    
9084                                    conjunctionable = true;
9085                            }
9086    
9087                            if (conjunctionable) {
9088                                    query.append(WHERE_AND);
9089                            }
9090    
9091                            query.append(_FINDER_COLUMN_G_F_S_STATUS_5);
9092    
9093                            conjunctionable = true;
9094    
9095                            String sql = query.toString();
9096    
9097                            Session session = null;
9098    
9099                            try {
9100                                    session = openSession();
9101    
9102                                    Query q = session.createQuery(sql);
9103    
9104                                    QueryPos qPos = QueryPos.getInstance(q);
9105    
9106                                    qPos.add(groupId);
9107    
9108                                    if (folderIds != null) {
9109                                            qPos.add(folderIds);
9110                                    }
9111    
9112                                    qPos.add(status);
9113    
9114                                    count = (Long)q.uniqueResult();
9115    
9116                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_S,
9117                                            finderArgs, count);
9118                            }
9119                            catch (Exception e) {
9120                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_S,
9121                                            finderArgs);
9122    
9123                                    throw processException(e);
9124                            }
9125                            finally {
9126                                    closeSession(session);
9127                            }
9128                    }
9129    
9130                    return count.intValue();
9131            }
9132    
9133            /**
9134             * Returns the number of bookmarks entries that the user has permission to view where groupId = &#63; and folderId = &#63; and status = &#63;.
9135             *
9136             * @param groupId the group ID
9137             * @param folderId the folder ID
9138             * @param status the status
9139             * @return the number of matching bookmarks entries that the user has permission to view
9140             * @throws SystemException if a system exception occurred
9141             */
9142            @Override
9143            public int filterCountByG_F_S(long groupId, long folderId, int status)
9144                    throws SystemException {
9145                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9146                            return countByG_F_S(groupId, folderId, status);
9147                    }
9148    
9149                    StringBundler query = new StringBundler(4);
9150    
9151                    query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
9152    
9153                    query.append(_FINDER_COLUMN_G_F_S_GROUPID_2);
9154    
9155                    query.append(_FINDER_COLUMN_G_F_S_FOLDERID_2);
9156    
9157                    query.append(_FINDER_COLUMN_G_F_S_STATUS_2);
9158    
9159                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9160                                    BookmarksEntry.class.getName(),
9161                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
9162                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
9163    
9164                    Session session = null;
9165    
9166                    try {
9167                            session = openSession();
9168    
9169                            Query q = session.createQuery(sql);
9170    
9171                            QueryPos qPos = QueryPos.getInstance(q);
9172    
9173                            qPos.add(groupId);
9174    
9175                            qPos.add(folderId);
9176    
9177                            qPos.add(status);
9178    
9179                            Long count = (Long)q.uniqueResult();
9180    
9181                            return count.intValue();
9182                    }
9183                    catch (Exception e) {
9184                            throw processException(e);
9185                    }
9186                    finally {
9187                            closeSession(session);
9188                    }
9189            }
9190    
9191            /**
9192             * Returns the number of bookmarks entries that the user has permission to view where groupId = &#63; and folderId = any &#63; and status = &#63;.
9193             *
9194             * @param groupId the group ID
9195             * @param folderIds the folder IDs
9196             * @param status the status
9197             * @return the number of matching bookmarks entries that the user has permission to view
9198             * @throws SystemException if a system exception occurred
9199             */
9200            @Override
9201            public int filterCountByG_F_S(long groupId, long[] folderIds, int status)
9202                    throws SystemException {
9203                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9204                            return countByG_F_S(groupId, folderIds, status);
9205                    }
9206    
9207                    StringBundler query = new StringBundler();
9208    
9209                    query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
9210    
9211                    boolean conjunctionable = false;
9212    
9213                    if (conjunctionable) {
9214                            query.append(WHERE_AND);
9215                    }
9216    
9217                    query.append(_FINDER_COLUMN_G_F_S_GROUPID_5);
9218    
9219                    conjunctionable = true;
9220    
9221                    if ((folderIds == null) || (folderIds.length > 0)) {
9222                            if (conjunctionable) {
9223                                    query.append(WHERE_AND);
9224                            }
9225    
9226                            query.append(StringPool.OPEN_PARENTHESIS);
9227    
9228                            for (int i = 0; i < folderIds.length; i++) {
9229                                    query.append(_FINDER_COLUMN_G_F_S_FOLDERID_5);
9230    
9231                                    if ((i + 1) < folderIds.length) {
9232                                            query.append(WHERE_OR);
9233                                    }
9234                            }
9235    
9236                            query.append(StringPool.CLOSE_PARENTHESIS);
9237    
9238                            conjunctionable = true;
9239                    }
9240    
9241                    if (conjunctionable) {
9242                            query.append(WHERE_AND);
9243                    }
9244    
9245                    query.append(_FINDER_COLUMN_G_F_S_STATUS_5);
9246    
9247                    conjunctionable = true;
9248    
9249                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9250                                    BookmarksEntry.class.getName(),
9251                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
9252                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
9253    
9254                    Session session = null;
9255    
9256                    try {
9257                            session = openSession();
9258    
9259                            Query q = session.createQuery(sql);
9260    
9261                            QueryPos qPos = QueryPos.getInstance(q);
9262    
9263                            qPos.add(groupId);
9264    
9265                            if (folderIds != null) {
9266                                    qPos.add(folderIds);
9267                            }
9268    
9269                            qPos.add(status);
9270    
9271                            Long count = (Long)q.uniqueResult();
9272    
9273                            return count.intValue();
9274                    }
9275                    catch (Exception e) {
9276                            throw processException(e);
9277                    }
9278                    finally {
9279                            closeSession(session);
9280                    }
9281            }
9282    
9283            private static final String _FINDER_COLUMN_G_F_S_GROUPID_2 = "bookmarksEntry.groupId = ? AND ";
9284            private static final String _FINDER_COLUMN_G_F_S_GROUPID_5 = "(" +
9285                    removeConjunction(_FINDER_COLUMN_G_F_S_GROUPID_2) + ")";
9286            private static final String _FINDER_COLUMN_G_F_S_FOLDERID_2 = "bookmarksEntry.folderId = ? AND ";
9287            private static final String _FINDER_COLUMN_G_F_S_FOLDERID_5 = "(" +
9288                    removeConjunction(_FINDER_COLUMN_G_F_S_FOLDERID_2) + ")";
9289            private static final String _FINDER_COLUMN_G_F_S_STATUS_2 = "bookmarksEntry.status = ?";
9290            private static final String _FINDER_COLUMN_G_F_S_STATUS_5 = "(" +
9291                    removeConjunction(_FINDER_COLUMN_G_F_S_STATUS_2) + ")";
9292            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_NOTS = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
9293                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
9294                            BookmarksEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
9295                            "findByG_F_NotS",
9296                            new String[] {
9297                                    Long.class.getName(), Long.class.getName(),
9298                                    Integer.class.getName(),
9299                                    
9300                            Integer.class.getName(), Integer.class.getName(),
9301                                    OrderByComparator.class.getName()
9302                            });
9303            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_NOTS =
9304                    new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
9305                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
9306                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_F_NotS",
9307                            new String[] {
9308                                    Long.class.getName(), Long.class.getName(),
9309                                    Integer.class.getName()
9310                            });
9311    
9312            /**
9313             * Returns all the bookmarks entries where groupId = &#63; and folderId = &#63; and status &ne; &#63;.
9314             *
9315             * @param groupId the group ID
9316             * @param folderId the folder ID
9317             * @param status the status
9318             * @return the matching bookmarks entries
9319             * @throws SystemException if a system exception occurred
9320             */
9321            @Override
9322            public List<BookmarksEntry> findByG_F_NotS(long groupId, long folderId,
9323                    int status) throws SystemException {
9324                    return findByG_F_NotS(groupId, folderId, status, QueryUtil.ALL_POS,
9325                            QueryUtil.ALL_POS, null);
9326            }
9327    
9328            /**
9329             * Returns a range of all the bookmarks entries where groupId = &#63; and folderId = &#63; and status &ne; &#63;.
9330             *
9331             * <p>
9332             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
9333             * </p>
9334             *
9335             * @param groupId the group ID
9336             * @param folderId the folder ID
9337             * @param status the status
9338             * @param start the lower bound of the range of bookmarks entries
9339             * @param end the upper bound of the range of bookmarks entries (not inclusive)
9340             * @return the range of matching bookmarks entries
9341             * @throws SystemException if a system exception occurred
9342             */
9343            @Override
9344            public List<BookmarksEntry> findByG_F_NotS(long groupId, long folderId,
9345                    int status, int start, int end) throws SystemException {
9346                    return findByG_F_NotS(groupId, folderId, status, start, end, null);
9347            }
9348    
9349            /**
9350             * Returns an ordered range of all the bookmarks entries where groupId = &#63; and folderId = &#63; and status &ne; &#63;.
9351             *
9352             * <p>
9353             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
9354             * </p>
9355             *
9356             * @param groupId the group ID
9357             * @param folderId the folder ID
9358             * @param status the status
9359             * @param start the lower bound of the range of bookmarks entries
9360             * @param end the upper bound of the range of bookmarks entries (not inclusive)
9361             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9362             * @return the ordered range of matching bookmarks entries
9363             * @throws SystemException if a system exception occurred
9364             */
9365            @Override
9366            public List<BookmarksEntry> findByG_F_NotS(long groupId, long folderId,
9367                    int status, int start, int end, OrderByComparator orderByComparator)
9368                    throws SystemException {
9369                    boolean pagination = true;
9370                    FinderPath finderPath = null;
9371                    Object[] finderArgs = null;
9372    
9373                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_NOTS;
9374                    finderArgs = new Object[] {
9375                                    groupId, folderId, status,
9376                                    
9377                                    start, end, orderByComparator
9378                            };
9379    
9380                    List<BookmarksEntry> list = (List<BookmarksEntry>)FinderCacheUtil.getResult(finderPath,
9381                                    finderArgs, this);
9382    
9383                    if ((list != null) && !list.isEmpty()) {
9384                            for (BookmarksEntry bookmarksEntry : list) {
9385                                    if ((groupId != bookmarksEntry.getGroupId()) ||
9386                                                    (folderId != bookmarksEntry.getFolderId()) ||
9387                                                    (status != bookmarksEntry.getStatus())) {
9388                                            list = null;
9389    
9390                                            break;
9391                                    }
9392                            }
9393                    }
9394    
9395                    if (list == null) {
9396                            StringBundler query = null;
9397    
9398                            if (orderByComparator != null) {
9399                                    query = new StringBundler(5 +
9400                                                    (orderByComparator.getOrderByFields().length * 3));
9401                            }
9402                            else {
9403                                    query = new StringBundler(5);
9404                            }
9405    
9406                            query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
9407    
9408                            query.append(_FINDER_COLUMN_G_F_NOTS_GROUPID_2);
9409    
9410                            query.append(_FINDER_COLUMN_G_F_NOTS_FOLDERID_2);
9411    
9412                            query.append(_FINDER_COLUMN_G_F_NOTS_STATUS_2);
9413    
9414                            if (orderByComparator != null) {
9415                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9416                                            orderByComparator);
9417                            }
9418                            else
9419                             if (pagination) {
9420                                    query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
9421                            }
9422    
9423                            String sql = query.toString();
9424    
9425                            Session session = null;
9426    
9427                            try {
9428                                    session = openSession();
9429    
9430                                    Query q = session.createQuery(sql);
9431    
9432                                    QueryPos qPos = QueryPos.getInstance(q);
9433    
9434                                    qPos.add(groupId);
9435    
9436                                    qPos.add(folderId);
9437    
9438                                    qPos.add(status);
9439    
9440                                    if (!pagination) {
9441                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
9442                                                            getDialect(), start, end, false);
9443    
9444                                            Collections.sort(list);
9445    
9446                                            list = new UnmodifiableList<BookmarksEntry>(list);
9447                                    }
9448                                    else {
9449                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
9450                                                            getDialect(), start, end);
9451                                    }
9452    
9453                                    cacheResult(list);
9454    
9455                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
9456                            }
9457                            catch (Exception e) {
9458                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
9459    
9460                                    throw processException(e);
9461                            }
9462                            finally {
9463                                    closeSession(session);
9464                            }
9465                    }
9466    
9467                    return list;
9468            }
9469    
9470            /**
9471             * Returns the first bookmarks entry in the ordered set where groupId = &#63; and folderId = &#63; and status &ne; &#63;.
9472             *
9473             * @param groupId the group ID
9474             * @param folderId the folder ID
9475             * @param status the status
9476             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9477             * @return the first matching bookmarks entry
9478             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
9479             * @throws SystemException if a system exception occurred
9480             */
9481            @Override
9482            public BookmarksEntry findByG_F_NotS_First(long groupId, long folderId,
9483                    int status, OrderByComparator orderByComparator)
9484                    throws NoSuchEntryException, SystemException {
9485                    BookmarksEntry bookmarksEntry = fetchByG_F_NotS_First(groupId,
9486                                    folderId, status, orderByComparator);
9487    
9488                    if (bookmarksEntry != null) {
9489                            return bookmarksEntry;
9490                    }
9491    
9492                    StringBundler msg = new StringBundler(8);
9493    
9494                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9495    
9496                    msg.append("groupId=");
9497                    msg.append(groupId);
9498    
9499                    msg.append(", folderId=");
9500                    msg.append(folderId);
9501    
9502                    msg.append(", status=");
9503                    msg.append(status);
9504    
9505                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9506    
9507                    throw new NoSuchEntryException(msg.toString());
9508            }
9509    
9510            /**
9511             * Returns the first bookmarks entry in the ordered set where groupId = &#63; and folderId = &#63; and status &ne; &#63;.
9512             *
9513             * @param groupId the group ID
9514             * @param folderId the folder ID
9515             * @param status the status
9516             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9517             * @return the first matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
9518             * @throws SystemException if a system exception occurred
9519             */
9520            @Override
9521            public BookmarksEntry fetchByG_F_NotS_First(long groupId, long folderId,
9522                    int status, OrderByComparator orderByComparator)
9523                    throws SystemException {
9524                    List<BookmarksEntry> list = findByG_F_NotS(groupId, folderId, status,
9525                                    0, 1, orderByComparator);
9526    
9527                    if (!list.isEmpty()) {
9528                            return list.get(0);
9529                    }
9530    
9531                    return null;
9532            }
9533    
9534            /**
9535             * Returns the last bookmarks entry in the ordered set where groupId = &#63; and folderId = &#63; and status &ne; &#63;.
9536             *
9537             * @param groupId the group ID
9538             * @param folderId the folder ID
9539             * @param status the status
9540             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9541             * @return the last matching bookmarks entry
9542             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
9543             * @throws SystemException if a system exception occurred
9544             */
9545            @Override
9546            public BookmarksEntry findByG_F_NotS_Last(long groupId, long folderId,
9547                    int status, OrderByComparator orderByComparator)
9548                    throws NoSuchEntryException, SystemException {
9549                    BookmarksEntry bookmarksEntry = fetchByG_F_NotS_Last(groupId, folderId,
9550                                    status, orderByComparator);
9551    
9552                    if (bookmarksEntry != null) {
9553                            return bookmarksEntry;
9554                    }
9555    
9556                    StringBundler msg = new StringBundler(8);
9557    
9558                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9559    
9560                    msg.append("groupId=");
9561                    msg.append(groupId);
9562    
9563                    msg.append(", folderId=");
9564                    msg.append(folderId);
9565    
9566                    msg.append(", status=");
9567                    msg.append(status);
9568    
9569                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9570    
9571                    throw new NoSuchEntryException(msg.toString());
9572            }
9573    
9574            /**
9575             * Returns the last bookmarks entry in the ordered set where groupId = &#63; and folderId = &#63; and status &ne; &#63;.
9576             *
9577             * @param groupId the group ID
9578             * @param folderId the folder ID
9579             * @param status the status
9580             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9581             * @return the last matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
9582             * @throws SystemException if a system exception occurred
9583             */
9584            @Override
9585            public BookmarksEntry fetchByG_F_NotS_Last(long groupId, long folderId,
9586                    int status, OrderByComparator orderByComparator)
9587                    throws SystemException {
9588                    int count = countByG_F_NotS(groupId, folderId, status);
9589    
9590                    if (count == 0) {
9591                            return null;
9592                    }
9593    
9594                    List<BookmarksEntry> list = findByG_F_NotS(groupId, folderId, status,
9595                                    count - 1, count, orderByComparator);
9596    
9597                    if (!list.isEmpty()) {
9598                            return list.get(0);
9599                    }
9600    
9601                    return null;
9602            }
9603    
9604            /**
9605             * 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;.
9606             *
9607             * @param entryId the primary key of the current bookmarks entry
9608             * @param groupId the group ID
9609             * @param folderId the folder ID
9610             * @param status the status
9611             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9612             * @return the previous, current, and next bookmarks entry
9613             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
9614             * @throws SystemException if a system exception occurred
9615             */
9616            @Override
9617            public BookmarksEntry[] findByG_F_NotS_PrevAndNext(long entryId,
9618                    long groupId, long folderId, int status,
9619                    OrderByComparator orderByComparator)
9620                    throws NoSuchEntryException, SystemException {
9621                    BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
9622    
9623                    Session session = null;
9624    
9625                    try {
9626                            session = openSession();
9627    
9628                            BookmarksEntry[] array = new BookmarksEntryImpl[3];
9629    
9630                            array[0] = getByG_F_NotS_PrevAndNext(session, bookmarksEntry,
9631                                            groupId, folderId, status, orderByComparator, true);
9632    
9633                            array[1] = bookmarksEntry;
9634    
9635                            array[2] = getByG_F_NotS_PrevAndNext(session, bookmarksEntry,
9636                                            groupId, folderId, status, orderByComparator, false);
9637    
9638                            return array;
9639                    }
9640                    catch (Exception e) {
9641                            throw processException(e);
9642                    }
9643                    finally {
9644                            closeSession(session);
9645                    }
9646            }
9647    
9648            protected BookmarksEntry getByG_F_NotS_PrevAndNext(Session session,
9649                    BookmarksEntry bookmarksEntry, long groupId, long folderId, int status,
9650                    OrderByComparator orderByComparator, boolean previous) {
9651                    StringBundler query = null;
9652    
9653                    if (orderByComparator != null) {
9654                            query = new StringBundler(6 +
9655                                            (orderByComparator.getOrderByFields().length * 6));
9656                    }
9657                    else {
9658                            query = new StringBundler(3);
9659                    }
9660    
9661                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
9662    
9663                    query.append(_FINDER_COLUMN_G_F_NOTS_GROUPID_2);
9664    
9665                    query.append(_FINDER_COLUMN_G_F_NOTS_FOLDERID_2);
9666    
9667                    query.append(_FINDER_COLUMN_G_F_NOTS_STATUS_2);
9668    
9669                    if (orderByComparator != null) {
9670                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9671    
9672                            if (orderByConditionFields.length > 0) {
9673                                    query.append(WHERE_AND);
9674                            }
9675    
9676                            for (int i = 0; i < orderByConditionFields.length; i++) {
9677                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9678                                    query.append(orderByConditionFields[i]);
9679    
9680                                    if ((i + 1) < orderByConditionFields.length) {
9681                                            if (orderByComparator.isAscending() ^ previous) {
9682                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9683                                            }
9684                                            else {
9685                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
9686                                            }
9687                                    }
9688                                    else {
9689                                            if (orderByComparator.isAscending() ^ previous) {
9690                                                    query.append(WHERE_GREATER_THAN);
9691                                            }
9692                                            else {
9693                                                    query.append(WHERE_LESSER_THAN);
9694                                            }
9695                                    }
9696                            }
9697    
9698                            query.append(ORDER_BY_CLAUSE);
9699    
9700                            String[] orderByFields = orderByComparator.getOrderByFields();
9701    
9702                            for (int i = 0; i < orderByFields.length; i++) {
9703                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9704                                    query.append(orderByFields[i]);
9705    
9706                                    if ((i + 1) < orderByFields.length) {
9707                                            if (orderByComparator.isAscending() ^ previous) {
9708                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
9709                                            }
9710                                            else {
9711                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
9712                                            }
9713                                    }
9714                                    else {
9715                                            if (orderByComparator.isAscending() ^ previous) {
9716                                                    query.append(ORDER_BY_ASC);
9717                                            }
9718                                            else {
9719                                                    query.append(ORDER_BY_DESC);
9720                                            }
9721                                    }
9722                            }
9723                    }
9724                    else {
9725                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
9726                    }
9727    
9728                    String sql = query.toString();
9729    
9730                    Query q = session.createQuery(sql);
9731    
9732                    q.setFirstResult(0);
9733                    q.setMaxResults(2);
9734    
9735                    QueryPos qPos = QueryPos.getInstance(q);
9736    
9737                    qPos.add(groupId);
9738    
9739                    qPos.add(folderId);
9740    
9741                    qPos.add(status);
9742    
9743                    if (orderByComparator != null) {
9744                            Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry);
9745    
9746                            for (Object value : values) {
9747                                    qPos.add(value);
9748                            }
9749                    }
9750    
9751                    List<BookmarksEntry> list = q.list();
9752    
9753                    if (list.size() == 2) {
9754                            return list.get(1);
9755                    }
9756                    else {
9757                            return null;
9758                    }
9759            }
9760    
9761            /**
9762             * Returns all the bookmarks entries that the user has permission to view where groupId = &#63; and folderId = &#63; and status &ne; &#63;.
9763             *
9764             * @param groupId the group ID
9765             * @param folderId the folder ID
9766             * @param status the status
9767             * @return the matching bookmarks entries that the user has permission to view
9768             * @throws SystemException if a system exception occurred
9769             */
9770            @Override
9771            public List<BookmarksEntry> filterFindByG_F_NotS(long groupId,
9772                    long folderId, int status) throws SystemException {
9773                    return filterFindByG_F_NotS(groupId, folderId, status,
9774                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
9775            }
9776    
9777            /**
9778             * 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;.
9779             *
9780             * <p>
9781             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
9782             * </p>
9783             *
9784             * @param groupId the group ID
9785             * @param folderId the folder ID
9786             * @param status the status
9787             * @param start the lower bound of the range of bookmarks entries
9788             * @param end the upper bound of the range of bookmarks entries (not inclusive)
9789             * @return the range of matching bookmarks entries that the user has permission to view
9790             * @throws SystemException if a system exception occurred
9791             */
9792            @Override
9793            public List<BookmarksEntry> filterFindByG_F_NotS(long groupId,
9794                    long folderId, int status, int start, int end)
9795                    throws SystemException {
9796                    return filterFindByG_F_NotS(groupId, folderId, status, start, end, null);
9797            }
9798    
9799            /**
9800             * 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;.
9801             *
9802             * <p>
9803             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
9804             * </p>
9805             *
9806             * @param groupId the group ID
9807             * @param folderId the folder ID
9808             * @param status the status
9809             * @param start the lower bound of the range of bookmarks entries
9810             * @param end the upper bound of the range of bookmarks entries (not inclusive)
9811             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9812             * @return the ordered range of matching bookmarks entries that the user has permission to view
9813             * @throws SystemException if a system exception occurred
9814             */
9815            @Override
9816            public List<BookmarksEntry> filterFindByG_F_NotS(long groupId,
9817                    long folderId, int status, int start, int end,
9818                    OrderByComparator orderByComparator) throws SystemException {
9819                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9820                            return findByG_F_NotS(groupId, folderId, status, start, end,
9821                                    orderByComparator);
9822                    }
9823    
9824                    StringBundler query = null;
9825    
9826                    if (orderByComparator != null) {
9827                            query = new StringBundler(5 +
9828                                            (orderByComparator.getOrderByFields().length * 3));
9829                    }
9830                    else {
9831                            query = new StringBundler(5);
9832                    }
9833    
9834                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
9835    
9836                    query.append(_FINDER_COLUMN_G_F_NOTS_GROUPID_2);
9837    
9838                    query.append(_FINDER_COLUMN_G_F_NOTS_FOLDERID_2);
9839    
9840                    query.append(_FINDER_COLUMN_G_F_NOTS_STATUS_2);
9841    
9842                    if (orderByComparator != null) {
9843                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9844                                    orderByComparator);
9845                    }
9846                    else {
9847                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
9848                    }
9849    
9850                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9851                                    BookmarksEntry.class.getName(),
9852                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
9853                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
9854    
9855                    Session session = null;
9856    
9857                    try {
9858                            session = openSession();
9859    
9860                            Query q = session.createQuery(sql);
9861    
9862                            QueryPos qPos = QueryPos.getInstance(q);
9863    
9864                            qPos.add(groupId);
9865    
9866                            qPos.add(folderId);
9867    
9868                            qPos.add(status);
9869    
9870                            return (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start,
9871                                    end);
9872                    }
9873                    catch (Exception e) {
9874                            throw processException(e);
9875                    }
9876                    finally {
9877                            closeSession(session);
9878                    }
9879            }
9880    
9881            /**
9882             * 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;.
9883             *
9884             * @param entryId the primary key of the current bookmarks entry
9885             * @param groupId the group ID
9886             * @param folderId the folder ID
9887             * @param status the status
9888             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9889             * @return the previous, current, and next bookmarks entry
9890             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
9891             * @throws SystemException if a system exception occurred
9892             */
9893            @Override
9894            public BookmarksEntry[] filterFindByG_F_NotS_PrevAndNext(long entryId,
9895                    long groupId, long folderId, int status,
9896                    OrderByComparator orderByComparator)
9897                    throws NoSuchEntryException, SystemException {
9898                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9899                            return findByG_F_NotS_PrevAndNext(entryId, groupId, folderId,
9900                                    status, orderByComparator);
9901                    }
9902    
9903                    BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
9904    
9905                    Session session = null;
9906    
9907                    try {
9908                            session = openSession();
9909    
9910                            BookmarksEntry[] array = new BookmarksEntryImpl[3];
9911    
9912                            array[0] = filterGetByG_F_NotS_PrevAndNext(session, bookmarksEntry,
9913                                            groupId, folderId, status, orderByComparator, true);
9914    
9915                            array[1] = bookmarksEntry;
9916    
9917                            array[2] = filterGetByG_F_NotS_PrevAndNext(session, bookmarksEntry,
9918                                            groupId, folderId, status, orderByComparator, false);
9919    
9920                            return array;
9921                    }
9922                    catch (Exception e) {
9923                            throw processException(e);
9924                    }
9925                    finally {
9926                            closeSession(session);
9927                    }
9928            }
9929    
9930            protected BookmarksEntry filterGetByG_F_NotS_PrevAndNext(Session session,
9931                    BookmarksEntry bookmarksEntry, long groupId, long folderId, int status,
9932                    OrderByComparator orderByComparator, boolean previous) {
9933                    StringBundler query = null;
9934    
9935                    if (orderByComparator != null) {
9936                            query = new StringBundler(6 +
9937                                            (orderByComparator.getOrderByFields().length * 6));
9938                    }
9939                    else {
9940                            query = new StringBundler(3);
9941                    }
9942    
9943                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
9944    
9945                    query.append(_FINDER_COLUMN_G_F_NOTS_GROUPID_2);
9946    
9947                    query.append(_FINDER_COLUMN_G_F_NOTS_FOLDERID_2);
9948    
9949                    query.append(_FINDER_COLUMN_G_F_NOTS_STATUS_2);
9950    
9951                    if (orderByComparator != null) {
9952                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9953    
9954                            if (orderByConditionFields.length > 0) {
9955                                    query.append(WHERE_AND);
9956                            }
9957    
9958                            for (int i = 0; i < orderByConditionFields.length; i++) {
9959                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9960                                    query.append(orderByConditionFields[i]);
9961    
9962                                    if ((i + 1) < orderByConditionFields.length) {
9963                                            if (orderByComparator.isAscending() ^ previous) {
9964                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9965                                            }
9966                                            else {
9967                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
9968                                            }
9969                                    }
9970                                    else {
9971                                            if (orderByComparator.isAscending() ^ previous) {
9972                                                    query.append(WHERE_GREATER_THAN);
9973                                            }
9974                                            else {
9975                                                    query.append(WHERE_LESSER_THAN);
9976                                            }
9977                                    }
9978                            }
9979    
9980                            query.append(ORDER_BY_CLAUSE);
9981    
9982                            String[] orderByFields = orderByComparator.getOrderByFields();
9983    
9984                            for (int i = 0; i < orderByFields.length; i++) {
9985                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9986                                    query.append(orderByFields[i]);
9987    
9988                                    if ((i + 1) < orderByFields.length) {
9989                                            if (orderByComparator.isAscending() ^ previous) {
9990                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
9991                                            }
9992                                            else {
9993                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
9994                                            }
9995                                    }
9996                                    else {
9997                                            if (orderByComparator.isAscending() ^ previous) {
9998                                                    query.append(ORDER_BY_ASC);
9999                                            }
10000                                            else {
10001                                                    query.append(ORDER_BY_DESC);
10002                                            }
10003                                    }
10004                            }
10005                    }
10006                    else {
10007                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
10008                    }
10009    
10010                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10011                                    BookmarksEntry.class.getName(),
10012                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
10013                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
10014    
10015                    Query q = session.createQuery(sql);
10016    
10017                    q.setFirstResult(0);
10018                    q.setMaxResults(2);
10019    
10020                    QueryPos qPos = QueryPos.getInstance(q);
10021    
10022                    qPos.add(groupId);
10023    
10024                    qPos.add(folderId);
10025    
10026                    qPos.add(status);
10027    
10028                    if (orderByComparator != null) {
10029                            Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry);
10030    
10031                            for (Object value : values) {
10032                                    qPos.add(value);
10033                            }
10034                    }
10035    
10036                    List<BookmarksEntry> list = q.list();
10037    
10038                    if (list.size() == 2) {
10039                            return list.get(1);
10040                    }
10041                    else {
10042                            return null;
10043                    }
10044            }
10045    
10046            /**
10047             * Returns all the bookmarks entries that the user has permission to view where groupId = &#63; and folderId = any &#63; and status &ne; &#63;.
10048             *
10049             * @param groupId the group ID
10050             * @param folderIds the folder IDs
10051             * @param status the status
10052             * @return the matching bookmarks entries that the user has permission to view
10053             * @throws SystemException if a system exception occurred
10054             */
10055            @Override
10056            public List<BookmarksEntry> filterFindByG_F_NotS(long groupId,
10057                    long[] folderIds, int status) throws SystemException {
10058                    return filterFindByG_F_NotS(groupId, folderIds, status,
10059                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
10060            }
10061    
10062            /**
10063             * 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;.
10064             *
10065             * <p>
10066             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
10067             * </p>
10068             *
10069             * @param groupId the group ID
10070             * @param folderIds the folder IDs
10071             * @param status the status
10072             * @param start the lower bound of the range of bookmarks entries
10073             * @param end the upper bound of the range of bookmarks entries (not inclusive)
10074             * @return the range of matching bookmarks entries that the user has permission to view
10075             * @throws SystemException if a system exception occurred
10076             */
10077            @Override
10078            public List<BookmarksEntry> filterFindByG_F_NotS(long groupId,
10079                    long[] folderIds, int status, int start, int end)
10080                    throws SystemException {
10081                    return filterFindByG_F_NotS(groupId, folderIds, status, start, end, null);
10082            }
10083    
10084            /**
10085             * 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;.
10086             *
10087             * <p>
10088             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
10089             * </p>
10090             *
10091             * @param groupId the group ID
10092             * @param folderIds the folder IDs
10093             * @param status the status
10094             * @param start the lower bound of the range of bookmarks entries
10095             * @param end the upper bound of the range of bookmarks entries (not inclusive)
10096             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10097             * @return the ordered range of matching bookmarks entries that the user has permission to view
10098             * @throws SystemException if a system exception occurred
10099             */
10100            @Override
10101            public List<BookmarksEntry> filterFindByG_F_NotS(long groupId,
10102                    long[] folderIds, int status, int start, int end,
10103                    OrderByComparator orderByComparator) throws SystemException {
10104                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10105                            return findByG_F_NotS(groupId, folderIds, status, start, end,
10106                                    orderByComparator);
10107                    }
10108    
10109                    StringBundler query = new StringBundler();
10110    
10111                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
10112    
10113                    boolean conjunctionable = false;
10114    
10115                    if (conjunctionable) {
10116                            query.append(WHERE_AND);
10117                    }
10118    
10119                    query.append(_FINDER_COLUMN_G_F_NOTS_GROUPID_5);
10120    
10121                    conjunctionable = true;
10122    
10123                    if ((folderIds == null) || (folderIds.length > 0)) {
10124                            if (conjunctionable) {
10125                                    query.append(WHERE_AND);
10126                            }
10127    
10128                            query.append(StringPool.OPEN_PARENTHESIS);
10129    
10130                            for (int i = 0; i < folderIds.length; i++) {
10131                                    query.append(_FINDER_COLUMN_G_F_NOTS_FOLDERID_5);
10132    
10133                                    if ((i + 1) < folderIds.length) {
10134                                            query.append(WHERE_OR);
10135                                    }
10136                            }
10137    
10138                            query.append(StringPool.CLOSE_PARENTHESIS);
10139    
10140                            conjunctionable = true;
10141                    }
10142    
10143                    if (conjunctionable) {
10144                            query.append(WHERE_AND);
10145                    }
10146    
10147                    query.append(_FINDER_COLUMN_G_F_NOTS_STATUS_5);
10148    
10149                    conjunctionable = true;
10150    
10151                    if (orderByComparator != null) {
10152                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10153                                    orderByComparator);
10154                    }
10155                    else {
10156                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
10157                    }
10158    
10159                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10160                                    BookmarksEntry.class.getName(),
10161                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
10162                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
10163    
10164                    Session session = null;
10165    
10166                    try {
10167                            session = openSession();
10168    
10169                            Query q = session.createQuery(sql);
10170    
10171                            QueryPos qPos = QueryPos.getInstance(q);
10172    
10173                            qPos.add(groupId);
10174    
10175                            if (folderIds != null) {
10176                                    qPos.add(folderIds);
10177                            }
10178    
10179                            qPos.add(status);
10180    
10181                            return (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start,
10182                                    end);
10183                    }
10184                    catch (Exception e) {
10185                            throw processException(e);
10186                    }
10187                    finally {
10188                            closeSession(session);
10189                    }
10190            }
10191    
10192            /**
10193             * Returns all the bookmarks entries where groupId = &#63; and folderId = any &#63; and status &ne; &#63;.
10194             *
10195             * <p>
10196             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link 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.
10197             * </p>
10198             *
10199             * @param groupId the group ID
10200             * @param folderIds the folder IDs
10201             * @param status the status
10202             * @return the matching bookmarks entries
10203             * @throws SystemException if a system exception occurred
10204             */
10205            @Override
10206            public List<BookmarksEntry> findByG_F_NotS(long groupId, long[] folderIds,
10207                    int status) throws SystemException {
10208                    return findByG_F_NotS(groupId, folderIds, status, QueryUtil.ALL_POS,
10209                            QueryUtil.ALL_POS, null);
10210            }
10211    
10212            /**
10213             * Returns a range of all the bookmarks entries where groupId = &#63; and folderId = any &#63; and status &ne; &#63;.
10214             *
10215             * <p>
10216             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link 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.
10217             * </p>
10218             *
10219             * @param groupId the group ID
10220             * @param folderIds the folder IDs
10221             * @param status the status
10222             * @param start the lower bound of the range of bookmarks entries
10223             * @param end the upper bound of the range of bookmarks entries (not inclusive)
10224             * @return the range of matching bookmarks entries
10225             * @throws SystemException if a system exception occurred
10226             */
10227            @Override
10228            public List<BookmarksEntry> findByG_F_NotS(long groupId, long[] folderIds,
10229                    int status, int start, int end) throws SystemException {
10230                    return findByG_F_NotS(groupId, folderIds, status, start, end, null);
10231            }
10232    
10233            /**
10234             * Returns an ordered range of all the bookmarks entries where groupId = &#63; and folderId = any &#63; and status &ne; &#63;.
10235             *
10236             * <p>
10237             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
10238             * </p>
10239             *
10240             * @param groupId the group ID
10241             * @param folderIds the folder IDs
10242             * @param status the status
10243             * @param start the lower bound of the range of bookmarks entries
10244             * @param end the upper bound of the range of bookmarks entries (not inclusive)
10245             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10246             * @return the ordered range of matching bookmarks entries
10247             * @throws SystemException if a system exception occurred
10248             */
10249            @Override
10250            public List<BookmarksEntry> findByG_F_NotS(long groupId, long[] folderIds,
10251                    int status, int start, int end, OrderByComparator orderByComparator)
10252                    throws SystemException {
10253                    if ((folderIds != null) && (folderIds.length == 1)) {
10254                            return findByG_F_NotS(groupId, folderIds[0], status, start, end,
10255                                    orderByComparator);
10256                    }
10257    
10258                    boolean pagination = true;
10259                    Object[] finderArgs = null;
10260    
10261                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
10262                                    (orderByComparator == null)) {
10263                            pagination = false;
10264                            finderArgs = new Object[] {
10265                                            groupId, StringUtil.merge(folderIds), status
10266                                    };
10267                    }
10268                    else {
10269                            finderArgs = new Object[] {
10270                                            groupId, StringUtil.merge(folderIds), status,
10271                                            
10272                                            start, end, orderByComparator
10273                                    };
10274                    }
10275    
10276                    List<BookmarksEntry> list = (List<BookmarksEntry>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_NOTS,
10277                                    finderArgs, this);
10278    
10279                    if ((list != null) && !list.isEmpty()) {
10280                            for (BookmarksEntry bookmarksEntry : list) {
10281                                    if ((groupId != bookmarksEntry.getGroupId()) ||
10282                                                    !ArrayUtil.contains(folderIds,
10283                                                            bookmarksEntry.getFolderId()) ||
10284                                                    (status != bookmarksEntry.getStatus())) {
10285                                            list = null;
10286    
10287                                            break;
10288                                    }
10289                            }
10290                    }
10291    
10292                    if (list == null) {
10293                            StringBundler query = new StringBundler();
10294    
10295                            query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
10296    
10297                            boolean conjunctionable = false;
10298    
10299                            if (conjunctionable) {
10300                                    query.append(WHERE_AND);
10301                            }
10302    
10303                            query.append(_FINDER_COLUMN_G_F_NOTS_GROUPID_5);
10304    
10305                            conjunctionable = true;
10306    
10307                            if ((folderIds == null) || (folderIds.length > 0)) {
10308                                    if (conjunctionable) {
10309                                            query.append(WHERE_AND);
10310                                    }
10311    
10312                                    query.append(StringPool.OPEN_PARENTHESIS);
10313    
10314                                    for (int i = 0; i < folderIds.length; i++) {
10315                                            query.append(_FINDER_COLUMN_G_F_NOTS_FOLDERID_5);
10316    
10317                                            if ((i + 1) < folderIds.length) {
10318                                                    query.append(WHERE_OR);
10319                                            }
10320                                    }
10321    
10322                                    query.append(StringPool.CLOSE_PARENTHESIS);
10323    
10324                                    conjunctionable = true;
10325                            }
10326    
10327                            if (conjunctionable) {
10328                                    query.append(WHERE_AND);
10329                            }
10330    
10331                            query.append(_FINDER_COLUMN_G_F_NOTS_STATUS_5);
10332    
10333                            conjunctionable = true;
10334    
10335                            if (orderByComparator != null) {
10336                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10337                                            orderByComparator);
10338                            }
10339                            else
10340                             if (pagination) {
10341                                    query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
10342                            }
10343    
10344                            String sql = query.toString();
10345    
10346                            Session session = null;
10347    
10348                            try {
10349                                    session = openSession();
10350    
10351                                    Query q = session.createQuery(sql);
10352    
10353                                    QueryPos qPos = QueryPos.getInstance(q);
10354    
10355                                    qPos.add(groupId);
10356    
10357                                    if (folderIds != null) {
10358                                            qPos.add(folderIds);
10359                                    }
10360    
10361                                    qPos.add(status);
10362    
10363                                    if (!pagination) {
10364                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
10365                                                            getDialect(), start, end, false);
10366    
10367                                            Collections.sort(list);
10368    
10369                                            list = new UnmodifiableList<BookmarksEntry>(list);
10370                                    }
10371                                    else {
10372                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
10373                                                            getDialect(), start, end);
10374                                    }
10375    
10376                                    cacheResult(list);
10377    
10378                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_NOTS,
10379                                            finderArgs, list);
10380                            }
10381                            catch (Exception e) {
10382                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_NOTS,
10383                                            finderArgs);
10384    
10385                                    throw processException(e);
10386                            }
10387                            finally {
10388                                    closeSession(session);
10389                            }
10390                    }
10391    
10392                    return list;
10393            }
10394    
10395            /**
10396             * Removes all the bookmarks entries where groupId = &#63; and folderId = &#63; and status &ne; &#63; from the database.
10397             *
10398             * @param groupId the group ID
10399             * @param folderId the folder ID
10400             * @param status the status
10401             * @throws SystemException if a system exception occurred
10402             */
10403            @Override
10404            public void removeByG_F_NotS(long groupId, long folderId, int status)
10405                    throws SystemException {
10406                    for (BookmarksEntry bookmarksEntry : findByG_F_NotS(groupId, folderId,
10407                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
10408                            remove(bookmarksEntry);
10409                    }
10410            }
10411    
10412            /**
10413             * Returns the number of bookmarks entries where groupId = &#63; and folderId = &#63; and status &ne; &#63;.
10414             *
10415             * @param groupId the group ID
10416             * @param folderId the folder ID
10417             * @param status the status
10418             * @return the number of matching bookmarks entries
10419             * @throws SystemException if a system exception occurred
10420             */
10421            @Override
10422            public int countByG_F_NotS(long groupId, long folderId, int status)
10423                    throws SystemException {
10424                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_NOTS;
10425    
10426                    Object[] finderArgs = new Object[] { groupId, folderId, status };
10427    
10428                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
10429                                    this);
10430    
10431                    if (count == null) {
10432                            StringBundler query = new StringBundler(4);
10433    
10434                            query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
10435    
10436                            query.append(_FINDER_COLUMN_G_F_NOTS_GROUPID_2);
10437    
10438                            query.append(_FINDER_COLUMN_G_F_NOTS_FOLDERID_2);
10439    
10440                            query.append(_FINDER_COLUMN_G_F_NOTS_STATUS_2);
10441    
10442                            String sql = query.toString();
10443    
10444                            Session session = null;
10445    
10446                            try {
10447                                    session = openSession();
10448    
10449                                    Query q = session.createQuery(sql);
10450    
10451                                    QueryPos qPos = QueryPos.getInstance(q);
10452    
10453                                    qPos.add(groupId);
10454    
10455                                    qPos.add(folderId);
10456    
10457                                    qPos.add(status);
10458    
10459                                    count = (Long)q.uniqueResult();
10460    
10461                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
10462                            }
10463                            catch (Exception e) {
10464                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
10465    
10466                                    throw processException(e);
10467                            }
10468                            finally {
10469                                    closeSession(session);
10470                            }
10471                    }
10472    
10473                    return count.intValue();
10474            }
10475    
10476            /**
10477             * Returns the number of bookmarks entries where groupId = &#63; and folderId = any &#63; and status &ne; &#63;.
10478             *
10479             * @param groupId the group ID
10480             * @param folderIds the folder IDs
10481             * @param status the status
10482             * @return the number of matching bookmarks entries
10483             * @throws SystemException if a system exception occurred
10484             */
10485            @Override
10486            public int countByG_F_NotS(long groupId, long[] folderIds, int status)
10487                    throws SystemException {
10488                    Object[] finderArgs = new Object[] {
10489                                    groupId, StringUtil.merge(folderIds), status
10490                            };
10491    
10492                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_NOTS,
10493                                    finderArgs, this);
10494    
10495                    if (count == null) {
10496                            StringBundler query = new StringBundler();
10497    
10498                            query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
10499    
10500                            boolean conjunctionable = false;
10501    
10502                            if (conjunctionable) {
10503                                    query.append(WHERE_AND);
10504                            }
10505    
10506                            query.append(_FINDER_COLUMN_G_F_NOTS_GROUPID_5);
10507    
10508                            conjunctionable = true;
10509    
10510                            if ((folderIds == null) || (folderIds.length > 0)) {
10511                                    if (conjunctionable) {
10512                                            query.append(WHERE_AND);
10513                                    }
10514    
10515                                    query.append(StringPool.OPEN_PARENTHESIS);
10516    
10517                                    for (int i = 0; i < folderIds.length; i++) {
10518                                            query.append(_FINDER_COLUMN_G_F_NOTS_FOLDERID_5);
10519    
10520                                            if ((i + 1) < folderIds.length) {
10521                                                    query.append(WHERE_OR);
10522                                            }
10523                                    }
10524    
10525                                    query.append(StringPool.CLOSE_PARENTHESIS);
10526    
10527                                    conjunctionable = true;
10528                            }
10529    
10530                            if (conjunctionable) {
10531                                    query.append(WHERE_AND);
10532                            }
10533    
10534                            query.append(_FINDER_COLUMN_G_F_NOTS_STATUS_5);
10535    
10536                            conjunctionable = true;
10537    
10538                            String sql = query.toString();
10539    
10540                            Session session = null;
10541    
10542                            try {
10543                                    session = openSession();
10544    
10545                                    Query q = session.createQuery(sql);
10546    
10547                                    QueryPos qPos = QueryPos.getInstance(q);
10548    
10549                                    qPos.add(groupId);
10550    
10551                                    if (folderIds != null) {
10552                                            qPos.add(folderIds);
10553                                    }
10554    
10555                                    qPos.add(status);
10556    
10557                                    count = (Long)q.uniqueResult();
10558    
10559                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_NOTS,
10560                                            finderArgs, count);
10561                            }
10562                            catch (Exception e) {
10563                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_NOTS,
10564                                            finderArgs);
10565    
10566                                    throw processException(e);
10567                            }
10568                            finally {
10569                                    closeSession(session);
10570                            }
10571                    }
10572    
10573                    return count.intValue();
10574            }
10575    
10576            /**
10577             * Returns the number of bookmarks entries that the user has permission to view where groupId = &#63; and folderId = &#63; and status &ne; &#63;.
10578             *
10579             * @param groupId the group ID
10580             * @param folderId the folder ID
10581             * @param status the status
10582             * @return the number of matching bookmarks entries that the user has permission to view
10583             * @throws SystemException if a system exception occurred
10584             */
10585            @Override
10586            public int filterCountByG_F_NotS(long groupId, long folderId, int status)
10587                    throws SystemException {
10588                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10589                            return countByG_F_NotS(groupId, folderId, status);
10590                    }
10591    
10592                    StringBundler query = new StringBundler(4);
10593    
10594                    query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
10595    
10596                    query.append(_FINDER_COLUMN_G_F_NOTS_GROUPID_2);
10597    
10598                    query.append(_FINDER_COLUMN_G_F_NOTS_FOLDERID_2);
10599    
10600                    query.append(_FINDER_COLUMN_G_F_NOTS_STATUS_2);
10601    
10602                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10603                                    BookmarksEntry.class.getName(),
10604                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
10605                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
10606    
10607                    Session session = null;
10608    
10609                    try {
10610                            session = openSession();
10611    
10612                            Query q = session.createQuery(sql);
10613    
10614                            QueryPos qPos = QueryPos.getInstance(q);
10615    
10616                            qPos.add(groupId);
10617    
10618                            qPos.add(folderId);
10619    
10620                            qPos.add(status);
10621    
10622                            Long count = (Long)q.uniqueResult();
10623    
10624                            return count.intValue();
10625                    }
10626                    catch (Exception e) {
10627                            throw processException(e);
10628                    }
10629                    finally {
10630                            closeSession(session);
10631                    }
10632            }
10633    
10634            /**
10635             * Returns the number of bookmarks entries that the user has permission to view where groupId = &#63; and folderId = any &#63; and status &ne; &#63;.
10636             *
10637             * @param groupId the group ID
10638             * @param folderIds the folder IDs
10639             * @param status the status
10640             * @return the number of matching bookmarks entries that the user has permission to view
10641             * @throws SystemException if a system exception occurred
10642             */
10643            @Override
10644            public int filterCountByG_F_NotS(long groupId, long[] folderIds, int status)
10645                    throws SystemException {
10646                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10647                            return countByG_F_NotS(groupId, folderIds, status);
10648                    }
10649    
10650                    StringBundler query = new StringBundler();
10651    
10652                    query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
10653    
10654                    boolean conjunctionable = false;
10655    
10656                    if (conjunctionable) {
10657                            query.append(WHERE_AND);
10658                    }
10659    
10660                    query.append(_FINDER_COLUMN_G_F_NOTS_GROUPID_5);
10661    
10662                    conjunctionable = true;
10663    
10664                    if ((folderIds == null) || (folderIds.length > 0)) {
10665                            if (conjunctionable) {
10666                                    query.append(WHERE_AND);
10667                            }
10668    
10669                            query.append(StringPool.OPEN_PARENTHESIS);
10670    
10671                            for (int i = 0; i < folderIds.length; i++) {
10672                                    query.append(_FINDER_COLUMN_G_F_NOTS_FOLDERID_5);
10673    
10674                                    if ((i + 1) < folderIds.length) {
10675                                            query.append(WHERE_OR);
10676                                    }
10677                            }
10678    
10679                            query.append(StringPool.CLOSE_PARENTHESIS);
10680    
10681                            conjunctionable = true;
10682                    }
10683    
10684                    if (conjunctionable) {
10685                            query.append(WHERE_AND);
10686                    }
10687    
10688                    query.append(_FINDER_COLUMN_G_F_NOTS_STATUS_5);
10689    
10690                    conjunctionable = true;
10691    
10692                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10693                                    BookmarksEntry.class.getName(),
10694                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
10695                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
10696    
10697                    Session session = null;
10698    
10699                    try {
10700                            session = openSession();
10701    
10702                            Query q = session.createQuery(sql);
10703    
10704                            QueryPos qPos = QueryPos.getInstance(q);
10705    
10706                            qPos.add(groupId);
10707    
10708                            if (folderIds != null) {
10709                                    qPos.add(folderIds);
10710                            }
10711    
10712                            qPos.add(status);
10713    
10714                            Long count = (Long)q.uniqueResult();
10715    
10716                            return count.intValue();
10717                    }
10718                    catch (Exception e) {
10719                            throw processException(e);
10720                    }
10721                    finally {
10722                            closeSession(session);
10723                    }
10724            }
10725    
10726            private static final String _FINDER_COLUMN_G_F_NOTS_GROUPID_2 = "bookmarksEntry.groupId = ? AND ";
10727            private static final String _FINDER_COLUMN_G_F_NOTS_GROUPID_5 = "(" +
10728                    removeConjunction(_FINDER_COLUMN_G_F_NOTS_GROUPID_2) + ")";
10729            private static final String _FINDER_COLUMN_G_F_NOTS_FOLDERID_2 = "bookmarksEntry.folderId = ? AND ";
10730            private static final String _FINDER_COLUMN_G_F_NOTS_FOLDERID_5 = "(" +
10731                    removeConjunction(_FINDER_COLUMN_G_F_NOTS_FOLDERID_2) + ")";
10732            private static final String _FINDER_COLUMN_G_F_NOTS_STATUS_2 = "bookmarksEntry.status != ?";
10733            private static final String _FINDER_COLUMN_G_F_NOTS_STATUS_5 = "(" +
10734                    removeConjunction(_FINDER_COLUMN_G_F_NOTS_STATUS_2) + ")";
10735            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_F_S = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
10736                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
10737                            BookmarksEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
10738                            "findByG_U_F_S",
10739                            new String[] {
10740                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
10741                                    Integer.class.getName(),
10742                                    
10743                            Integer.class.getName(), Integer.class.getName(),
10744                                    OrderByComparator.class.getName()
10745                            });
10746            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_F_S =
10747                    new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
10748                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
10749                            BookmarksEntryImpl.class,
10750                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U_F_S",
10751                            new String[] {
10752                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
10753                                    Integer.class.getName()
10754                            },
10755                            BookmarksEntryModelImpl.GROUPID_COLUMN_BITMASK |
10756                            BookmarksEntryModelImpl.USERID_COLUMN_BITMASK |
10757                            BookmarksEntryModelImpl.FOLDERID_COLUMN_BITMASK |
10758                            BookmarksEntryModelImpl.STATUS_COLUMN_BITMASK |
10759                            BookmarksEntryModelImpl.NAME_COLUMN_BITMASK);
10760            public static final FinderPath FINDER_PATH_COUNT_BY_G_U_F_S = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
10761                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
10762                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U_F_S",
10763                            new String[] {
10764                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
10765                                    Integer.class.getName()
10766                            });
10767            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_F_S = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
10768                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
10769                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_U_F_S",
10770                            new String[] {
10771                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
10772                                    Integer.class.getName()
10773                            });
10774    
10775            /**
10776             * Returns all the bookmarks entries where groupId = &#63; and userId = &#63; and folderId = &#63; and status = &#63;.
10777             *
10778             * @param groupId the group ID
10779             * @param userId the user ID
10780             * @param folderId the folder ID
10781             * @param status the status
10782             * @return the matching bookmarks entries
10783             * @throws SystemException if a system exception occurred
10784             */
10785            @Override
10786            public List<BookmarksEntry> findByG_U_F_S(long groupId, long userId,
10787                    long folderId, int status) throws SystemException {
10788                    return findByG_U_F_S(groupId, userId, folderId, status,
10789                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
10790            }
10791    
10792            /**
10793             * Returns a range of all the bookmarks entries where groupId = &#63; and userId = &#63; and folderId = &#63; and status = &#63;.
10794             *
10795             * <p>
10796             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
10797             * </p>
10798             *
10799             * @param groupId the group ID
10800             * @param userId the user ID
10801             * @param folderId the folder ID
10802             * @param status the status
10803             * @param start the lower bound of the range of bookmarks entries
10804             * @param end the upper bound of the range of bookmarks entries (not inclusive)
10805             * @return the range of matching bookmarks entries
10806             * @throws SystemException if a system exception occurred
10807             */
10808            @Override
10809            public List<BookmarksEntry> findByG_U_F_S(long groupId, long userId,
10810                    long folderId, int status, int start, int end)
10811                    throws SystemException {
10812                    return findByG_U_F_S(groupId, userId, folderId, status, start, end, null);
10813            }
10814    
10815            /**
10816             * Returns an ordered range of all the bookmarks entries where groupId = &#63; and userId = &#63; and folderId = &#63; and status = &#63;.
10817             *
10818             * <p>
10819             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
10820             * </p>
10821             *
10822             * @param groupId the group ID
10823             * @param userId the user ID
10824             * @param folderId the folder ID
10825             * @param status the status
10826             * @param start the lower bound of the range of bookmarks entries
10827             * @param end the upper bound of the range of bookmarks entries (not inclusive)
10828             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10829             * @return the ordered range of matching bookmarks entries
10830             * @throws SystemException if a system exception occurred
10831             */
10832            @Override
10833            public List<BookmarksEntry> findByG_U_F_S(long groupId, long userId,
10834                    long folderId, int status, int start, int end,
10835                    OrderByComparator orderByComparator) throws SystemException {
10836                    boolean pagination = true;
10837                    FinderPath finderPath = null;
10838                    Object[] finderArgs = null;
10839    
10840                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
10841                                    (orderByComparator == null)) {
10842                            pagination = false;
10843                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_F_S;
10844                            finderArgs = new Object[] { groupId, userId, folderId, status };
10845                    }
10846                    else {
10847                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_F_S;
10848                            finderArgs = new Object[] {
10849                                            groupId, userId, folderId, status,
10850                                            
10851                                            start, end, orderByComparator
10852                                    };
10853                    }
10854    
10855                    List<BookmarksEntry> list = (List<BookmarksEntry>)FinderCacheUtil.getResult(finderPath,
10856                                    finderArgs, this);
10857    
10858                    if ((list != null) && !list.isEmpty()) {
10859                            for (BookmarksEntry bookmarksEntry : list) {
10860                                    if ((groupId != bookmarksEntry.getGroupId()) ||
10861                                                    (userId != bookmarksEntry.getUserId()) ||
10862                                                    (folderId != bookmarksEntry.getFolderId()) ||
10863                                                    (status != bookmarksEntry.getStatus())) {
10864                                            list = null;
10865    
10866                                            break;
10867                                    }
10868                            }
10869                    }
10870    
10871                    if (list == null) {
10872                            StringBundler query = null;
10873    
10874                            if (orderByComparator != null) {
10875                                    query = new StringBundler(6 +
10876                                                    (orderByComparator.getOrderByFields().length * 3));
10877                            }
10878                            else {
10879                                    query = new StringBundler(6);
10880                            }
10881    
10882                            query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
10883    
10884                            query.append(_FINDER_COLUMN_G_U_F_S_GROUPID_2);
10885    
10886                            query.append(_FINDER_COLUMN_G_U_F_S_USERID_2);
10887    
10888                            query.append(_FINDER_COLUMN_G_U_F_S_FOLDERID_2);
10889    
10890                            query.append(_FINDER_COLUMN_G_U_F_S_STATUS_2);
10891    
10892                            if (orderByComparator != null) {
10893                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10894                                            orderByComparator);
10895                            }
10896                            else
10897                             if (pagination) {
10898                                    query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
10899                            }
10900    
10901                            String sql = query.toString();
10902    
10903                            Session session = null;
10904    
10905                            try {
10906                                    session = openSession();
10907    
10908                                    Query q = session.createQuery(sql);
10909    
10910                                    QueryPos qPos = QueryPos.getInstance(q);
10911    
10912                                    qPos.add(groupId);
10913    
10914                                    qPos.add(userId);
10915    
10916                                    qPos.add(folderId);
10917    
10918                                    qPos.add(status);
10919    
10920                                    if (!pagination) {
10921                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
10922                                                            getDialect(), start, end, false);
10923    
10924                                            Collections.sort(list);
10925    
10926                                            list = new UnmodifiableList<BookmarksEntry>(list);
10927                                    }
10928                                    else {
10929                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
10930                                                            getDialect(), start, end);
10931                                    }
10932    
10933                                    cacheResult(list);
10934    
10935                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
10936                            }
10937                            catch (Exception e) {
10938                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
10939    
10940                                    throw processException(e);
10941                            }
10942                            finally {
10943                                    closeSession(session);
10944                            }
10945                    }
10946    
10947                    return list;
10948            }
10949    
10950            /**
10951             * Returns the first bookmarks entry in the ordered set where groupId = &#63; and userId = &#63; and folderId = &#63; and status = &#63;.
10952             *
10953             * @param groupId the group ID
10954             * @param userId the user ID
10955             * @param folderId the folder ID
10956             * @param status the status
10957             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10958             * @return the first matching bookmarks entry
10959             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
10960             * @throws SystemException if a system exception occurred
10961             */
10962            @Override
10963            public BookmarksEntry findByG_U_F_S_First(long groupId, long userId,
10964                    long folderId, int status, OrderByComparator orderByComparator)
10965                    throws NoSuchEntryException, SystemException {
10966                    BookmarksEntry bookmarksEntry = fetchByG_U_F_S_First(groupId, userId,
10967                                    folderId, status, orderByComparator);
10968    
10969                    if (bookmarksEntry != null) {
10970                            return bookmarksEntry;
10971                    }
10972    
10973                    StringBundler msg = new StringBundler(10);
10974    
10975                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
10976    
10977                    msg.append("groupId=");
10978                    msg.append(groupId);
10979    
10980                    msg.append(", userId=");
10981                    msg.append(userId);
10982    
10983                    msg.append(", folderId=");
10984                    msg.append(folderId);
10985    
10986                    msg.append(", status=");
10987                    msg.append(status);
10988    
10989                    msg.append(StringPool.CLOSE_CURLY_BRACE);
10990    
10991                    throw new NoSuchEntryException(msg.toString());
10992            }
10993    
10994            /**
10995             * Returns the first bookmarks entry in the ordered set where groupId = &#63; and userId = &#63; and folderId = &#63; and status = &#63;.
10996             *
10997             * @param groupId the group ID
10998             * @param userId the user ID
10999             * @param folderId the folder ID
11000             * @param status the status
11001             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11002             * @return the first matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
11003             * @throws SystemException if a system exception occurred
11004             */
11005            @Override
11006            public BookmarksEntry fetchByG_U_F_S_First(long groupId, long userId,
11007                    long folderId, int status, OrderByComparator orderByComparator)
11008                    throws SystemException {
11009                    List<BookmarksEntry> list = findByG_U_F_S(groupId, userId, folderId,
11010                                    status, 0, 1, orderByComparator);
11011    
11012                    if (!list.isEmpty()) {
11013                            return list.get(0);
11014                    }
11015    
11016                    return null;
11017            }
11018    
11019            /**
11020             * Returns the last bookmarks entry in the ordered set where groupId = &#63; and userId = &#63; and folderId = &#63; and status = &#63;.
11021             *
11022             * @param groupId the group ID
11023             * @param userId the user ID
11024             * @param folderId the folder ID
11025             * @param status the status
11026             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11027             * @return the last matching bookmarks entry
11028             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
11029             * @throws SystemException if a system exception occurred
11030             */
11031            @Override
11032            public BookmarksEntry findByG_U_F_S_Last(long groupId, long userId,
11033                    long folderId, int status, OrderByComparator orderByComparator)
11034                    throws NoSuchEntryException, SystemException {
11035                    BookmarksEntry bookmarksEntry = fetchByG_U_F_S_Last(groupId, userId,
11036                                    folderId, status, orderByComparator);
11037    
11038                    if (bookmarksEntry != null) {
11039                            return bookmarksEntry;
11040                    }
11041    
11042                    StringBundler msg = new StringBundler(10);
11043    
11044                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
11045    
11046                    msg.append("groupId=");
11047                    msg.append(groupId);
11048    
11049                    msg.append(", userId=");
11050                    msg.append(userId);
11051    
11052                    msg.append(", folderId=");
11053                    msg.append(folderId);
11054    
11055                    msg.append(", status=");
11056                    msg.append(status);
11057    
11058                    msg.append(StringPool.CLOSE_CURLY_BRACE);
11059    
11060                    throw new NoSuchEntryException(msg.toString());
11061            }
11062    
11063            /**
11064             * Returns the last bookmarks entry in the ordered set where groupId = &#63; and userId = &#63; and folderId = &#63; and status = &#63;.
11065             *
11066             * @param groupId the group ID
11067             * @param userId the user ID
11068             * @param folderId the folder ID
11069             * @param status the status
11070             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11071             * @return the last matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
11072             * @throws SystemException if a system exception occurred
11073             */
11074            @Override
11075            public BookmarksEntry fetchByG_U_F_S_Last(long groupId, long userId,
11076                    long folderId, int status, OrderByComparator orderByComparator)
11077                    throws SystemException {
11078                    int count = countByG_U_F_S(groupId, userId, folderId, status);
11079    
11080                    if (count == 0) {
11081                            return null;
11082                    }
11083    
11084                    List<BookmarksEntry> list = findByG_U_F_S(groupId, userId, folderId,
11085                                    status, count - 1, count, orderByComparator);
11086    
11087                    if (!list.isEmpty()) {
11088                            return list.get(0);
11089                    }
11090    
11091                    return null;
11092            }
11093    
11094            /**
11095             * 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;.
11096             *
11097             * @param entryId the primary key of the current bookmarks entry
11098             * @param groupId the group ID
11099             * @param userId the user ID
11100             * @param folderId the folder ID
11101             * @param status the status
11102             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11103             * @return the previous, current, and next bookmarks entry
11104             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
11105             * @throws SystemException if a system exception occurred
11106             */
11107            @Override
11108            public BookmarksEntry[] findByG_U_F_S_PrevAndNext(long entryId,
11109                    long groupId, long userId, long folderId, int status,
11110                    OrderByComparator orderByComparator)
11111                    throws NoSuchEntryException, SystemException {
11112                    BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
11113    
11114                    Session session = null;
11115    
11116                    try {
11117                            session = openSession();
11118    
11119                            BookmarksEntry[] array = new BookmarksEntryImpl[3];
11120    
11121                            array[0] = getByG_U_F_S_PrevAndNext(session, bookmarksEntry,
11122                                            groupId, userId, folderId, status, orderByComparator, true);
11123    
11124                            array[1] = bookmarksEntry;
11125    
11126                            array[2] = getByG_U_F_S_PrevAndNext(session, bookmarksEntry,
11127                                            groupId, userId, folderId, status, orderByComparator, false);
11128    
11129                            return array;
11130                    }
11131                    catch (Exception e) {
11132                            throw processException(e);
11133                    }
11134                    finally {
11135                            closeSession(session);
11136                    }
11137            }
11138    
11139            protected BookmarksEntry getByG_U_F_S_PrevAndNext(Session session,
11140                    BookmarksEntry bookmarksEntry, long groupId, long userId,
11141                    long folderId, int status, OrderByComparator orderByComparator,
11142                    boolean previous) {
11143                    StringBundler query = null;
11144    
11145                    if (orderByComparator != null) {
11146                            query = new StringBundler(6 +
11147                                            (orderByComparator.getOrderByFields().length * 6));
11148                    }
11149                    else {
11150                            query = new StringBundler(3);
11151                    }
11152    
11153                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
11154    
11155                    query.append(_FINDER_COLUMN_G_U_F_S_GROUPID_2);
11156    
11157                    query.append(_FINDER_COLUMN_G_U_F_S_USERID_2);
11158    
11159                    query.append(_FINDER_COLUMN_G_U_F_S_FOLDERID_2);
11160    
11161                    query.append(_FINDER_COLUMN_G_U_F_S_STATUS_2);
11162    
11163                    if (orderByComparator != null) {
11164                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11165    
11166                            if (orderByConditionFields.length > 0) {
11167                                    query.append(WHERE_AND);
11168                            }
11169    
11170                            for (int i = 0; i < orderByConditionFields.length; i++) {
11171                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11172                                    query.append(orderByConditionFields[i]);
11173    
11174                                    if ((i + 1) < orderByConditionFields.length) {
11175                                            if (orderByComparator.isAscending() ^ previous) {
11176                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
11177                                            }
11178                                            else {
11179                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
11180                                            }
11181                                    }
11182                                    else {
11183                                            if (orderByComparator.isAscending() ^ previous) {
11184                                                    query.append(WHERE_GREATER_THAN);
11185                                            }
11186                                            else {
11187                                                    query.append(WHERE_LESSER_THAN);
11188                                            }
11189                                    }
11190                            }
11191    
11192                            query.append(ORDER_BY_CLAUSE);
11193    
11194                            String[] orderByFields = orderByComparator.getOrderByFields();
11195    
11196                            for (int i = 0; i < orderByFields.length; i++) {
11197                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11198                                    query.append(orderByFields[i]);
11199    
11200                                    if ((i + 1) < orderByFields.length) {
11201                                            if (orderByComparator.isAscending() ^ previous) {
11202                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
11203                                            }
11204                                            else {
11205                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
11206                                            }
11207                                    }
11208                                    else {
11209                                            if (orderByComparator.isAscending() ^ previous) {
11210                                                    query.append(ORDER_BY_ASC);
11211                                            }
11212                                            else {
11213                                                    query.append(ORDER_BY_DESC);
11214                                            }
11215                                    }
11216                            }
11217                    }
11218                    else {
11219                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
11220                    }
11221    
11222                    String sql = query.toString();
11223    
11224                    Query q = session.createQuery(sql);
11225    
11226                    q.setFirstResult(0);
11227                    q.setMaxResults(2);
11228    
11229                    QueryPos qPos = QueryPos.getInstance(q);
11230    
11231                    qPos.add(groupId);
11232    
11233                    qPos.add(userId);
11234    
11235                    qPos.add(folderId);
11236    
11237                    qPos.add(status);
11238    
11239                    if (orderByComparator != null) {
11240                            Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry);
11241    
11242                            for (Object value : values) {
11243                                    qPos.add(value);
11244                            }
11245                    }
11246    
11247                    List<BookmarksEntry> list = q.list();
11248    
11249                    if (list.size() == 2) {
11250                            return list.get(1);
11251                    }
11252                    else {
11253                            return null;
11254                    }
11255            }
11256    
11257            /**
11258             * Returns all the bookmarks entries that the user has permission to view where groupId = &#63; and userId = &#63; and folderId = &#63; and status = &#63;.
11259             *
11260             * @param groupId the group ID
11261             * @param userId the user ID
11262             * @param folderId the folder ID
11263             * @param status the status
11264             * @return the matching bookmarks entries that the user has permission to view
11265             * @throws SystemException if a system exception occurred
11266             */
11267            @Override
11268            public List<BookmarksEntry> filterFindByG_U_F_S(long groupId, long userId,
11269                    long folderId, int status) throws SystemException {
11270                    return filterFindByG_U_F_S(groupId, userId, folderId, status,
11271                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
11272            }
11273    
11274            /**
11275             * 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;.
11276             *
11277             * <p>
11278             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
11279             * </p>
11280             *
11281             * @param groupId the group ID
11282             * @param userId the user ID
11283             * @param folderId the folder ID
11284             * @param status the status
11285             * @param start the lower bound of the range of bookmarks entries
11286             * @param end the upper bound of the range of bookmarks entries (not inclusive)
11287             * @return the range of matching bookmarks entries that the user has permission to view
11288             * @throws SystemException if a system exception occurred
11289             */
11290            @Override
11291            public List<BookmarksEntry> filterFindByG_U_F_S(long groupId, long userId,
11292                    long folderId, int status, int start, int end)
11293                    throws SystemException {
11294                    return filterFindByG_U_F_S(groupId, userId, folderId, status, start,
11295                            end, null);
11296            }
11297    
11298            /**
11299             * 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;.
11300             *
11301             * <p>
11302             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
11303             * </p>
11304             *
11305             * @param groupId the group ID
11306             * @param userId the user ID
11307             * @param folderId the folder ID
11308             * @param status the status
11309             * @param start the lower bound of the range of bookmarks entries
11310             * @param end the upper bound of the range of bookmarks entries (not inclusive)
11311             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11312             * @return the ordered range of matching bookmarks entries that the user has permission to view
11313             * @throws SystemException if a system exception occurred
11314             */
11315            @Override
11316            public List<BookmarksEntry> filterFindByG_U_F_S(long groupId, long userId,
11317                    long folderId, int status, int start, int end,
11318                    OrderByComparator orderByComparator) throws SystemException {
11319                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11320                            return findByG_U_F_S(groupId, userId, folderId, status, start, end,
11321                                    orderByComparator);
11322                    }
11323    
11324                    StringBundler query = null;
11325    
11326                    if (orderByComparator != null) {
11327                            query = new StringBundler(6 +
11328                                            (orderByComparator.getOrderByFields().length * 3));
11329                    }
11330                    else {
11331                            query = new StringBundler(6);
11332                    }
11333    
11334                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
11335    
11336                    query.append(_FINDER_COLUMN_G_U_F_S_GROUPID_2);
11337    
11338                    query.append(_FINDER_COLUMN_G_U_F_S_USERID_2);
11339    
11340                    query.append(_FINDER_COLUMN_G_U_F_S_FOLDERID_2);
11341    
11342                    query.append(_FINDER_COLUMN_G_U_F_S_STATUS_2);
11343    
11344                    if (orderByComparator != null) {
11345                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11346                                    orderByComparator);
11347                    }
11348                    else {
11349                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
11350                    }
11351    
11352                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11353                                    BookmarksEntry.class.getName(),
11354                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
11355                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
11356    
11357                    Session session = null;
11358    
11359                    try {
11360                            session = openSession();
11361    
11362                            Query q = session.createQuery(sql);
11363    
11364                            QueryPos qPos = QueryPos.getInstance(q);
11365    
11366                            qPos.add(groupId);
11367    
11368                            qPos.add(userId);
11369    
11370                            qPos.add(folderId);
11371    
11372                            qPos.add(status);
11373    
11374                            return (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start,
11375                                    end);
11376                    }
11377                    catch (Exception e) {
11378                            throw processException(e);
11379                    }
11380                    finally {
11381                            closeSession(session);
11382                    }
11383            }
11384    
11385            /**
11386             * 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;.
11387             *
11388             * @param entryId the primary key of the current bookmarks entry
11389             * @param groupId the group ID
11390             * @param userId the user ID
11391             * @param folderId the folder ID
11392             * @param status the status
11393             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
11394             * @return the previous, current, and next bookmarks entry
11395             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
11396             * @throws SystemException if a system exception occurred
11397             */
11398            @Override
11399            public BookmarksEntry[] filterFindByG_U_F_S_PrevAndNext(long entryId,
11400                    long groupId, long userId, long folderId, int status,
11401                    OrderByComparator orderByComparator)
11402                    throws NoSuchEntryException, SystemException {
11403                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11404                            return findByG_U_F_S_PrevAndNext(entryId, groupId, userId,
11405                                    folderId, status, orderByComparator);
11406                    }
11407    
11408                    BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
11409    
11410                    Session session = null;
11411    
11412                    try {
11413                            session = openSession();
11414    
11415                            BookmarksEntry[] array = new BookmarksEntryImpl[3];
11416    
11417                            array[0] = filterGetByG_U_F_S_PrevAndNext(session, bookmarksEntry,
11418                                            groupId, userId, folderId, status, orderByComparator, true);
11419    
11420                            array[1] = bookmarksEntry;
11421    
11422                            array[2] = filterGetByG_U_F_S_PrevAndNext(session, bookmarksEntry,
11423                                            groupId, userId, folderId, status, orderByComparator, false);
11424    
11425                            return array;
11426                    }
11427                    catch (Exception e) {
11428                            throw processException(e);
11429                    }
11430                    finally {
11431                            closeSession(session);
11432                    }
11433            }
11434    
11435            protected BookmarksEntry filterGetByG_U_F_S_PrevAndNext(Session session,
11436                    BookmarksEntry bookmarksEntry, long groupId, long userId,
11437                    long folderId, int status, OrderByComparator orderByComparator,
11438                    boolean previous) {
11439                    StringBundler query = null;
11440    
11441                    if (orderByComparator != null) {
11442                            query = new StringBundler(6 +
11443                                            (orderByComparator.getOrderByFields().length * 6));
11444                    }
11445                    else {
11446                            query = new StringBundler(3);
11447                    }
11448    
11449                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
11450    
11451                    query.append(_FINDER_COLUMN_G_U_F_S_GROUPID_2);
11452    
11453                    query.append(_FINDER_COLUMN_G_U_F_S_USERID_2);
11454    
11455                    query.append(_FINDER_COLUMN_G_U_F_S_FOLDERID_2);
11456    
11457                    query.append(_FINDER_COLUMN_G_U_F_S_STATUS_2);
11458    
11459                    if (orderByComparator != null) {
11460                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
11461    
11462                            if (orderByConditionFields.length > 0) {
11463                                    query.append(WHERE_AND);
11464                            }
11465    
11466                            for (int i = 0; i < orderByConditionFields.length; i++) {
11467                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11468                                    query.append(orderByConditionFields[i]);
11469    
11470                                    if ((i + 1) < orderByConditionFields.length) {
11471                                            if (orderByComparator.isAscending() ^ previous) {
11472                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
11473                                            }
11474                                            else {
11475                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
11476                                            }
11477                                    }
11478                                    else {
11479                                            if (orderByComparator.isAscending() ^ previous) {
11480                                                    query.append(WHERE_GREATER_THAN);
11481                                            }
11482                                            else {
11483                                                    query.append(WHERE_LESSER_THAN);
11484                                            }
11485                                    }
11486                            }
11487    
11488                            query.append(ORDER_BY_CLAUSE);
11489    
11490                            String[] orderByFields = orderByComparator.getOrderByFields();
11491    
11492                            for (int i = 0; i < orderByFields.length; i++) {
11493                                    query.append(_ORDER_BY_ENTITY_ALIAS);
11494                                    query.append(orderByFields[i]);
11495    
11496                                    if ((i + 1) < orderByFields.length) {
11497                                            if (orderByComparator.isAscending() ^ previous) {
11498                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
11499                                            }
11500                                            else {
11501                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
11502                                            }
11503                                    }
11504                                    else {
11505                                            if (orderByComparator.isAscending() ^ previous) {
11506                                                    query.append(ORDER_BY_ASC);
11507                                            }
11508                                            else {
11509                                                    query.append(ORDER_BY_DESC);
11510                                            }
11511                                    }
11512                            }
11513                    }
11514                    else {
11515                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
11516                    }
11517    
11518                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11519                                    BookmarksEntry.class.getName(),
11520                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
11521                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
11522    
11523                    Query q = session.createQuery(sql);
11524    
11525                    q.setFirstResult(0);
11526                    q.setMaxResults(2);
11527    
11528                    QueryPos qPos = QueryPos.getInstance(q);
11529    
11530                    qPos.add(groupId);
11531    
11532                    qPos.add(userId);
11533    
11534                    qPos.add(folderId);
11535    
11536                    qPos.add(status);
11537    
11538                    if (orderByComparator != null) {
11539                            Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry);
11540    
11541                            for (Object value : values) {
11542                                    qPos.add(value);
11543                            }
11544                    }
11545    
11546                    List<BookmarksEntry> list = q.list();
11547    
11548                    if (list.size() == 2) {
11549                            return list.get(1);
11550                    }
11551                    else {
11552                            return null;
11553                    }
11554            }
11555    
11556            /**
11557             * 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;.
11558             *
11559             * @param groupId the group ID
11560             * @param userId the user ID
11561             * @param folderIds the folder IDs
11562             * @param status the status
11563             * @return the matching bookmarks entries that the user has permission to view
11564             * @throws SystemException if a system exception occurred
11565             */
11566            @Override
11567            public List<BookmarksEntry> filterFindByG_U_F_S(long groupId, long userId,
11568                    long[] folderIds, int status) throws SystemException {
11569                    return filterFindByG_U_F_S(groupId, userId, folderIds, status,
11570                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
11571            }
11572    
11573            /**
11574             * 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;.
11575             *
11576             * <p>
11577             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
11578             * </p>
11579             *
11580             * @param groupId the group ID
11581             * @param userId the user ID
11582             * @param folderIds the folder IDs
11583             * @param status the status
11584             * @param start the lower bound of the range of bookmarks entries
11585             * @param end the upper bound of the range of bookmarks entries (not inclusive)
11586             * @return the range of matching bookmarks entries that the user has permission to view
11587             * @throws SystemException if a system exception occurred
11588             */
11589            @Override
11590            public List<BookmarksEntry> filterFindByG_U_F_S(long groupId, long userId,
11591                    long[] folderIds, int status, int start, int end)
11592                    throws SystemException {
11593                    return filterFindByG_U_F_S(groupId, userId, folderIds, status, start,
11594                            end, null);
11595            }
11596    
11597            /**
11598             * 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;.
11599             *
11600             * <p>
11601             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
11602             * </p>
11603             *
11604             * @param groupId the group ID
11605             * @param userId the user ID
11606             * @param folderIds the folder IDs
11607             * @param status the status
11608             * @param start the lower bound of the range of bookmarks entries
11609             * @param end the upper bound of the range of bookmarks entries (not inclusive)
11610             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11611             * @return the ordered range of matching bookmarks entries that the user has permission to view
11612             * @throws SystemException if a system exception occurred
11613             */
11614            @Override
11615            public List<BookmarksEntry> filterFindByG_U_F_S(long groupId, long userId,
11616                    long[] folderIds, int status, int start, int end,
11617                    OrderByComparator orderByComparator) throws SystemException {
11618                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
11619                            return findByG_U_F_S(groupId, userId, folderIds, status, start,
11620                                    end, orderByComparator);
11621                    }
11622    
11623                    StringBundler query = new StringBundler();
11624    
11625                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
11626    
11627                    boolean conjunctionable = false;
11628    
11629                    if (conjunctionable) {
11630                            query.append(WHERE_AND);
11631                    }
11632    
11633                    query.append(_FINDER_COLUMN_G_U_F_S_GROUPID_5);
11634    
11635                    conjunctionable = true;
11636    
11637                    if (conjunctionable) {
11638                            query.append(WHERE_AND);
11639                    }
11640    
11641                    query.append(_FINDER_COLUMN_G_U_F_S_USERID_5);
11642    
11643                    conjunctionable = true;
11644    
11645                    if ((folderIds == null) || (folderIds.length > 0)) {
11646                            if (conjunctionable) {
11647                                    query.append(WHERE_AND);
11648                            }
11649    
11650                            query.append(StringPool.OPEN_PARENTHESIS);
11651    
11652                            for (int i = 0; i < folderIds.length; i++) {
11653                                    query.append(_FINDER_COLUMN_G_U_F_S_FOLDERID_5);
11654    
11655                                    if ((i + 1) < folderIds.length) {
11656                                            query.append(WHERE_OR);
11657                                    }
11658                            }
11659    
11660                            query.append(StringPool.CLOSE_PARENTHESIS);
11661    
11662                            conjunctionable = true;
11663                    }
11664    
11665                    if (conjunctionable) {
11666                            query.append(WHERE_AND);
11667                    }
11668    
11669                    query.append(_FINDER_COLUMN_G_U_F_S_STATUS_5);
11670    
11671                    conjunctionable = true;
11672    
11673                    if (orderByComparator != null) {
11674                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11675                                    orderByComparator);
11676                    }
11677                    else {
11678                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
11679                    }
11680    
11681                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
11682                                    BookmarksEntry.class.getName(),
11683                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
11684                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
11685    
11686                    Session session = null;
11687    
11688                    try {
11689                            session = openSession();
11690    
11691                            Query q = session.createQuery(sql);
11692    
11693                            QueryPos qPos = QueryPos.getInstance(q);
11694    
11695                            qPos.add(groupId);
11696    
11697                            qPos.add(userId);
11698    
11699                            if (folderIds != null) {
11700                                    qPos.add(folderIds);
11701                            }
11702    
11703                            qPos.add(status);
11704    
11705                            return (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start,
11706                                    end);
11707                    }
11708                    catch (Exception e) {
11709                            throw processException(e);
11710                    }
11711                    finally {
11712                            closeSession(session);
11713                    }
11714            }
11715    
11716            /**
11717             * Returns all the bookmarks entries where groupId = &#63; and userId = &#63; and folderId = any &#63; and status = &#63;.
11718             *
11719             * <p>
11720             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
11721             * </p>
11722             *
11723             * @param groupId the group ID
11724             * @param userId the user ID
11725             * @param folderIds the folder IDs
11726             * @param status the status
11727             * @return the matching bookmarks entries
11728             * @throws SystemException if a system exception occurred
11729             */
11730            @Override
11731            public List<BookmarksEntry> findByG_U_F_S(long groupId, long userId,
11732                    long[] folderIds, int status) throws SystemException {
11733                    return findByG_U_F_S(groupId, userId, folderIds, status,
11734                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
11735            }
11736    
11737            /**
11738             * Returns a range of all the bookmarks entries where groupId = &#63; and userId = &#63; and folderId = any &#63; and status = &#63;.
11739             *
11740             * <p>
11741             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
11742             * </p>
11743             *
11744             * @param groupId the group ID
11745             * @param userId the user ID
11746             * @param folderIds the folder IDs
11747             * @param status the status
11748             * @param start the lower bound of the range of bookmarks entries
11749             * @param end the upper bound of the range of bookmarks entries (not inclusive)
11750             * @return the range of matching bookmarks entries
11751             * @throws SystemException if a system exception occurred
11752             */
11753            @Override
11754            public List<BookmarksEntry> findByG_U_F_S(long groupId, long userId,
11755                    long[] folderIds, int status, int start, int end)
11756                    throws SystemException {
11757                    return findByG_U_F_S(groupId, userId, folderIds, status, start, end,
11758                            null);
11759            }
11760    
11761            /**
11762             * Returns an ordered range of all the bookmarks entries where groupId = &#63; and userId = &#63; and folderId = any &#63; and status = &#63;.
11763             *
11764             * <p>
11765             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
11766             * </p>
11767             *
11768             * @param groupId the group ID
11769             * @param userId the user ID
11770             * @param folderIds the folder IDs
11771             * @param status the status
11772             * @param start the lower bound of the range of bookmarks entries
11773             * @param end the upper bound of the range of bookmarks entries (not inclusive)
11774             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11775             * @return the ordered range of matching bookmarks entries
11776             * @throws SystemException if a system exception occurred
11777             */
11778            @Override
11779            public List<BookmarksEntry> findByG_U_F_S(long groupId, long userId,
11780                    long[] folderIds, int status, int start, int end,
11781                    OrderByComparator orderByComparator) throws SystemException {
11782                    if ((folderIds != null) && (folderIds.length == 1)) {
11783                            return findByG_U_F_S(groupId, userId, folderIds[0], status, start,
11784                                    end, orderByComparator);
11785                    }
11786    
11787                    boolean pagination = true;
11788                    Object[] finderArgs = null;
11789    
11790                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
11791                                    (orderByComparator == null)) {
11792                            pagination = false;
11793                            finderArgs = new Object[] {
11794                                            groupId, userId, StringUtil.merge(folderIds), status
11795                                    };
11796                    }
11797                    else {
11798                            finderArgs = new Object[] {
11799                                            groupId, userId, StringUtil.merge(folderIds), status,
11800                                            
11801                                            start, end, orderByComparator
11802                                    };
11803                    }
11804    
11805                    List<BookmarksEntry> list = (List<BookmarksEntry>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_F_S,
11806                                    finderArgs, this);
11807    
11808                    if ((list != null) && !list.isEmpty()) {
11809                            for (BookmarksEntry bookmarksEntry : list) {
11810                                    if ((groupId != bookmarksEntry.getGroupId()) ||
11811                                                    (userId != bookmarksEntry.getUserId()) ||
11812                                                    !ArrayUtil.contains(folderIds,
11813                                                            bookmarksEntry.getFolderId()) ||
11814                                                    (status != bookmarksEntry.getStatus())) {
11815                                            list = null;
11816    
11817                                            break;
11818                                    }
11819                            }
11820                    }
11821    
11822                    if (list == null) {
11823                            StringBundler query = new StringBundler();
11824    
11825                            query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
11826    
11827                            boolean conjunctionable = false;
11828    
11829                            if (conjunctionable) {
11830                                    query.append(WHERE_AND);
11831                            }
11832    
11833                            query.append(_FINDER_COLUMN_G_U_F_S_GROUPID_5);
11834    
11835                            conjunctionable = true;
11836    
11837                            if (conjunctionable) {
11838                                    query.append(WHERE_AND);
11839                            }
11840    
11841                            query.append(_FINDER_COLUMN_G_U_F_S_USERID_5);
11842    
11843                            conjunctionable = true;
11844    
11845                            if ((folderIds == null) || (folderIds.length > 0)) {
11846                                    if (conjunctionable) {
11847                                            query.append(WHERE_AND);
11848                                    }
11849    
11850                                    query.append(StringPool.OPEN_PARENTHESIS);
11851    
11852                                    for (int i = 0; i < folderIds.length; i++) {
11853                                            query.append(_FINDER_COLUMN_G_U_F_S_FOLDERID_5);
11854    
11855                                            if ((i + 1) < folderIds.length) {
11856                                                    query.append(WHERE_OR);
11857                                            }
11858                                    }
11859    
11860                                    query.append(StringPool.CLOSE_PARENTHESIS);
11861    
11862                                    conjunctionable = true;
11863                            }
11864    
11865                            if (conjunctionable) {
11866                                    query.append(WHERE_AND);
11867                            }
11868    
11869                            query.append(_FINDER_COLUMN_G_U_F_S_STATUS_5);
11870    
11871                            conjunctionable = true;
11872    
11873                            if (orderByComparator != null) {
11874                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11875                                            orderByComparator);
11876                            }
11877                            else
11878                             if (pagination) {
11879                                    query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
11880                            }
11881    
11882                            String sql = query.toString();
11883    
11884                            Session session = null;
11885    
11886                            try {
11887                                    session = openSession();
11888    
11889                                    Query q = session.createQuery(sql);
11890    
11891                                    QueryPos qPos = QueryPos.getInstance(q);
11892    
11893                                    qPos.add(groupId);
11894    
11895                                    qPos.add(userId);
11896    
11897                                    if (folderIds != null) {
11898                                            qPos.add(folderIds);
11899                                    }
11900    
11901                                    qPos.add(status);
11902    
11903                                    if (!pagination) {
11904                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
11905                                                            getDialect(), start, end, false);
11906    
11907                                            Collections.sort(list);
11908    
11909                                            list = new UnmodifiableList<BookmarksEntry>(list);
11910                                    }
11911                                    else {
11912                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
11913                                                            getDialect(), start, end);
11914                                    }
11915    
11916                                    cacheResult(list);
11917    
11918                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_F_S,
11919                                            finderArgs, list);
11920                            }
11921                            catch (Exception e) {
11922                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_F_S,
11923                                            finderArgs);
11924    
11925                                    throw processException(e);
11926                            }
11927                            finally {
11928                                    closeSession(session);
11929                            }
11930                    }
11931    
11932                    return list;
11933            }
11934    
11935            /**
11936             * Removes all the bookmarks entries where groupId = &#63; and userId = &#63; and folderId = &#63; and status = &#63; from the database.
11937             *
11938             * @param groupId the group ID
11939             * @param userId the user ID
11940             * @param folderId the folder ID
11941             * @param status the status
11942             * @throws SystemException if a system exception occurred
11943             */
11944            @Override
11945            public void removeByG_U_F_S(long groupId, long userId, long folderId,
11946                    int status) throws SystemException {
11947                    for (BookmarksEntry bookmarksEntry : findByG_U_F_S(groupId, userId,
11948                                    folderId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
11949                            remove(bookmarksEntry);
11950                    }
11951            }
11952    
11953            /**
11954             * Returns the number of bookmarks entries where groupId = &#63; and userId = &#63; and folderId = &#63; and status = &#63;.
11955             *
11956             * @param groupId the group ID
11957             * @param userId the user ID
11958             * @param folderId the folder ID
11959             * @param status the status
11960             * @return the number of matching bookmarks entries
11961             * @throws SystemException if a system exception occurred
11962             */
11963            @Override
11964            public int countByG_U_F_S(long groupId, long userId, long folderId,
11965                    int status) throws SystemException {
11966                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_U_F_S;
11967    
11968                    Object[] finderArgs = new Object[] { groupId, userId, folderId, status };
11969    
11970                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
11971                                    this);
11972    
11973                    if (count == null) {
11974                            StringBundler query = new StringBundler(5);
11975    
11976                            query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
11977    
11978                            query.append(_FINDER_COLUMN_G_U_F_S_GROUPID_2);
11979    
11980                            query.append(_FINDER_COLUMN_G_U_F_S_USERID_2);
11981    
11982                            query.append(_FINDER_COLUMN_G_U_F_S_FOLDERID_2);
11983    
11984                            query.append(_FINDER_COLUMN_G_U_F_S_STATUS_2);
11985    
11986                            String sql = query.toString();
11987    
11988                            Session session = null;
11989    
11990                            try {
11991                                    session = openSession();
11992    
11993                                    Query q = session.createQuery(sql);
11994    
11995                                    QueryPos qPos = QueryPos.getInstance(q);
11996    
11997                                    qPos.add(groupId);
11998    
11999                                    qPos.add(userId);
12000    
12001                                    qPos.add(folderId);
12002    
12003                                    qPos.add(status);
12004    
12005                                    count = (Long)q.uniqueResult();
12006    
12007                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
12008                            }
12009                            catch (Exception e) {
12010                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
12011    
12012                                    throw processException(e);
12013                            }
12014                            finally {
12015                                    closeSession(session);
12016                            }
12017                    }
12018    
12019                    return count.intValue();
12020            }
12021    
12022            /**
12023             * Returns the number of bookmarks entries where groupId = &#63; and userId = &#63; and folderId = any &#63; and status = &#63;.
12024             *
12025             * @param groupId the group ID
12026             * @param userId the user ID
12027             * @param folderIds the folder IDs
12028             * @param status the status
12029             * @return the number of matching bookmarks entries
12030             * @throws SystemException if a system exception occurred
12031             */
12032            @Override
12033            public int countByG_U_F_S(long groupId, long userId, long[] folderIds,
12034                    int status) throws SystemException {
12035                    Object[] finderArgs = new Object[] {
12036                                    groupId, userId, StringUtil.merge(folderIds), status
12037                            };
12038    
12039                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_F_S,
12040                                    finderArgs, this);
12041    
12042                    if (count == null) {
12043                            StringBundler query = new StringBundler();
12044    
12045                            query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
12046    
12047                            boolean conjunctionable = false;
12048    
12049                            if (conjunctionable) {
12050                                    query.append(WHERE_AND);
12051                            }
12052    
12053                            query.append(_FINDER_COLUMN_G_U_F_S_GROUPID_5);
12054    
12055                            conjunctionable = true;
12056    
12057                            if (conjunctionable) {
12058                                    query.append(WHERE_AND);
12059                            }
12060    
12061                            query.append(_FINDER_COLUMN_G_U_F_S_USERID_5);
12062    
12063                            conjunctionable = true;
12064    
12065                            if ((folderIds == null) || (folderIds.length > 0)) {
12066                                    if (conjunctionable) {
12067                                            query.append(WHERE_AND);
12068                                    }
12069    
12070                                    query.append(StringPool.OPEN_PARENTHESIS);
12071    
12072                                    for (int i = 0; i < folderIds.length; i++) {
12073                                            query.append(_FINDER_COLUMN_G_U_F_S_FOLDERID_5);
12074    
12075                                            if ((i + 1) < folderIds.length) {
12076                                                    query.append(WHERE_OR);
12077                                            }
12078                                    }
12079    
12080                                    query.append(StringPool.CLOSE_PARENTHESIS);
12081    
12082                                    conjunctionable = true;
12083                            }
12084    
12085                            if (conjunctionable) {
12086                                    query.append(WHERE_AND);
12087                            }
12088    
12089                            query.append(_FINDER_COLUMN_G_U_F_S_STATUS_5);
12090    
12091                            conjunctionable = true;
12092    
12093                            String sql = query.toString();
12094    
12095                            Session session = null;
12096    
12097                            try {
12098                                    session = openSession();
12099    
12100                                    Query q = session.createQuery(sql);
12101    
12102                                    QueryPos qPos = QueryPos.getInstance(q);
12103    
12104                                    qPos.add(groupId);
12105    
12106                                    qPos.add(userId);
12107    
12108                                    if (folderIds != null) {
12109                                            qPos.add(folderIds);
12110                                    }
12111    
12112                                    qPos.add(status);
12113    
12114                                    count = (Long)q.uniqueResult();
12115    
12116                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_F_S,
12117                                            finderArgs, count);
12118                            }
12119                            catch (Exception e) {
12120                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_F_S,
12121                                            finderArgs);
12122    
12123                                    throw processException(e);
12124                            }
12125                            finally {
12126                                    closeSession(session);
12127                            }
12128                    }
12129    
12130                    return count.intValue();
12131            }
12132    
12133            /**
12134             * 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;.
12135             *
12136             * @param groupId the group ID
12137             * @param userId the user ID
12138             * @param folderId the folder ID
12139             * @param status the status
12140             * @return the number of matching bookmarks entries that the user has permission to view
12141             * @throws SystemException if a system exception occurred
12142             */
12143            @Override
12144            public int filterCountByG_U_F_S(long groupId, long userId, long folderId,
12145                    int status) throws SystemException {
12146                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12147                            return countByG_U_F_S(groupId, userId, folderId, status);
12148                    }
12149    
12150                    StringBundler query = new StringBundler(5);
12151    
12152                    query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
12153    
12154                    query.append(_FINDER_COLUMN_G_U_F_S_GROUPID_2);
12155    
12156                    query.append(_FINDER_COLUMN_G_U_F_S_USERID_2);
12157    
12158                    query.append(_FINDER_COLUMN_G_U_F_S_FOLDERID_2);
12159    
12160                    query.append(_FINDER_COLUMN_G_U_F_S_STATUS_2);
12161    
12162                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12163                                    BookmarksEntry.class.getName(),
12164                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
12165                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
12166    
12167                    Session session = null;
12168    
12169                    try {
12170                            session = openSession();
12171    
12172                            Query q = session.createQuery(sql);
12173    
12174                            QueryPos qPos = QueryPos.getInstance(q);
12175    
12176                            qPos.add(groupId);
12177    
12178                            qPos.add(userId);
12179    
12180                            qPos.add(folderId);
12181    
12182                            qPos.add(status);
12183    
12184                            Long count = (Long)q.uniqueResult();
12185    
12186                            return count.intValue();
12187                    }
12188                    catch (Exception e) {
12189                            throw processException(e);
12190                    }
12191                    finally {
12192                            closeSession(session);
12193                    }
12194            }
12195    
12196            /**
12197             * 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;.
12198             *
12199             * @param groupId the group ID
12200             * @param userId the user ID
12201             * @param folderIds the folder IDs
12202             * @param status the status
12203             * @return the number of matching bookmarks entries that the user has permission to view
12204             * @throws SystemException if a system exception occurred
12205             */
12206            @Override
12207            public int filterCountByG_U_F_S(long groupId, long userId,
12208                    long[] folderIds, int status) throws SystemException {
12209                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
12210                            return countByG_U_F_S(groupId, userId, folderIds, status);
12211                    }
12212    
12213                    StringBundler query = new StringBundler();
12214    
12215                    query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
12216    
12217                    boolean conjunctionable = false;
12218    
12219                    if (conjunctionable) {
12220                            query.append(WHERE_AND);
12221                    }
12222    
12223                    query.append(_FINDER_COLUMN_G_U_F_S_GROUPID_5);
12224    
12225                    conjunctionable = true;
12226    
12227                    if (conjunctionable) {
12228                            query.append(WHERE_AND);
12229                    }
12230    
12231                    query.append(_FINDER_COLUMN_G_U_F_S_USERID_5);
12232    
12233                    conjunctionable = true;
12234    
12235                    if ((folderIds == null) || (folderIds.length > 0)) {
12236                            if (conjunctionable) {
12237                                    query.append(WHERE_AND);
12238                            }
12239    
12240                            query.append(StringPool.OPEN_PARENTHESIS);
12241    
12242                            for (int i = 0; i < folderIds.length; i++) {
12243                                    query.append(_FINDER_COLUMN_G_U_F_S_FOLDERID_5);
12244    
12245                                    if ((i + 1) < folderIds.length) {
12246                                            query.append(WHERE_OR);
12247                                    }
12248                            }
12249    
12250                            query.append(StringPool.CLOSE_PARENTHESIS);
12251    
12252                            conjunctionable = true;
12253                    }
12254    
12255                    if (conjunctionable) {
12256                            query.append(WHERE_AND);
12257                    }
12258    
12259                    query.append(_FINDER_COLUMN_G_U_F_S_STATUS_5);
12260    
12261                    conjunctionable = true;
12262    
12263                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
12264                                    BookmarksEntry.class.getName(),
12265                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
12266                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
12267    
12268                    Session session = null;
12269    
12270                    try {
12271                            session = openSession();
12272    
12273                            Query q = session.createQuery(sql);
12274    
12275                            QueryPos qPos = QueryPos.getInstance(q);
12276    
12277                            qPos.add(groupId);
12278    
12279                            qPos.add(userId);
12280    
12281                            if (folderIds != null) {
12282                                    qPos.add(folderIds);
12283                            }
12284    
12285                            qPos.add(status);
12286    
12287                            Long count = (Long)q.uniqueResult();
12288    
12289                            return count.intValue();
12290                    }
12291                    catch (Exception e) {
12292                            throw processException(e);
12293                    }
12294                    finally {
12295                            closeSession(session);
12296                    }
12297            }
12298    
12299            private static final String _FINDER_COLUMN_G_U_F_S_GROUPID_2 = "bookmarksEntry.groupId = ? AND ";
12300            private static final String _FINDER_COLUMN_G_U_F_S_GROUPID_5 = "(" +
12301                    removeConjunction(_FINDER_COLUMN_G_U_F_S_GROUPID_2) + ")";
12302            private static final String _FINDER_COLUMN_G_U_F_S_USERID_2 = "bookmarksEntry.userId = ? AND ";
12303            private static final String _FINDER_COLUMN_G_U_F_S_USERID_5 = "(" +
12304                    removeConjunction(_FINDER_COLUMN_G_U_F_S_USERID_2) + ")";
12305            private static final String _FINDER_COLUMN_G_U_F_S_FOLDERID_2 = "bookmarksEntry.folderId = ? AND ";
12306            private static final String _FINDER_COLUMN_G_U_F_S_FOLDERID_5 = "(" +
12307                    removeConjunction(_FINDER_COLUMN_G_U_F_S_FOLDERID_2) + ")";
12308            private static final String _FINDER_COLUMN_G_U_F_S_STATUS_2 = "bookmarksEntry.status = ?";
12309            private static final String _FINDER_COLUMN_G_U_F_S_STATUS_5 = "(" +
12310                    removeConjunction(_FINDER_COLUMN_G_U_F_S_STATUS_2) + ")";
12311    
12312            public BookmarksEntryPersistenceImpl() {
12313                    setModelClass(BookmarksEntry.class);
12314            }
12315    
12316            /**
12317             * Caches the bookmarks entry in the entity cache if it is enabled.
12318             *
12319             * @param bookmarksEntry the bookmarks entry
12320             */
12321            @Override
12322            public void cacheResult(BookmarksEntry bookmarksEntry) {
12323                    EntityCacheUtil.putResult(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
12324                            BookmarksEntryImpl.class, bookmarksEntry.getPrimaryKey(),
12325                            bookmarksEntry);
12326    
12327                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
12328                            new Object[] { bookmarksEntry.getUuid(), bookmarksEntry.getGroupId() },
12329                            bookmarksEntry);
12330    
12331                    bookmarksEntry.resetOriginalValues();
12332            }
12333    
12334            /**
12335             * Caches the bookmarks entries in the entity cache if it is enabled.
12336             *
12337             * @param bookmarksEntries the bookmarks entries
12338             */
12339            @Override
12340            public void cacheResult(List<BookmarksEntry> bookmarksEntries) {
12341                    for (BookmarksEntry bookmarksEntry : bookmarksEntries) {
12342                            if (EntityCacheUtil.getResult(
12343                                                    BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
12344                                                    BookmarksEntryImpl.class, bookmarksEntry.getPrimaryKey()) == null) {
12345                                    cacheResult(bookmarksEntry);
12346                            }
12347                            else {
12348                                    bookmarksEntry.resetOriginalValues();
12349                            }
12350                    }
12351            }
12352    
12353            /**
12354             * Clears the cache for all bookmarks entries.
12355             *
12356             * <p>
12357             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
12358             * </p>
12359             */
12360            @Override
12361            public void clearCache() {
12362                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
12363                            CacheRegistryUtil.clear(BookmarksEntryImpl.class.getName());
12364                    }
12365    
12366                    EntityCacheUtil.clearCache(BookmarksEntryImpl.class.getName());
12367    
12368                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
12369                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
12370                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
12371            }
12372    
12373            /**
12374             * Clears the cache for the bookmarks entry.
12375             *
12376             * <p>
12377             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
12378             * </p>
12379             */
12380            @Override
12381            public void clearCache(BookmarksEntry bookmarksEntry) {
12382                    EntityCacheUtil.removeResult(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
12383                            BookmarksEntryImpl.class, bookmarksEntry.getPrimaryKey());
12384    
12385                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
12386                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
12387    
12388                    clearUniqueFindersCache(bookmarksEntry);
12389            }
12390    
12391            @Override
12392            public void clearCache(List<BookmarksEntry> bookmarksEntries) {
12393                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
12394                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
12395    
12396                    for (BookmarksEntry bookmarksEntry : bookmarksEntries) {
12397                            EntityCacheUtil.removeResult(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
12398                                    BookmarksEntryImpl.class, bookmarksEntry.getPrimaryKey());
12399    
12400                            clearUniqueFindersCache(bookmarksEntry);
12401                    }
12402            }
12403    
12404            protected void cacheUniqueFindersCache(BookmarksEntry bookmarksEntry) {
12405                    if (bookmarksEntry.isNew()) {
12406                            Object[] args = new Object[] {
12407                                            bookmarksEntry.getUuid(), bookmarksEntry.getGroupId()
12408                                    };
12409    
12410                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
12411                                    Long.valueOf(1));
12412                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
12413                                    bookmarksEntry);
12414                    }
12415                    else {
12416                            BookmarksEntryModelImpl bookmarksEntryModelImpl = (BookmarksEntryModelImpl)bookmarksEntry;
12417    
12418                            if ((bookmarksEntryModelImpl.getColumnBitmask() &
12419                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
12420                                    Object[] args = new Object[] {
12421                                                    bookmarksEntry.getUuid(), bookmarksEntry.getGroupId()
12422                                            };
12423    
12424                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
12425                                            Long.valueOf(1));
12426                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
12427                                            bookmarksEntry);
12428                            }
12429                    }
12430            }
12431    
12432            protected void clearUniqueFindersCache(BookmarksEntry bookmarksEntry) {
12433                    BookmarksEntryModelImpl bookmarksEntryModelImpl = (BookmarksEntryModelImpl)bookmarksEntry;
12434    
12435                    Object[] args = new Object[] {
12436                                    bookmarksEntry.getUuid(), bookmarksEntry.getGroupId()
12437                            };
12438    
12439                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
12440                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
12441    
12442                    if ((bookmarksEntryModelImpl.getColumnBitmask() &
12443                                    FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
12444                            args = new Object[] {
12445                                            bookmarksEntryModelImpl.getOriginalUuid(),
12446                                            bookmarksEntryModelImpl.getOriginalGroupId()
12447                                    };
12448    
12449                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
12450                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
12451                    }
12452            }
12453    
12454            /**
12455             * Creates a new bookmarks entry with the primary key. Does not add the bookmarks entry to the database.
12456             *
12457             * @param entryId the primary key for the new bookmarks entry
12458             * @return the new bookmarks entry
12459             */
12460            @Override
12461            public BookmarksEntry create(long entryId) {
12462                    BookmarksEntry bookmarksEntry = new BookmarksEntryImpl();
12463    
12464                    bookmarksEntry.setNew(true);
12465                    bookmarksEntry.setPrimaryKey(entryId);
12466    
12467                    String uuid = PortalUUIDUtil.generate();
12468    
12469                    bookmarksEntry.setUuid(uuid);
12470    
12471                    return bookmarksEntry;
12472            }
12473    
12474            /**
12475             * Removes the bookmarks entry with the primary key from the database. Also notifies the appropriate model listeners.
12476             *
12477             * @param entryId the primary key of the bookmarks entry
12478             * @return the bookmarks entry that was removed
12479             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
12480             * @throws SystemException if a system exception occurred
12481             */
12482            @Override
12483            public BookmarksEntry remove(long entryId)
12484                    throws NoSuchEntryException, SystemException {
12485                    return remove((Serializable)entryId);
12486            }
12487    
12488            /**
12489             * Removes the bookmarks entry with the primary key from the database. Also notifies the appropriate model listeners.
12490             *
12491             * @param primaryKey the primary key of the bookmarks entry
12492             * @return the bookmarks entry that was removed
12493             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
12494             * @throws SystemException if a system exception occurred
12495             */
12496            @Override
12497            public BookmarksEntry remove(Serializable primaryKey)
12498                    throws NoSuchEntryException, SystemException {
12499                    Session session = null;
12500    
12501                    try {
12502                            session = openSession();
12503    
12504                            BookmarksEntry bookmarksEntry = (BookmarksEntry)session.get(BookmarksEntryImpl.class,
12505                                            primaryKey);
12506    
12507                            if (bookmarksEntry == null) {
12508                                    if (_log.isWarnEnabled()) {
12509                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
12510                                    }
12511    
12512                                    throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
12513                                            primaryKey);
12514                            }
12515    
12516                            return remove(bookmarksEntry);
12517                    }
12518                    catch (NoSuchEntryException nsee) {
12519                            throw nsee;
12520                    }
12521                    catch (Exception e) {
12522                            throw processException(e);
12523                    }
12524                    finally {
12525                            closeSession(session);
12526                    }
12527            }
12528    
12529            @Override
12530            protected BookmarksEntry removeImpl(BookmarksEntry bookmarksEntry)
12531                    throws SystemException {
12532                    bookmarksEntry = toUnwrappedModel(bookmarksEntry);
12533    
12534                    Session session = null;
12535    
12536                    try {
12537                            session = openSession();
12538    
12539                            if (!session.contains(bookmarksEntry)) {
12540                                    bookmarksEntry = (BookmarksEntry)session.get(BookmarksEntryImpl.class,
12541                                                    bookmarksEntry.getPrimaryKeyObj());
12542                            }
12543    
12544                            if (bookmarksEntry != null) {
12545                                    session.delete(bookmarksEntry);
12546                            }
12547                    }
12548                    catch (Exception e) {
12549                            throw processException(e);
12550                    }
12551                    finally {
12552                            closeSession(session);
12553                    }
12554    
12555                    if (bookmarksEntry != null) {
12556                            clearCache(bookmarksEntry);
12557                    }
12558    
12559                    return bookmarksEntry;
12560            }
12561    
12562            @Override
12563            public BookmarksEntry updateImpl(
12564                    com.liferay.portlet.bookmarks.model.BookmarksEntry bookmarksEntry)
12565                    throws SystemException {
12566                    bookmarksEntry = toUnwrappedModel(bookmarksEntry);
12567    
12568                    boolean isNew = bookmarksEntry.isNew();
12569    
12570                    BookmarksEntryModelImpl bookmarksEntryModelImpl = (BookmarksEntryModelImpl)bookmarksEntry;
12571    
12572                    if (Validator.isNull(bookmarksEntry.getUuid())) {
12573                            String uuid = PortalUUIDUtil.generate();
12574    
12575                            bookmarksEntry.setUuid(uuid);
12576                    }
12577    
12578                    Session session = null;
12579    
12580                    try {
12581                            session = openSession();
12582    
12583                            if (bookmarksEntry.isNew()) {
12584                                    session.save(bookmarksEntry);
12585    
12586                                    bookmarksEntry.setNew(false);
12587                            }
12588                            else {
12589                                    session.merge(bookmarksEntry);
12590                            }
12591                    }
12592                    catch (Exception e) {
12593                            throw processException(e);
12594                    }
12595                    finally {
12596                            closeSession(session);
12597                    }
12598    
12599                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
12600    
12601                    if (isNew || !BookmarksEntryModelImpl.COLUMN_BITMASK_ENABLED) {
12602                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
12603                    }
12604    
12605                    else {
12606                            if ((bookmarksEntryModelImpl.getColumnBitmask() &
12607                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEBLOCKID.getColumnBitmask()) != 0) {
12608                                    Object[] args = new Object[] {
12609                                                    bookmarksEntryModelImpl.getOriginalResourceBlockId()
12610                                            };
12611    
12612                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RESOURCEBLOCKID,
12613                                            args);
12614                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEBLOCKID,
12615                                            args);
12616    
12617                                    args = new Object[] { bookmarksEntryModelImpl.getResourceBlockId() };
12618    
12619                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RESOURCEBLOCKID,
12620                                            args);
12621                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEBLOCKID,
12622                                            args);
12623                            }
12624    
12625                            if ((bookmarksEntryModelImpl.getColumnBitmask() &
12626                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
12627                                    Object[] args = new Object[] {
12628                                                    bookmarksEntryModelImpl.getOriginalUuid()
12629                                            };
12630    
12631                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
12632                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
12633                                            args);
12634    
12635                                    args = new Object[] { bookmarksEntryModelImpl.getUuid() };
12636    
12637                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
12638                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
12639                                            args);
12640                            }
12641    
12642                            if ((bookmarksEntryModelImpl.getColumnBitmask() &
12643                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
12644                                    Object[] args = new Object[] {
12645                                                    bookmarksEntryModelImpl.getOriginalUuid(),
12646                                                    bookmarksEntryModelImpl.getOriginalCompanyId()
12647                                            };
12648    
12649                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
12650                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
12651                                            args);
12652    
12653                                    args = new Object[] {
12654                                                    bookmarksEntryModelImpl.getUuid(),
12655                                                    bookmarksEntryModelImpl.getCompanyId()
12656                                            };
12657    
12658                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
12659                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
12660                                            args);
12661                            }
12662    
12663                            if ((bookmarksEntryModelImpl.getColumnBitmask() &
12664                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
12665                                    Object[] args = new Object[] {
12666                                                    bookmarksEntryModelImpl.getOriginalCompanyId()
12667                                            };
12668    
12669                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
12670                                            args);
12671                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
12672                                            args);
12673    
12674                                    args = new Object[] { bookmarksEntryModelImpl.getCompanyId() };
12675    
12676                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
12677                                            args);
12678                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
12679                                            args);
12680                            }
12681    
12682                            if ((bookmarksEntryModelImpl.getColumnBitmask() &
12683                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F.getColumnBitmask()) != 0) {
12684                                    Object[] args = new Object[] {
12685                                                    bookmarksEntryModelImpl.getOriginalGroupId(),
12686                                                    bookmarksEntryModelImpl.getOriginalFolderId()
12687                                            };
12688    
12689                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F, args);
12690                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F,
12691                                            args);
12692    
12693                                    args = new Object[] {
12694                                                    bookmarksEntryModelImpl.getGroupId(),
12695                                                    bookmarksEntryModelImpl.getFolderId()
12696                                            };
12697    
12698                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F, args);
12699                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F,
12700                                            args);
12701                            }
12702    
12703                            if ((bookmarksEntryModelImpl.getColumnBitmask() &
12704                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S.getColumnBitmask()) != 0) {
12705                                    Object[] args = new Object[] {
12706                                                    bookmarksEntryModelImpl.getOriginalGroupId(),
12707                                                    bookmarksEntryModelImpl.getOriginalStatus()
12708                                            };
12709    
12710                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
12711                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
12712                                            args);
12713    
12714                                    args = new Object[] {
12715                                                    bookmarksEntryModelImpl.getGroupId(),
12716                                                    bookmarksEntryModelImpl.getStatus()
12717                                            };
12718    
12719                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
12720                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
12721                                            args);
12722                            }
12723    
12724                            if ((bookmarksEntryModelImpl.getColumnBitmask() &
12725                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S.getColumnBitmask()) != 0) {
12726                                    Object[] args = new Object[] {
12727                                                    bookmarksEntryModelImpl.getOriginalGroupId(),
12728                                                    bookmarksEntryModelImpl.getOriginalUserId(),
12729                                                    bookmarksEntryModelImpl.getOriginalStatus()
12730                                            };
12731    
12732                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_S, args);
12733                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S,
12734                                            args);
12735    
12736                                    args = new Object[] {
12737                                                    bookmarksEntryModelImpl.getGroupId(),
12738                                                    bookmarksEntryModelImpl.getUserId(),
12739                                                    bookmarksEntryModelImpl.getStatus()
12740                                            };
12741    
12742                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_S, args);
12743                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S,
12744                                            args);
12745                            }
12746    
12747                            if ((bookmarksEntryModelImpl.getColumnBitmask() &
12748                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_S.getColumnBitmask()) != 0) {
12749                                    Object[] args = new Object[] {
12750                                                    bookmarksEntryModelImpl.getOriginalGroupId(),
12751                                                    bookmarksEntryModelImpl.getOriginalFolderId(),
12752                                                    bookmarksEntryModelImpl.getOriginalStatus()
12753                                            };
12754    
12755                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F_S, args);
12756                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_S,
12757                                            args);
12758    
12759                                    args = new Object[] {
12760                                                    bookmarksEntryModelImpl.getGroupId(),
12761                                                    bookmarksEntryModelImpl.getFolderId(),
12762                                                    bookmarksEntryModelImpl.getStatus()
12763                                            };
12764    
12765                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F_S, args);
12766                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_S,
12767                                            args);
12768                            }
12769    
12770                            if ((bookmarksEntryModelImpl.getColumnBitmask() &
12771                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_F_S.getColumnBitmask()) != 0) {
12772                                    Object[] args = new Object[] {
12773                                                    bookmarksEntryModelImpl.getOriginalGroupId(),
12774                                                    bookmarksEntryModelImpl.getOriginalUserId(),
12775                                                    bookmarksEntryModelImpl.getOriginalFolderId(),
12776                                                    bookmarksEntryModelImpl.getOriginalStatus()
12777                                            };
12778    
12779                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_F_S, args);
12780                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_F_S,
12781                                            args);
12782    
12783                                    args = new Object[] {
12784                                                    bookmarksEntryModelImpl.getGroupId(),
12785                                                    bookmarksEntryModelImpl.getUserId(),
12786                                                    bookmarksEntryModelImpl.getFolderId(),
12787                                                    bookmarksEntryModelImpl.getStatus()
12788                                            };
12789    
12790                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_F_S, args);
12791                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_F_S,
12792                                            args);
12793                            }
12794                    }
12795    
12796                    EntityCacheUtil.putResult(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
12797                            BookmarksEntryImpl.class, bookmarksEntry.getPrimaryKey(),
12798                            bookmarksEntry);
12799    
12800                    clearUniqueFindersCache(bookmarksEntry);
12801                    cacheUniqueFindersCache(bookmarksEntry);
12802    
12803                    return bookmarksEntry;
12804            }
12805    
12806            protected BookmarksEntry toUnwrappedModel(BookmarksEntry bookmarksEntry) {
12807                    if (bookmarksEntry instanceof BookmarksEntryImpl) {
12808                            return bookmarksEntry;
12809                    }
12810    
12811                    BookmarksEntryImpl bookmarksEntryImpl = new BookmarksEntryImpl();
12812    
12813                    bookmarksEntryImpl.setNew(bookmarksEntry.isNew());
12814                    bookmarksEntryImpl.setPrimaryKey(bookmarksEntry.getPrimaryKey());
12815    
12816                    bookmarksEntryImpl.setUuid(bookmarksEntry.getUuid());
12817                    bookmarksEntryImpl.setEntryId(bookmarksEntry.getEntryId());
12818                    bookmarksEntryImpl.setGroupId(bookmarksEntry.getGroupId());
12819                    bookmarksEntryImpl.setCompanyId(bookmarksEntry.getCompanyId());
12820                    bookmarksEntryImpl.setUserId(bookmarksEntry.getUserId());
12821                    bookmarksEntryImpl.setUserName(bookmarksEntry.getUserName());
12822                    bookmarksEntryImpl.setCreateDate(bookmarksEntry.getCreateDate());
12823                    bookmarksEntryImpl.setModifiedDate(bookmarksEntry.getModifiedDate());
12824                    bookmarksEntryImpl.setResourceBlockId(bookmarksEntry.getResourceBlockId());
12825                    bookmarksEntryImpl.setFolderId(bookmarksEntry.getFolderId());
12826                    bookmarksEntryImpl.setTreePath(bookmarksEntry.getTreePath());
12827                    bookmarksEntryImpl.setName(bookmarksEntry.getName());
12828                    bookmarksEntryImpl.setUrl(bookmarksEntry.getUrl());
12829                    bookmarksEntryImpl.setDescription(bookmarksEntry.getDescription());
12830                    bookmarksEntryImpl.setVisits(bookmarksEntry.getVisits());
12831                    bookmarksEntryImpl.setPriority(bookmarksEntry.getPriority());
12832                    bookmarksEntryImpl.setStatus(bookmarksEntry.getStatus());
12833                    bookmarksEntryImpl.setStatusByUserId(bookmarksEntry.getStatusByUserId());
12834                    bookmarksEntryImpl.setStatusByUserName(bookmarksEntry.getStatusByUserName());
12835                    bookmarksEntryImpl.setStatusDate(bookmarksEntry.getStatusDate());
12836    
12837                    return bookmarksEntryImpl;
12838            }
12839    
12840            /**
12841             * Returns the bookmarks entry with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
12842             *
12843             * @param primaryKey the primary key of the bookmarks entry
12844             * @return the bookmarks entry
12845             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
12846             * @throws SystemException if a system exception occurred
12847             */
12848            @Override
12849            public BookmarksEntry findByPrimaryKey(Serializable primaryKey)
12850                    throws NoSuchEntryException, SystemException {
12851                    BookmarksEntry bookmarksEntry = fetchByPrimaryKey(primaryKey);
12852    
12853                    if (bookmarksEntry == null) {
12854                            if (_log.isWarnEnabled()) {
12855                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
12856                            }
12857    
12858                            throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
12859                                    primaryKey);
12860                    }
12861    
12862                    return bookmarksEntry;
12863            }
12864    
12865            /**
12866             * Returns the bookmarks entry with the primary key or throws a {@link com.liferay.portlet.bookmarks.NoSuchEntryException} if it could not be found.
12867             *
12868             * @param entryId the primary key of the bookmarks entry
12869             * @return the bookmarks entry
12870             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
12871             * @throws SystemException if a system exception occurred
12872             */
12873            @Override
12874            public BookmarksEntry findByPrimaryKey(long entryId)
12875                    throws NoSuchEntryException, SystemException {
12876                    return findByPrimaryKey((Serializable)entryId);
12877            }
12878    
12879            /**
12880             * Returns the bookmarks entry with the primary key or returns <code>null</code> if it could not be found.
12881             *
12882             * @param primaryKey the primary key of the bookmarks entry
12883             * @return the bookmarks entry, or <code>null</code> if a bookmarks entry with the primary key could not be found
12884             * @throws SystemException if a system exception occurred
12885             */
12886            @Override
12887            public BookmarksEntry fetchByPrimaryKey(Serializable primaryKey)
12888                    throws SystemException {
12889                    BookmarksEntry bookmarksEntry = (BookmarksEntry)EntityCacheUtil.getResult(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
12890                                    BookmarksEntryImpl.class, primaryKey);
12891    
12892                    if (bookmarksEntry == _nullBookmarksEntry) {
12893                            return null;
12894                    }
12895    
12896                    if (bookmarksEntry == null) {
12897                            Session session = null;
12898    
12899                            try {
12900                                    session = openSession();
12901    
12902                                    bookmarksEntry = (BookmarksEntry)session.get(BookmarksEntryImpl.class,
12903                                                    primaryKey);
12904    
12905                                    if (bookmarksEntry != null) {
12906                                            cacheResult(bookmarksEntry);
12907                                    }
12908                                    else {
12909                                            EntityCacheUtil.putResult(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
12910                                                    BookmarksEntryImpl.class, primaryKey,
12911                                                    _nullBookmarksEntry);
12912                                    }
12913                            }
12914                            catch (Exception e) {
12915                                    EntityCacheUtil.removeResult(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
12916                                            BookmarksEntryImpl.class, primaryKey);
12917    
12918                                    throw processException(e);
12919                            }
12920                            finally {
12921                                    closeSession(session);
12922                            }
12923                    }
12924    
12925                    return bookmarksEntry;
12926            }
12927    
12928            /**
12929             * Returns the bookmarks entry with the primary key or returns <code>null</code> if it could not be found.
12930             *
12931             * @param entryId the primary key of the bookmarks entry
12932             * @return the bookmarks entry, or <code>null</code> if a bookmarks entry with the primary key could not be found
12933             * @throws SystemException if a system exception occurred
12934             */
12935            @Override
12936            public BookmarksEntry fetchByPrimaryKey(long entryId)
12937                    throws SystemException {
12938                    return fetchByPrimaryKey((Serializable)entryId);
12939            }
12940    
12941            /**
12942             * Returns all the bookmarks entries.
12943             *
12944             * @return the bookmarks entries
12945             * @throws SystemException if a system exception occurred
12946             */
12947            @Override
12948            public List<BookmarksEntry> findAll() throws SystemException {
12949                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
12950            }
12951    
12952            /**
12953             * Returns a range of all the bookmarks entries.
12954             *
12955             * <p>
12956             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
12957             * </p>
12958             *
12959             * @param start the lower bound of the range of bookmarks entries
12960             * @param end the upper bound of the range of bookmarks entries (not inclusive)
12961             * @return the range of bookmarks entries
12962             * @throws SystemException if a system exception occurred
12963             */
12964            @Override
12965            public List<BookmarksEntry> findAll(int start, int end)
12966                    throws SystemException {
12967                    return findAll(start, end, null);
12968            }
12969    
12970            /**
12971             * Returns an ordered range of all the bookmarks entries.
12972             *
12973             * <p>
12974             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
12975             * </p>
12976             *
12977             * @param start the lower bound of the range of bookmarks entries
12978             * @param end the upper bound of the range of bookmarks entries (not inclusive)
12979             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
12980             * @return the ordered range of bookmarks entries
12981             * @throws SystemException if a system exception occurred
12982             */
12983            @Override
12984            public List<BookmarksEntry> findAll(int start, int end,
12985                    OrderByComparator orderByComparator) throws SystemException {
12986                    boolean pagination = true;
12987                    FinderPath finderPath = null;
12988                    Object[] finderArgs = null;
12989    
12990                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
12991                                    (orderByComparator == null)) {
12992                            pagination = false;
12993                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
12994                            finderArgs = FINDER_ARGS_EMPTY;
12995                    }
12996                    else {
12997                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
12998                            finderArgs = new Object[] { start, end, orderByComparator };
12999                    }
13000    
13001                    List<BookmarksEntry> list = (List<BookmarksEntry>)FinderCacheUtil.getResult(finderPath,
13002                                    finderArgs, this);
13003    
13004                    if (list == null) {
13005                            StringBundler query = null;
13006                            String sql = null;
13007    
13008                            if (orderByComparator != null) {
13009                                    query = new StringBundler(2 +
13010                                                    (orderByComparator.getOrderByFields().length * 3));
13011    
13012                                    query.append(_SQL_SELECT_BOOKMARKSENTRY);
13013    
13014                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
13015                                            orderByComparator);
13016    
13017                                    sql = query.toString();
13018                            }
13019                            else {
13020                                    sql = _SQL_SELECT_BOOKMARKSENTRY;
13021    
13022                                    if (pagination) {
13023                                            sql = sql.concat(BookmarksEntryModelImpl.ORDER_BY_JPQL);
13024                                    }
13025                            }
13026    
13027                            Session session = null;
13028    
13029                            try {
13030                                    session = openSession();
13031    
13032                                    Query q = session.createQuery(sql);
13033    
13034                                    if (!pagination) {
13035                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
13036                                                            getDialect(), start, end, false);
13037    
13038                                            Collections.sort(list);
13039    
13040                                            list = new UnmodifiableList<BookmarksEntry>(list);
13041                                    }
13042                                    else {
13043                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
13044                                                            getDialect(), start, end);
13045                                    }
13046    
13047                                    cacheResult(list);
13048    
13049                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
13050                            }
13051                            catch (Exception e) {
13052                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
13053    
13054                                    throw processException(e);
13055                            }
13056                            finally {
13057                                    closeSession(session);
13058                            }
13059                    }
13060    
13061                    return list;
13062            }
13063    
13064            /**
13065             * Removes all the bookmarks entries from the database.
13066             *
13067             * @throws SystemException if a system exception occurred
13068             */
13069            @Override
13070            public void removeAll() throws SystemException {
13071                    for (BookmarksEntry bookmarksEntry : findAll()) {
13072                            remove(bookmarksEntry);
13073                    }
13074            }
13075    
13076            /**
13077             * Returns the number of bookmarks entries.
13078             *
13079             * @return the number of bookmarks entries
13080             * @throws SystemException if a system exception occurred
13081             */
13082            @Override
13083            public int countAll() throws SystemException {
13084                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
13085                                    FINDER_ARGS_EMPTY, this);
13086    
13087                    if (count == null) {
13088                            Session session = null;
13089    
13090                            try {
13091                                    session = openSession();
13092    
13093                                    Query q = session.createQuery(_SQL_COUNT_BOOKMARKSENTRY);
13094    
13095                                    count = (Long)q.uniqueResult();
13096    
13097                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
13098                                            FINDER_ARGS_EMPTY, count);
13099                            }
13100                            catch (Exception e) {
13101                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
13102                                            FINDER_ARGS_EMPTY);
13103    
13104                                    throw processException(e);
13105                            }
13106                            finally {
13107                                    closeSession(session);
13108                            }
13109                    }
13110    
13111                    return count.intValue();
13112            }
13113    
13114            @Override
13115            protected Set<String> getBadColumnNames() {
13116                    return _badColumnNames;
13117            }
13118    
13119            /**
13120             * Initializes the bookmarks entry persistence.
13121             */
13122            public void afterPropertiesSet() {
13123                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
13124                                            com.liferay.portal.util.PropsUtil.get(
13125                                                    "value.object.listener.com.liferay.portlet.bookmarks.model.BookmarksEntry")));
13126    
13127                    if (listenerClassNames.length > 0) {
13128                            try {
13129                                    List<ModelListener<BookmarksEntry>> listenersList = new ArrayList<ModelListener<BookmarksEntry>>();
13130    
13131                                    for (String listenerClassName : listenerClassNames) {
13132                                            listenersList.add((ModelListener<BookmarksEntry>)InstanceFactory.newInstance(
13133                                                            getClassLoader(), listenerClassName));
13134                                    }
13135    
13136                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
13137                            }
13138                            catch (Exception e) {
13139                                    _log.error(e);
13140                            }
13141                    }
13142            }
13143    
13144            public void destroy() {
13145                    EntityCacheUtil.removeCache(BookmarksEntryImpl.class.getName());
13146                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
13147                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
13148                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
13149            }
13150    
13151            private static final String _SQL_SELECT_BOOKMARKSENTRY = "SELECT bookmarksEntry FROM BookmarksEntry bookmarksEntry";
13152            private static final String _SQL_SELECT_BOOKMARKSENTRY_WHERE = "SELECT bookmarksEntry FROM BookmarksEntry bookmarksEntry WHERE ";
13153            private static final String _SQL_COUNT_BOOKMARKSENTRY = "SELECT COUNT(bookmarksEntry) FROM BookmarksEntry bookmarksEntry";
13154            private static final String _SQL_COUNT_BOOKMARKSENTRY_WHERE = "SELECT COUNT(bookmarksEntry) FROM BookmarksEntry bookmarksEntry WHERE ";
13155            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "bookmarksEntry.entryId";
13156            private static final String _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN = "bookmarksEntry.userId";
13157            private static final String _ORDER_BY_ENTITY_ALIAS = "bookmarksEntry.";
13158            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No BookmarksEntry exists with the primary key ";
13159            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No BookmarksEntry exists with the key {";
13160            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
13161            private static Log _log = LogFactoryUtil.getLog(BookmarksEntryPersistenceImpl.class);
13162            private static Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
13163                                    "uuid"
13164                            });
13165            private static BookmarksEntry _nullBookmarksEntry = new BookmarksEntryImpl() {
13166                            @Override
13167                            public Object clone() {
13168                                    return this;
13169                            }
13170    
13171                            @Override
13172                            public CacheModel<BookmarksEntry> toCacheModel() {
13173                                    return _nullBookmarksEntryCacheModel;
13174                            }
13175                    };
13176    
13177            private static CacheModel<BookmarksEntry> _nullBookmarksEntryCacheModel = new CacheModel<BookmarksEntry>() {
13178                            @Override
13179                            public BookmarksEntry toEntityModel() {
13180                                    return _nullBookmarksEntry;
13181                            }
13182                    };
13183    }