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            public List<BookmarksEntry> findByResourceBlockId(long resourceBlockId)
124                    throws SystemException {
125                    return findByResourceBlockId(resourceBlockId, QueryUtil.ALL_POS,
126                            QueryUtil.ALL_POS, null);
127            }
128    
129            /**
130             * Returns a range of all the bookmarks entries where resourceBlockId = &#63;.
131             *
132             * <p>
133             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
134             * </p>
135             *
136             * @param resourceBlockId the resource block ID
137             * @param start the lower bound of the range of bookmarks entries
138             * @param end the upper bound of the range of bookmarks entries (not inclusive)
139             * @return the range of matching bookmarks entries
140             * @throws SystemException if a system exception occurred
141             */
142            public List<BookmarksEntry> findByResourceBlockId(long resourceBlockId,
143                    int start, int end) throws SystemException {
144                    return findByResourceBlockId(resourceBlockId, start, end, null);
145            }
146    
147            /**
148             * Returns an ordered range of all the bookmarks entries where resourceBlockId = &#63;.
149             *
150             * <p>
151             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
152             * </p>
153             *
154             * @param resourceBlockId the resource block ID
155             * @param start the lower bound of the range of bookmarks entries
156             * @param end the upper bound of the range of bookmarks entries (not inclusive)
157             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
158             * @return the ordered range of matching bookmarks entries
159             * @throws SystemException if a system exception occurred
160             */
161            public List<BookmarksEntry> findByResourceBlockId(long resourceBlockId,
162                    int start, int end, OrderByComparator orderByComparator)
163                    throws SystemException {
164                    boolean pagination = true;
165                    FinderPath finderPath = null;
166                    Object[] finderArgs = null;
167    
168                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
169                                    (orderByComparator == null)) {
170                            pagination = false;
171                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEBLOCKID;
172                            finderArgs = new Object[] { resourceBlockId };
173                    }
174                    else {
175                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_RESOURCEBLOCKID;
176                            finderArgs = new Object[] {
177                                            resourceBlockId,
178                                            
179                                            start, end, orderByComparator
180                                    };
181                    }
182    
183                    List<BookmarksEntry> list = (List<BookmarksEntry>)FinderCacheUtil.getResult(finderPath,
184                                    finderArgs, this);
185    
186                    if ((list != null) && !list.isEmpty()) {
187                            for (BookmarksEntry bookmarksEntry : list) {
188                                    if ((resourceBlockId != bookmarksEntry.getResourceBlockId())) {
189                                            list = null;
190    
191                                            break;
192                                    }
193                            }
194                    }
195    
196                    if (list == null) {
197                            StringBundler query = null;
198    
199                            if (orderByComparator != null) {
200                                    query = new StringBundler(3 +
201                                                    (orderByComparator.getOrderByFields().length * 3));
202                            }
203                            else {
204                                    query = new StringBundler(3);
205                            }
206    
207                            query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
208    
209                            query.append(_FINDER_COLUMN_RESOURCEBLOCKID_RESOURCEBLOCKID_2);
210    
211                            if (orderByComparator != null) {
212                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
213                                            orderByComparator);
214                            }
215                            else
216                             if (pagination) {
217                                    query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
218                            }
219    
220                            String sql = query.toString();
221    
222                            Session session = null;
223    
224                            try {
225                                    session = openSession();
226    
227                                    Query q = session.createQuery(sql);
228    
229                                    QueryPos qPos = QueryPos.getInstance(q);
230    
231                                    qPos.add(resourceBlockId);
232    
233                                    if (!pagination) {
234                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
235                                                            getDialect(), start, end, false);
236    
237                                            Collections.sort(list);
238    
239                                            list = new UnmodifiableList<BookmarksEntry>(list);
240                                    }
241                                    else {
242                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
243                                                            getDialect(), start, end);
244                                    }
245    
246                                    cacheResult(list);
247    
248                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
249                            }
250                            catch (Exception e) {
251                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
252    
253                                    throw processException(e);
254                            }
255                            finally {
256                                    closeSession(session);
257                            }
258                    }
259    
260                    return list;
261            }
262    
263            /**
264             * Returns the first bookmarks entry in the ordered set where resourceBlockId = &#63;.
265             *
266             * @param resourceBlockId the resource block ID
267             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
268             * @return the first matching bookmarks entry
269             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
270             * @throws SystemException if a system exception occurred
271             */
272            public BookmarksEntry findByResourceBlockId_First(long resourceBlockId,
273                    OrderByComparator orderByComparator)
274                    throws NoSuchEntryException, SystemException {
275                    BookmarksEntry bookmarksEntry = fetchByResourceBlockId_First(resourceBlockId,
276                                    orderByComparator);
277    
278                    if (bookmarksEntry != null) {
279                            return bookmarksEntry;
280                    }
281    
282                    StringBundler msg = new StringBundler(4);
283    
284                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
285    
286                    msg.append("resourceBlockId=");
287                    msg.append(resourceBlockId);
288    
289                    msg.append(StringPool.CLOSE_CURLY_BRACE);
290    
291                    throw new NoSuchEntryException(msg.toString());
292            }
293    
294            /**
295             * Returns the first bookmarks entry in the ordered set where resourceBlockId = &#63;.
296             *
297             * @param resourceBlockId the resource block ID
298             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
299             * @return the first matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
300             * @throws SystemException if a system exception occurred
301             */
302            public BookmarksEntry fetchByResourceBlockId_First(long resourceBlockId,
303                    OrderByComparator orderByComparator) throws SystemException {
304                    List<BookmarksEntry> list = findByResourceBlockId(resourceBlockId, 0,
305                                    1, orderByComparator);
306    
307                    if (!list.isEmpty()) {
308                            return list.get(0);
309                    }
310    
311                    return null;
312            }
313    
314            /**
315             * Returns the last bookmarks entry in the ordered set where resourceBlockId = &#63;.
316             *
317             * @param resourceBlockId the resource block ID
318             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
319             * @return the last matching bookmarks entry
320             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
321             * @throws SystemException if a system exception occurred
322             */
323            public BookmarksEntry findByResourceBlockId_Last(long resourceBlockId,
324                    OrderByComparator orderByComparator)
325                    throws NoSuchEntryException, SystemException {
326                    BookmarksEntry bookmarksEntry = fetchByResourceBlockId_Last(resourceBlockId,
327                                    orderByComparator);
328    
329                    if (bookmarksEntry != null) {
330                            return bookmarksEntry;
331                    }
332    
333                    StringBundler msg = new StringBundler(4);
334    
335                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
336    
337                    msg.append("resourceBlockId=");
338                    msg.append(resourceBlockId);
339    
340                    msg.append(StringPool.CLOSE_CURLY_BRACE);
341    
342                    throw new NoSuchEntryException(msg.toString());
343            }
344    
345            /**
346             * Returns the last bookmarks entry in the ordered set where resourceBlockId = &#63;.
347             *
348             * @param resourceBlockId the resource block ID
349             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
350             * @return the last matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
351             * @throws SystemException if a system exception occurred
352             */
353            public BookmarksEntry fetchByResourceBlockId_Last(long resourceBlockId,
354                    OrderByComparator orderByComparator) throws SystemException {
355                    int count = countByResourceBlockId(resourceBlockId);
356    
357                    List<BookmarksEntry> list = findByResourceBlockId(resourceBlockId,
358                                    count - 1, count, orderByComparator);
359    
360                    if (!list.isEmpty()) {
361                            return list.get(0);
362                    }
363    
364                    return null;
365            }
366    
367            /**
368             * Returns the bookmarks entries before and after the current bookmarks entry in the ordered set where resourceBlockId = &#63;.
369             *
370             * @param entryId the primary key of the current bookmarks entry
371             * @param resourceBlockId the resource block ID
372             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
373             * @return the previous, current, and next bookmarks entry
374             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
375             * @throws SystemException if a system exception occurred
376             */
377            public BookmarksEntry[] findByResourceBlockId_PrevAndNext(long entryId,
378                    long resourceBlockId, OrderByComparator orderByComparator)
379                    throws NoSuchEntryException, SystemException {
380                    BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
381    
382                    Session session = null;
383    
384                    try {
385                            session = openSession();
386    
387                            BookmarksEntry[] array = new BookmarksEntryImpl[3];
388    
389                            array[0] = getByResourceBlockId_PrevAndNext(session,
390                                            bookmarksEntry, resourceBlockId, orderByComparator, true);
391    
392                            array[1] = bookmarksEntry;
393    
394                            array[2] = getByResourceBlockId_PrevAndNext(session,
395                                            bookmarksEntry, resourceBlockId, orderByComparator, false);
396    
397                            return array;
398                    }
399                    catch (Exception e) {
400                            throw processException(e);
401                    }
402                    finally {
403                            closeSession(session);
404                    }
405            }
406    
407            protected BookmarksEntry getByResourceBlockId_PrevAndNext(Session session,
408                    BookmarksEntry bookmarksEntry, long resourceBlockId,
409                    OrderByComparator orderByComparator, boolean previous) {
410                    StringBundler query = null;
411    
412                    if (orderByComparator != null) {
413                            query = new StringBundler(6 +
414                                            (orderByComparator.getOrderByFields().length * 6));
415                    }
416                    else {
417                            query = new StringBundler(3);
418                    }
419    
420                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
421    
422                    query.append(_FINDER_COLUMN_RESOURCEBLOCKID_RESOURCEBLOCKID_2);
423    
424                    if (orderByComparator != null) {
425                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
426    
427                            if (orderByConditionFields.length > 0) {
428                                    query.append(WHERE_AND);
429                            }
430    
431                            for (int i = 0; i < orderByConditionFields.length; i++) {
432                                    query.append(_ORDER_BY_ENTITY_ALIAS);
433                                    query.append(orderByConditionFields[i]);
434    
435                                    if ((i + 1) < orderByConditionFields.length) {
436                                            if (orderByComparator.isAscending() ^ previous) {
437                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
438                                            }
439                                            else {
440                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
441                                            }
442                                    }
443                                    else {
444                                            if (orderByComparator.isAscending() ^ previous) {
445                                                    query.append(WHERE_GREATER_THAN);
446                                            }
447                                            else {
448                                                    query.append(WHERE_LESSER_THAN);
449                                            }
450                                    }
451                            }
452    
453                            query.append(ORDER_BY_CLAUSE);
454    
455                            String[] orderByFields = orderByComparator.getOrderByFields();
456    
457                            for (int i = 0; i < orderByFields.length; i++) {
458                                    query.append(_ORDER_BY_ENTITY_ALIAS);
459                                    query.append(orderByFields[i]);
460    
461                                    if ((i + 1) < orderByFields.length) {
462                                            if (orderByComparator.isAscending() ^ previous) {
463                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
464                                            }
465                                            else {
466                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
467                                            }
468                                    }
469                                    else {
470                                            if (orderByComparator.isAscending() ^ previous) {
471                                                    query.append(ORDER_BY_ASC);
472                                            }
473                                            else {
474                                                    query.append(ORDER_BY_DESC);
475                                            }
476                                    }
477                            }
478                    }
479                    else {
480                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
481                    }
482    
483                    String sql = query.toString();
484    
485                    Query q = session.createQuery(sql);
486    
487                    q.setFirstResult(0);
488                    q.setMaxResults(2);
489    
490                    QueryPos qPos = QueryPos.getInstance(q);
491    
492                    qPos.add(resourceBlockId);
493    
494                    if (orderByComparator != null) {
495                            Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry);
496    
497                            for (Object value : values) {
498                                    qPos.add(value);
499                            }
500                    }
501    
502                    List<BookmarksEntry> list = q.list();
503    
504                    if (list.size() == 2) {
505                            return list.get(1);
506                    }
507                    else {
508                            return null;
509                    }
510            }
511    
512            /**
513             * Removes all the bookmarks entries where resourceBlockId = &#63; from the database.
514             *
515             * @param resourceBlockId the resource block ID
516             * @throws SystemException if a system exception occurred
517             */
518            public void removeByResourceBlockId(long resourceBlockId)
519                    throws SystemException {
520                    for (BookmarksEntry bookmarksEntry : findByResourceBlockId(
521                                    resourceBlockId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
522                            remove(bookmarksEntry);
523                    }
524            }
525    
526            /**
527             * Returns the number of bookmarks entries where resourceBlockId = &#63;.
528             *
529             * @param resourceBlockId the resource block ID
530             * @return the number of matching bookmarks entries
531             * @throws SystemException if a system exception occurred
532             */
533            public int countByResourceBlockId(long resourceBlockId)
534                    throws SystemException {
535                    FinderPath finderPath = FINDER_PATH_COUNT_BY_RESOURCEBLOCKID;
536    
537                    Object[] finderArgs = new Object[] { resourceBlockId };
538    
539                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
540                                    this);
541    
542                    if (count == null) {
543                            StringBundler query = new StringBundler(2);
544    
545                            query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
546    
547                            query.append(_FINDER_COLUMN_RESOURCEBLOCKID_RESOURCEBLOCKID_2);
548    
549                            String sql = query.toString();
550    
551                            Session session = null;
552    
553                            try {
554                                    session = openSession();
555    
556                                    Query q = session.createQuery(sql);
557    
558                                    QueryPos qPos = QueryPos.getInstance(q);
559    
560                                    qPos.add(resourceBlockId);
561    
562                                    count = (Long)q.uniqueResult();
563    
564                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
565                            }
566                            catch (Exception e) {
567                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
568    
569                                    throw processException(e);
570                            }
571                            finally {
572                                    closeSession(session);
573                            }
574                    }
575    
576                    return count.intValue();
577            }
578    
579            private static final String _FINDER_COLUMN_RESOURCEBLOCKID_RESOURCEBLOCKID_2 =
580                    "bookmarksEntry.resourceBlockId = ?";
581            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
582                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
583                            BookmarksEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
584                            "findByUuid",
585                            new String[] {
586                                    String.class.getName(),
587                                    
588                            Integer.class.getName(), Integer.class.getName(),
589                                    OrderByComparator.class.getName()
590                            });
591            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
592                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
593                            BookmarksEntryImpl.class,
594                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
595                            new String[] { String.class.getName() },
596                            BookmarksEntryModelImpl.UUID_COLUMN_BITMASK |
597                            BookmarksEntryModelImpl.FOLDERID_COLUMN_BITMASK |
598                            BookmarksEntryModelImpl.NAME_COLUMN_BITMASK);
599            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
600                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
601                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
602                            new String[] { String.class.getName() });
603    
604            /**
605             * Returns all the bookmarks entries where uuid = &#63;.
606             *
607             * @param uuid the uuid
608             * @return the matching bookmarks entries
609             * @throws SystemException if a system exception occurred
610             */
611            public List<BookmarksEntry> findByUuid(String uuid)
612                    throws SystemException {
613                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
614            }
615    
616            /**
617             * Returns a range of all the bookmarks entries where uuid = &#63;.
618             *
619             * <p>
620             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
621             * </p>
622             *
623             * @param uuid the uuid
624             * @param start the lower bound of the range of bookmarks entries
625             * @param end the upper bound of the range of bookmarks entries (not inclusive)
626             * @return the range of matching bookmarks entries
627             * @throws SystemException if a system exception occurred
628             */
629            public List<BookmarksEntry> findByUuid(String uuid, int start, int end)
630                    throws SystemException {
631                    return findByUuid(uuid, start, end, null);
632            }
633    
634            /**
635             * Returns an ordered range of all the bookmarks entries where uuid = &#63;.
636             *
637             * <p>
638             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
639             * </p>
640             *
641             * @param uuid the uuid
642             * @param start the lower bound of the range of bookmarks entries
643             * @param end the upper bound of the range of bookmarks entries (not inclusive)
644             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
645             * @return the ordered range of matching bookmarks entries
646             * @throws SystemException if a system exception occurred
647             */
648            public List<BookmarksEntry> findByUuid(String uuid, int start, int end,
649                    OrderByComparator orderByComparator) throws SystemException {
650                    boolean pagination = true;
651                    FinderPath finderPath = null;
652                    Object[] finderArgs = null;
653    
654                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
655                                    (orderByComparator == null)) {
656                            pagination = false;
657                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
658                            finderArgs = new Object[] { uuid };
659                    }
660                    else {
661                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
662                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
663                    }
664    
665                    List<BookmarksEntry> list = (List<BookmarksEntry>)FinderCacheUtil.getResult(finderPath,
666                                    finderArgs, this);
667    
668                    if ((list != null) && !list.isEmpty()) {
669                            for (BookmarksEntry bookmarksEntry : list) {
670                                    if (!Validator.equals(uuid, bookmarksEntry.getUuid())) {
671                                            list = null;
672    
673                                            break;
674                                    }
675                            }
676                    }
677    
678                    if (list == null) {
679                            StringBundler query = null;
680    
681                            if (orderByComparator != null) {
682                                    query = new StringBundler(3 +
683                                                    (orderByComparator.getOrderByFields().length * 3));
684                            }
685                            else {
686                                    query = new StringBundler(3);
687                            }
688    
689                            query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
690    
691                            boolean bindUuid = false;
692    
693                            if (uuid == null) {
694                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
695                            }
696                            else if (uuid.equals(StringPool.BLANK)) {
697                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
698                            }
699                            else {
700                                    bindUuid = true;
701    
702                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
703                            }
704    
705                            if (orderByComparator != null) {
706                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
707                                            orderByComparator);
708                            }
709                            else
710                             if (pagination) {
711                                    query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
712                            }
713    
714                            String sql = query.toString();
715    
716                            Session session = null;
717    
718                            try {
719                                    session = openSession();
720    
721                                    Query q = session.createQuery(sql);
722    
723                                    QueryPos qPos = QueryPos.getInstance(q);
724    
725                                    if (bindUuid) {
726                                            qPos.add(uuid);
727                                    }
728    
729                                    if (!pagination) {
730                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
731                                                            getDialect(), start, end, false);
732    
733                                            Collections.sort(list);
734    
735                                            list = new UnmodifiableList<BookmarksEntry>(list);
736                                    }
737                                    else {
738                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
739                                                            getDialect(), start, end);
740                                    }
741    
742                                    cacheResult(list);
743    
744                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
745                            }
746                            catch (Exception e) {
747                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
748    
749                                    throw processException(e);
750                            }
751                            finally {
752                                    closeSession(session);
753                            }
754                    }
755    
756                    return list;
757            }
758    
759            /**
760             * Returns the first bookmarks entry in the ordered set where uuid = &#63;.
761             *
762             * @param uuid the uuid
763             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
764             * @return the first matching bookmarks entry
765             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
766             * @throws SystemException if a system exception occurred
767             */
768            public BookmarksEntry findByUuid_First(String uuid,
769                    OrderByComparator orderByComparator)
770                    throws NoSuchEntryException, SystemException {
771                    BookmarksEntry bookmarksEntry = fetchByUuid_First(uuid,
772                                    orderByComparator);
773    
774                    if (bookmarksEntry != null) {
775                            return bookmarksEntry;
776                    }
777    
778                    StringBundler msg = new StringBundler(4);
779    
780                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
781    
782                    msg.append("uuid=");
783                    msg.append(uuid);
784    
785                    msg.append(StringPool.CLOSE_CURLY_BRACE);
786    
787                    throw new NoSuchEntryException(msg.toString());
788            }
789    
790            /**
791             * Returns the first bookmarks entry in the ordered set where uuid = &#63;.
792             *
793             * @param uuid the uuid
794             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
795             * @return the first matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
796             * @throws SystemException if a system exception occurred
797             */
798            public BookmarksEntry fetchByUuid_First(String uuid,
799                    OrderByComparator orderByComparator) throws SystemException {
800                    List<BookmarksEntry> list = findByUuid(uuid, 0, 1, orderByComparator);
801    
802                    if (!list.isEmpty()) {
803                            return list.get(0);
804                    }
805    
806                    return null;
807            }
808    
809            /**
810             * Returns the last bookmarks entry in the ordered set where uuid = &#63;.
811             *
812             * @param uuid the uuid
813             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
814             * @return the last matching bookmarks entry
815             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
816             * @throws SystemException if a system exception occurred
817             */
818            public BookmarksEntry findByUuid_Last(String uuid,
819                    OrderByComparator orderByComparator)
820                    throws NoSuchEntryException, SystemException {
821                    BookmarksEntry bookmarksEntry = fetchByUuid_Last(uuid, orderByComparator);
822    
823                    if (bookmarksEntry != null) {
824                            return bookmarksEntry;
825                    }
826    
827                    StringBundler msg = new StringBundler(4);
828    
829                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
830    
831                    msg.append("uuid=");
832                    msg.append(uuid);
833    
834                    msg.append(StringPool.CLOSE_CURLY_BRACE);
835    
836                    throw new NoSuchEntryException(msg.toString());
837            }
838    
839            /**
840             * Returns the last bookmarks entry in the ordered set where uuid = &#63;.
841             *
842             * @param uuid the uuid
843             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
844             * @return the last matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
845             * @throws SystemException if a system exception occurred
846             */
847            public BookmarksEntry fetchByUuid_Last(String uuid,
848                    OrderByComparator orderByComparator) throws SystemException {
849                    int count = countByUuid(uuid);
850    
851                    List<BookmarksEntry> list = findByUuid(uuid, count - 1, count,
852                                    orderByComparator);
853    
854                    if (!list.isEmpty()) {
855                            return list.get(0);
856                    }
857    
858                    return null;
859            }
860    
861            /**
862             * Returns the bookmarks entries before and after the current bookmarks entry in the ordered set where uuid = &#63;.
863             *
864             * @param entryId the primary key of the current bookmarks entry
865             * @param uuid the uuid
866             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
867             * @return the previous, current, and next bookmarks entry
868             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
869             * @throws SystemException if a system exception occurred
870             */
871            public BookmarksEntry[] findByUuid_PrevAndNext(long entryId, String uuid,
872                    OrderByComparator orderByComparator)
873                    throws NoSuchEntryException, SystemException {
874                    BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
875    
876                    Session session = null;
877    
878                    try {
879                            session = openSession();
880    
881                            BookmarksEntry[] array = new BookmarksEntryImpl[3];
882    
883                            array[0] = getByUuid_PrevAndNext(session, bookmarksEntry, uuid,
884                                            orderByComparator, true);
885    
886                            array[1] = bookmarksEntry;
887    
888                            array[2] = getByUuid_PrevAndNext(session, bookmarksEntry, uuid,
889                                            orderByComparator, false);
890    
891                            return array;
892                    }
893                    catch (Exception e) {
894                            throw processException(e);
895                    }
896                    finally {
897                            closeSession(session);
898                    }
899            }
900    
901            protected BookmarksEntry getByUuid_PrevAndNext(Session session,
902                    BookmarksEntry bookmarksEntry, String uuid,
903                    OrderByComparator orderByComparator, boolean previous) {
904                    StringBundler query = null;
905    
906                    if (orderByComparator != null) {
907                            query = new StringBundler(6 +
908                                            (orderByComparator.getOrderByFields().length * 6));
909                    }
910                    else {
911                            query = new StringBundler(3);
912                    }
913    
914                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
915    
916                    boolean bindUuid = false;
917    
918                    if (uuid == null) {
919                            query.append(_FINDER_COLUMN_UUID_UUID_1);
920                    }
921                    else if (uuid.equals(StringPool.BLANK)) {
922                            query.append(_FINDER_COLUMN_UUID_UUID_3);
923                    }
924                    else {
925                            bindUuid = true;
926    
927                            query.append(_FINDER_COLUMN_UUID_UUID_2);
928                    }
929    
930                    if (orderByComparator != null) {
931                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
932    
933                            if (orderByConditionFields.length > 0) {
934                                    query.append(WHERE_AND);
935                            }
936    
937                            for (int i = 0; i < orderByConditionFields.length; i++) {
938                                    query.append(_ORDER_BY_ENTITY_ALIAS);
939                                    query.append(orderByConditionFields[i]);
940    
941                                    if ((i + 1) < orderByConditionFields.length) {
942                                            if (orderByComparator.isAscending() ^ previous) {
943                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
944                                            }
945                                            else {
946                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
947                                            }
948                                    }
949                                    else {
950                                            if (orderByComparator.isAscending() ^ previous) {
951                                                    query.append(WHERE_GREATER_THAN);
952                                            }
953                                            else {
954                                                    query.append(WHERE_LESSER_THAN);
955                                            }
956                                    }
957                            }
958    
959                            query.append(ORDER_BY_CLAUSE);
960    
961                            String[] orderByFields = orderByComparator.getOrderByFields();
962    
963                            for (int i = 0; i < orderByFields.length; i++) {
964                                    query.append(_ORDER_BY_ENTITY_ALIAS);
965                                    query.append(orderByFields[i]);
966    
967                                    if ((i + 1) < orderByFields.length) {
968                                            if (orderByComparator.isAscending() ^ previous) {
969                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
970                                            }
971                                            else {
972                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
973                                            }
974                                    }
975                                    else {
976                                            if (orderByComparator.isAscending() ^ previous) {
977                                                    query.append(ORDER_BY_ASC);
978                                            }
979                                            else {
980                                                    query.append(ORDER_BY_DESC);
981                                            }
982                                    }
983                            }
984                    }
985                    else {
986                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
987                    }
988    
989                    String sql = query.toString();
990    
991                    Query q = session.createQuery(sql);
992    
993                    q.setFirstResult(0);
994                    q.setMaxResults(2);
995    
996                    QueryPos qPos = QueryPos.getInstance(q);
997    
998                    if (bindUuid) {
999                            qPos.add(uuid);
1000                    }
1001    
1002                    if (orderByComparator != null) {
1003                            Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry);
1004    
1005                            for (Object value : values) {
1006                                    qPos.add(value);
1007                            }
1008                    }
1009    
1010                    List<BookmarksEntry> list = q.list();
1011    
1012                    if (list.size() == 2) {
1013                            return list.get(1);
1014                    }
1015                    else {
1016                            return null;
1017                    }
1018            }
1019    
1020            /**
1021             * Removes all the bookmarks entries where uuid = &#63; from the database.
1022             *
1023             * @param uuid the uuid
1024             * @throws SystemException if a system exception occurred
1025             */
1026            public void removeByUuid(String uuid) throws SystemException {
1027                    for (BookmarksEntry bookmarksEntry : findByUuid(uuid,
1028                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1029                            remove(bookmarksEntry);
1030                    }
1031            }
1032    
1033            /**
1034             * Returns the number of bookmarks entries where uuid = &#63;.
1035             *
1036             * @param uuid the uuid
1037             * @return the number of matching bookmarks entries
1038             * @throws SystemException if a system exception occurred
1039             */
1040            public int countByUuid(String uuid) throws SystemException {
1041                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
1042    
1043                    Object[] finderArgs = new Object[] { uuid };
1044    
1045                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1046                                    this);
1047    
1048                    if (count == null) {
1049                            StringBundler query = new StringBundler(2);
1050    
1051                            query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
1052    
1053                            boolean bindUuid = false;
1054    
1055                            if (uuid == null) {
1056                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
1057                            }
1058                            else if (uuid.equals(StringPool.BLANK)) {
1059                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
1060                            }
1061                            else {
1062                                    bindUuid = true;
1063    
1064                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
1065                            }
1066    
1067                            String sql = query.toString();
1068    
1069                            Session session = null;
1070    
1071                            try {
1072                                    session = openSession();
1073    
1074                                    Query q = session.createQuery(sql);
1075    
1076                                    QueryPos qPos = QueryPos.getInstance(q);
1077    
1078                                    if (bindUuid) {
1079                                            qPos.add(uuid);
1080                                    }
1081    
1082                                    count = (Long)q.uniqueResult();
1083    
1084                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
1085                            }
1086                            catch (Exception e) {
1087                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1088    
1089                                    throw processException(e);
1090                            }
1091                            finally {
1092                                    closeSession(session);
1093                            }
1094                    }
1095    
1096                    return count.intValue();
1097            }
1098    
1099            private static final String _FINDER_COLUMN_UUID_UUID_1 = "bookmarksEntry.uuid IS NULL";
1100            private static final String _FINDER_COLUMN_UUID_UUID_2 = "bookmarksEntry.uuid = ?";
1101            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(bookmarksEntry.uuid IS NULL OR bookmarksEntry.uuid = '')";
1102            public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
1103                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
1104                            BookmarksEntryImpl.class, FINDER_CLASS_NAME_ENTITY,
1105                            "fetchByUUID_G",
1106                            new String[] { String.class.getName(), Long.class.getName() },
1107                            BookmarksEntryModelImpl.UUID_COLUMN_BITMASK |
1108                            BookmarksEntryModelImpl.GROUPID_COLUMN_BITMASK);
1109            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
1110                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
1111                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
1112                            new String[] { String.class.getName(), Long.class.getName() });
1113    
1114            /**
1115             * 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.
1116             *
1117             * @param uuid the uuid
1118             * @param groupId the group ID
1119             * @return the matching bookmarks entry
1120             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
1121             * @throws SystemException if a system exception occurred
1122             */
1123            public BookmarksEntry findByUUID_G(String uuid, long groupId)
1124                    throws NoSuchEntryException, SystemException {
1125                    BookmarksEntry bookmarksEntry = fetchByUUID_G(uuid, groupId);
1126    
1127                    if (bookmarksEntry == null) {
1128                            StringBundler msg = new StringBundler(6);
1129    
1130                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1131    
1132                            msg.append("uuid=");
1133                            msg.append(uuid);
1134    
1135                            msg.append(", groupId=");
1136                            msg.append(groupId);
1137    
1138                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1139    
1140                            if (_log.isWarnEnabled()) {
1141                                    _log.warn(msg.toString());
1142                            }
1143    
1144                            throw new NoSuchEntryException(msg.toString());
1145                    }
1146    
1147                    return bookmarksEntry;
1148            }
1149    
1150            /**
1151             * 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.
1152             *
1153             * @param uuid the uuid
1154             * @param groupId the group ID
1155             * @return the matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
1156             * @throws SystemException if a system exception occurred
1157             */
1158            public BookmarksEntry fetchByUUID_G(String uuid, long groupId)
1159                    throws SystemException {
1160                    return fetchByUUID_G(uuid, groupId, true);
1161            }
1162    
1163            /**
1164             * 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.
1165             *
1166             * @param uuid the uuid
1167             * @param groupId the group ID
1168             * @param retrieveFromCache whether to use the finder cache
1169             * @return the matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
1170             * @throws SystemException if a system exception occurred
1171             */
1172            public BookmarksEntry fetchByUUID_G(String uuid, long groupId,
1173                    boolean retrieveFromCache) throws SystemException {
1174                    Object[] finderArgs = new Object[] { uuid, groupId };
1175    
1176                    Object result = null;
1177    
1178                    if (retrieveFromCache) {
1179                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
1180                                            finderArgs, this);
1181                    }
1182    
1183                    if (result instanceof BookmarksEntry) {
1184                            BookmarksEntry bookmarksEntry = (BookmarksEntry)result;
1185    
1186                            if (!Validator.equals(uuid, bookmarksEntry.getUuid()) ||
1187                                            (groupId != bookmarksEntry.getGroupId())) {
1188                                    result = null;
1189                            }
1190                    }
1191    
1192                    if (result == null) {
1193                            StringBundler query = new StringBundler(4);
1194    
1195                            query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
1196    
1197                            boolean bindUuid = false;
1198    
1199                            if (uuid == null) {
1200                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1201                            }
1202                            else if (uuid.equals(StringPool.BLANK)) {
1203                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1204                            }
1205                            else {
1206                                    bindUuid = true;
1207    
1208                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1209                            }
1210    
1211                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1212    
1213                            String sql = query.toString();
1214    
1215                            Session session = null;
1216    
1217                            try {
1218                                    session = openSession();
1219    
1220                                    Query q = session.createQuery(sql);
1221    
1222                                    QueryPos qPos = QueryPos.getInstance(q);
1223    
1224                                    if (bindUuid) {
1225                                            qPos.add(uuid);
1226                                    }
1227    
1228                                    qPos.add(groupId);
1229    
1230                                    List<BookmarksEntry> list = q.list();
1231    
1232                                    if (list.isEmpty()) {
1233                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1234                                                    finderArgs, list);
1235                                    }
1236                                    else {
1237                                            BookmarksEntry bookmarksEntry = list.get(0);
1238    
1239                                            result = bookmarksEntry;
1240    
1241                                            cacheResult(bookmarksEntry);
1242    
1243                                            if ((bookmarksEntry.getUuid() == null) ||
1244                                                            !bookmarksEntry.getUuid().equals(uuid) ||
1245                                                            (bookmarksEntry.getGroupId() != groupId)) {
1246                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1247                                                            finderArgs, bookmarksEntry);
1248                                            }
1249                                    }
1250                            }
1251                            catch (Exception e) {
1252                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
1253                                            finderArgs);
1254    
1255                                    throw processException(e);
1256                            }
1257                            finally {
1258                                    closeSession(session);
1259                            }
1260                    }
1261    
1262                    if (result instanceof List<?>) {
1263                            return null;
1264                    }
1265                    else {
1266                            return (BookmarksEntry)result;
1267                    }
1268            }
1269    
1270            /**
1271             * Removes the bookmarks entry where uuid = &#63; and groupId = &#63; from the database.
1272             *
1273             * @param uuid the uuid
1274             * @param groupId the group ID
1275             * @return the bookmarks entry that was removed
1276             * @throws SystemException if a system exception occurred
1277             */
1278            public BookmarksEntry removeByUUID_G(String uuid, long groupId)
1279                    throws NoSuchEntryException, SystemException {
1280                    BookmarksEntry bookmarksEntry = findByUUID_G(uuid, groupId);
1281    
1282                    return remove(bookmarksEntry);
1283            }
1284    
1285            /**
1286             * Returns the number of bookmarks entries where uuid = &#63; and groupId = &#63;.
1287             *
1288             * @param uuid the uuid
1289             * @param groupId the group ID
1290             * @return the number of matching bookmarks entries
1291             * @throws SystemException if a system exception occurred
1292             */
1293            public int countByUUID_G(String uuid, long groupId)
1294                    throws SystemException {
1295                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_G;
1296    
1297                    Object[] finderArgs = new Object[] { uuid, groupId };
1298    
1299                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1300                                    this);
1301    
1302                    if (count == null) {
1303                            StringBundler query = new StringBundler(3);
1304    
1305                            query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
1306    
1307                            boolean bindUuid = false;
1308    
1309                            if (uuid == null) {
1310                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1311                            }
1312                            else if (uuid.equals(StringPool.BLANK)) {
1313                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1314                            }
1315                            else {
1316                                    bindUuid = true;
1317    
1318                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1319                            }
1320    
1321                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1322    
1323                            String sql = query.toString();
1324    
1325                            Session session = null;
1326    
1327                            try {
1328                                    session = openSession();
1329    
1330                                    Query q = session.createQuery(sql);
1331    
1332                                    QueryPos qPos = QueryPos.getInstance(q);
1333    
1334                                    if (bindUuid) {
1335                                            qPos.add(uuid);
1336                                    }
1337    
1338                                    qPos.add(groupId);
1339    
1340                                    count = (Long)q.uniqueResult();
1341    
1342                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
1343                            }
1344                            catch (Exception e) {
1345                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1346    
1347                                    throw processException(e);
1348                            }
1349                            finally {
1350                                    closeSession(session);
1351                            }
1352                    }
1353    
1354                    return count.intValue();
1355            }
1356    
1357            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "bookmarksEntry.uuid IS NULL AND ";
1358            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "bookmarksEntry.uuid = ? AND ";
1359            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(bookmarksEntry.uuid IS NULL OR bookmarksEntry.uuid = '') AND ";
1360            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "bookmarksEntry.groupId = ?";
1361            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
1362                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
1363                            BookmarksEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
1364                            "findByUuid_C",
1365                            new String[] {
1366                                    String.class.getName(), Long.class.getName(),
1367                                    
1368                            Integer.class.getName(), Integer.class.getName(),
1369                                    OrderByComparator.class.getName()
1370                            });
1371            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
1372                    new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
1373                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
1374                            BookmarksEntryImpl.class,
1375                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
1376                            new String[] { String.class.getName(), Long.class.getName() },
1377                            BookmarksEntryModelImpl.UUID_COLUMN_BITMASK |
1378                            BookmarksEntryModelImpl.COMPANYID_COLUMN_BITMASK |
1379                            BookmarksEntryModelImpl.FOLDERID_COLUMN_BITMASK |
1380                            BookmarksEntryModelImpl.NAME_COLUMN_BITMASK);
1381            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
1382                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
1383                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
1384                            new String[] { String.class.getName(), Long.class.getName() });
1385    
1386            /**
1387             * Returns all the bookmarks entries where uuid = &#63; and companyId = &#63;.
1388             *
1389             * @param uuid the uuid
1390             * @param companyId the company ID
1391             * @return the matching bookmarks entries
1392             * @throws SystemException if a system exception occurred
1393             */
1394            public List<BookmarksEntry> findByUuid_C(String uuid, long companyId)
1395                    throws SystemException {
1396                    return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
1397                            QueryUtil.ALL_POS, null);
1398            }
1399    
1400            /**
1401             * Returns a range of all the bookmarks entries where uuid = &#63; and companyId = &#63;.
1402             *
1403             * <p>
1404             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
1405             * </p>
1406             *
1407             * @param uuid the uuid
1408             * @param companyId the company ID
1409             * @param start the lower bound of the range of bookmarks entries
1410             * @param end the upper bound of the range of bookmarks entries (not inclusive)
1411             * @return the range of matching bookmarks entries
1412             * @throws SystemException if a system exception occurred
1413             */
1414            public List<BookmarksEntry> findByUuid_C(String uuid, long companyId,
1415                    int start, int end) throws SystemException {
1416                    return findByUuid_C(uuid, companyId, start, end, null);
1417            }
1418    
1419            /**
1420             * Returns an ordered range of all the bookmarks entries where uuid = &#63; and companyId = &#63;.
1421             *
1422             * <p>
1423             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
1424             * </p>
1425             *
1426             * @param uuid the uuid
1427             * @param companyId the company ID
1428             * @param start the lower bound of the range of bookmarks entries
1429             * @param end the upper bound of the range of bookmarks entries (not inclusive)
1430             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1431             * @return the ordered range of matching bookmarks entries
1432             * @throws SystemException if a system exception occurred
1433             */
1434            public List<BookmarksEntry> findByUuid_C(String uuid, long companyId,
1435                    int start, int end, OrderByComparator orderByComparator)
1436                    throws SystemException {
1437                    boolean pagination = true;
1438                    FinderPath finderPath = null;
1439                    Object[] finderArgs = null;
1440    
1441                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1442                                    (orderByComparator == null)) {
1443                            pagination = false;
1444                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
1445                            finderArgs = new Object[] { uuid, companyId };
1446                    }
1447                    else {
1448                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
1449                            finderArgs = new Object[] {
1450                                            uuid, companyId,
1451                                            
1452                                            start, end, orderByComparator
1453                                    };
1454                    }
1455    
1456                    List<BookmarksEntry> list = (List<BookmarksEntry>)FinderCacheUtil.getResult(finderPath,
1457                                    finderArgs, this);
1458    
1459                    if ((list != null) && !list.isEmpty()) {
1460                            for (BookmarksEntry bookmarksEntry : list) {
1461                                    if (!Validator.equals(uuid, bookmarksEntry.getUuid()) ||
1462                                                    (companyId != bookmarksEntry.getCompanyId())) {
1463                                            list = null;
1464    
1465                                            break;
1466                                    }
1467                            }
1468                    }
1469    
1470                    if (list == null) {
1471                            StringBundler query = null;
1472    
1473                            if (orderByComparator != null) {
1474                                    query = new StringBundler(4 +
1475                                                    (orderByComparator.getOrderByFields().length * 3));
1476                            }
1477                            else {
1478                                    query = new StringBundler(4);
1479                            }
1480    
1481                            query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
1482    
1483                            boolean bindUuid = false;
1484    
1485                            if (uuid == null) {
1486                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1487                            }
1488                            else if (uuid.equals(StringPool.BLANK)) {
1489                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1490                            }
1491                            else {
1492                                    bindUuid = true;
1493    
1494                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1495                            }
1496    
1497                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1498    
1499                            if (orderByComparator != null) {
1500                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1501                                            orderByComparator);
1502                            }
1503                            else
1504                             if (pagination) {
1505                                    query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
1506                            }
1507    
1508                            String sql = query.toString();
1509    
1510                            Session session = null;
1511    
1512                            try {
1513                                    session = openSession();
1514    
1515                                    Query q = session.createQuery(sql);
1516    
1517                                    QueryPos qPos = QueryPos.getInstance(q);
1518    
1519                                    if (bindUuid) {
1520                                            qPos.add(uuid);
1521                                    }
1522    
1523                                    qPos.add(companyId);
1524    
1525                                    if (!pagination) {
1526                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
1527                                                            getDialect(), start, end, false);
1528    
1529                                            Collections.sort(list);
1530    
1531                                            list = new UnmodifiableList<BookmarksEntry>(list);
1532                                    }
1533                                    else {
1534                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
1535                                                            getDialect(), start, end);
1536                                    }
1537    
1538                                    cacheResult(list);
1539    
1540                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1541                            }
1542                            catch (Exception e) {
1543                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1544    
1545                                    throw processException(e);
1546                            }
1547                            finally {
1548                                    closeSession(session);
1549                            }
1550                    }
1551    
1552                    return list;
1553            }
1554    
1555            /**
1556             * Returns the first bookmarks entry in the ordered set where uuid = &#63; and companyId = &#63;.
1557             *
1558             * @param uuid the uuid
1559             * @param companyId the company ID
1560             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1561             * @return the first matching bookmarks entry
1562             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
1563             * @throws SystemException if a system exception occurred
1564             */
1565            public BookmarksEntry findByUuid_C_First(String uuid, long companyId,
1566                    OrderByComparator orderByComparator)
1567                    throws NoSuchEntryException, SystemException {
1568                    BookmarksEntry bookmarksEntry = fetchByUuid_C_First(uuid, companyId,
1569                                    orderByComparator);
1570    
1571                    if (bookmarksEntry != null) {
1572                            return bookmarksEntry;
1573                    }
1574    
1575                    StringBundler msg = new StringBundler(6);
1576    
1577                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1578    
1579                    msg.append("uuid=");
1580                    msg.append(uuid);
1581    
1582                    msg.append(", companyId=");
1583                    msg.append(companyId);
1584    
1585                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1586    
1587                    throw new NoSuchEntryException(msg.toString());
1588            }
1589    
1590            /**
1591             * Returns the first bookmarks entry in the ordered set where uuid = &#63; and companyId = &#63;.
1592             *
1593             * @param uuid the uuid
1594             * @param companyId the company ID
1595             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1596             * @return the first matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
1597             * @throws SystemException if a system exception occurred
1598             */
1599            public BookmarksEntry fetchByUuid_C_First(String uuid, long companyId,
1600                    OrderByComparator orderByComparator) throws SystemException {
1601                    List<BookmarksEntry> list = findByUuid_C(uuid, companyId, 0, 1,
1602                                    orderByComparator);
1603    
1604                    if (!list.isEmpty()) {
1605                            return list.get(0);
1606                    }
1607    
1608                    return null;
1609            }
1610    
1611            /**
1612             * Returns the last bookmarks entry in the ordered set where uuid = &#63; and companyId = &#63;.
1613             *
1614             * @param uuid the uuid
1615             * @param companyId the company ID
1616             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1617             * @return the last matching bookmarks entry
1618             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
1619             * @throws SystemException if a system exception occurred
1620             */
1621            public BookmarksEntry findByUuid_C_Last(String uuid, long companyId,
1622                    OrderByComparator orderByComparator)
1623                    throws NoSuchEntryException, SystemException {
1624                    BookmarksEntry bookmarksEntry = fetchByUuid_C_Last(uuid, companyId,
1625                                    orderByComparator);
1626    
1627                    if (bookmarksEntry != null) {
1628                            return bookmarksEntry;
1629                    }
1630    
1631                    StringBundler msg = new StringBundler(6);
1632    
1633                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1634    
1635                    msg.append("uuid=");
1636                    msg.append(uuid);
1637    
1638                    msg.append(", companyId=");
1639                    msg.append(companyId);
1640    
1641                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1642    
1643                    throw new NoSuchEntryException(msg.toString());
1644            }
1645    
1646            /**
1647             * Returns the last bookmarks entry in the ordered set where uuid = &#63; and companyId = &#63;.
1648             *
1649             * @param uuid the uuid
1650             * @param companyId the company ID
1651             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1652             * @return the last matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
1653             * @throws SystemException if a system exception occurred
1654             */
1655            public BookmarksEntry fetchByUuid_C_Last(String uuid, long companyId,
1656                    OrderByComparator orderByComparator) throws SystemException {
1657                    int count = countByUuid_C(uuid, companyId);
1658    
1659                    List<BookmarksEntry> list = findByUuid_C(uuid, companyId, count - 1,
1660                                    count, orderByComparator);
1661    
1662                    if (!list.isEmpty()) {
1663                            return list.get(0);
1664                    }
1665    
1666                    return null;
1667            }
1668    
1669            /**
1670             * Returns the bookmarks entries before and after the current bookmarks entry in the ordered set where uuid = &#63; and companyId = &#63;.
1671             *
1672             * @param entryId the primary key of the current bookmarks entry
1673             * @param uuid the uuid
1674             * @param companyId the company ID
1675             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1676             * @return the previous, current, and next bookmarks entry
1677             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
1678             * @throws SystemException if a system exception occurred
1679             */
1680            public BookmarksEntry[] findByUuid_C_PrevAndNext(long entryId, String uuid,
1681                    long companyId, OrderByComparator orderByComparator)
1682                    throws NoSuchEntryException, SystemException {
1683                    BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
1684    
1685                    Session session = null;
1686    
1687                    try {
1688                            session = openSession();
1689    
1690                            BookmarksEntry[] array = new BookmarksEntryImpl[3];
1691    
1692                            array[0] = getByUuid_C_PrevAndNext(session, bookmarksEntry, uuid,
1693                                            companyId, orderByComparator, true);
1694    
1695                            array[1] = bookmarksEntry;
1696    
1697                            array[2] = getByUuid_C_PrevAndNext(session, bookmarksEntry, uuid,
1698                                            companyId, orderByComparator, false);
1699    
1700                            return array;
1701                    }
1702                    catch (Exception e) {
1703                            throw processException(e);
1704                    }
1705                    finally {
1706                            closeSession(session);
1707                    }
1708            }
1709    
1710            protected BookmarksEntry getByUuid_C_PrevAndNext(Session session,
1711                    BookmarksEntry bookmarksEntry, String uuid, long companyId,
1712                    OrderByComparator orderByComparator, boolean previous) {
1713                    StringBundler query = null;
1714    
1715                    if (orderByComparator != null) {
1716                            query = new StringBundler(6 +
1717                                            (orderByComparator.getOrderByFields().length * 6));
1718                    }
1719                    else {
1720                            query = new StringBundler(3);
1721                    }
1722    
1723                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
1724    
1725                    boolean bindUuid = false;
1726    
1727                    if (uuid == null) {
1728                            query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1729                    }
1730                    else if (uuid.equals(StringPool.BLANK)) {
1731                            query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1732                    }
1733                    else {
1734                            bindUuid = true;
1735    
1736                            query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1737                    }
1738    
1739                    query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1740    
1741                    if (orderByComparator != null) {
1742                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1743    
1744                            if (orderByConditionFields.length > 0) {
1745                                    query.append(WHERE_AND);
1746                            }
1747    
1748                            for (int i = 0; i < orderByConditionFields.length; i++) {
1749                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1750                                    query.append(orderByConditionFields[i]);
1751    
1752                                    if ((i + 1) < orderByConditionFields.length) {
1753                                            if (orderByComparator.isAscending() ^ previous) {
1754                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1755                                            }
1756                                            else {
1757                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1758                                            }
1759                                    }
1760                                    else {
1761                                            if (orderByComparator.isAscending() ^ previous) {
1762                                                    query.append(WHERE_GREATER_THAN);
1763                                            }
1764                                            else {
1765                                                    query.append(WHERE_LESSER_THAN);
1766                                            }
1767                                    }
1768                            }
1769    
1770                            query.append(ORDER_BY_CLAUSE);
1771    
1772                            String[] orderByFields = orderByComparator.getOrderByFields();
1773    
1774                            for (int i = 0; i < orderByFields.length; i++) {
1775                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1776                                    query.append(orderByFields[i]);
1777    
1778                                    if ((i + 1) < orderByFields.length) {
1779                                            if (orderByComparator.isAscending() ^ previous) {
1780                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1781                                            }
1782                                            else {
1783                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1784                                            }
1785                                    }
1786                                    else {
1787                                            if (orderByComparator.isAscending() ^ previous) {
1788                                                    query.append(ORDER_BY_ASC);
1789                                            }
1790                                            else {
1791                                                    query.append(ORDER_BY_DESC);
1792                                            }
1793                                    }
1794                            }
1795                    }
1796                    else {
1797                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
1798                    }
1799    
1800                    String sql = query.toString();
1801    
1802                    Query q = session.createQuery(sql);
1803    
1804                    q.setFirstResult(0);
1805                    q.setMaxResults(2);
1806    
1807                    QueryPos qPos = QueryPos.getInstance(q);
1808    
1809                    if (bindUuid) {
1810                            qPos.add(uuid);
1811                    }
1812    
1813                    qPos.add(companyId);
1814    
1815                    if (orderByComparator != null) {
1816                            Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry);
1817    
1818                            for (Object value : values) {
1819                                    qPos.add(value);
1820                            }
1821                    }
1822    
1823                    List<BookmarksEntry> list = q.list();
1824    
1825                    if (list.size() == 2) {
1826                            return list.get(1);
1827                    }
1828                    else {
1829                            return null;
1830                    }
1831            }
1832    
1833            /**
1834             * Removes all the bookmarks entries where uuid = &#63; and companyId = &#63; from the database.
1835             *
1836             * @param uuid the uuid
1837             * @param companyId the company ID
1838             * @throws SystemException if a system exception occurred
1839             */
1840            public void removeByUuid_C(String uuid, long companyId)
1841                    throws SystemException {
1842                    for (BookmarksEntry bookmarksEntry : findByUuid_C(uuid, companyId,
1843                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1844                            remove(bookmarksEntry);
1845                    }
1846            }
1847    
1848            /**
1849             * Returns the number of bookmarks entries where uuid = &#63; and companyId = &#63;.
1850             *
1851             * @param uuid the uuid
1852             * @param companyId the company ID
1853             * @return the number of matching bookmarks entries
1854             * @throws SystemException if a system exception occurred
1855             */
1856            public int countByUuid_C(String uuid, long companyId)
1857                    throws SystemException {
1858                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1859    
1860                    Object[] finderArgs = new Object[] { uuid, companyId };
1861    
1862                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1863                                    this);
1864    
1865                    if (count == null) {
1866                            StringBundler query = new StringBundler(3);
1867    
1868                            query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
1869    
1870                            boolean bindUuid = false;
1871    
1872                            if (uuid == null) {
1873                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1874                            }
1875                            else if (uuid.equals(StringPool.BLANK)) {
1876                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1877                            }
1878                            else {
1879                                    bindUuid = true;
1880    
1881                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1882                            }
1883    
1884                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1885    
1886                            String sql = query.toString();
1887    
1888                            Session session = null;
1889    
1890                            try {
1891                                    session = openSession();
1892    
1893                                    Query q = session.createQuery(sql);
1894    
1895                                    QueryPos qPos = QueryPos.getInstance(q);
1896    
1897                                    if (bindUuid) {
1898                                            qPos.add(uuid);
1899                                    }
1900    
1901                                    qPos.add(companyId);
1902    
1903                                    count = (Long)q.uniqueResult();
1904    
1905                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
1906                            }
1907                            catch (Exception e) {
1908                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1909    
1910                                    throw processException(e);
1911                            }
1912                            finally {
1913                                    closeSession(session);
1914                            }
1915                    }
1916    
1917                    return count.intValue();
1918            }
1919    
1920            private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "bookmarksEntry.uuid IS NULL AND ";
1921            private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "bookmarksEntry.uuid = ? AND ";
1922            private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(bookmarksEntry.uuid IS NULL OR bookmarksEntry.uuid = '') AND ";
1923            private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "bookmarksEntry.companyId = ?";
1924            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
1925                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
1926                            BookmarksEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
1927                            "findByG_F",
1928                            new String[] {
1929                                    Long.class.getName(), Long.class.getName(),
1930                                    
1931                            Integer.class.getName(), Integer.class.getName(),
1932                                    OrderByComparator.class.getName()
1933                            });
1934            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
1935                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
1936                            BookmarksEntryImpl.class,
1937                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_F",
1938                            new String[] { Long.class.getName(), Long.class.getName() },
1939                            BookmarksEntryModelImpl.GROUPID_COLUMN_BITMASK |
1940                            BookmarksEntryModelImpl.FOLDERID_COLUMN_BITMASK |
1941                            BookmarksEntryModelImpl.NAME_COLUMN_BITMASK);
1942            public static final FinderPath FINDER_PATH_COUNT_BY_G_F = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
1943                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
1944                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_F",
1945                            new String[] { Long.class.getName(), Long.class.getName() });
1946            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
1947                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
1948                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_F",
1949                            new String[] { Long.class.getName(), Long.class.getName() });
1950    
1951            /**
1952             * Returns all the bookmarks entries where groupId = &#63; and folderId = &#63;.
1953             *
1954             * @param groupId the group ID
1955             * @param folderId the folder ID
1956             * @return the matching bookmarks entries
1957             * @throws SystemException if a system exception occurred
1958             */
1959            public List<BookmarksEntry> findByG_F(long groupId, long folderId)
1960                    throws SystemException {
1961                    return findByG_F(groupId, folderId, QueryUtil.ALL_POS,
1962                            QueryUtil.ALL_POS, null);
1963            }
1964    
1965            /**
1966             * Returns a range of all the bookmarks entries where groupId = &#63; and folderId = &#63;.
1967             *
1968             * <p>
1969             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
1970             * </p>
1971             *
1972             * @param groupId the group ID
1973             * @param folderId the folder ID
1974             * @param start the lower bound of the range of bookmarks entries
1975             * @param end the upper bound of the range of bookmarks entries (not inclusive)
1976             * @return the range of matching bookmarks entries
1977             * @throws SystemException if a system exception occurred
1978             */
1979            public List<BookmarksEntry> findByG_F(long groupId, long folderId,
1980                    int start, int end) throws SystemException {
1981                    return findByG_F(groupId, folderId, start, end, null);
1982            }
1983    
1984            /**
1985             * Returns an ordered range of all the bookmarks entries where groupId = &#63; and folderId = &#63;.
1986             *
1987             * <p>
1988             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
1989             * </p>
1990             *
1991             * @param groupId the group ID
1992             * @param folderId the folder ID
1993             * @param start the lower bound of the range of bookmarks entries
1994             * @param end the upper bound of the range of bookmarks entries (not inclusive)
1995             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1996             * @return the ordered range of matching bookmarks entries
1997             * @throws SystemException if a system exception occurred
1998             */
1999            public List<BookmarksEntry> findByG_F(long groupId, long folderId,
2000                    int start, int end, OrderByComparator orderByComparator)
2001                    throws SystemException {
2002                    boolean pagination = true;
2003                    FinderPath finderPath = null;
2004                    Object[] finderArgs = null;
2005    
2006                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2007                                    (orderByComparator == null)) {
2008                            pagination = false;
2009                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F;
2010                            finderArgs = new Object[] { groupId, folderId };
2011                    }
2012                    else {
2013                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F;
2014                            finderArgs = new Object[] {
2015                                            groupId, folderId,
2016                                            
2017                                            start, end, orderByComparator
2018                                    };
2019                    }
2020    
2021                    List<BookmarksEntry> list = (List<BookmarksEntry>)FinderCacheUtil.getResult(finderPath,
2022                                    finderArgs, this);
2023    
2024                    if ((list != null) && !list.isEmpty()) {
2025                            for (BookmarksEntry bookmarksEntry : list) {
2026                                    if ((groupId != bookmarksEntry.getGroupId()) ||
2027                                                    (folderId != bookmarksEntry.getFolderId())) {
2028                                            list = null;
2029    
2030                                            break;
2031                                    }
2032                            }
2033                    }
2034    
2035                    if (list == null) {
2036                            StringBundler query = null;
2037    
2038                            if (orderByComparator != null) {
2039                                    query = new StringBundler(4 +
2040                                                    (orderByComparator.getOrderByFields().length * 3));
2041                            }
2042                            else {
2043                                    query = new StringBundler(4);
2044                            }
2045    
2046                            query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
2047    
2048                            query.append(_FINDER_COLUMN_G_F_GROUPID_2);
2049    
2050                            query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
2051    
2052                            if (orderByComparator != null) {
2053                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2054                                            orderByComparator);
2055                            }
2056                            else
2057                             if (pagination) {
2058                                    query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
2059                            }
2060    
2061                            String sql = query.toString();
2062    
2063                            Session session = null;
2064    
2065                            try {
2066                                    session = openSession();
2067    
2068                                    Query q = session.createQuery(sql);
2069    
2070                                    QueryPos qPos = QueryPos.getInstance(q);
2071    
2072                                    qPos.add(groupId);
2073    
2074                                    qPos.add(folderId);
2075    
2076                                    if (!pagination) {
2077                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
2078                                                            getDialect(), start, end, false);
2079    
2080                                            Collections.sort(list);
2081    
2082                                            list = new UnmodifiableList<BookmarksEntry>(list);
2083                                    }
2084                                    else {
2085                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
2086                                                            getDialect(), start, end);
2087                                    }
2088    
2089                                    cacheResult(list);
2090    
2091                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
2092                            }
2093                            catch (Exception e) {
2094                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2095    
2096                                    throw processException(e);
2097                            }
2098                            finally {
2099                                    closeSession(session);
2100                            }
2101                    }
2102    
2103                    return list;
2104            }
2105    
2106            /**
2107             * Returns the first bookmarks entry in the ordered set where groupId = &#63; and folderId = &#63;.
2108             *
2109             * @param groupId the group ID
2110             * @param folderId the folder ID
2111             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2112             * @return the first matching bookmarks entry
2113             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
2114             * @throws SystemException if a system exception occurred
2115             */
2116            public BookmarksEntry findByG_F_First(long groupId, long folderId,
2117                    OrderByComparator orderByComparator)
2118                    throws NoSuchEntryException, SystemException {
2119                    BookmarksEntry bookmarksEntry = fetchByG_F_First(groupId, folderId,
2120                                    orderByComparator);
2121    
2122                    if (bookmarksEntry != null) {
2123                            return bookmarksEntry;
2124                    }
2125    
2126                    StringBundler msg = new StringBundler(6);
2127    
2128                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2129    
2130                    msg.append("groupId=");
2131                    msg.append(groupId);
2132    
2133                    msg.append(", folderId=");
2134                    msg.append(folderId);
2135    
2136                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2137    
2138                    throw new NoSuchEntryException(msg.toString());
2139            }
2140    
2141            /**
2142             * Returns the first bookmarks entry in the ordered set where groupId = &#63; and folderId = &#63;.
2143             *
2144             * @param groupId the group ID
2145             * @param folderId the folder ID
2146             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2147             * @return the first matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
2148             * @throws SystemException if a system exception occurred
2149             */
2150            public BookmarksEntry fetchByG_F_First(long groupId, long folderId,
2151                    OrderByComparator orderByComparator) throws SystemException {
2152                    List<BookmarksEntry> list = findByG_F(groupId, folderId, 0, 1,
2153                                    orderByComparator);
2154    
2155                    if (!list.isEmpty()) {
2156                            return list.get(0);
2157                    }
2158    
2159                    return null;
2160            }
2161    
2162            /**
2163             * Returns the last bookmarks entry in the ordered set where groupId = &#63; and folderId = &#63;.
2164             *
2165             * @param groupId the group ID
2166             * @param folderId the folder ID
2167             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2168             * @return the last matching bookmarks entry
2169             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
2170             * @throws SystemException if a system exception occurred
2171             */
2172            public BookmarksEntry findByG_F_Last(long groupId, long folderId,
2173                    OrderByComparator orderByComparator)
2174                    throws NoSuchEntryException, SystemException {
2175                    BookmarksEntry bookmarksEntry = fetchByG_F_Last(groupId, folderId,
2176                                    orderByComparator);
2177    
2178                    if (bookmarksEntry != null) {
2179                            return bookmarksEntry;
2180                    }
2181    
2182                    StringBundler msg = new StringBundler(6);
2183    
2184                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2185    
2186                    msg.append("groupId=");
2187                    msg.append(groupId);
2188    
2189                    msg.append(", folderId=");
2190                    msg.append(folderId);
2191    
2192                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2193    
2194                    throw new NoSuchEntryException(msg.toString());
2195            }
2196    
2197            /**
2198             * Returns the last bookmarks entry in the ordered set where groupId = &#63; and folderId = &#63;.
2199             *
2200             * @param groupId the group ID
2201             * @param folderId the folder ID
2202             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2203             * @return the last matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
2204             * @throws SystemException if a system exception occurred
2205             */
2206            public BookmarksEntry fetchByG_F_Last(long groupId, long folderId,
2207                    OrderByComparator orderByComparator) throws SystemException {
2208                    int count = countByG_F(groupId, folderId);
2209    
2210                    List<BookmarksEntry> list = findByG_F(groupId, folderId, count - 1,
2211                                    count, orderByComparator);
2212    
2213                    if (!list.isEmpty()) {
2214                            return list.get(0);
2215                    }
2216    
2217                    return null;
2218            }
2219    
2220            /**
2221             * Returns the bookmarks entries before and after the current bookmarks entry in the ordered set where groupId = &#63; and folderId = &#63;.
2222             *
2223             * @param entryId the primary key of the current bookmarks entry
2224             * @param groupId the group ID
2225             * @param folderId the folder ID
2226             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2227             * @return the previous, current, and next bookmarks entry
2228             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
2229             * @throws SystemException if a system exception occurred
2230             */
2231            public BookmarksEntry[] findByG_F_PrevAndNext(long entryId, long groupId,
2232                    long folderId, OrderByComparator orderByComparator)
2233                    throws NoSuchEntryException, SystemException {
2234                    BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
2235    
2236                    Session session = null;
2237    
2238                    try {
2239                            session = openSession();
2240    
2241                            BookmarksEntry[] array = new BookmarksEntryImpl[3];
2242    
2243                            array[0] = getByG_F_PrevAndNext(session, bookmarksEntry, groupId,
2244                                            folderId, orderByComparator, true);
2245    
2246                            array[1] = bookmarksEntry;
2247    
2248                            array[2] = getByG_F_PrevAndNext(session, bookmarksEntry, groupId,
2249                                            folderId, orderByComparator, false);
2250    
2251                            return array;
2252                    }
2253                    catch (Exception e) {
2254                            throw processException(e);
2255                    }
2256                    finally {
2257                            closeSession(session);
2258                    }
2259            }
2260    
2261            protected BookmarksEntry getByG_F_PrevAndNext(Session session,
2262                    BookmarksEntry bookmarksEntry, long groupId, long folderId,
2263                    OrderByComparator orderByComparator, boolean previous) {
2264                    StringBundler query = null;
2265    
2266                    if (orderByComparator != null) {
2267                            query = new StringBundler(6 +
2268                                            (orderByComparator.getOrderByFields().length * 6));
2269                    }
2270                    else {
2271                            query = new StringBundler(3);
2272                    }
2273    
2274                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
2275    
2276                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
2277    
2278                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
2279    
2280                    if (orderByComparator != null) {
2281                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2282    
2283                            if (orderByConditionFields.length > 0) {
2284                                    query.append(WHERE_AND);
2285                            }
2286    
2287                            for (int i = 0; i < orderByConditionFields.length; i++) {
2288                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2289                                    query.append(orderByConditionFields[i]);
2290    
2291                                    if ((i + 1) < orderByConditionFields.length) {
2292                                            if (orderByComparator.isAscending() ^ previous) {
2293                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2294                                            }
2295                                            else {
2296                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2297                                            }
2298                                    }
2299                                    else {
2300                                            if (orderByComparator.isAscending() ^ previous) {
2301                                                    query.append(WHERE_GREATER_THAN);
2302                                            }
2303                                            else {
2304                                                    query.append(WHERE_LESSER_THAN);
2305                                            }
2306                                    }
2307                            }
2308    
2309                            query.append(ORDER_BY_CLAUSE);
2310    
2311                            String[] orderByFields = orderByComparator.getOrderByFields();
2312    
2313                            for (int i = 0; i < orderByFields.length; i++) {
2314                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2315                                    query.append(orderByFields[i]);
2316    
2317                                    if ((i + 1) < orderByFields.length) {
2318                                            if (orderByComparator.isAscending() ^ previous) {
2319                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2320                                            }
2321                                            else {
2322                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2323                                            }
2324                                    }
2325                                    else {
2326                                            if (orderByComparator.isAscending() ^ previous) {
2327                                                    query.append(ORDER_BY_ASC);
2328                                            }
2329                                            else {
2330                                                    query.append(ORDER_BY_DESC);
2331                                            }
2332                                    }
2333                            }
2334                    }
2335                    else {
2336                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
2337                    }
2338    
2339                    String sql = query.toString();
2340    
2341                    Query q = session.createQuery(sql);
2342    
2343                    q.setFirstResult(0);
2344                    q.setMaxResults(2);
2345    
2346                    QueryPos qPos = QueryPos.getInstance(q);
2347    
2348                    qPos.add(groupId);
2349    
2350                    qPos.add(folderId);
2351    
2352                    if (orderByComparator != null) {
2353                            Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry);
2354    
2355                            for (Object value : values) {
2356                                    qPos.add(value);
2357                            }
2358                    }
2359    
2360                    List<BookmarksEntry> list = q.list();
2361    
2362                    if (list.size() == 2) {
2363                            return list.get(1);
2364                    }
2365                    else {
2366                            return null;
2367                    }
2368            }
2369    
2370            /**
2371             * Returns all the bookmarks entries that the user has permission to view where groupId = &#63; and folderId = &#63;.
2372             *
2373             * @param groupId the group ID
2374             * @param folderId the folder ID
2375             * @return the matching bookmarks entries that the user has permission to view
2376             * @throws SystemException if a system exception occurred
2377             */
2378            public List<BookmarksEntry> filterFindByG_F(long groupId, long folderId)
2379                    throws SystemException {
2380                    return filterFindByG_F(groupId, folderId, QueryUtil.ALL_POS,
2381                            QueryUtil.ALL_POS, null);
2382            }
2383    
2384            /**
2385             * Returns a range of all the bookmarks entries that the user has permission to view where groupId = &#63; and folderId = &#63;.
2386             *
2387             * <p>
2388             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
2389             * </p>
2390             *
2391             * @param groupId the group ID
2392             * @param folderId the folder ID
2393             * @param start the lower bound of the range of bookmarks entries
2394             * @param end the upper bound of the range of bookmarks entries (not inclusive)
2395             * @return the range of matching bookmarks entries that the user has permission to view
2396             * @throws SystemException if a system exception occurred
2397             */
2398            public List<BookmarksEntry> filterFindByG_F(long groupId, long folderId,
2399                    int start, int end) throws SystemException {
2400                    return filterFindByG_F(groupId, folderId, start, end, null);
2401            }
2402    
2403            /**
2404             * Returns an ordered range of all the bookmarks entries that the user has permissions to view where groupId = &#63; and folderId = &#63;.
2405             *
2406             * <p>
2407             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
2408             * </p>
2409             *
2410             * @param groupId the group ID
2411             * @param folderId the folder ID
2412             * @param start the lower bound of the range of bookmarks entries
2413             * @param end the upper bound of the range of bookmarks entries (not inclusive)
2414             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2415             * @return the ordered range of matching bookmarks entries that the user has permission to view
2416             * @throws SystemException if a system exception occurred
2417             */
2418            public List<BookmarksEntry> filterFindByG_F(long groupId, long folderId,
2419                    int start, int end, OrderByComparator orderByComparator)
2420                    throws SystemException {
2421                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2422                            return findByG_F(groupId, folderId, start, end, orderByComparator);
2423                    }
2424    
2425                    StringBundler query = null;
2426    
2427                    if (orderByComparator != null) {
2428                            query = new StringBundler(4 +
2429                                            (orderByComparator.getOrderByFields().length * 3));
2430                    }
2431                    else {
2432                            query = new StringBundler(4);
2433                    }
2434    
2435                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
2436    
2437                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
2438    
2439                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
2440    
2441                    if (orderByComparator != null) {
2442                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2443                                    orderByComparator);
2444                    }
2445                    else {
2446                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
2447                    }
2448    
2449                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2450                                    BookmarksEntry.class.getName(),
2451                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
2452                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
2453    
2454                    Session session = null;
2455    
2456                    try {
2457                            session = openSession();
2458    
2459                            Query q = session.createQuery(sql);
2460    
2461                            QueryPos qPos = QueryPos.getInstance(q);
2462    
2463                            qPos.add(groupId);
2464    
2465                            qPos.add(folderId);
2466    
2467                            return (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start,
2468                                    end);
2469                    }
2470                    catch (Exception e) {
2471                            throw processException(e);
2472                    }
2473                    finally {
2474                            closeSession(session);
2475                    }
2476            }
2477    
2478            /**
2479             * 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;.
2480             *
2481             * @param entryId the primary key of the current bookmarks entry
2482             * @param groupId the group ID
2483             * @param folderId the folder ID
2484             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2485             * @return the previous, current, and next bookmarks entry
2486             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
2487             * @throws SystemException if a system exception occurred
2488             */
2489            public BookmarksEntry[] filterFindByG_F_PrevAndNext(long entryId,
2490                    long groupId, long folderId, OrderByComparator orderByComparator)
2491                    throws NoSuchEntryException, SystemException {
2492                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2493                            return findByG_F_PrevAndNext(entryId, groupId, folderId,
2494                                    orderByComparator);
2495                    }
2496    
2497                    BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
2498    
2499                    Session session = null;
2500    
2501                    try {
2502                            session = openSession();
2503    
2504                            BookmarksEntry[] array = new BookmarksEntryImpl[3];
2505    
2506                            array[0] = filterGetByG_F_PrevAndNext(session, bookmarksEntry,
2507                                            groupId, folderId, orderByComparator, true);
2508    
2509                            array[1] = bookmarksEntry;
2510    
2511                            array[2] = filterGetByG_F_PrevAndNext(session, bookmarksEntry,
2512                                            groupId, folderId, orderByComparator, false);
2513    
2514                            return array;
2515                    }
2516                    catch (Exception e) {
2517                            throw processException(e);
2518                    }
2519                    finally {
2520                            closeSession(session);
2521                    }
2522            }
2523    
2524            protected BookmarksEntry filterGetByG_F_PrevAndNext(Session session,
2525                    BookmarksEntry bookmarksEntry, long groupId, long folderId,
2526                    OrderByComparator orderByComparator, boolean previous) {
2527                    StringBundler query = null;
2528    
2529                    if (orderByComparator != null) {
2530                            query = new StringBundler(6 +
2531                                            (orderByComparator.getOrderByFields().length * 6));
2532                    }
2533                    else {
2534                            query = new StringBundler(3);
2535                    }
2536    
2537                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
2538    
2539                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
2540    
2541                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
2542    
2543                    if (orderByComparator != null) {
2544                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2545    
2546                            if (orderByConditionFields.length > 0) {
2547                                    query.append(WHERE_AND);
2548                            }
2549    
2550                            for (int i = 0; i < orderByConditionFields.length; i++) {
2551                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2552                                    query.append(orderByConditionFields[i]);
2553    
2554                                    if ((i + 1) < orderByConditionFields.length) {
2555                                            if (orderByComparator.isAscending() ^ previous) {
2556                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2557                                            }
2558                                            else {
2559                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2560                                            }
2561                                    }
2562                                    else {
2563                                            if (orderByComparator.isAscending() ^ previous) {
2564                                                    query.append(WHERE_GREATER_THAN);
2565                                            }
2566                                            else {
2567                                                    query.append(WHERE_LESSER_THAN);
2568                                            }
2569                                    }
2570                            }
2571    
2572                            query.append(ORDER_BY_CLAUSE);
2573    
2574                            String[] orderByFields = orderByComparator.getOrderByFields();
2575    
2576                            for (int i = 0; i < orderByFields.length; i++) {
2577                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2578                                    query.append(orderByFields[i]);
2579    
2580                                    if ((i + 1) < orderByFields.length) {
2581                                            if (orderByComparator.isAscending() ^ previous) {
2582                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2583                                            }
2584                                            else {
2585                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2586                                            }
2587                                    }
2588                                    else {
2589                                            if (orderByComparator.isAscending() ^ previous) {
2590                                                    query.append(ORDER_BY_ASC);
2591                                            }
2592                                            else {
2593                                                    query.append(ORDER_BY_DESC);
2594                                            }
2595                                    }
2596                            }
2597                    }
2598                    else {
2599                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
2600                    }
2601    
2602                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2603                                    BookmarksEntry.class.getName(),
2604                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
2605                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
2606    
2607                    Query q = session.createQuery(sql);
2608    
2609                    q.setFirstResult(0);
2610                    q.setMaxResults(2);
2611    
2612                    QueryPos qPos = QueryPos.getInstance(q);
2613    
2614                    qPos.add(groupId);
2615    
2616                    qPos.add(folderId);
2617    
2618                    if (orderByComparator != null) {
2619                            Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry);
2620    
2621                            for (Object value : values) {
2622                                    qPos.add(value);
2623                            }
2624                    }
2625    
2626                    List<BookmarksEntry> list = q.list();
2627    
2628                    if (list.size() == 2) {
2629                            return list.get(1);
2630                    }
2631                    else {
2632                            return null;
2633                    }
2634            }
2635    
2636            /**
2637             * Returns all the bookmarks entries that the user has permission to view where groupId = &#63; and folderId = any &#63;.
2638             *
2639             * @param groupId the group ID
2640             * @param folderIds the folder IDs
2641             * @return the matching bookmarks entries that the user has permission to view
2642             * @throws SystemException if a system exception occurred
2643             */
2644            public List<BookmarksEntry> filterFindByG_F(long groupId, long[] folderIds)
2645                    throws SystemException {
2646                    return filterFindByG_F(groupId, folderIds, QueryUtil.ALL_POS,
2647                            QueryUtil.ALL_POS, null);
2648            }
2649    
2650            /**
2651             * Returns a range of all the bookmarks entries that the user has permission to view where groupId = &#63; and folderId = any &#63;.
2652             *
2653             * <p>
2654             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
2655             * </p>
2656             *
2657             * @param groupId the group ID
2658             * @param folderIds the folder IDs
2659             * @param start the lower bound of the range of bookmarks entries
2660             * @param end the upper bound of the range of bookmarks entries (not inclusive)
2661             * @return the range of matching bookmarks entries that the user has permission to view
2662             * @throws SystemException if a system exception occurred
2663             */
2664            public List<BookmarksEntry> filterFindByG_F(long groupId, long[] folderIds,
2665                    int start, int end) throws SystemException {
2666                    return filterFindByG_F(groupId, folderIds, start, end, null);
2667            }
2668    
2669            /**
2670             * Returns an ordered range of all the bookmarks entries that the user has permission to view where groupId = &#63; and folderId = any &#63;.
2671             *
2672             * <p>
2673             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
2674             * </p>
2675             *
2676             * @param groupId the group ID
2677             * @param folderIds the folder IDs
2678             * @param start the lower bound of the range of bookmarks entries
2679             * @param end the upper bound of the range of bookmarks entries (not inclusive)
2680             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2681             * @return the ordered range of matching bookmarks entries that the user has permission to view
2682             * @throws SystemException if a system exception occurred
2683             */
2684            public List<BookmarksEntry> filterFindByG_F(long groupId, long[] folderIds,
2685                    int start, int end, OrderByComparator orderByComparator)
2686                    throws SystemException {
2687                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2688                            return findByG_F(groupId, folderIds, start, end, orderByComparator);
2689                    }
2690    
2691                    StringBundler query = new StringBundler();
2692    
2693                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
2694    
2695                    boolean conjunctionable = false;
2696    
2697                    if (conjunctionable) {
2698                            query.append(WHERE_AND);
2699                    }
2700    
2701                    query.append(_FINDER_COLUMN_G_F_GROUPID_5);
2702    
2703                    conjunctionable = true;
2704    
2705                    if ((folderIds == null) || (folderIds.length > 0)) {
2706                            if (conjunctionable) {
2707                                    query.append(WHERE_AND);
2708                            }
2709    
2710                            query.append(StringPool.OPEN_PARENTHESIS);
2711    
2712                            for (int i = 0; i < folderIds.length; i++) {
2713                                    query.append(_FINDER_COLUMN_G_F_FOLDERID_5);
2714    
2715                                    if ((i + 1) < folderIds.length) {
2716                                            query.append(WHERE_OR);
2717                                    }
2718                            }
2719    
2720                            query.append(StringPool.CLOSE_PARENTHESIS);
2721    
2722                            conjunctionable = true;
2723                    }
2724    
2725                    if (orderByComparator != null) {
2726                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2727                                    orderByComparator);
2728                    }
2729                    else {
2730                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
2731                    }
2732    
2733                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2734                                    BookmarksEntry.class.getName(),
2735                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
2736                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
2737    
2738                    Session session = null;
2739    
2740                    try {
2741                            session = openSession();
2742    
2743                            Query q = session.createQuery(sql);
2744    
2745                            QueryPos qPos = QueryPos.getInstance(q);
2746    
2747                            qPos.add(groupId);
2748    
2749                            if (folderIds != null) {
2750                                    qPos.add(folderIds);
2751                            }
2752    
2753                            return (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start,
2754                                    end);
2755                    }
2756                    catch (Exception e) {
2757                            throw processException(e);
2758                    }
2759                    finally {
2760                            closeSession(session);
2761                    }
2762            }
2763    
2764            /**
2765             * Returns all the bookmarks entries where groupId = &#63; and folderId = any &#63;.
2766             *
2767             * <p>
2768             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
2769             * </p>
2770             *
2771             * @param groupId the group ID
2772             * @param folderIds the folder IDs
2773             * @return the matching bookmarks entries
2774             * @throws SystemException if a system exception occurred
2775             */
2776            public List<BookmarksEntry> findByG_F(long groupId, long[] folderIds)
2777                    throws SystemException {
2778                    return findByG_F(groupId, folderIds, QueryUtil.ALL_POS,
2779                            QueryUtil.ALL_POS, null);
2780            }
2781    
2782            /**
2783             * Returns a range of all the bookmarks entries where groupId = &#63; and folderId = any &#63;.
2784             *
2785             * <p>
2786             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
2787             * </p>
2788             *
2789             * @param groupId the group ID
2790             * @param folderIds the folder IDs
2791             * @param start the lower bound of the range of bookmarks entries
2792             * @param end the upper bound of the range of bookmarks entries (not inclusive)
2793             * @return the range of matching bookmarks entries
2794             * @throws SystemException if a system exception occurred
2795             */
2796            public List<BookmarksEntry> findByG_F(long groupId, long[] folderIds,
2797                    int start, int end) throws SystemException {
2798                    return findByG_F(groupId, folderIds, start, end, null);
2799            }
2800    
2801            /**
2802             * Returns an ordered range of all the bookmarks entries where groupId = &#63; and folderId = any &#63;.
2803             *
2804             * <p>
2805             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
2806             * </p>
2807             *
2808             * @param groupId the group ID
2809             * @param folderIds the folder IDs
2810             * @param start the lower bound of the range of bookmarks entries
2811             * @param end the upper bound of the range of bookmarks entries (not inclusive)
2812             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2813             * @return the ordered range of matching bookmarks entries
2814             * @throws SystemException if a system exception occurred
2815             */
2816            public List<BookmarksEntry> findByG_F(long groupId, long[] folderIds,
2817                    int start, int end, OrderByComparator orderByComparator)
2818                    throws SystemException {
2819                    if ((folderIds != null) && (folderIds.length == 1)) {
2820                            return findByG_F(groupId, folderIds[0], start, end,
2821                                    orderByComparator);
2822                    }
2823    
2824                    boolean pagination = true;
2825                    Object[] finderArgs = null;
2826    
2827                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2828                                    (orderByComparator == null)) {
2829                            pagination = false;
2830                            finderArgs = new Object[] { groupId, StringUtil.merge(folderIds) };
2831                    }
2832                    else {
2833                            finderArgs = new Object[] {
2834                                            groupId, StringUtil.merge(folderIds),
2835                                            
2836                                            start, end, orderByComparator
2837                                    };
2838                    }
2839    
2840                    List<BookmarksEntry> list = (List<BookmarksEntry>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F,
2841                                    finderArgs, this);
2842    
2843                    if ((list != null) && !list.isEmpty()) {
2844                            for (BookmarksEntry bookmarksEntry : list) {
2845                                    if ((groupId != bookmarksEntry.getGroupId()) ||
2846                                                    !ArrayUtil.contains(folderIds,
2847                                                            bookmarksEntry.getFolderId())) {
2848                                            list = null;
2849    
2850                                            break;
2851                                    }
2852                            }
2853                    }
2854    
2855                    if (list == null) {
2856                            StringBundler query = new StringBundler();
2857    
2858                            query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
2859    
2860                            boolean conjunctionable = false;
2861    
2862                            if (conjunctionable) {
2863                                    query.append(WHERE_AND);
2864                            }
2865    
2866                            query.append(_FINDER_COLUMN_G_F_GROUPID_5);
2867    
2868                            conjunctionable = true;
2869    
2870                            if ((folderIds == null) || (folderIds.length > 0)) {
2871                                    if (conjunctionable) {
2872                                            query.append(WHERE_AND);
2873                                    }
2874    
2875                                    query.append(StringPool.OPEN_PARENTHESIS);
2876    
2877                                    for (int i = 0; i < folderIds.length; i++) {
2878                                            query.append(_FINDER_COLUMN_G_F_FOLDERID_5);
2879    
2880                                            if ((i + 1) < folderIds.length) {
2881                                                    query.append(WHERE_OR);
2882                                            }
2883                                    }
2884    
2885                                    query.append(StringPool.CLOSE_PARENTHESIS);
2886    
2887                                    conjunctionable = true;
2888                            }
2889    
2890                            if (orderByComparator != null) {
2891                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2892                                            orderByComparator);
2893                            }
2894                            else
2895                             if (pagination) {
2896                                    query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
2897                            }
2898    
2899                            String sql = query.toString();
2900    
2901                            Session session = null;
2902    
2903                            try {
2904                                    session = openSession();
2905    
2906                                    Query q = session.createQuery(sql);
2907    
2908                                    QueryPos qPos = QueryPos.getInstance(q);
2909    
2910                                    qPos.add(groupId);
2911    
2912                                    if (folderIds != null) {
2913                                            qPos.add(folderIds);
2914                                    }
2915    
2916                                    if (!pagination) {
2917                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
2918                                                            getDialect(), start, end, false);
2919    
2920                                            Collections.sort(list);
2921    
2922                                            list = new UnmodifiableList<BookmarksEntry>(list);
2923                                    }
2924                                    else {
2925                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
2926                                                            getDialect(), start, end);
2927                                    }
2928    
2929                                    cacheResult(list);
2930    
2931                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F,
2932                                            finderArgs, list);
2933                            }
2934                            catch (Exception e) {
2935                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F,
2936                                            finderArgs);
2937    
2938                                    throw processException(e);
2939                            }
2940                            finally {
2941                                    closeSession(session);
2942                            }
2943                    }
2944    
2945                    return list;
2946            }
2947    
2948            /**
2949             * Removes all the bookmarks entries where groupId = &#63; and folderId = &#63; from the database.
2950             *
2951             * @param groupId the group ID
2952             * @param folderId the folder ID
2953             * @throws SystemException if a system exception occurred
2954             */
2955            public void removeByG_F(long groupId, long folderId)
2956                    throws SystemException {
2957                    for (BookmarksEntry bookmarksEntry : findByG_F(groupId, folderId,
2958                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2959                            remove(bookmarksEntry);
2960                    }
2961            }
2962    
2963            /**
2964             * Returns the number of bookmarks entries where groupId = &#63; and folderId = &#63;.
2965             *
2966             * @param groupId the group ID
2967             * @param folderId the folder ID
2968             * @return the number of matching bookmarks entries
2969             * @throws SystemException if a system exception occurred
2970             */
2971            public int countByG_F(long groupId, long folderId)
2972                    throws SystemException {
2973                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_F;
2974    
2975                    Object[] finderArgs = new Object[] { groupId, folderId };
2976    
2977                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2978                                    this);
2979    
2980                    if (count == null) {
2981                            StringBundler query = new StringBundler(3);
2982    
2983                            query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
2984    
2985                            query.append(_FINDER_COLUMN_G_F_GROUPID_2);
2986    
2987                            query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
2988    
2989                            String sql = query.toString();
2990    
2991                            Session session = null;
2992    
2993                            try {
2994                                    session = openSession();
2995    
2996                                    Query q = session.createQuery(sql);
2997    
2998                                    QueryPos qPos = QueryPos.getInstance(q);
2999    
3000                                    qPos.add(groupId);
3001    
3002                                    qPos.add(folderId);
3003    
3004                                    count = (Long)q.uniqueResult();
3005    
3006                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
3007                            }
3008                            catch (Exception e) {
3009                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3010    
3011                                    throw processException(e);
3012                            }
3013                            finally {
3014                                    closeSession(session);
3015                            }
3016                    }
3017    
3018                    return count.intValue();
3019            }
3020    
3021            /**
3022             * Returns the number of bookmarks entries where groupId = &#63; and folderId = any &#63;.
3023             *
3024             * @param groupId the group ID
3025             * @param folderIds the folder IDs
3026             * @return the number of matching bookmarks entries
3027             * @throws SystemException if a system exception occurred
3028             */
3029            public int countByG_F(long groupId, long[] folderIds)
3030                    throws SystemException {
3031                    Object[] finderArgs = new Object[] { groupId, StringUtil.merge(folderIds) };
3032    
3033                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F,
3034                                    finderArgs, this);
3035    
3036                    if (count == null) {
3037                            StringBundler query = new StringBundler();
3038    
3039                            query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
3040    
3041                            boolean conjunctionable = false;
3042    
3043                            if (conjunctionable) {
3044                                    query.append(WHERE_AND);
3045                            }
3046    
3047                            query.append(_FINDER_COLUMN_G_F_GROUPID_5);
3048    
3049                            conjunctionable = true;
3050    
3051                            if ((folderIds == null) || (folderIds.length > 0)) {
3052                                    if (conjunctionable) {
3053                                            query.append(WHERE_AND);
3054                                    }
3055    
3056                                    query.append(StringPool.OPEN_PARENTHESIS);
3057    
3058                                    for (int i = 0; i < folderIds.length; i++) {
3059                                            query.append(_FINDER_COLUMN_G_F_FOLDERID_5);
3060    
3061                                            if ((i + 1) < folderIds.length) {
3062                                                    query.append(WHERE_OR);
3063                                            }
3064                                    }
3065    
3066                                    query.append(StringPool.CLOSE_PARENTHESIS);
3067    
3068                                    conjunctionable = true;
3069                            }
3070    
3071                            String sql = query.toString();
3072    
3073                            Session session = null;
3074    
3075                            try {
3076                                    session = openSession();
3077    
3078                                    Query q = session.createQuery(sql);
3079    
3080                                    QueryPos qPos = QueryPos.getInstance(q);
3081    
3082                                    qPos.add(groupId);
3083    
3084                                    if (folderIds != null) {
3085                                            qPos.add(folderIds);
3086                                    }
3087    
3088                                    count = (Long)q.uniqueResult();
3089    
3090                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F,
3091                                            finderArgs, count);
3092                            }
3093                            catch (Exception e) {
3094                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F,
3095                                            finderArgs);
3096    
3097                                    throw processException(e);
3098                            }
3099                            finally {
3100                                    closeSession(session);
3101                            }
3102                    }
3103    
3104                    return count.intValue();
3105            }
3106    
3107            /**
3108             * Returns the number of bookmarks entries that the user has permission to view where groupId = &#63; and folderId = &#63;.
3109             *
3110             * @param groupId the group ID
3111             * @param folderId the folder ID
3112             * @return the number of matching bookmarks entries that the user has permission to view
3113             * @throws SystemException if a system exception occurred
3114             */
3115            public int filterCountByG_F(long groupId, long folderId)
3116                    throws SystemException {
3117                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3118                            return countByG_F(groupId, folderId);
3119                    }
3120    
3121                    StringBundler query = new StringBundler(3);
3122    
3123                    query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
3124    
3125                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
3126    
3127                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
3128    
3129                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3130                                    BookmarksEntry.class.getName(),
3131                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
3132                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
3133    
3134                    Session session = null;
3135    
3136                    try {
3137                            session = openSession();
3138    
3139                            Query q = session.createQuery(sql);
3140    
3141                            QueryPos qPos = QueryPos.getInstance(q);
3142    
3143                            qPos.add(groupId);
3144    
3145                            qPos.add(folderId);
3146    
3147                            Long count = (Long)q.uniqueResult();
3148    
3149                            return count.intValue();
3150                    }
3151                    catch (Exception e) {
3152                            throw processException(e);
3153                    }
3154                    finally {
3155                            closeSession(session);
3156                    }
3157            }
3158    
3159            /**
3160             * Returns the number of bookmarks entries that the user has permission to view where groupId = &#63; and folderId = any &#63;.
3161             *
3162             * @param groupId the group ID
3163             * @param folderIds the folder IDs
3164             * @return the number of matching bookmarks entries that the user has permission to view
3165             * @throws SystemException if a system exception occurred
3166             */
3167            public int filterCountByG_F(long groupId, long[] folderIds)
3168                    throws SystemException {
3169                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3170                            return countByG_F(groupId, folderIds);
3171                    }
3172    
3173                    StringBundler query = new StringBundler();
3174    
3175                    query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
3176    
3177                    boolean conjunctionable = false;
3178    
3179                    if (conjunctionable) {
3180                            query.append(WHERE_AND);
3181                    }
3182    
3183                    query.append(_FINDER_COLUMN_G_F_GROUPID_5);
3184    
3185                    conjunctionable = true;
3186    
3187                    if ((folderIds == null) || (folderIds.length > 0)) {
3188                            if (conjunctionable) {
3189                                    query.append(WHERE_AND);
3190                            }
3191    
3192                            query.append(StringPool.OPEN_PARENTHESIS);
3193    
3194                            for (int i = 0; i < folderIds.length; i++) {
3195                                    query.append(_FINDER_COLUMN_G_F_FOLDERID_5);
3196    
3197                                    if ((i + 1) < folderIds.length) {
3198                                            query.append(WHERE_OR);
3199                                    }
3200                            }
3201    
3202                            query.append(StringPool.CLOSE_PARENTHESIS);
3203    
3204                            conjunctionable = true;
3205                    }
3206    
3207                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3208                                    BookmarksEntry.class.getName(),
3209                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
3210                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
3211    
3212                    Session session = null;
3213    
3214                    try {
3215                            session = openSession();
3216    
3217                            Query q = session.createQuery(sql);
3218    
3219                            QueryPos qPos = QueryPos.getInstance(q);
3220    
3221                            qPos.add(groupId);
3222    
3223                            if (folderIds != null) {
3224                                    qPos.add(folderIds);
3225                            }
3226    
3227                            Long count = (Long)q.uniqueResult();
3228    
3229                            return count.intValue();
3230                    }
3231                    catch (Exception e) {
3232                            throw processException(e);
3233                    }
3234                    finally {
3235                            closeSession(session);
3236                    }
3237            }
3238    
3239            private static final String _FINDER_COLUMN_G_F_GROUPID_2 = "bookmarksEntry.groupId = ? AND ";
3240            private static final String _FINDER_COLUMN_G_F_GROUPID_5 = "(" +
3241                    removeConjunction(_FINDER_COLUMN_G_F_GROUPID_2) + ")";
3242            private static final String _FINDER_COLUMN_G_F_FOLDERID_2 = "bookmarksEntry.folderId = ?";
3243            private static final String _FINDER_COLUMN_G_F_FOLDERID_5 = "(" +
3244                    removeConjunction(_FINDER_COLUMN_G_F_FOLDERID_2) + ")";
3245            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
3246                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
3247                            BookmarksEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
3248                            "findByG_S",
3249                            new String[] {
3250                                    Long.class.getName(), Integer.class.getName(),
3251                                    
3252                            Integer.class.getName(), Integer.class.getName(),
3253                                    OrderByComparator.class.getName()
3254                            });
3255            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
3256                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
3257                            BookmarksEntryImpl.class,
3258                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_S",
3259                            new String[] { Long.class.getName(), Integer.class.getName() },
3260                            BookmarksEntryModelImpl.GROUPID_COLUMN_BITMASK |
3261                            BookmarksEntryModelImpl.STATUS_COLUMN_BITMASK |
3262                            BookmarksEntryModelImpl.FOLDERID_COLUMN_BITMASK |
3263                            BookmarksEntryModelImpl.NAME_COLUMN_BITMASK);
3264            public static final FinderPath FINDER_PATH_COUNT_BY_G_S = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
3265                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
3266                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_S",
3267                            new String[] { Long.class.getName(), Integer.class.getName() });
3268    
3269            /**
3270             * Returns all the bookmarks entries where groupId = &#63; and status = &#63;.
3271             *
3272             * @param groupId the group ID
3273             * @param status the status
3274             * @return the matching bookmarks entries
3275             * @throws SystemException if a system exception occurred
3276             */
3277            public List<BookmarksEntry> findByG_S(long groupId, int status)
3278                    throws SystemException {
3279                    return findByG_S(groupId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
3280                            null);
3281            }
3282    
3283            /**
3284             * Returns a range of all the bookmarks entries where groupId = &#63; and status = &#63;.
3285             *
3286             * <p>
3287             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
3288             * </p>
3289             *
3290             * @param groupId the group ID
3291             * @param status the status
3292             * @param start the lower bound of the range of bookmarks entries
3293             * @param end the upper bound of the range of bookmarks entries (not inclusive)
3294             * @return the range of matching bookmarks entries
3295             * @throws SystemException if a system exception occurred
3296             */
3297            public List<BookmarksEntry> findByG_S(long groupId, int status, int start,
3298                    int end) throws SystemException {
3299                    return findByG_S(groupId, status, start, end, null);
3300            }
3301    
3302            /**
3303             * Returns an ordered range of all the bookmarks entries where groupId = &#63; and status = &#63;.
3304             *
3305             * <p>
3306             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
3307             * </p>
3308             *
3309             * @param groupId the group ID
3310             * @param status the status
3311             * @param start the lower bound of the range of bookmarks entries
3312             * @param end the upper bound of the range of bookmarks entries (not inclusive)
3313             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3314             * @return the ordered range of matching bookmarks entries
3315             * @throws SystemException if a system exception occurred
3316             */
3317            public List<BookmarksEntry> findByG_S(long groupId, int status, int start,
3318                    int end, OrderByComparator orderByComparator) throws SystemException {
3319                    boolean pagination = true;
3320                    FinderPath finderPath = null;
3321                    Object[] finderArgs = null;
3322    
3323                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3324                                    (orderByComparator == null)) {
3325                            pagination = false;
3326                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S;
3327                            finderArgs = new Object[] { groupId, status };
3328                    }
3329                    else {
3330                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S;
3331                            finderArgs = new Object[] {
3332                                            groupId, status,
3333                                            
3334                                            start, end, orderByComparator
3335                                    };
3336                    }
3337    
3338                    List<BookmarksEntry> list = (List<BookmarksEntry>)FinderCacheUtil.getResult(finderPath,
3339                                    finderArgs, this);
3340    
3341                    if ((list != null) && !list.isEmpty()) {
3342                            for (BookmarksEntry bookmarksEntry : list) {
3343                                    if ((groupId != bookmarksEntry.getGroupId()) ||
3344                                                    (status != bookmarksEntry.getStatus())) {
3345                                            list = null;
3346    
3347                                            break;
3348                                    }
3349                            }
3350                    }
3351    
3352                    if (list == null) {
3353                            StringBundler query = null;
3354    
3355                            if (orderByComparator != null) {
3356                                    query = new StringBundler(4 +
3357                                                    (orderByComparator.getOrderByFields().length * 3));
3358                            }
3359                            else {
3360                                    query = new StringBundler(4);
3361                            }
3362    
3363                            query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
3364    
3365                            query.append(_FINDER_COLUMN_G_S_GROUPID_2);
3366    
3367                            query.append(_FINDER_COLUMN_G_S_STATUS_2);
3368    
3369                            if (orderByComparator != null) {
3370                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3371                                            orderByComparator);
3372                            }
3373                            else
3374                             if (pagination) {
3375                                    query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
3376                            }
3377    
3378                            String sql = query.toString();
3379    
3380                            Session session = null;
3381    
3382                            try {
3383                                    session = openSession();
3384    
3385                                    Query q = session.createQuery(sql);
3386    
3387                                    QueryPos qPos = QueryPos.getInstance(q);
3388    
3389                                    qPos.add(groupId);
3390    
3391                                    qPos.add(status);
3392    
3393                                    if (!pagination) {
3394                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
3395                                                            getDialect(), start, end, false);
3396    
3397                                            Collections.sort(list);
3398    
3399                                            list = new UnmodifiableList<BookmarksEntry>(list);
3400                                    }
3401                                    else {
3402                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
3403                                                            getDialect(), start, end);
3404                                    }
3405    
3406                                    cacheResult(list);
3407    
3408                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
3409                            }
3410                            catch (Exception e) {
3411                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3412    
3413                                    throw processException(e);
3414                            }
3415                            finally {
3416                                    closeSession(session);
3417                            }
3418                    }
3419    
3420                    return list;
3421            }
3422    
3423            /**
3424             * Returns the first bookmarks entry in the ordered set where groupId = &#63; and status = &#63;.
3425             *
3426             * @param groupId the group ID
3427             * @param status the status
3428             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3429             * @return the first matching bookmarks entry
3430             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
3431             * @throws SystemException if a system exception occurred
3432             */
3433            public BookmarksEntry findByG_S_First(long groupId, int status,
3434                    OrderByComparator orderByComparator)
3435                    throws NoSuchEntryException, SystemException {
3436                    BookmarksEntry bookmarksEntry = fetchByG_S_First(groupId, status,
3437                                    orderByComparator);
3438    
3439                    if (bookmarksEntry != null) {
3440                            return bookmarksEntry;
3441                    }
3442    
3443                    StringBundler msg = new StringBundler(6);
3444    
3445                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3446    
3447                    msg.append("groupId=");
3448                    msg.append(groupId);
3449    
3450                    msg.append(", status=");
3451                    msg.append(status);
3452    
3453                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3454    
3455                    throw new NoSuchEntryException(msg.toString());
3456            }
3457    
3458            /**
3459             * Returns the first bookmarks entry in the ordered set where groupId = &#63; and status = &#63;.
3460             *
3461             * @param groupId the group ID
3462             * @param status the status
3463             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3464             * @return the first matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
3465             * @throws SystemException if a system exception occurred
3466             */
3467            public BookmarksEntry fetchByG_S_First(long groupId, int status,
3468                    OrderByComparator orderByComparator) throws SystemException {
3469                    List<BookmarksEntry> list = findByG_S(groupId, status, 0, 1,
3470                                    orderByComparator);
3471    
3472                    if (!list.isEmpty()) {
3473                            return list.get(0);
3474                    }
3475    
3476                    return null;
3477            }
3478    
3479            /**
3480             * Returns the last bookmarks entry in the ordered set where groupId = &#63; and status = &#63;.
3481             *
3482             * @param groupId the group ID
3483             * @param status the status
3484             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3485             * @return the last matching bookmarks entry
3486             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
3487             * @throws SystemException if a system exception occurred
3488             */
3489            public BookmarksEntry findByG_S_Last(long groupId, int status,
3490                    OrderByComparator orderByComparator)
3491                    throws NoSuchEntryException, SystemException {
3492                    BookmarksEntry bookmarksEntry = fetchByG_S_Last(groupId, status,
3493                                    orderByComparator);
3494    
3495                    if (bookmarksEntry != null) {
3496                            return bookmarksEntry;
3497                    }
3498    
3499                    StringBundler msg = new StringBundler(6);
3500    
3501                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3502    
3503                    msg.append("groupId=");
3504                    msg.append(groupId);
3505    
3506                    msg.append(", status=");
3507                    msg.append(status);
3508    
3509                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3510    
3511                    throw new NoSuchEntryException(msg.toString());
3512            }
3513    
3514            /**
3515             * Returns the last bookmarks entry in the ordered set where groupId = &#63; and status = &#63;.
3516             *
3517             * @param groupId the group ID
3518             * @param status the status
3519             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3520             * @return the last matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
3521             * @throws SystemException if a system exception occurred
3522             */
3523            public BookmarksEntry fetchByG_S_Last(long groupId, int status,
3524                    OrderByComparator orderByComparator) throws SystemException {
3525                    int count = countByG_S(groupId, status);
3526    
3527                    List<BookmarksEntry> list = findByG_S(groupId, status, count - 1,
3528                                    count, orderByComparator);
3529    
3530                    if (!list.isEmpty()) {
3531                            return list.get(0);
3532                    }
3533    
3534                    return null;
3535            }
3536    
3537            /**
3538             * Returns the bookmarks entries before and after the current bookmarks entry in the ordered set where groupId = &#63; and status = &#63;.
3539             *
3540             * @param entryId the primary key of the current bookmarks entry
3541             * @param groupId the group ID
3542             * @param status the status
3543             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3544             * @return the previous, current, and next bookmarks entry
3545             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
3546             * @throws SystemException if a system exception occurred
3547             */
3548            public BookmarksEntry[] findByG_S_PrevAndNext(long entryId, long groupId,
3549                    int status, OrderByComparator orderByComparator)
3550                    throws NoSuchEntryException, SystemException {
3551                    BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
3552    
3553                    Session session = null;
3554    
3555                    try {
3556                            session = openSession();
3557    
3558                            BookmarksEntry[] array = new BookmarksEntryImpl[3];
3559    
3560                            array[0] = getByG_S_PrevAndNext(session, bookmarksEntry, groupId,
3561                                            status, orderByComparator, true);
3562    
3563                            array[1] = bookmarksEntry;
3564    
3565                            array[2] = getByG_S_PrevAndNext(session, bookmarksEntry, groupId,
3566                                            status, orderByComparator, false);
3567    
3568                            return array;
3569                    }
3570                    catch (Exception e) {
3571                            throw processException(e);
3572                    }
3573                    finally {
3574                            closeSession(session);
3575                    }
3576            }
3577    
3578            protected BookmarksEntry getByG_S_PrevAndNext(Session session,
3579                    BookmarksEntry bookmarksEntry, long groupId, int status,
3580                    OrderByComparator orderByComparator, boolean previous) {
3581                    StringBundler query = null;
3582    
3583                    if (orderByComparator != null) {
3584                            query = new StringBundler(6 +
3585                                            (orderByComparator.getOrderByFields().length * 6));
3586                    }
3587                    else {
3588                            query = new StringBundler(3);
3589                    }
3590    
3591                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
3592    
3593                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
3594    
3595                    query.append(_FINDER_COLUMN_G_S_STATUS_2);
3596    
3597                    if (orderByComparator != null) {
3598                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3599    
3600                            if (orderByConditionFields.length > 0) {
3601                                    query.append(WHERE_AND);
3602                            }
3603    
3604                            for (int i = 0; i < orderByConditionFields.length; i++) {
3605                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3606                                    query.append(orderByConditionFields[i]);
3607    
3608                                    if ((i + 1) < orderByConditionFields.length) {
3609                                            if (orderByComparator.isAscending() ^ previous) {
3610                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3611                                            }
3612                                            else {
3613                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3614                                            }
3615                                    }
3616                                    else {
3617                                            if (orderByComparator.isAscending() ^ previous) {
3618                                                    query.append(WHERE_GREATER_THAN);
3619                                            }
3620                                            else {
3621                                                    query.append(WHERE_LESSER_THAN);
3622                                            }
3623                                    }
3624                            }
3625    
3626                            query.append(ORDER_BY_CLAUSE);
3627    
3628                            String[] orderByFields = orderByComparator.getOrderByFields();
3629    
3630                            for (int i = 0; i < orderByFields.length; i++) {
3631                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3632                                    query.append(orderByFields[i]);
3633    
3634                                    if ((i + 1) < orderByFields.length) {
3635                                            if (orderByComparator.isAscending() ^ previous) {
3636                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3637                                            }
3638                                            else {
3639                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3640                                            }
3641                                    }
3642                                    else {
3643                                            if (orderByComparator.isAscending() ^ previous) {
3644                                                    query.append(ORDER_BY_ASC);
3645                                            }
3646                                            else {
3647                                                    query.append(ORDER_BY_DESC);
3648                                            }
3649                                    }
3650                            }
3651                    }
3652                    else {
3653                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
3654                    }
3655    
3656                    String sql = query.toString();
3657    
3658                    Query q = session.createQuery(sql);
3659    
3660                    q.setFirstResult(0);
3661                    q.setMaxResults(2);
3662    
3663                    QueryPos qPos = QueryPos.getInstance(q);
3664    
3665                    qPos.add(groupId);
3666    
3667                    qPos.add(status);
3668    
3669                    if (orderByComparator != null) {
3670                            Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry);
3671    
3672                            for (Object value : values) {
3673                                    qPos.add(value);
3674                            }
3675                    }
3676    
3677                    List<BookmarksEntry> list = q.list();
3678    
3679                    if (list.size() == 2) {
3680                            return list.get(1);
3681                    }
3682                    else {
3683                            return null;
3684                    }
3685            }
3686    
3687            /**
3688             * Returns all the bookmarks entries that the user has permission to view where groupId = &#63; and status = &#63;.
3689             *
3690             * @param groupId the group ID
3691             * @param status the status
3692             * @return the matching bookmarks entries that the user has permission to view
3693             * @throws SystemException if a system exception occurred
3694             */
3695            public List<BookmarksEntry> filterFindByG_S(long groupId, int status)
3696                    throws SystemException {
3697                    return filterFindByG_S(groupId, status, QueryUtil.ALL_POS,
3698                            QueryUtil.ALL_POS, null);
3699            }
3700    
3701            /**
3702             * Returns a range of all the bookmarks entries that the user has permission to view where groupId = &#63; and status = &#63;.
3703             *
3704             * <p>
3705             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
3706             * </p>
3707             *
3708             * @param groupId the group ID
3709             * @param status the status
3710             * @param start the lower bound of the range of bookmarks entries
3711             * @param end the upper bound of the range of bookmarks entries (not inclusive)
3712             * @return the range of matching bookmarks entries that the user has permission to view
3713             * @throws SystemException if a system exception occurred
3714             */
3715            public List<BookmarksEntry> filterFindByG_S(long groupId, int status,
3716                    int start, int end) throws SystemException {
3717                    return filterFindByG_S(groupId, status, start, end, null);
3718            }
3719    
3720            /**
3721             * Returns an ordered range of all the bookmarks entries that the user has permissions to view where groupId = &#63; and status = &#63;.
3722             *
3723             * <p>
3724             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
3725             * </p>
3726             *
3727             * @param groupId the group ID
3728             * @param status the status
3729             * @param start the lower bound of the range of bookmarks entries
3730             * @param end the upper bound of the range of bookmarks entries (not inclusive)
3731             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3732             * @return the ordered range of matching bookmarks entries that the user has permission to view
3733             * @throws SystemException if a system exception occurred
3734             */
3735            public List<BookmarksEntry> filterFindByG_S(long groupId, int status,
3736                    int start, int end, OrderByComparator orderByComparator)
3737                    throws SystemException {
3738                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3739                            return findByG_S(groupId, status, start, end, orderByComparator);
3740                    }
3741    
3742                    StringBundler query = null;
3743    
3744                    if (orderByComparator != null) {
3745                            query = new StringBundler(4 +
3746                                            (orderByComparator.getOrderByFields().length * 3));
3747                    }
3748                    else {
3749                            query = new StringBundler(4);
3750                    }
3751    
3752                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
3753    
3754                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
3755    
3756                    query.append(_FINDER_COLUMN_G_S_STATUS_2);
3757    
3758                    if (orderByComparator != null) {
3759                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3760                                    orderByComparator);
3761                    }
3762                    else {
3763                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
3764                    }
3765    
3766                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3767                                    BookmarksEntry.class.getName(),
3768                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
3769                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
3770    
3771                    Session session = null;
3772    
3773                    try {
3774                            session = openSession();
3775    
3776                            Query q = session.createQuery(sql);
3777    
3778                            QueryPos qPos = QueryPos.getInstance(q);
3779    
3780                            qPos.add(groupId);
3781    
3782                            qPos.add(status);
3783    
3784                            return (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start,
3785                                    end);
3786                    }
3787                    catch (Exception e) {
3788                            throw processException(e);
3789                    }
3790                    finally {
3791                            closeSession(session);
3792                    }
3793            }
3794    
3795            /**
3796             * 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;.
3797             *
3798             * @param entryId the primary key of the current bookmarks entry
3799             * @param groupId the group ID
3800             * @param status the status
3801             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3802             * @return the previous, current, and next bookmarks entry
3803             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
3804             * @throws SystemException if a system exception occurred
3805             */
3806            public BookmarksEntry[] filterFindByG_S_PrevAndNext(long entryId,
3807                    long groupId, int status, OrderByComparator orderByComparator)
3808                    throws NoSuchEntryException, SystemException {
3809                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3810                            return findByG_S_PrevAndNext(entryId, groupId, status,
3811                                    orderByComparator);
3812                    }
3813    
3814                    BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
3815    
3816                    Session session = null;
3817    
3818                    try {
3819                            session = openSession();
3820    
3821                            BookmarksEntry[] array = new BookmarksEntryImpl[3];
3822    
3823                            array[0] = filterGetByG_S_PrevAndNext(session, bookmarksEntry,
3824                                            groupId, status, orderByComparator, true);
3825    
3826                            array[1] = bookmarksEntry;
3827    
3828                            array[2] = filterGetByG_S_PrevAndNext(session, bookmarksEntry,
3829                                            groupId, status, orderByComparator, false);
3830    
3831                            return array;
3832                    }
3833                    catch (Exception e) {
3834                            throw processException(e);
3835                    }
3836                    finally {
3837                            closeSession(session);
3838                    }
3839            }
3840    
3841            protected BookmarksEntry filterGetByG_S_PrevAndNext(Session session,
3842                    BookmarksEntry bookmarksEntry, long groupId, int status,
3843                    OrderByComparator orderByComparator, boolean previous) {
3844                    StringBundler query = null;
3845    
3846                    if (orderByComparator != null) {
3847                            query = new StringBundler(6 +
3848                                            (orderByComparator.getOrderByFields().length * 6));
3849                    }
3850                    else {
3851                            query = new StringBundler(3);
3852                    }
3853    
3854                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
3855    
3856                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
3857    
3858                    query.append(_FINDER_COLUMN_G_S_STATUS_2);
3859    
3860                    if (orderByComparator != null) {
3861                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3862    
3863                            if (orderByConditionFields.length > 0) {
3864                                    query.append(WHERE_AND);
3865                            }
3866    
3867                            for (int i = 0; i < orderByConditionFields.length; i++) {
3868                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3869                                    query.append(orderByConditionFields[i]);
3870    
3871                                    if ((i + 1) < orderByConditionFields.length) {
3872                                            if (orderByComparator.isAscending() ^ previous) {
3873                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3874                                            }
3875                                            else {
3876                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3877                                            }
3878                                    }
3879                                    else {
3880                                            if (orderByComparator.isAscending() ^ previous) {
3881                                                    query.append(WHERE_GREATER_THAN);
3882                                            }
3883                                            else {
3884                                                    query.append(WHERE_LESSER_THAN);
3885                                            }
3886                                    }
3887                            }
3888    
3889                            query.append(ORDER_BY_CLAUSE);
3890    
3891                            String[] orderByFields = orderByComparator.getOrderByFields();
3892    
3893                            for (int i = 0; i < orderByFields.length; i++) {
3894                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3895                                    query.append(orderByFields[i]);
3896    
3897                                    if ((i + 1) < orderByFields.length) {
3898                                            if (orderByComparator.isAscending() ^ previous) {
3899                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3900                                            }
3901                                            else {
3902                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3903                                            }
3904                                    }
3905                                    else {
3906                                            if (orderByComparator.isAscending() ^ previous) {
3907                                                    query.append(ORDER_BY_ASC);
3908                                            }
3909                                            else {
3910                                                    query.append(ORDER_BY_DESC);
3911                                            }
3912                                    }
3913                            }
3914                    }
3915                    else {
3916                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
3917                    }
3918    
3919                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3920                                    BookmarksEntry.class.getName(),
3921                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
3922                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
3923    
3924                    Query q = session.createQuery(sql);
3925    
3926                    q.setFirstResult(0);
3927                    q.setMaxResults(2);
3928    
3929                    QueryPos qPos = QueryPos.getInstance(q);
3930    
3931                    qPos.add(groupId);
3932    
3933                    qPos.add(status);
3934    
3935                    if (orderByComparator != null) {
3936                            Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry);
3937    
3938                            for (Object value : values) {
3939                                    qPos.add(value);
3940                            }
3941                    }
3942    
3943                    List<BookmarksEntry> list = q.list();
3944    
3945                    if (list.size() == 2) {
3946                            return list.get(1);
3947                    }
3948                    else {
3949                            return null;
3950                    }
3951            }
3952    
3953            /**
3954             * Removes all the bookmarks entries where groupId = &#63; and status = &#63; from the database.
3955             *
3956             * @param groupId the group ID
3957             * @param status the status
3958             * @throws SystemException if a system exception occurred
3959             */
3960            public void removeByG_S(long groupId, int status) throws SystemException {
3961                    for (BookmarksEntry bookmarksEntry : findByG_S(groupId, status,
3962                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3963                            remove(bookmarksEntry);
3964                    }
3965            }
3966    
3967            /**
3968             * Returns the number of bookmarks entries where groupId = &#63; and status = &#63;.
3969             *
3970             * @param groupId the group ID
3971             * @param status the status
3972             * @return the number of matching bookmarks entries
3973             * @throws SystemException if a system exception occurred
3974             */
3975            public int countByG_S(long groupId, int status) throws SystemException {
3976                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_S;
3977    
3978                    Object[] finderArgs = new Object[] { groupId, status };
3979    
3980                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3981                                    this);
3982    
3983                    if (count == null) {
3984                            StringBundler query = new StringBundler(3);
3985    
3986                            query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
3987    
3988                            query.append(_FINDER_COLUMN_G_S_GROUPID_2);
3989    
3990                            query.append(_FINDER_COLUMN_G_S_STATUS_2);
3991    
3992                            String sql = query.toString();
3993    
3994                            Session session = null;
3995    
3996                            try {
3997                                    session = openSession();
3998    
3999                                    Query q = session.createQuery(sql);
4000    
4001                                    QueryPos qPos = QueryPos.getInstance(q);
4002    
4003                                    qPos.add(groupId);
4004    
4005                                    qPos.add(status);
4006    
4007                                    count = (Long)q.uniqueResult();
4008    
4009                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
4010                            }
4011                            catch (Exception e) {
4012                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4013    
4014                                    throw processException(e);
4015                            }
4016                            finally {
4017                                    closeSession(session);
4018                            }
4019                    }
4020    
4021                    return count.intValue();
4022            }
4023    
4024            /**
4025             * Returns the number of bookmarks entries that the user has permission to view where groupId = &#63; and status = &#63;.
4026             *
4027             * @param groupId the group ID
4028             * @param status the status
4029             * @return the number of matching bookmarks entries that the user has permission to view
4030             * @throws SystemException if a system exception occurred
4031             */
4032            public int filterCountByG_S(long groupId, int status)
4033                    throws SystemException {
4034                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4035                            return countByG_S(groupId, status);
4036                    }
4037    
4038                    StringBundler query = new StringBundler(3);
4039    
4040                    query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
4041    
4042                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4043    
4044                    query.append(_FINDER_COLUMN_G_S_STATUS_2);
4045    
4046                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4047                                    BookmarksEntry.class.getName(),
4048                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
4049                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
4050    
4051                    Session session = null;
4052    
4053                    try {
4054                            session = openSession();
4055    
4056                            Query q = session.createQuery(sql);
4057    
4058                            QueryPos qPos = QueryPos.getInstance(q);
4059    
4060                            qPos.add(groupId);
4061    
4062                            qPos.add(status);
4063    
4064                            Long count = (Long)q.uniqueResult();
4065    
4066                            return count.intValue();
4067                    }
4068                    catch (Exception e) {
4069                            throw processException(e);
4070                    }
4071                    finally {
4072                            closeSession(session);
4073                    }
4074            }
4075    
4076            private static final String _FINDER_COLUMN_G_S_GROUPID_2 = "bookmarksEntry.groupId = ? AND ";
4077            private static final String _FINDER_COLUMN_G_S_STATUS_2 = "bookmarksEntry.status = ?";
4078            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_S = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
4079                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
4080                            BookmarksEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
4081                            "findByG_U_S",
4082                            new String[] {
4083                                    Long.class.getName(), Long.class.getName(),
4084                                    Integer.class.getName(),
4085                                    
4086                            Integer.class.getName(), Integer.class.getName(),
4087                                    OrderByComparator.class.getName()
4088                            });
4089            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
4090                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
4091                            BookmarksEntryImpl.class,
4092                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U_S",
4093                            new String[] {
4094                                    Long.class.getName(), Long.class.getName(),
4095                                    Integer.class.getName()
4096                            },
4097                            BookmarksEntryModelImpl.GROUPID_COLUMN_BITMASK |
4098                            BookmarksEntryModelImpl.USERID_COLUMN_BITMASK |
4099                            BookmarksEntryModelImpl.STATUS_COLUMN_BITMASK |
4100                            BookmarksEntryModelImpl.FOLDERID_COLUMN_BITMASK |
4101                            BookmarksEntryModelImpl.NAME_COLUMN_BITMASK);
4102            public static final FinderPath FINDER_PATH_COUNT_BY_G_U_S = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
4103                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
4104                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U_S",
4105                            new String[] {
4106                                    Long.class.getName(), Long.class.getName(),
4107                                    Integer.class.getName()
4108                            });
4109    
4110            /**
4111             * Returns all the bookmarks entries where groupId = &#63; and userId = &#63; and status = &#63;.
4112             *
4113             * @param groupId the group ID
4114             * @param userId the user ID
4115             * @param status the status
4116             * @return the matching bookmarks entries
4117             * @throws SystemException if a system exception occurred
4118             */
4119            public List<BookmarksEntry> findByG_U_S(long groupId, long userId,
4120                    int status) throws SystemException {
4121                    return findByG_U_S(groupId, userId, status, QueryUtil.ALL_POS,
4122                            QueryUtil.ALL_POS, null);
4123            }
4124    
4125            /**
4126             * Returns a range of all the bookmarks entries where groupId = &#63; and userId = &#63; and status = &#63;.
4127             *
4128             * <p>
4129             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
4130             * </p>
4131             *
4132             * @param groupId the group ID
4133             * @param userId the user ID
4134             * @param status the status
4135             * @param start the lower bound of the range of bookmarks entries
4136             * @param end the upper bound of the range of bookmarks entries (not inclusive)
4137             * @return the range of matching bookmarks entries
4138             * @throws SystemException if a system exception occurred
4139             */
4140            public List<BookmarksEntry> findByG_U_S(long groupId, long userId,
4141                    int status, int start, int end) throws SystemException {
4142                    return findByG_U_S(groupId, userId, status, start, end, null);
4143            }
4144    
4145            /**
4146             * Returns an ordered range of all the bookmarks entries where groupId = &#63; and userId = &#63; and status = &#63;.
4147             *
4148             * <p>
4149             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
4150             * </p>
4151             *
4152             * @param groupId the group ID
4153             * @param userId the user ID
4154             * @param status the status
4155             * @param start the lower bound of the range of bookmarks entries
4156             * @param end the upper bound of the range of bookmarks entries (not inclusive)
4157             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4158             * @return the ordered range of matching bookmarks entries
4159             * @throws SystemException if a system exception occurred
4160             */
4161            public List<BookmarksEntry> findByG_U_S(long groupId, long userId,
4162                    int status, int start, int end, OrderByComparator orderByComparator)
4163                    throws SystemException {
4164                    boolean pagination = true;
4165                    FinderPath finderPath = null;
4166                    Object[] finderArgs = null;
4167    
4168                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4169                                    (orderByComparator == null)) {
4170                            pagination = false;
4171                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S;
4172                            finderArgs = new Object[] { groupId, userId, status };
4173                    }
4174                    else {
4175                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_S;
4176                            finderArgs = new Object[] {
4177                                            groupId, userId, status,
4178                                            
4179                                            start, end, orderByComparator
4180                                    };
4181                    }
4182    
4183                    List<BookmarksEntry> list = (List<BookmarksEntry>)FinderCacheUtil.getResult(finderPath,
4184                                    finderArgs, this);
4185    
4186                    if ((list != null) && !list.isEmpty()) {
4187                            for (BookmarksEntry bookmarksEntry : list) {
4188                                    if ((groupId != bookmarksEntry.getGroupId()) ||
4189                                                    (userId != bookmarksEntry.getUserId()) ||
4190                                                    (status != bookmarksEntry.getStatus())) {
4191                                            list = null;
4192    
4193                                            break;
4194                                    }
4195                            }
4196                    }
4197    
4198                    if (list == null) {
4199                            StringBundler query = null;
4200    
4201                            if (orderByComparator != null) {
4202                                    query = new StringBundler(5 +
4203                                                    (orderByComparator.getOrderByFields().length * 3));
4204                            }
4205                            else {
4206                                    query = new StringBundler(5);
4207                            }
4208    
4209                            query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
4210    
4211                            query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
4212    
4213                            query.append(_FINDER_COLUMN_G_U_S_USERID_2);
4214    
4215                            query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
4216    
4217                            if (orderByComparator != null) {
4218                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4219                                            orderByComparator);
4220                            }
4221                            else
4222                             if (pagination) {
4223                                    query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
4224                            }
4225    
4226                            String sql = query.toString();
4227    
4228                            Session session = null;
4229    
4230                            try {
4231                                    session = openSession();
4232    
4233                                    Query q = session.createQuery(sql);
4234    
4235                                    QueryPos qPos = QueryPos.getInstance(q);
4236    
4237                                    qPos.add(groupId);
4238    
4239                                    qPos.add(userId);
4240    
4241                                    qPos.add(status);
4242    
4243                                    if (!pagination) {
4244                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
4245                                                            getDialect(), start, end, false);
4246    
4247                                            Collections.sort(list);
4248    
4249                                            list = new UnmodifiableList<BookmarksEntry>(list);
4250                                    }
4251                                    else {
4252                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
4253                                                            getDialect(), start, end);
4254                                    }
4255    
4256                                    cacheResult(list);
4257    
4258                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
4259                            }
4260                            catch (Exception e) {
4261                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4262    
4263                                    throw processException(e);
4264                            }
4265                            finally {
4266                                    closeSession(session);
4267                            }
4268                    }
4269    
4270                    return list;
4271            }
4272    
4273            /**
4274             * Returns the first bookmarks entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
4275             *
4276             * @param groupId the group ID
4277             * @param userId the user ID
4278             * @param status the status
4279             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4280             * @return the first matching bookmarks entry
4281             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
4282             * @throws SystemException if a system exception occurred
4283             */
4284            public BookmarksEntry findByG_U_S_First(long groupId, long userId,
4285                    int status, OrderByComparator orderByComparator)
4286                    throws NoSuchEntryException, SystemException {
4287                    BookmarksEntry bookmarksEntry = fetchByG_U_S_First(groupId, userId,
4288                                    status, orderByComparator);
4289    
4290                    if (bookmarksEntry != null) {
4291                            return bookmarksEntry;
4292                    }
4293    
4294                    StringBundler msg = new StringBundler(8);
4295    
4296                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4297    
4298                    msg.append("groupId=");
4299                    msg.append(groupId);
4300    
4301                    msg.append(", userId=");
4302                    msg.append(userId);
4303    
4304                    msg.append(", status=");
4305                    msg.append(status);
4306    
4307                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4308    
4309                    throw new NoSuchEntryException(msg.toString());
4310            }
4311    
4312            /**
4313             * Returns the first bookmarks entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
4314             *
4315             * @param groupId the group ID
4316             * @param userId the user ID
4317             * @param status the status
4318             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4319             * @return the first matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
4320             * @throws SystemException if a system exception occurred
4321             */
4322            public BookmarksEntry fetchByG_U_S_First(long groupId, long userId,
4323                    int status, OrderByComparator orderByComparator)
4324                    throws SystemException {
4325                    List<BookmarksEntry> list = findByG_U_S(groupId, userId, status, 0, 1,
4326                                    orderByComparator);
4327    
4328                    if (!list.isEmpty()) {
4329                            return list.get(0);
4330                    }
4331    
4332                    return null;
4333            }
4334    
4335            /**
4336             * Returns the last bookmarks entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
4337             *
4338             * @param groupId the group ID
4339             * @param userId the user ID
4340             * @param status the status
4341             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4342             * @return the last matching bookmarks entry
4343             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
4344             * @throws SystemException if a system exception occurred
4345             */
4346            public BookmarksEntry findByG_U_S_Last(long groupId, long userId,
4347                    int status, OrderByComparator orderByComparator)
4348                    throws NoSuchEntryException, SystemException {
4349                    BookmarksEntry bookmarksEntry = fetchByG_U_S_Last(groupId, userId,
4350                                    status, orderByComparator);
4351    
4352                    if (bookmarksEntry != null) {
4353                            return bookmarksEntry;
4354                    }
4355    
4356                    StringBundler msg = new StringBundler(8);
4357    
4358                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4359    
4360                    msg.append("groupId=");
4361                    msg.append(groupId);
4362    
4363                    msg.append(", userId=");
4364                    msg.append(userId);
4365    
4366                    msg.append(", status=");
4367                    msg.append(status);
4368    
4369                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4370    
4371                    throw new NoSuchEntryException(msg.toString());
4372            }
4373    
4374            /**
4375             * Returns the last bookmarks entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
4376             *
4377             * @param groupId the group ID
4378             * @param userId the user ID
4379             * @param status the status
4380             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4381             * @return the last matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
4382             * @throws SystemException if a system exception occurred
4383             */
4384            public BookmarksEntry fetchByG_U_S_Last(long groupId, long userId,
4385                    int status, OrderByComparator orderByComparator)
4386                    throws SystemException {
4387                    int count = countByG_U_S(groupId, userId, status);
4388    
4389                    List<BookmarksEntry> list = findByG_U_S(groupId, userId, status,
4390                                    count - 1, count, orderByComparator);
4391    
4392                    if (!list.isEmpty()) {
4393                            return list.get(0);
4394                    }
4395    
4396                    return null;
4397            }
4398    
4399            /**
4400             * Returns the bookmarks entries before and after the current bookmarks entry in the ordered set where groupId = &#63; and userId = &#63; and status = &#63;.
4401             *
4402             * @param entryId the primary key of the current bookmarks entry
4403             * @param groupId the group ID
4404             * @param userId the user ID
4405             * @param status the status
4406             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4407             * @return the previous, current, and next bookmarks entry
4408             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
4409             * @throws SystemException if a system exception occurred
4410             */
4411            public BookmarksEntry[] findByG_U_S_PrevAndNext(long entryId, long groupId,
4412                    long userId, int status, OrderByComparator orderByComparator)
4413                    throws NoSuchEntryException, SystemException {
4414                    BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
4415    
4416                    Session session = null;
4417    
4418                    try {
4419                            session = openSession();
4420    
4421                            BookmarksEntry[] array = new BookmarksEntryImpl[3];
4422    
4423                            array[0] = getByG_U_S_PrevAndNext(session, bookmarksEntry, groupId,
4424                                            userId, status, orderByComparator, true);
4425    
4426                            array[1] = bookmarksEntry;
4427    
4428                            array[2] = getByG_U_S_PrevAndNext(session, bookmarksEntry, groupId,
4429                                            userId, status, orderByComparator, false);
4430    
4431                            return array;
4432                    }
4433                    catch (Exception e) {
4434                            throw processException(e);
4435                    }
4436                    finally {
4437                            closeSession(session);
4438                    }
4439            }
4440    
4441            protected BookmarksEntry getByG_U_S_PrevAndNext(Session session,
4442                    BookmarksEntry bookmarksEntry, long groupId, long userId, int status,
4443                    OrderByComparator orderByComparator, boolean previous) {
4444                    StringBundler query = null;
4445    
4446                    if (orderByComparator != null) {
4447                            query = new StringBundler(6 +
4448                                            (orderByComparator.getOrderByFields().length * 6));
4449                    }
4450                    else {
4451                            query = new StringBundler(3);
4452                    }
4453    
4454                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
4455    
4456                    query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
4457    
4458                    query.append(_FINDER_COLUMN_G_U_S_USERID_2);
4459    
4460                    query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
4461    
4462                    if (orderByComparator != null) {
4463                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4464    
4465                            if (orderByConditionFields.length > 0) {
4466                                    query.append(WHERE_AND);
4467                            }
4468    
4469                            for (int i = 0; i < orderByConditionFields.length; i++) {
4470                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4471                                    query.append(orderByConditionFields[i]);
4472    
4473                                    if ((i + 1) < orderByConditionFields.length) {
4474                                            if (orderByComparator.isAscending() ^ previous) {
4475                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4476                                            }
4477                                            else {
4478                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4479                                            }
4480                                    }
4481                                    else {
4482                                            if (orderByComparator.isAscending() ^ previous) {
4483                                                    query.append(WHERE_GREATER_THAN);
4484                                            }
4485                                            else {
4486                                                    query.append(WHERE_LESSER_THAN);
4487                                            }
4488                                    }
4489                            }
4490    
4491                            query.append(ORDER_BY_CLAUSE);
4492    
4493                            String[] orderByFields = orderByComparator.getOrderByFields();
4494    
4495                            for (int i = 0; i < orderByFields.length; i++) {
4496                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4497                                    query.append(orderByFields[i]);
4498    
4499                                    if ((i + 1) < orderByFields.length) {
4500                                            if (orderByComparator.isAscending() ^ previous) {
4501                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4502                                            }
4503                                            else {
4504                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4505                                            }
4506                                    }
4507                                    else {
4508                                            if (orderByComparator.isAscending() ^ previous) {
4509                                                    query.append(ORDER_BY_ASC);
4510                                            }
4511                                            else {
4512                                                    query.append(ORDER_BY_DESC);
4513                                            }
4514                                    }
4515                            }
4516                    }
4517                    else {
4518                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
4519                    }
4520    
4521                    String sql = query.toString();
4522    
4523                    Query q = session.createQuery(sql);
4524    
4525                    q.setFirstResult(0);
4526                    q.setMaxResults(2);
4527    
4528                    QueryPos qPos = QueryPos.getInstance(q);
4529    
4530                    qPos.add(groupId);
4531    
4532                    qPos.add(userId);
4533    
4534                    qPos.add(status);
4535    
4536                    if (orderByComparator != null) {
4537                            Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry);
4538    
4539                            for (Object value : values) {
4540                                    qPos.add(value);
4541                            }
4542                    }
4543    
4544                    List<BookmarksEntry> list = q.list();
4545    
4546                    if (list.size() == 2) {
4547                            return list.get(1);
4548                    }
4549                    else {
4550                            return null;
4551                    }
4552            }
4553    
4554            /**
4555             * Returns all the bookmarks entries that the user has permission to view where groupId = &#63; and userId = &#63; and status = &#63;.
4556             *
4557             * @param groupId the group ID
4558             * @param userId the user ID
4559             * @param status the status
4560             * @return the matching bookmarks entries that the user has permission to view
4561             * @throws SystemException if a system exception occurred
4562             */
4563            public List<BookmarksEntry> filterFindByG_U_S(long groupId, long userId,
4564                    int status) throws SystemException {
4565                    return filterFindByG_U_S(groupId, userId, status, QueryUtil.ALL_POS,
4566                            QueryUtil.ALL_POS, null);
4567            }
4568    
4569            /**
4570             * Returns a range of all the bookmarks entries that the user has permission to view where groupId = &#63; and userId = &#63; and status = &#63;.
4571             *
4572             * <p>
4573             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link 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.
4574             * </p>
4575             *
4576             * @param groupId the group ID
4577             * @param userId the user ID
4578             * @param status the status
4579             * @param start the lower bound of the range of bookmarks entries
4580             * @param end the upper bound of the range of bookmarks entries (not inclusive)
4581             * @return the range of matching bookmarks entries that the user has permission to view
4582             * @throws SystemException if a system exception occurred
4583             */
4584            public List<BookmarksEntry> filterFindByG_U_S(long groupId, long userId,
4585                    int status, int start, int end) throws SystemException {
4586                    return filterFindByG_U_S(groupId, userId, status, start, end, null);
4587            }
4588    
4589            /**
4590             * 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;.
4591             *
4592             * <p>
4593             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link 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.
4594             * </p>
4595             *
4596             * @param groupId the group ID
4597             * @param userId the user ID
4598             * @param status the status
4599             * @param start the lower bound of the range of bookmarks entries
4600             * @param end the upper bound of the range of bookmarks entries (not inclusive)
4601             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4602             * @return the ordered range of matching bookmarks entries that the user has permission to view
4603             * @throws SystemException if a system exception occurred
4604             */
4605            public List<BookmarksEntry> filterFindByG_U_S(long groupId, long userId,
4606                    int status, int start, int end, OrderByComparator orderByComparator)
4607                    throws SystemException {
4608                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4609                            return findByG_U_S(groupId, userId, status, start, end,
4610                                    orderByComparator);
4611                    }
4612    
4613                    StringBundler query = null;
4614    
4615                    if (orderByComparator != null) {
4616                            query = new StringBundler(5 +
4617                                            (orderByComparator.getOrderByFields().length * 3));
4618                    }
4619                    else {
4620                            query = new StringBundler(5);
4621                    }
4622    
4623                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
4624    
4625                    query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
4626    
4627                    query.append(_FINDER_COLUMN_G_U_S_USERID_2);
4628    
4629                    query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
4630    
4631                    if (orderByComparator != null) {
4632                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4633                                    orderByComparator);
4634                    }
4635                    else {
4636                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
4637                    }
4638    
4639                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4640                                    BookmarksEntry.class.getName(),
4641                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
4642                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
4643    
4644                    Session session = null;
4645    
4646                    try {
4647                            session = openSession();
4648    
4649                            Query q = session.createQuery(sql);
4650    
4651                            QueryPos qPos = QueryPos.getInstance(q);
4652    
4653                            qPos.add(groupId);
4654    
4655                            qPos.add(userId);
4656    
4657                            qPos.add(status);
4658    
4659                            return (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start,
4660                                    end);
4661                    }
4662                    catch (Exception e) {
4663                            throw processException(e);
4664                    }
4665                    finally {
4666                            closeSession(session);
4667                    }
4668            }
4669    
4670            /**
4671             * 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;.
4672             *
4673             * @param entryId the primary key of the current bookmarks entry
4674             * @param groupId the group ID
4675             * @param userId the user ID
4676             * @param status the status
4677             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4678             * @return the previous, current, and next bookmarks entry
4679             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
4680             * @throws SystemException if a system exception occurred
4681             */
4682            public BookmarksEntry[] filterFindByG_U_S_PrevAndNext(long entryId,
4683                    long groupId, long userId, int status,
4684                    OrderByComparator orderByComparator)
4685                    throws NoSuchEntryException, SystemException {
4686                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4687                            return findByG_U_S_PrevAndNext(entryId, groupId, userId, status,
4688                                    orderByComparator);
4689                    }
4690    
4691                    BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
4692    
4693                    Session session = null;
4694    
4695                    try {
4696                            session = openSession();
4697    
4698                            BookmarksEntry[] array = new BookmarksEntryImpl[3];
4699    
4700                            array[0] = filterGetByG_U_S_PrevAndNext(session, bookmarksEntry,
4701                                            groupId, userId, status, orderByComparator, true);
4702    
4703                            array[1] = bookmarksEntry;
4704    
4705                            array[2] = filterGetByG_U_S_PrevAndNext(session, bookmarksEntry,
4706                                            groupId, userId, status, orderByComparator, false);
4707    
4708                            return array;
4709                    }
4710                    catch (Exception e) {
4711                            throw processException(e);
4712                    }
4713                    finally {
4714                            closeSession(session);
4715                    }
4716            }
4717    
4718            protected BookmarksEntry filterGetByG_U_S_PrevAndNext(Session session,
4719                    BookmarksEntry bookmarksEntry, long groupId, long userId, int status,
4720                    OrderByComparator orderByComparator, boolean previous) {
4721                    StringBundler query = null;
4722    
4723                    if (orderByComparator != null) {
4724                            query = new StringBundler(6 +
4725                                            (orderByComparator.getOrderByFields().length * 6));
4726                    }
4727                    else {
4728                            query = new StringBundler(3);
4729                    }
4730    
4731                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
4732    
4733                    query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
4734    
4735                    query.append(_FINDER_COLUMN_G_U_S_USERID_2);
4736    
4737                    query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
4738    
4739                    if (orderByComparator != null) {
4740                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4741    
4742                            if (orderByConditionFields.length > 0) {
4743                                    query.append(WHERE_AND);
4744                            }
4745    
4746                            for (int i = 0; i < orderByConditionFields.length; i++) {
4747                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4748                                    query.append(orderByConditionFields[i]);
4749    
4750                                    if ((i + 1) < orderByConditionFields.length) {
4751                                            if (orderByComparator.isAscending() ^ previous) {
4752                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4753                                            }
4754                                            else {
4755                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4756                                            }
4757                                    }
4758                                    else {
4759                                            if (orderByComparator.isAscending() ^ previous) {
4760                                                    query.append(WHERE_GREATER_THAN);
4761                                            }
4762                                            else {
4763                                                    query.append(WHERE_LESSER_THAN);
4764                                            }
4765                                    }
4766                            }
4767    
4768                            query.append(ORDER_BY_CLAUSE);
4769    
4770                            String[] orderByFields = orderByComparator.getOrderByFields();
4771    
4772                            for (int i = 0; i < orderByFields.length; i++) {
4773                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4774                                    query.append(orderByFields[i]);
4775    
4776                                    if ((i + 1) < orderByFields.length) {
4777                                            if (orderByComparator.isAscending() ^ previous) {
4778                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4779                                            }
4780                                            else {
4781                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4782                                            }
4783                                    }
4784                                    else {
4785                                            if (orderByComparator.isAscending() ^ previous) {
4786                                                    query.append(ORDER_BY_ASC);
4787                                            }
4788                                            else {
4789                                                    query.append(ORDER_BY_DESC);
4790                                            }
4791                                    }
4792                            }
4793                    }
4794                    else {
4795                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
4796                    }
4797    
4798                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4799                                    BookmarksEntry.class.getName(),
4800                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
4801                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
4802    
4803                    Query q = session.createQuery(sql);
4804    
4805                    q.setFirstResult(0);
4806                    q.setMaxResults(2);
4807    
4808                    QueryPos qPos = QueryPos.getInstance(q);
4809    
4810                    qPos.add(groupId);
4811    
4812                    qPos.add(userId);
4813    
4814                    qPos.add(status);
4815    
4816                    if (orderByComparator != null) {
4817                            Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry);
4818    
4819                            for (Object value : values) {
4820                                    qPos.add(value);
4821                            }
4822                    }
4823    
4824                    List<BookmarksEntry> list = q.list();
4825    
4826                    if (list.size() == 2) {
4827                            return list.get(1);
4828                    }
4829                    else {
4830                            return null;
4831                    }
4832            }
4833    
4834            /**
4835             * Removes all the bookmarks entries where groupId = &#63; and userId = &#63; and status = &#63; from the database.
4836             *
4837             * @param groupId the group ID
4838             * @param userId the user ID
4839             * @param status the status
4840             * @throws SystemException if a system exception occurred
4841             */
4842            public void removeByG_U_S(long groupId, long userId, int status)
4843                    throws SystemException {
4844                    for (BookmarksEntry bookmarksEntry : findByG_U_S(groupId, userId,
4845                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
4846                            remove(bookmarksEntry);
4847                    }
4848            }
4849    
4850            /**
4851             * Returns the number of bookmarks entries where groupId = &#63; and userId = &#63; and status = &#63;.
4852             *
4853             * @param groupId the group ID
4854             * @param userId the user ID
4855             * @param status the status
4856             * @return the number of matching bookmarks entries
4857             * @throws SystemException if a system exception occurred
4858             */
4859            public int countByG_U_S(long groupId, long userId, int status)
4860                    throws SystemException {
4861                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_U_S;
4862    
4863                    Object[] finderArgs = new Object[] { groupId, userId, status };
4864    
4865                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
4866                                    this);
4867    
4868                    if (count == null) {
4869                            StringBundler query = new StringBundler(4);
4870    
4871                            query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
4872    
4873                            query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
4874    
4875                            query.append(_FINDER_COLUMN_G_U_S_USERID_2);
4876    
4877                            query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
4878    
4879                            String sql = query.toString();
4880    
4881                            Session session = null;
4882    
4883                            try {
4884                                    session = openSession();
4885    
4886                                    Query q = session.createQuery(sql);
4887    
4888                                    QueryPos qPos = QueryPos.getInstance(q);
4889    
4890                                    qPos.add(groupId);
4891    
4892                                    qPos.add(userId);
4893    
4894                                    qPos.add(status);
4895    
4896                                    count = (Long)q.uniqueResult();
4897    
4898                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
4899                            }
4900                            catch (Exception e) {
4901                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4902    
4903                                    throw processException(e);
4904                            }
4905                            finally {
4906                                    closeSession(session);
4907                            }
4908                    }
4909    
4910                    return count.intValue();
4911            }
4912    
4913            /**
4914             * Returns the number of bookmarks entries that the user has permission to view where groupId = &#63; and userId = &#63; and status = &#63;.
4915             *
4916             * @param groupId the group ID
4917             * @param userId the user ID
4918             * @param status the status
4919             * @return the number of matching bookmarks entries that the user has permission to view
4920             * @throws SystemException if a system exception occurred
4921             */
4922            public int filterCountByG_U_S(long groupId, long userId, int status)
4923                    throws SystemException {
4924                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4925                            return countByG_U_S(groupId, userId, status);
4926                    }
4927    
4928                    StringBundler query = new StringBundler(4);
4929    
4930                    query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
4931    
4932                    query.append(_FINDER_COLUMN_G_U_S_GROUPID_2);
4933    
4934                    query.append(_FINDER_COLUMN_G_U_S_USERID_2);
4935    
4936                    query.append(_FINDER_COLUMN_G_U_S_STATUS_2);
4937    
4938                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4939                                    BookmarksEntry.class.getName(),
4940                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
4941                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
4942    
4943                    Session session = null;
4944    
4945                    try {
4946                            session = openSession();
4947    
4948                            Query q = session.createQuery(sql);
4949    
4950                            QueryPos qPos = QueryPos.getInstance(q);
4951    
4952                            qPos.add(groupId);
4953    
4954                            qPos.add(userId);
4955    
4956                            qPos.add(status);
4957    
4958                            Long count = (Long)q.uniqueResult();
4959    
4960                            return count.intValue();
4961                    }
4962                    catch (Exception e) {
4963                            throw processException(e);
4964                    }
4965                    finally {
4966                            closeSession(session);
4967                    }
4968            }
4969    
4970            private static final String _FINDER_COLUMN_G_U_S_GROUPID_2 = "bookmarksEntry.groupId = ? AND ";
4971            private static final String _FINDER_COLUMN_G_U_S_USERID_2 = "bookmarksEntry.userId = ? AND ";
4972            private static final String _FINDER_COLUMN_G_U_S_STATUS_2 = "bookmarksEntry.status = ?";
4973            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_S = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
4974                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
4975                            BookmarksEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
4976                            "findByG_F_S",
4977                            new String[] {
4978                                    Long.class.getName(), Long.class.getName(),
4979                                    Integer.class.getName(),
4980                                    
4981                            Integer.class.getName(), Integer.class.getName(),
4982                                    OrderByComparator.class.getName()
4983                            });
4984            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_S = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
4985                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
4986                            BookmarksEntryImpl.class,
4987                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_F_S",
4988                            new String[] {
4989                                    Long.class.getName(), Long.class.getName(),
4990                                    Integer.class.getName()
4991                            },
4992                            BookmarksEntryModelImpl.GROUPID_COLUMN_BITMASK |
4993                            BookmarksEntryModelImpl.FOLDERID_COLUMN_BITMASK |
4994                            BookmarksEntryModelImpl.STATUS_COLUMN_BITMASK |
4995                            BookmarksEntryModelImpl.NAME_COLUMN_BITMASK);
4996            public static final FinderPath FINDER_PATH_COUNT_BY_G_F_S = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
4997                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
4998                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_F_S",
4999                            new String[] {
5000                                    Long.class.getName(), Long.class.getName(),
5001                                    Integer.class.getName()
5002                            });
5003            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_S = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
5004                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
5005                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_F_S",
5006                            new String[] {
5007                                    Long.class.getName(), Long.class.getName(),
5008                                    Integer.class.getName()
5009                            });
5010    
5011            /**
5012             * Returns all the bookmarks entries where groupId = &#63; and folderId = &#63; and status = &#63;.
5013             *
5014             * @param groupId the group ID
5015             * @param folderId the folder ID
5016             * @param status the status
5017             * @return the matching bookmarks entries
5018             * @throws SystemException if a system exception occurred
5019             */
5020            public List<BookmarksEntry> findByG_F_S(long groupId, long folderId,
5021                    int status) throws SystemException {
5022                    return findByG_F_S(groupId, folderId, status, QueryUtil.ALL_POS,
5023                            QueryUtil.ALL_POS, null);
5024            }
5025    
5026            /**
5027             * Returns a range of all the bookmarks entries where groupId = &#63; and folderId = &#63; and status = &#63;.
5028             *
5029             * <p>
5030             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
5031             * </p>
5032             *
5033             * @param groupId the group ID
5034             * @param folderId the folder ID
5035             * @param status the status
5036             * @param start the lower bound of the range of bookmarks entries
5037             * @param end the upper bound of the range of bookmarks entries (not inclusive)
5038             * @return the range of matching bookmarks entries
5039             * @throws SystemException if a system exception occurred
5040             */
5041            public List<BookmarksEntry> findByG_F_S(long groupId, long folderId,
5042                    int status, int start, int end) throws SystemException {
5043                    return findByG_F_S(groupId, folderId, status, start, end, null);
5044            }
5045    
5046            /**
5047             * Returns an ordered range of all the bookmarks entries where groupId = &#63; and folderId = &#63; and status = &#63;.
5048             *
5049             * <p>
5050             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
5051             * </p>
5052             *
5053             * @param groupId the group ID
5054             * @param folderId the folder ID
5055             * @param status the status
5056             * @param start the lower bound of the range of bookmarks entries
5057             * @param end the upper bound of the range of bookmarks entries (not inclusive)
5058             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5059             * @return the ordered range of matching bookmarks entries
5060             * @throws SystemException if a system exception occurred
5061             */
5062            public List<BookmarksEntry> findByG_F_S(long groupId, long folderId,
5063                    int status, int start, int end, OrderByComparator orderByComparator)
5064                    throws SystemException {
5065                    boolean pagination = true;
5066                    FinderPath finderPath = null;
5067                    Object[] finderArgs = null;
5068    
5069                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5070                                    (orderByComparator == null)) {
5071                            pagination = false;
5072                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_S;
5073                            finderArgs = new Object[] { groupId, folderId, status };
5074                    }
5075                    else {
5076                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_S;
5077                            finderArgs = new Object[] {
5078                                            groupId, folderId, status,
5079                                            
5080                                            start, end, orderByComparator
5081                                    };
5082                    }
5083    
5084                    List<BookmarksEntry> list = (List<BookmarksEntry>)FinderCacheUtil.getResult(finderPath,
5085                                    finderArgs, this);
5086    
5087                    if ((list != null) && !list.isEmpty()) {
5088                            for (BookmarksEntry bookmarksEntry : list) {
5089                                    if ((groupId != bookmarksEntry.getGroupId()) ||
5090                                                    (folderId != bookmarksEntry.getFolderId()) ||
5091                                                    (status != bookmarksEntry.getStatus())) {
5092                                            list = null;
5093    
5094                                            break;
5095                                    }
5096                            }
5097                    }
5098    
5099                    if (list == null) {
5100                            StringBundler query = null;
5101    
5102                            if (orderByComparator != null) {
5103                                    query = new StringBundler(5 +
5104                                                    (orderByComparator.getOrderByFields().length * 3));
5105                            }
5106                            else {
5107                                    query = new StringBundler(5);
5108                            }
5109    
5110                            query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
5111    
5112                            query.append(_FINDER_COLUMN_G_F_S_GROUPID_2);
5113    
5114                            query.append(_FINDER_COLUMN_G_F_S_FOLDERID_2);
5115    
5116                            query.append(_FINDER_COLUMN_G_F_S_STATUS_2);
5117    
5118                            if (orderByComparator != null) {
5119                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5120                                            orderByComparator);
5121                            }
5122                            else
5123                             if (pagination) {
5124                                    query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
5125                            }
5126    
5127                            String sql = query.toString();
5128    
5129                            Session session = null;
5130    
5131                            try {
5132                                    session = openSession();
5133    
5134                                    Query q = session.createQuery(sql);
5135    
5136                                    QueryPos qPos = QueryPos.getInstance(q);
5137    
5138                                    qPos.add(groupId);
5139    
5140                                    qPos.add(folderId);
5141    
5142                                    qPos.add(status);
5143    
5144                                    if (!pagination) {
5145                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
5146                                                            getDialect(), start, end, false);
5147    
5148                                            Collections.sort(list);
5149    
5150                                            list = new UnmodifiableList<BookmarksEntry>(list);
5151                                    }
5152                                    else {
5153                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
5154                                                            getDialect(), start, end);
5155                                    }
5156    
5157                                    cacheResult(list);
5158    
5159                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
5160                            }
5161                            catch (Exception e) {
5162                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5163    
5164                                    throw processException(e);
5165                            }
5166                            finally {
5167                                    closeSession(session);
5168                            }
5169                    }
5170    
5171                    return list;
5172            }
5173    
5174            /**
5175             * Returns the first bookmarks entry in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
5176             *
5177             * @param groupId the group ID
5178             * @param folderId the folder ID
5179             * @param status the status
5180             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5181             * @return the first matching bookmarks entry
5182             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
5183             * @throws SystemException if a system exception occurred
5184             */
5185            public BookmarksEntry findByG_F_S_First(long groupId, long folderId,
5186                    int status, OrderByComparator orderByComparator)
5187                    throws NoSuchEntryException, SystemException {
5188                    BookmarksEntry bookmarksEntry = fetchByG_F_S_First(groupId, folderId,
5189                                    status, orderByComparator);
5190    
5191                    if (bookmarksEntry != null) {
5192                            return bookmarksEntry;
5193                    }
5194    
5195                    StringBundler msg = new StringBundler(8);
5196    
5197                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5198    
5199                    msg.append("groupId=");
5200                    msg.append(groupId);
5201    
5202                    msg.append(", folderId=");
5203                    msg.append(folderId);
5204    
5205                    msg.append(", status=");
5206                    msg.append(status);
5207    
5208                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5209    
5210                    throw new NoSuchEntryException(msg.toString());
5211            }
5212    
5213            /**
5214             * Returns the first bookmarks entry in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
5215             *
5216             * @param groupId the group ID
5217             * @param folderId the folder ID
5218             * @param status the status
5219             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5220             * @return the first matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
5221             * @throws SystemException if a system exception occurred
5222             */
5223            public BookmarksEntry fetchByG_F_S_First(long groupId, long folderId,
5224                    int status, OrderByComparator orderByComparator)
5225                    throws SystemException {
5226                    List<BookmarksEntry> list = findByG_F_S(groupId, folderId, status, 0,
5227                                    1, orderByComparator);
5228    
5229                    if (!list.isEmpty()) {
5230                            return list.get(0);
5231                    }
5232    
5233                    return null;
5234            }
5235    
5236            /**
5237             * Returns the last bookmarks entry in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
5238             *
5239             * @param groupId the group ID
5240             * @param folderId the folder ID
5241             * @param status the status
5242             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5243             * @return the last matching bookmarks entry
5244             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
5245             * @throws SystemException if a system exception occurred
5246             */
5247            public BookmarksEntry findByG_F_S_Last(long groupId, long folderId,
5248                    int status, OrderByComparator orderByComparator)
5249                    throws NoSuchEntryException, SystemException {
5250                    BookmarksEntry bookmarksEntry = fetchByG_F_S_Last(groupId, folderId,
5251                                    status, orderByComparator);
5252    
5253                    if (bookmarksEntry != null) {
5254                            return bookmarksEntry;
5255                    }
5256    
5257                    StringBundler msg = new StringBundler(8);
5258    
5259                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5260    
5261                    msg.append("groupId=");
5262                    msg.append(groupId);
5263    
5264                    msg.append(", folderId=");
5265                    msg.append(folderId);
5266    
5267                    msg.append(", status=");
5268                    msg.append(status);
5269    
5270                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5271    
5272                    throw new NoSuchEntryException(msg.toString());
5273            }
5274    
5275            /**
5276             * Returns the last bookmarks entry in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
5277             *
5278             * @param groupId the group ID
5279             * @param folderId the folder ID
5280             * @param status the status
5281             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5282             * @return the last matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
5283             * @throws SystemException if a system exception occurred
5284             */
5285            public BookmarksEntry fetchByG_F_S_Last(long groupId, long folderId,
5286                    int status, OrderByComparator orderByComparator)
5287                    throws SystemException {
5288                    int count = countByG_F_S(groupId, folderId, status);
5289    
5290                    List<BookmarksEntry> list = findByG_F_S(groupId, folderId, status,
5291                                    count - 1, count, orderByComparator);
5292    
5293                    if (!list.isEmpty()) {
5294                            return list.get(0);
5295                    }
5296    
5297                    return null;
5298            }
5299    
5300            /**
5301             * Returns the bookmarks entries before and after the current bookmarks entry in the ordered set where groupId = &#63; and folderId = &#63; and status = &#63;.
5302             *
5303             * @param entryId the primary key of the current bookmarks entry
5304             * @param groupId the group ID
5305             * @param folderId the folder ID
5306             * @param status the status
5307             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5308             * @return the previous, current, and next bookmarks entry
5309             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
5310             * @throws SystemException if a system exception occurred
5311             */
5312            public BookmarksEntry[] findByG_F_S_PrevAndNext(long entryId, long groupId,
5313                    long folderId, int status, OrderByComparator orderByComparator)
5314                    throws NoSuchEntryException, SystemException {
5315                    BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
5316    
5317                    Session session = null;
5318    
5319                    try {
5320                            session = openSession();
5321    
5322                            BookmarksEntry[] array = new BookmarksEntryImpl[3];
5323    
5324                            array[0] = getByG_F_S_PrevAndNext(session, bookmarksEntry, groupId,
5325                                            folderId, status, orderByComparator, true);
5326    
5327                            array[1] = bookmarksEntry;
5328    
5329                            array[2] = getByG_F_S_PrevAndNext(session, bookmarksEntry, groupId,
5330                                            folderId, status, orderByComparator, false);
5331    
5332                            return array;
5333                    }
5334                    catch (Exception e) {
5335                            throw processException(e);
5336                    }
5337                    finally {
5338                            closeSession(session);
5339                    }
5340            }
5341    
5342            protected BookmarksEntry getByG_F_S_PrevAndNext(Session session,
5343                    BookmarksEntry bookmarksEntry, long groupId, long folderId, int status,
5344                    OrderByComparator orderByComparator, boolean previous) {
5345                    StringBundler query = null;
5346    
5347                    if (orderByComparator != null) {
5348                            query = new StringBundler(6 +
5349                                            (orderByComparator.getOrderByFields().length * 6));
5350                    }
5351                    else {
5352                            query = new StringBundler(3);
5353                    }
5354    
5355                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
5356    
5357                    query.append(_FINDER_COLUMN_G_F_S_GROUPID_2);
5358    
5359                    query.append(_FINDER_COLUMN_G_F_S_FOLDERID_2);
5360    
5361                    query.append(_FINDER_COLUMN_G_F_S_STATUS_2);
5362    
5363                    if (orderByComparator != null) {
5364                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5365    
5366                            if (orderByConditionFields.length > 0) {
5367                                    query.append(WHERE_AND);
5368                            }
5369    
5370                            for (int i = 0; i < orderByConditionFields.length; i++) {
5371                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5372                                    query.append(orderByConditionFields[i]);
5373    
5374                                    if ((i + 1) < orderByConditionFields.length) {
5375                                            if (orderByComparator.isAscending() ^ previous) {
5376                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5377                                            }
5378                                            else {
5379                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5380                                            }
5381                                    }
5382                                    else {
5383                                            if (orderByComparator.isAscending() ^ previous) {
5384                                                    query.append(WHERE_GREATER_THAN);
5385                                            }
5386                                            else {
5387                                                    query.append(WHERE_LESSER_THAN);
5388                                            }
5389                                    }
5390                            }
5391    
5392                            query.append(ORDER_BY_CLAUSE);
5393    
5394                            String[] orderByFields = orderByComparator.getOrderByFields();
5395    
5396                            for (int i = 0; i < orderByFields.length; i++) {
5397                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5398                                    query.append(orderByFields[i]);
5399    
5400                                    if ((i + 1) < orderByFields.length) {
5401                                            if (orderByComparator.isAscending() ^ previous) {
5402                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5403                                            }
5404                                            else {
5405                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5406                                            }
5407                                    }
5408                                    else {
5409                                            if (orderByComparator.isAscending() ^ previous) {
5410                                                    query.append(ORDER_BY_ASC);
5411                                            }
5412                                            else {
5413                                                    query.append(ORDER_BY_DESC);
5414                                            }
5415                                    }
5416                            }
5417                    }
5418                    else {
5419                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
5420                    }
5421    
5422                    String sql = query.toString();
5423    
5424                    Query q = session.createQuery(sql);
5425    
5426                    q.setFirstResult(0);
5427                    q.setMaxResults(2);
5428    
5429                    QueryPos qPos = QueryPos.getInstance(q);
5430    
5431                    qPos.add(groupId);
5432    
5433                    qPos.add(folderId);
5434    
5435                    qPos.add(status);
5436    
5437                    if (orderByComparator != null) {
5438                            Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry);
5439    
5440                            for (Object value : values) {
5441                                    qPos.add(value);
5442                            }
5443                    }
5444    
5445                    List<BookmarksEntry> list = q.list();
5446    
5447                    if (list.size() == 2) {
5448                            return list.get(1);
5449                    }
5450                    else {
5451                            return null;
5452                    }
5453            }
5454    
5455            /**
5456             * Returns all the bookmarks entries that the user has permission to view where groupId = &#63; and folderId = &#63; and status = &#63;.
5457             *
5458             * @param groupId the group ID
5459             * @param folderId the folder ID
5460             * @param status the status
5461             * @return the matching bookmarks entries that the user has permission to view
5462             * @throws SystemException if a system exception occurred
5463             */
5464            public List<BookmarksEntry> filterFindByG_F_S(long groupId, long folderId,
5465                    int status) throws SystemException {
5466                    return filterFindByG_F_S(groupId, folderId, status, QueryUtil.ALL_POS,
5467                            QueryUtil.ALL_POS, null);
5468            }
5469    
5470            /**
5471             * Returns a range of all the bookmarks entries that the user has permission to view where groupId = &#63; and folderId = &#63; and status = &#63;.
5472             *
5473             * <p>
5474             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
5475             * </p>
5476             *
5477             * @param groupId the group ID
5478             * @param folderId the folder ID
5479             * @param status the status
5480             * @param start the lower bound of the range of bookmarks entries
5481             * @param end the upper bound of the range of bookmarks entries (not inclusive)
5482             * @return the range of matching bookmarks entries that the user has permission to view
5483             * @throws SystemException if a system exception occurred
5484             */
5485            public List<BookmarksEntry> filterFindByG_F_S(long groupId, long folderId,
5486                    int status, int start, int end) throws SystemException {
5487                    return filterFindByG_F_S(groupId, folderId, status, start, end, null);
5488            }
5489    
5490            /**
5491             * 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;.
5492             *
5493             * <p>
5494             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
5495             * </p>
5496             *
5497             * @param groupId the group ID
5498             * @param folderId the folder ID
5499             * @param status the status
5500             * @param start the lower bound of the range of bookmarks entries
5501             * @param end the upper bound of the range of bookmarks entries (not inclusive)
5502             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5503             * @return the ordered range of matching bookmarks entries that the user has permission to view
5504             * @throws SystemException if a system exception occurred
5505             */
5506            public List<BookmarksEntry> filterFindByG_F_S(long groupId, long folderId,
5507                    int status, int start, int end, OrderByComparator orderByComparator)
5508                    throws SystemException {
5509                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5510                            return findByG_F_S(groupId, folderId, status, start, end,
5511                                    orderByComparator);
5512                    }
5513    
5514                    StringBundler query = null;
5515    
5516                    if (orderByComparator != null) {
5517                            query = new StringBundler(5 +
5518                                            (orderByComparator.getOrderByFields().length * 3));
5519                    }
5520                    else {
5521                            query = new StringBundler(5);
5522                    }
5523    
5524                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
5525    
5526                    query.append(_FINDER_COLUMN_G_F_S_GROUPID_2);
5527    
5528                    query.append(_FINDER_COLUMN_G_F_S_FOLDERID_2);
5529    
5530                    query.append(_FINDER_COLUMN_G_F_S_STATUS_2);
5531    
5532                    if (orderByComparator != null) {
5533                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5534                                    orderByComparator);
5535                    }
5536                    else {
5537                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
5538                    }
5539    
5540                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5541                                    BookmarksEntry.class.getName(),
5542                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
5543                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
5544    
5545                    Session session = null;
5546    
5547                    try {
5548                            session = openSession();
5549    
5550                            Query q = session.createQuery(sql);
5551    
5552                            QueryPos qPos = QueryPos.getInstance(q);
5553    
5554                            qPos.add(groupId);
5555    
5556                            qPos.add(folderId);
5557    
5558                            qPos.add(status);
5559    
5560                            return (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start,
5561                                    end);
5562                    }
5563                    catch (Exception e) {
5564                            throw processException(e);
5565                    }
5566                    finally {
5567                            closeSession(session);
5568                    }
5569            }
5570    
5571            /**
5572             * 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;.
5573             *
5574             * @param entryId the primary key of the current bookmarks entry
5575             * @param groupId the group ID
5576             * @param folderId the folder ID
5577             * @param status the status
5578             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5579             * @return the previous, current, and next bookmarks entry
5580             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
5581             * @throws SystemException if a system exception occurred
5582             */
5583            public BookmarksEntry[] filterFindByG_F_S_PrevAndNext(long entryId,
5584                    long groupId, long folderId, int status,
5585                    OrderByComparator orderByComparator)
5586                    throws NoSuchEntryException, SystemException {
5587                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5588                            return findByG_F_S_PrevAndNext(entryId, groupId, folderId, status,
5589                                    orderByComparator);
5590                    }
5591    
5592                    BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
5593    
5594                    Session session = null;
5595    
5596                    try {
5597                            session = openSession();
5598    
5599                            BookmarksEntry[] array = new BookmarksEntryImpl[3];
5600    
5601                            array[0] = filterGetByG_F_S_PrevAndNext(session, bookmarksEntry,
5602                                            groupId, folderId, status, orderByComparator, true);
5603    
5604                            array[1] = bookmarksEntry;
5605    
5606                            array[2] = filterGetByG_F_S_PrevAndNext(session, bookmarksEntry,
5607                                            groupId, folderId, status, orderByComparator, false);
5608    
5609                            return array;
5610                    }
5611                    catch (Exception e) {
5612                            throw processException(e);
5613                    }
5614                    finally {
5615                            closeSession(session);
5616                    }
5617            }
5618    
5619            protected BookmarksEntry filterGetByG_F_S_PrevAndNext(Session session,
5620                    BookmarksEntry bookmarksEntry, long groupId, long folderId, int status,
5621                    OrderByComparator orderByComparator, boolean previous) {
5622                    StringBundler query = null;
5623    
5624                    if (orderByComparator != null) {
5625                            query = new StringBundler(6 +
5626                                            (orderByComparator.getOrderByFields().length * 6));
5627                    }
5628                    else {
5629                            query = new StringBundler(3);
5630                    }
5631    
5632                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
5633    
5634                    query.append(_FINDER_COLUMN_G_F_S_GROUPID_2);
5635    
5636                    query.append(_FINDER_COLUMN_G_F_S_FOLDERID_2);
5637    
5638                    query.append(_FINDER_COLUMN_G_F_S_STATUS_2);
5639    
5640                    if (orderByComparator != null) {
5641                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5642    
5643                            if (orderByConditionFields.length > 0) {
5644                                    query.append(WHERE_AND);
5645                            }
5646    
5647                            for (int i = 0; i < orderByConditionFields.length; i++) {
5648                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5649                                    query.append(orderByConditionFields[i]);
5650    
5651                                    if ((i + 1) < orderByConditionFields.length) {
5652                                            if (orderByComparator.isAscending() ^ previous) {
5653                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5654                                            }
5655                                            else {
5656                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5657                                            }
5658                                    }
5659                                    else {
5660                                            if (orderByComparator.isAscending() ^ previous) {
5661                                                    query.append(WHERE_GREATER_THAN);
5662                                            }
5663                                            else {
5664                                                    query.append(WHERE_LESSER_THAN);
5665                                            }
5666                                    }
5667                            }
5668    
5669                            query.append(ORDER_BY_CLAUSE);
5670    
5671                            String[] orderByFields = orderByComparator.getOrderByFields();
5672    
5673                            for (int i = 0; i < orderByFields.length; i++) {
5674                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5675                                    query.append(orderByFields[i]);
5676    
5677                                    if ((i + 1) < orderByFields.length) {
5678                                            if (orderByComparator.isAscending() ^ previous) {
5679                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5680                                            }
5681                                            else {
5682                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5683                                            }
5684                                    }
5685                                    else {
5686                                            if (orderByComparator.isAscending() ^ previous) {
5687                                                    query.append(ORDER_BY_ASC);
5688                                            }
5689                                            else {
5690                                                    query.append(ORDER_BY_DESC);
5691                                            }
5692                                    }
5693                            }
5694                    }
5695                    else {
5696                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
5697                    }
5698    
5699                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5700                                    BookmarksEntry.class.getName(),
5701                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
5702                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
5703    
5704                    Query q = session.createQuery(sql);
5705    
5706                    q.setFirstResult(0);
5707                    q.setMaxResults(2);
5708    
5709                    QueryPos qPos = QueryPos.getInstance(q);
5710    
5711                    qPos.add(groupId);
5712    
5713                    qPos.add(folderId);
5714    
5715                    qPos.add(status);
5716    
5717                    if (orderByComparator != null) {
5718                            Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry);
5719    
5720                            for (Object value : values) {
5721                                    qPos.add(value);
5722                            }
5723                    }
5724    
5725                    List<BookmarksEntry> list = q.list();
5726    
5727                    if (list.size() == 2) {
5728                            return list.get(1);
5729                    }
5730                    else {
5731                            return null;
5732                    }
5733            }
5734    
5735            /**
5736             * Returns all the bookmarks entries that the user has permission to view where groupId = &#63; and folderId = any &#63; and status = &#63;.
5737             *
5738             * @param groupId the group ID
5739             * @param folderIds the folder IDs
5740             * @param status the status
5741             * @return the matching bookmarks entries that the user has permission to view
5742             * @throws SystemException if a system exception occurred
5743             */
5744            public List<BookmarksEntry> filterFindByG_F_S(long groupId,
5745                    long[] folderIds, int status) throws SystemException {
5746                    return filterFindByG_F_S(groupId, folderIds, status, QueryUtil.ALL_POS,
5747                            QueryUtil.ALL_POS, null);
5748            }
5749    
5750            /**
5751             * 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;.
5752             *
5753             * <p>
5754             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
5755             * </p>
5756             *
5757             * @param groupId the group ID
5758             * @param folderIds the folder IDs
5759             * @param status the status
5760             * @param start the lower bound of the range of bookmarks entries
5761             * @param end the upper bound of the range of bookmarks entries (not inclusive)
5762             * @return the range of matching bookmarks entries that the user has permission to view
5763             * @throws SystemException if a system exception occurred
5764             */
5765            public List<BookmarksEntry> filterFindByG_F_S(long groupId,
5766                    long[] folderIds, int status, int start, int end)
5767                    throws SystemException {
5768                    return filterFindByG_F_S(groupId, folderIds, status, start, end, null);
5769            }
5770    
5771            /**
5772             * 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;.
5773             *
5774             * <p>
5775             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
5776             * </p>
5777             *
5778             * @param groupId the group ID
5779             * @param folderIds the folder IDs
5780             * @param status the status
5781             * @param start the lower bound of the range of bookmarks entries
5782             * @param end the upper bound of the range of bookmarks entries (not inclusive)
5783             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5784             * @return the ordered range of matching bookmarks entries that the user has permission to view
5785             * @throws SystemException if a system exception occurred
5786             */
5787            public List<BookmarksEntry> filterFindByG_F_S(long groupId,
5788                    long[] folderIds, int status, int start, int end,
5789                    OrderByComparator orderByComparator) throws SystemException {
5790                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5791                            return findByG_F_S(groupId, folderIds, status, start, end,
5792                                    orderByComparator);
5793                    }
5794    
5795                    StringBundler query = new StringBundler();
5796    
5797                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
5798    
5799                    boolean conjunctionable = false;
5800    
5801                    if (conjunctionable) {
5802                            query.append(WHERE_AND);
5803                    }
5804    
5805                    query.append(_FINDER_COLUMN_G_F_S_GROUPID_5);
5806    
5807                    conjunctionable = true;
5808    
5809                    if ((folderIds == null) || (folderIds.length > 0)) {
5810                            if (conjunctionable) {
5811                                    query.append(WHERE_AND);
5812                            }
5813    
5814                            query.append(StringPool.OPEN_PARENTHESIS);
5815    
5816                            for (int i = 0; i < folderIds.length; i++) {
5817                                    query.append(_FINDER_COLUMN_G_F_S_FOLDERID_5);
5818    
5819                                    if ((i + 1) < folderIds.length) {
5820                                            query.append(WHERE_OR);
5821                                    }
5822                            }
5823    
5824                            query.append(StringPool.CLOSE_PARENTHESIS);
5825    
5826                            conjunctionable = true;
5827                    }
5828    
5829                    if (conjunctionable) {
5830                            query.append(WHERE_AND);
5831                    }
5832    
5833                    query.append(_FINDER_COLUMN_G_F_S_STATUS_5);
5834    
5835                    conjunctionable = true;
5836    
5837                    if (orderByComparator != null) {
5838                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5839                                    orderByComparator);
5840                    }
5841                    else {
5842                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
5843                    }
5844    
5845                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5846                                    BookmarksEntry.class.getName(),
5847                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
5848                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
5849    
5850                    Session session = null;
5851    
5852                    try {
5853                            session = openSession();
5854    
5855                            Query q = session.createQuery(sql);
5856    
5857                            QueryPos qPos = QueryPos.getInstance(q);
5858    
5859                            qPos.add(groupId);
5860    
5861                            if (folderIds != null) {
5862                                    qPos.add(folderIds);
5863                            }
5864    
5865                            qPos.add(status);
5866    
5867                            return (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start,
5868                                    end);
5869                    }
5870                    catch (Exception e) {
5871                            throw processException(e);
5872                    }
5873                    finally {
5874                            closeSession(session);
5875                    }
5876            }
5877    
5878            /**
5879             * Returns all the bookmarks entries where groupId = &#63; and folderId = any &#63; and status = &#63;.
5880             *
5881             * <p>
5882             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
5883             * </p>
5884             *
5885             * @param groupId the group ID
5886             * @param folderIds the folder IDs
5887             * @param status the status
5888             * @return the matching bookmarks entries
5889             * @throws SystemException if a system exception occurred
5890             */
5891            public List<BookmarksEntry> findByG_F_S(long groupId, long[] folderIds,
5892                    int status) throws SystemException {
5893                    return findByG_F_S(groupId, folderIds, status, QueryUtil.ALL_POS,
5894                            QueryUtil.ALL_POS, null);
5895            }
5896    
5897            /**
5898             * Returns a range of all the bookmarks entries where groupId = &#63; and folderId = any &#63; and status = &#63;.
5899             *
5900             * <p>
5901             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
5902             * </p>
5903             *
5904             * @param groupId the group ID
5905             * @param folderIds the folder IDs
5906             * @param status the status
5907             * @param start the lower bound of the range of bookmarks entries
5908             * @param end the upper bound of the range of bookmarks entries (not inclusive)
5909             * @return the range of matching bookmarks entries
5910             * @throws SystemException if a system exception occurred
5911             */
5912            public List<BookmarksEntry> findByG_F_S(long groupId, long[] folderIds,
5913                    int status, int start, int end) throws SystemException {
5914                    return findByG_F_S(groupId, folderIds, status, start, end, null);
5915            }
5916    
5917            /**
5918             * Returns an ordered range of all the bookmarks entries where groupId = &#63; and folderId = any &#63; and status = &#63;.
5919             *
5920             * <p>
5921             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
5922             * </p>
5923             *
5924             * @param groupId the group ID
5925             * @param folderIds the folder IDs
5926             * @param status the status
5927             * @param start the lower bound of the range of bookmarks entries
5928             * @param end the upper bound of the range of bookmarks entries (not inclusive)
5929             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5930             * @return the ordered range of matching bookmarks entries
5931             * @throws SystemException if a system exception occurred
5932             */
5933            public List<BookmarksEntry> findByG_F_S(long groupId, long[] folderIds,
5934                    int status, int start, int end, OrderByComparator orderByComparator)
5935                    throws SystemException {
5936                    if ((folderIds != null) && (folderIds.length == 1)) {
5937                            return findByG_F_S(groupId, folderIds[0], status, start, end,
5938                                    orderByComparator);
5939                    }
5940    
5941                    boolean pagination = true;
5942                    Object[] finderArgs = null;
5943    
5944                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5945                                    (orderByComparator == null)) {
5946                            pagination = false;
5947                            finderArgs = new Object[] {
5948                                            groupId, StringUtil.merge(folderIds), status
5949                                    };
5950                    }
5951                    else {
5952                            finderArgs = new Object[] {
5953                                            groupId, StringUtil.merge(folderIds), status,
5954                                            
5955                                            start, end, orderByComparator
5956                                    };
5957                    }
5958    
5959                    List<BookmarksEntry> list = (List<BookmarksEntry>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_S,
5960                                    finderArgs, this);
5961    
5962                    if ((list != null) && !list.isEmpty()) {
5963                            for (BookmarksEntry bookmarksEntry : list) {
5964                                    if ((groupId != bookmarksEntry.getGroupId()) ||
5965                                                    !ArrayUtil.contains(folderIds,
5966                                                            bookmarksEntry.getFolderId()) ||
5967                                                    (status != bookmarksEntry.getStatus())) {
5968                                            list = null;
5969    
5970                                            break;
5971                                    }
5972                            }
5973                    }
5974    
5975                    if (list == null) {
5976                            StringBundler query = new StringBundler();
5977    
5978                            query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
5979    
5980                            boolean conjunctionable = false;
5981    
5982                            if (conjunctionable) {
5983                                    query.append(WHERE_AND);
5984                            }
5985    
5986                            query.append(_FINDER_COLUMN_G_F_S_GROUPID_5);
5987    
5988                            conjunctionable = true;
5989    
5990                            if ((folderIds == null) || (folderIds.length > 0)) {
5991                                    if (conjunctionable) {
5992                                            query.append(WHERE_AND);
5993                                    }
5994    
5995                                    query.append(StringPool.OPEN_PARENTHESIS);
5996    
5997                                    for (int i = 0; i < folderIds.length; i++) {
5998                                            query.append(_FINDER_COLUMN_G_F_S_FOLDERID_5);
5999    
6000                                            if ((i + 1) < folderIds.length) {
6001                                                    query.append(WHERE_OR);
6002                                            }
6003                                    }
6004    
6005                                    query.append(StringPool.CLOSE_PARENTHESIS);
6006    
6007                                    conjunctionable = true;
6008                            }
6009    
6010                            if (conjunctionable) {
6011                                    query.append(WHERE_AND);
6012                            }
6013    
6014                            query.append(_FINDER_COLUMN_G_F_S_STATUS_5);
6015    
6016                            conjunctionable = true;
6017    
6018                            if (orderByComparator != null) {
6019                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6020                                            orderByComparator);
6021                            }
6022                            else
6023                             if (pagination) {
6024                                    query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
6025                            }
6026    
6027                            String sql = query.toString();
6028    
6029                            Session session = null;
6030    
6031                            try {
6032                                    session = openSession();
6033    
6034                                    Query q = session.createQuery(sql);
6035    
6036                                    QueryPos qPos = QueryPos.getInstance(q);
6037    
6038                                    qPos.add(groupId);
6039    
6040                                    if (folderIds != null) {
6041                                            qPos.add(folderIds);
6042                                    }
6043    
6044                                    qPos.add(status);
6045    
6046                                    if (!pagination) {
6047                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
6048                                                            getDialect(), start, end, false);
6049    
6050                                            Collections.sort(list);
6051    
6052                                            list = new UnmodifiableList<BookmarksEntry>(list);
6053                                    }
6054                                    else {
6055                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
6056                                                            getDialect(), start, end);
6057                                    }
6058    
6059                                    cacheResult(list);
6060    
6061                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_S,
6062                                            finderArgs, list);
6063                            }
6064                            catch (Exception e) {
6065                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F_S,
6066                                            finderArgs);
6067    
6068                                    throw processException(e);
6069                            }
6070                            finally {
6071                                    closeSession(session);
6072                            }
6073                    }
6074    
6075                    return list;
6076            }
6077    
6078            /**
6079             * Removes all the bookmarks entries where groupId = &#63; and folderId = &#63; and status = &#63; from the database.
6080             *
6081             * @param groupId the group ID
6082             * @param folderId the folder ID
6083             * @param status the status
6084             * @throws SystemException if a system exception occurred
6085             */
6086            public void removeByG_F_S(long groupId, long folderId, int status)
6087                    throws SystemException {
6088                    for (BookmarksEntry bookmarksEntry : findByG_F_S(groupId, folderId,
6089                                    status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
6090                            remove(bookmarksEntry);
6091                    }
6092            }
6093    
6094            /**
6095             * Returns the number of bookmarks entries where groupId = &#63; and folderId = &#63; and status = &#63;.
6096             *
6097             * @param groupId the group ID
6098             * @param folderId the folder ID
6099             * @param status the status
6100             * @return the number of matching bookmarks entries
6101             * @throws SystemException if a system exception occurred
6102             */
6103            public int countByG_F_S(long groupId, long folderId, int status)
6104                    throws SystemException {
6105                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_F_S;
6106    
6107                    Object[] finderArgs = new Object[] { groupId, folderId, status };
6108    
6109                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
6110                                    this);
6111    
6112                    if (count == null) {
6113                            StringBundler query = new StringBundler(4);
6114    
6115                            query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
6116    
6117                            query.append(_FINDER_COLUMN_G_F_S_GROUPID_2);
6118    
6119                            query.append(_FINDER_COLUMN_G_F_S_FOLDERID_2);
6120    
6121                            query.append(_FINDER_COLUMN_G_F_S_STATUS_2);
6122    
6123                            String sql = query.toString();
6124    
6125                            Session session = null;
6126    
6127                            try {
6128                                    session = openSession();
6129    
6130                                    Query q = session.createQuery(sql);
6131    
6132                                    QueryPos qPos = QueryPos.getInstance(q);
6133    
6134                                    qPos.add(groupId);
6135    
6136                                    qPos.add(folderId);
6137    
6138                                    qPos.add(status);
6139    
6140                                    count = (Long)q.uniqueResult();
6141    
6142                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
6143                            }
6144                            catch (Exception e) {
6145                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6146    
6147                                    throw processException(e);
6148                            }
6149                            finally {
6150                                    closeSession(session);
6151                            }
6152                    }
6153    
6154                    return count.intValue();
6155            }
6156    
6157            /**
6158             * Returns the number of bookmarks entries where groupId = &#63; and folderId = any &#63; and status = &#63;.
6159             *
6160             * @param groupId the group ID
6161             * @param folderIds the folder IDs
6162             * @param status the status
6163             * @return the number of matching bookmarks entries
6164             * @throws SystemException if a system exception occurred
6165             */
6166            public int countByG_F_S(long groupId, long[] folderIds, int status)
6167                    throws SystemException {
6168                    Object[] finderArgs = new Object[] {
6169                                    groupId, StringUtil.merge(folderIds), status
6170                            };
6171    
6172                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_S,
6173                                    finderArgs, this);
6174    
6175                    if (count == null) {
6176                            StringBundler query = new StringBundler();
6177    
6178                            query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
6179    
6180                            boolean conjunctionable = false;
6181    
6182                            if (conjunctionable) {
6183                                    query.append(WHERE_AND);
6184                            }
6185    
6186                            query.append(_FINDER_COLUMN_G_F_S_GROUPID_5);
6187    
6188                            conjunctionable = true;
6189    
6190                            if ((folderIds == null) || (folderIds.length > 0)) {
6191                                    if (conjunctionable) {
6192                                            query.append(WHERE_AND);
6193                                    }
6194    
6195                                    query.append(StringPool.OPEN_PARENTHESIS);
6196    
6197                                    for (int i = 0; i < folderIds.length; i++) {
6198                                            query.append(_FINDER_COLUMN_G_F_S_FOLDERID_5);
6199    
6200                                            if ((i + 1) < folderIds.length) {
6201                                                    query.append(WHERE_OR);
6202                                            }
6203                                    }
6204    
6205                                    query.append(StringPool.CLOSE_PARENTHESIS);
6206    
6207                                    conjunctionable = true;
6208                            }
6209    
6210                            if (conjunctionable) {
6211                                    query.append(WHERE_AND);
6212                            }
6213    
6214                            query.append(_FINDER_COLUMN_G_F_S_STATUS_5);
6215    
6216                            conjunctionable = true;
6217    
6218                            String sql = query.toString();
6219    
6220                            Session session = null;
6221    
6222                            try {
6223                                    session = openSession();
6224    
6225                                    Query q = session.createQuery(sql);
6226    
6227                                    QueryPos qPos = QueryPos.getInstance(q);
6228    
6229                                    qPos.add(groupId);
6230    
6231                                    if (folderIds != null) {
6232                                            qPos.add(folderIds);
6233                                    }
6234    
6235                                    qPos.add(status);
6236    
6237                                    count = (Long)q.uniqueResult();
6238    
6239                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_S,
6240                                            finderArgs, count);
6241                            }
6242                            catch (Exception e) {
6243                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F_S,
6244                                            finderArgs);
6245    
6246                                    throw processException(e);
6247                            }
6248                            finally {
6249                                    closeSession(session);
6250                            }
6251                    }
6252    
6253                    return count.intValue();
6254            }
6255    
6256            /**
6257             * Returns the number of bookmarks entries that the user has permission to view where groupId = &#63; and folderId = &#63; and status = &#63;.
6258             *
6259             * @param groupId the group ID
6260             * @param folderId the folder ID
6261             * @param status the status
6262             * @return the number of matching bookmarks entries that the user has permission to view
6263             * @throws SystemException if a system exception occurred
6264             */
6265            public int filterCountByG_F_S(long groupId, long folderId, int status)
6266                    throws SystemException {
6267                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6268                            return countByG_F_S(groupId, folderId, status);
6269                    }
6270    
6271                    StringBundler query = new StringBundler(4);
6272    
6273                    query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
6274    
6275                    query.append(_FINDER_COLUMN_G_F_S_GROUPID_2);
6276    
6277                    query.append(_FINDER_COLUMN_G_F_S_FOLDERID_2);
6278    
6279                    query.append(_FINDER_COLUMN_G_F_S_STATUS_2);
6280    
6281                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6282                                    BookmarksEntry.class.getName(),
6283                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
6284                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
6285    
6286                    Session session = null;
6287    
6288                    try {
6289                            session = openSession();
6290    
6291                            Query q = session.createQuery(sql);
6292    
6293                            QueryPos qPos = QueryPos.getInstance(q);
6294    
6295                            qPos.add(groupId);
6296    
6297                            qPos.add(folderId);
6298    
6299                            qPos.add(status);
6300    
6301                            Long count = (Long)q.uniqueResult();
6302    
6303                            return count.intValue();
6304                    }
6305                    catch (Exception e) {
6306                            throw processException(e);
6307                    }
6308                    finally {
6309                            closeSession(session);
6310                    }
6311            }
6312    
6313            /**
6314             * Returns the number of bookmarks entries that the user has permission to view where groupId = &#63; and folderId = any &#63; and status = &#63;.
6315             *
6316             * @param groupId the group ID
6317             * @param folderIds the folder IDs
6318             * @param status the status
6319             * @return the number of matching bookmarks entries that the user has permission to view
6320             * @throws SystemException if a system exception occurred
6321             */
6322            public int filterCountByG_F_S(long groupId, long[] folderIds, int status)
6323                    throws SystemException {
6324                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6325                            return countByG_F_S(groupId, folderIds, status);
6326                    }
6327    
6328                    StringBundler query = new StringBundler();
6329    
6330                    query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
6331    
6332                    boolean conjunctionable = false;
6333    
6334                    if (conjunctionable) {
6335                            query.append(WHERE_AND);
6336                    }
6337    
6338                    query.append(_FINDER_COLUMN_G_F_S_GROUPID_5);
6339    
6340                    conjunctionable = true;
6341    
6342                    if ((folderIds == null) || (folderIds.length > 0)) {
6343                            if (conjunctionable) {
6344                                    query.append(WHERE_AND);
6345                            }
6346    
6347                            query.append(StringPool.OPEN_PARENTHESIS);
6348    
6349                            for (int i = 0; i < folderIds.length; i++) {
6350                                    query.append(_FINDER_COLUMN_G_F_S_FOLDERID_5);
6351    
6352                                    if ((i + 1) < folderIds.length) {
6353                                            query.append(WHERE_OR);
6354                                    }
6355                            }
6356    
6357                            query.append(StringPool.CLOSE_PARENTHESIS);
6358    
6359                            conjunctionable = true;
6360                    }
6361    
6362                    if (conjunctionable) {
6363                            query.append(WHERE_AND);
6364                    }
6365    
6366                    query.append(_FINDER_COLUMN_G_F_S_STATUS_5);
6367    
6368                    conjunctionable = true;
6369    
6370                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6371                                    BookmarksEntry.class.getName(),
6372                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
6373                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
6374    
6375                    Session session = null;
6376    
6377                    try {
6378                            session = openSession();
6379    
6380                            Query q = session.createQuery(sql);
6381    
6382                            QueryPos qPos = QueryPos.getInstance(q);
6383    
6384                            qPos.add(groupId);
6385    
6386                            if (folderIds != null) {
6387                                    qPos.add(folderIds);
6388                            }
6389    
6390                            qPos.add(status);
6391    
6392                            Long count = (Long)q.uniqueResult();
6393    
6394                            return count.intValue();
6395                    }
6396                    catch (Exception e) {
6397                            throw processException(e);
6398                    }
6399                    finally {
6400                            closeSession(session);
6401                    }
6402            }
6403    
6404            private static final String _FINDER_COLUMN_G_F_S_GROUPID_2 = "bookmarksEntry.groupId = ? AND ";
6405            private static final String _FINDER_COLUMN_G_F_S_GROUPID_5 = "(" +
6406                    removeConjunction(_FINDER_COLUMN_G_F_S_GROUPID_2) + ")";
6407            private static final String _FINDER_COLUMN_G_F_S_FOLDERID_2 = "bookmarksEntry.folderId = ? AND ";
6408            private static final String _FINDER_COLUMN_G_F_S_FOLDERID_5 = "(" +
6409                    removeConjunction(_FINDER_COLUMN_G_F_S_FOLDERID_2) + ")";
6410            private static final String _FINDER_COLUMN_G_F_S_STATUS_2 = "bookmarksEntry.status = ?";
6411            private static final String _FINDER_COLUMN_G_F_S_STATUS_5 = "(" +
6412                    removeConjunction(_FINDER_COLUMN_G_F_S_STATUS_2) + ")";
6413            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_F_S = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
6414                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
6415                            BookmarksEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
6416                            "findByG_U_F_S",
6417                            new String[] {
6418                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
6419                                    Integer.class.getName(),
6420                                    
6421                            Integer.class.getName(), Integer.class.getName(),
6422                                    OrderByComparator.class.getName()
6423                            });
6424            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_F_S =
6425                    new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
6426                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
6427                            BookmarksEntryImpl.class,
6428                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U_F_S",
6429                            new String[] {
6430                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
6431                                    Integer.class.getName()
6432                            },
6433                            BookmarksEntryModelImpl.GROUPID_COLUMN_BITMASK |
6434                            BookmarksEntryModelImpl.USERID_COLUMN_BITMASK |
6435                            BookmarksEntryModelImpl.FOLDERID_COLUMN_BITMASK |
6436                            BookmarksEntryModelImpl.STATUS_COLUMN_BITMASK |
6437                            BookmarksEntryModelImpl.NAME_COLUMN_BITMASK);
6438            public static final FinderPath FINDER_PATH_COUNT_BY_G_U_F_S = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
6439                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
6440                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U_F_S",
6441                            new String[] {
6442                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
6443                                    Integer.class.getName()
6444                            });
6445            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_F_S = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
6446                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
6447                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_U_F_S",
6448                            new String[] {
6449                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
6450                                    Integer.class.getName()
6451                            });
6452    
6453            /**
6454             * Returns all the bookmarks entries where groupId = &#63; and userId = &#63; and folderId = &#63; and status = &#63;.
6455             *
6456             * @param groupId the group ID
6457             * @param userId the user ID
6458             * @param folderId the folder ID
6459             * @param status the status
6460             * @return the matching bookmarks entries
6461             * @throws SystemException if a system exception occurred
6462             */
6463            public List<BookmarksEntry> findByG_U_F_S(long groupId, long userId,
6464                    long folderId, int status) throws SystemException {
6465                    return findByG_U_F_S(groupId, userId, folderId, status,
6466                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
6467            }
6468    
6469            /**
6470             * Returns a range of all the bookmarks entries where groupId = &#63; and userId = &#63; and folderId = &#63; and status = &#63;.
6471             *
6472             * <p>
6473             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
6474             * </p>
6475             *
6476             * @param groupId the group ID
6477             * @param userId the user ID
6478             * @param folderId the folder ID
6479             * @param status the status
6480             * @param start the lower bound of the range of bookmarks entries
6481             * @param end the upper bound of the range of bookmarks entries (not inclusive)
6482             * @return the range of matching bookmarks entries
6483             * @throws SystemException if a system exception occurred
6484             */
6485            public List<BookmarksEntry> findByG_U_F_S(long groupId, long userId,
6486                    long folderId, int status, int start, int end)
6487                    throws SystemException {
6488                    return findByG_U_F_S(groupId, userId, folderId, status, start, end, null);
6489            }
6490    
6491            /**
6492             * Returns an ordered range of all the bookmarks entries where groupId = &#63; and userId = &#63; and folderId = &#63; and status = &#63;.
6493             *
6494             * <p>
6495             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
6496             * </p>
6497             *
6498             * @param groupId the group ID
6499             * @param userId the user ID
6500             * @param folderId the folder ID
6501             * @param status the status
6502             * @param start the lower bound of the range of bookmarks entries
6503             * @param end the upper bound of the range of bookmarks entries (not inclusive)
6504             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6505             * @return the ordered range of matching bookmarks entries
6506             * @throws SystemException if a system exception occurred
6507             */
6508            public List<BookmarksEntry> findByG_U_F_S(long groupId, long userId,
6509                    long folderId, int status, int start, int end,
6510                    OrderByComparator orderByComparator) throws SystemException {
6511                    boolean pagination = true;
6512                    FinderPath finderPath = null;
6513                    Object[] finderArgs = null;
6514    
6515                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6516                                    (orderByComparator == null)) {
6517                            pagination = false;
6518                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_F_S;
6519                            finderArgs = new Object[] { groupId, userId, folderId, status };
6520                    }
6521                    else {
6522                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_F_S;
6523                            finderArgs = new Object[] {
6524                                            groupId, userId, folderId, status,
6525                                            
6526                                            start, end, orderByComparator
6527                                    };
6528                    }
6529    
6530                    List<BookmarksEntry> list = (List<BookmarksEntry>)FinderCacheUtil.getResult(finderPath,
6531                                    finderArgs, this);
6532    
6533                    if ((list != null) && !list.isEmpty()) {
6534                            for (BookmarksEntry bookmarksEntry : list) {
6535                                    if ((groupId != bookmarksEntry.getGroupId()) ||
6536                                                    (userId != bookmarksEntry.getUserId()) ||
6537                                                    (folderId != bookmarksEntry.getFolderId()) ||
6538                                                    (status != bookmarksEntry.getStatus())) {
6539                                            list = null;
6540    
6541                                            break;
6542                                    }
6543                            }
6544                    }
6545    
6546                    if (list == null) {
6547                            StringBundler query = null;
6548    
6549                            if (orderByComparator != null) {
6550                                    query = new StringBundler(6 +
6551                                                    (orderByComparator.getOrderByFields().length * 3));
6552                            }
6553                            else {
6554                                    query = new StringBundler(6);
6555                            }
6556    
6557                            query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
6558    
6559                            query.append(_FINDER_COLUMN_G_U_F_S_GROUPID_2);
6560    
6561                            query.append(_FINDER_COLUMN_G_U_F_S_USERID_2);
6562    
6563                            query.append(_FINDER_COLUMN_G_U_F_S_FOLDERID_2);
6564    
6565                            query.append(_FINDER_COLUMN_G_U_F_S_STATUS_2);
6566    
6567                            if (orderByComparator != null) {
6568                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6569                                            orderByComparator);
6570                            }
6571                            else
6572                             if (pagination) {
6573                                    query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
6574                            }
6575    
6576                            String sql = query.toString();
6577    
6578                            Session session = null;
6579    
6580                            try {
6581                                    session = openSession();
6582    
6583                                    Query q = session.createQuery(sql);
6584    
6585                                    QueryPos qPos = QueryPos.getInstance(q);
6586    
6587                                    qPos.add(groupId);
6588    
6589                                    qPos.add(userId);
6590    
6591                                    qPos.add(folderId);
6592    
6593                                    qPos.add(status);
6594    
6595                                    if (!pagination) {
6596                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
6597                                                            getDialect(), start, end, false);
6598    
6599                                            Collections.sort(list);
6600    
6601                                            list = new UnmodifiableList<BookmarksEntry>(list);
6602                                    }
6603                                    else {
6604                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
6605                                                            getDialect(), start, end);
6606                                    }
6607    
6608                                    cacheResult(list);
6609    
6610                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
6611                            }
6612                            catch (Exception e) {
6613                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6614    
6615                                    throw processException(e);
6616                            }
6617                            finally {
6618                                    closeSession(session);
6619                            }
6620                    }
6621    
6622                    return list;
6623            }
6624    
6625            /**
6626             * Returns the first bookmarks entry in the ordered set where groupId = &#63; and userId = &#63; and folderId = &#63; and status = &#63;.
6627             *
6628             * @param groupId the group ID
6629             * @param userId the user ID
6630             * @param folderId the folder ID
6631             * @param status the status
6632             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6633             * @return the first matching bookmarks entry
6634             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
6635             * @throws SystemException if a system exception occurred
6636             */
6637            public BookmarksEntry findByG_U_F_S_First(long groupId, long userId,
6638                    long folderId, int status, OrderByComparator orderByComparator)
6639                    throws NoSuchEntryException, SystemException {
6640                    BookmarksEntry bookmarksEntry = fetchByG_U_F_S_First(groupId, userId,
6641                                    folderId, status, orderByComparator);
6642    
6643                    if (bookmarksEntry != null) {
6644                            return bookmarksEntry;
6645                    }
6646    
6647                    StringBundler msg = new StringBundler(10);
6648    
6649                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6650    
6651                    msg.append("groupId=");
6652                    msg.append(groupId);
6653    
6654                    msg.append(", userId=");
6655                    msg.append(userId);
6656    
6657                    msg.append(", folderId=");
6658                    msg.append(folderId);
6659    
6660                    msg.append(", status=");
6661                    msg.append(status);
6662    
6663                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6664    
6665                    throw new NoSuchEntryException(msg.toString());
6666            }
6667    
6668            /**
6669             * Returns the first bookmarks entry in the ordered set where groupId = &#63; and userId = &#63; and folderId = &#63; and status = &#63;.
6670             *
6671             * @param groupId the group ID
6672             * @param userId the user ID
6673             * @param folderId the folder ID
6674             * @param status the status
6675             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6676             * @return the first matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
6677             * @throws SystemException if a system exception occurred
6678             */
6679            public BookmarksEntry fetchByG_U_F_S_First(long groupId, long userId,
6680                    long folderId, int status, OrderByComparator orderByComparator)
6681                    throws SystemException {
6682                    List<BookmarksEntry> list = findByG_U_F_S(groupId, userId, folderId,
6683                                    status, 0, 1, orderByComparator);
6684    
6685                    if (!list.isEmpty()) {
6686                            return list.get(0);
6687                    }
6688    
6689                    return null;
6690            }
6691    
6692            /**
6693             * Returns the last bookmarks entry in the ordered set where groupId = &#63; and userId = &#63; and folderId = &#63; and status = &#63;.
6694             *
6695             * @param groupId the group ID
6696             * @param userId the user ID
6697             * @param folderId the folder ID
6698             * @param status the status
6699             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6700             * @return the last matching bookmarks entry
6701             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
6702             * @throws SystemException if a system exception occurred
6703             */
6704            public BookmarksEntry findByG_U_F_S_Last(long groupId, long userId,
6705                    long folderId, int status, OrderByComparator orderByComparator)
6706                    throws NoSuchEntryException, SystemException {
6707                    BookmarksEntry bookmarksEntry = fetchByG_U_F_S_Last(groupId, userId,
6708                                    folderId, status, orderByComparator);
6709    
6710                    if (bookmarksEntry != null) {
6711                            return bookmarksEntry;
6712                    }
6713    
6714                    StringBundler msg = new StringBundler(10);
6715    
6716                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6717    
6718                    msg.append("groupId=");
6719                    msg.append(groupId);
6720    
6721                    msg.append(", userId=");
6722                    msg.append(userId);
6723    
6724                    msg.append(", folderId=");
6725                    msg.append(folderId);
6726    
6727                    msg.append(", status=");
6728                    msg.append(status);
6729    
6730                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6731    
6732                    throw new NoSuchEntryException(msg.toString());
6733            }
6734    
6735            /**
6736             * Returns the last bookmarks entry in the ordered set where groupId = &#63; and userId = &#63; and folderId = &#63; and status = &#63;.
6737             *
6738             * @param groupId the group ID
6739             * @param userId the user ID
6740             * @param folderId the folder ID
6741             * @param status the status
6742             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6743             * @return the last matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
6744             * @throws SystemException if a system exception occurred
6745             */
6746            public BookmarksEntry fetchByG_U_F_S_Last(long groupId, long userId,
6747                    long folderId, int status, OrderByComparator orderByComparator)
6748                    throws SystemException {
6749                    int count = countByG_U_F_S(groupId, userId, folderId, status);
6750    
6751                    List<BookmarksEntry> list = findByG_U_F_S(groupId, userId, folderId,
6752                                    status, count - 1, count, orderByComparator);
6753    
6754                    if (!list.isEmpty()) {
6755                            return list.get(0);
6756                    }
6757    
6758                    return null;
6759            }
6760    
6761            /**
6762             * 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;.
6763             *
6764             * @param entryId the primary key of the current bookmarks entry
6765             * @param groupId the group ID
6766             * @param userId the user ID
6767             * @param folderId the folder ID
6768             * @param status the status
6769             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6770             * @return the previous, current, and next bookmarks entry
6771             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
6772             * @throws SystemException if a system exception occurred
6773             */
6774            public BookmarksEntry[] findByG_U_F_S_PrevAndNext(long entryId,
6775                    long groupId, long userId, long folderId, int status,
6776                    OrderByComparator orderByComparator)
6777                    throws NoSuchEntryException, SystemException {
6778                    BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
6779    
6780                    Session session = null;
6781    
6782                    try {
6783                            session = openSession();
6784    
6785                            BookmarksEntry[] array = new BookmarksEntryImpl[3];
6786    
6787                            array[0] = getByG_U_F_S_PrevAndNext(session, bookmarksEntry,
6788                                            groupId, userId, folderId, status, orderByComparator, true);
6789    
6790                            array[1] = bookmarksEntry;
6791    
6792                            array[2] = getByG_U_F_S_PrevAndNext(session, bookmarksEntry,
6793                                            groupId, userId, folderId, status, orderByComparator, false);
6794    
6795                            return array;
6796                    }
6797                    catch (Exception e) {
6798                            throw processException(e);
6799                    }
6800                    finally {
6801                            closeSession(session);
6802                    }
6803            }
6804    
6805            protected BookmarksEntry getByG_U_F_S_PrevAndNext(Session session,
6806                    BookmarksEntry bookmarksEntry, long groupId, long userId,
6807                    long folderId, int status, OrderByComparator orderByComparator,
6808                    boolean previous) {
6809                    StringBundler query = null;
6810    
6811                    if (orderByComparator != null) {
6812                            query = new StringBundler(6 +
6813                                            (orderByComparator.getOrderByFields().length * 6));
6814                    }
6815                    else {
6816                            query = new StringBundler(3);
6817                    }
6818    
6819                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
6820    
6821                    query.append(_FINDER_COLUMN_G_U_F_S_GROUPID_2);
6822    
6823                    query.append(_FINDER_COLUMN_G_U_F_S_USERID_2);
6824    
6825                    query.append(_FINDER_COLUMN_G_U_F_S_FOLDERID_2);
6826    
6827                    query.append(_FINDER_COLUMN_G_U_F_S_STATUS_2);
6828    
6829                    if (orderByComparator != null) {
6830                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6831    
6832                            if (orderByConditionFields.length > 0) {
6833                                    query.append(WHERE_AND);
6834                            }
6835    
6836                            for (int i = 0; i < orderByConditionFields.length; i++) {
6837                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6838                                    query.append(orderByConditionFields[i]);
6839    
6840                                    if ((i + 1) < orderByConditionFields.length) {
6841                                            if (orderByComparator.isAscending() ^ previous) {
6842                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6843                                            }
6844                                            else {
6845                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6846                                            }
6847                                    }
6848                                    else {
6849                                            if (orderByComparator.isAscending() ^ previous) {
6850                                                    query.append(WHERE_GREATER_THAN);
6851                                            }
6852                                            else {
6853                                                    query.append(WHERE_LESSER_THAN);
6854                                            }
6855                                    }
6856                            }
6857    
6858                            query.append(ORDER_BY_CLAUSE);
6859    
6860                            String[] orderByFields = orderByComparator.getOrderByFields();
6861    
6862                            for (int i = 0; i < orderByFields.length; i++) {
6863                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6864                                    query.append(orderByFields[i]);
6865    
6866                                    if ((i + 1) < orderByFields.length) {
6867                                            if (orderByComparator.isAscending() ^ previous) {
6868                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6869                                            }
6870                                            else {
6871                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6872                                            }
6873                                    }
6874                                    else {
6875                                            if (orderByComparator.isAscending() ^ previous) {
6876                                                    query.append(ORDER_BY_ASC);
6877                                            }
6878                                            else {
6879                                                    query.append(ORDER_BY_DESC);
6880                                            }
6881                                    }
6882                            }
6883                    }
6884                    else {
6885                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
6886                    }
6887    
6888                    String sql = query.toString();
6889    
6890                    Query q = session.createQuery(sql);
6891    
6892                    q.setFirstResult(0);
6893                    q.setMaxResults(2);
6894    
6895                    QueryPos qPos = QueryPos.getInstance(q);
6896    
6897                    qPos.add(groupId);
6898    
6899                    qPos.add(userId);
6900    
6901                    qPos.add(folderId);
6902    
6903                    qPos.add(status);
6904    
6905                    if (orderByComparator != null) {
6906                            Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry);
6907    
6908                            for (Object value : values) {
6909                                    qPos.add(value);
6910                            }
6911                    }
6912    
6913                    List<BookmarksEntry> list = q.list();
6914    
6915                    if (list.size() == 2) {
6916                            return list.get(1);
6917                    }
6918                    else {
6919                            return null;
6920                    }
6921            }
6922    
6923            /**
6924             * Returns all the bookmarks entries that the user has permission to view where groupId = &#63; and userId = &#63; and folderId = &#63; and status = &#63;.
6925             *
6926             * @param groupId the group ID
6927             * @param userId the user ID
6928             * @param folderId the folder ID
6929             * @param status the status
6930             * @return the matching bookmarks entries that the user has permission to view
6931             * @throws SystemException if a system exception occurred
6932             */
6933            public List<BookmarksEntry> filterFindByG_U_F_S(long groupId, long userId,
6934                    long folderId, int status) throws SystemException {
6935                    return filterFindByG_U_F_S(groupId, userId, folderId, status,
6936                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
6937            }
6938    
6939            /**
6940             * 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;.
6941             *
6942             * <p>
6943             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
6944             * </p>
6945             *
6946             * @param groupId the group ID
6947             * @param userId the user ID
6948             * @param folderId the folder ID
6949             * @param status the status
6950             * @param start the lower bound of the range of bookmarks entries
6951             * @param end the upper bound of the range of bookmarks entries (not inclusive)
6952             * @return the range of matching bookmarks entries that the user has permission to view
6953             * @throws SystemException if a system exception occurred
6954             */
6955            public List<BookmarksEntry> filterFindByG_U_F_S(long groupId, long userId,
6956                    long folderId, int status, int start, int end)
6957                    throws SystemException {
6958                    return filterFindByG_U_F_S(groupId, userId, folderId, status, start,
6959                            end, null);
6960            }
6961    
6962            /**
6963             * 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;.
6964             *
6965             * <p>
6966             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
6967             * </p>
6968             *
6969             * @param groupId the group ID
6970             * @param userId the user ID
6971             * @param folderId the folder ID
6972             * @param status the status
6973             * @param start the lower bound of the range of bookmarks entries
6974             * @param end the upper bound of the range of bookmarks entries (not inclusive)
6975             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6976             * @return the ordered range of matching bookmarks entries that the user has permission to view
6977             * @throws SystemException if a system exception occurred
6978             */
6979            public List<BookmarksEntry> filterFindByG_U_F_S(long groupId, long userId,
6980                    long folderId, int status, int start, int end,
6981                    OrderByComparator orderByComparator) throws SystemException {
6982                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6983                            return findByG_U_F_S(groupId, userId, folderId, status, start, end,
6984                                    orderByComparator);
6985                    }
6986    
6987                    StringBundler query = null;
6988    
6989                    if (orderByComparator != null) {
6990                            query = new StringBundler(6 +
6991                                            (orderByComparator.getOrderByFields().length * 3));
6992                    }
6993                    else {
6994                            query = new StringBundler(6);
6995                    }
6996    
6997                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
6998    
6999                    query.append(_FINDER_COLUMN_G_U_F_S_GROUPID_2);
7000    
7001                    query.append(_FINDER_COLUMN_G_U_F_S_USERID_2);
7002    
7003                    query.append(_FINDER_COLUMN_G_U_F_S_FOLDERID_2);
7004    
7005                    query.append(_FINDER_COLUMN_G_U_F_S_STATUS_2);
7006    
7007                    if (orderByComparator != null) {
7008                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7009                                    orderByComparator);
7010                    }
7011                    else {
7012                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
7013                    }
7014    
7015                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7016                                    BookmarksEntry.class.getName(),
7017                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
7018                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
7019    
7020                    Session session = null;
7021    
7022                    try {
7023                            session = openSession();
7024    
7025                            Query q = session.createQuery(sql);
7026    
7027                            QueryPos qPos = QueryPos.getInstance(q);
7028    
7029                            qPos.add(groupId);
7030    
7031                            qPos.add(userId);
7032    
7033                            qPos.add(folderId);
7034    
7035                            qPos.add(status);
7036    
7037                            return (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start,
7038                                    end);
7039                    }
7040                    catch (Exception e) {
7041                            throw processException(e);
7042                    }
7043                    finally {
7044                            closeSession(session);
7045                    }
7046            }
7047    
7048            /**
7049             * 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;.
7050             *
7051             * @param entryId the primary key of the current bookmarks entry
7052             * @param groupId the group ID
7053             * @param userId the user ID
7054             * @param folderId the folder ID
7055             * @param status the status
7056             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7057             * @return the previous, current, and next bookmarks entry
7058             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
7059             * @throws SystemException if a system exception occurred
7060             */
7061            public BookmarksEntry[] filterFindByG_U_F_S_PrevAndNext(long entryId,
7062                    long groupId, long userId, long folderId, int status,
7063                    OrderByComparator orderByComparator)
7064                    throws NoSuchEntryException, SystemException {
7065                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7066                            return findByG_U_F_S_PrevAndNext(entryId, groupId, userId,
7067                                    folderId, status, orderByComparator);
7068                    }
7069    
7070                    BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
7071    
7072                    Session session = null;
7073    
7074                    try {
7075                            session = openSession();
7076    
7077                            BookmarksEntry[] array = new BookmarksEntryImpl[3];
7078    
7079                            array[0] = filterGetByG_U_F_S_PrevAndNext(session, bookmarksEntry,
7080                                            groupId, userId, folderId, status, orderByComparator, true);
7081    
7082                            array[1] = bookmarksEntry;
7083    
7084                            array[2] = filterGetByG_U_F_S_PrevAndNext(session, bookmarksEntry,
7085                                            groupId, userId, folderId, status, orderByComparator, false);
7086    
7087                            return array;
7088                    }
7089                    catch (Exception e) {
7090                            throw processException(e);
7091                    }
7092                    finally {
7093                            closeSession(session);
7094                    }
7095            }
7096    
7097            protected BookmarksEntry filterGetByG_U_F_S_PrevAndNext(Session session,
7098                    BookmarksEntry bookmarksEntry, long groupId, long userId,
7099                    long folderId, int status, OrderByComparator orderByComparator,
7100                    boolean previous) {
7101                    StringBundler query = null;
7102    
7103                    if (orderByComparator != null) {
7104                            query = new StringBundler(6 +
7105                                            (orderByComparator.getOrderByFields().length * 6));
7106                    }
7107                    else {
7108                            query = new StringBundler(3);
7109                    }
7110    
7111                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
7112    
7113                    query.append(_FINDER_COLUMN_G_U_F_S_GROUPID_2);
7114    
7115                    query.append(_FINDER_COLUMN_G_U_F_S_USERID_2);
7116    
7117                    query.append(_FINDER_COLUMN_G_U_F_S_FOLDERID_2);
7118    
7119                    query.append(_FINDER_COLUMN_G_U_F_S_STATUS_2);
7120    
7121                    if (orderByComparator != null) {
7122                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7123    
7124                            if (orderByConditionFields.length > 0) {
7125                                    query.append(WHERE_AND);
7126                            }
7127    
7128                            for (int i = 0; i < orderByConditionFields.length; i++) {
7129                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7130                                    query.append(orderByConditionFields[i]);
7131    
7132                                    if ((i + 1) < orderByConditionFields.length) {
7133                                            if (orderByComparator.isAscending() ^ previous) {
7134                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7135                                            }
7136                                            else {
7137                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7138                                            }
7139                                    }
7140                                    else {
7141                                            if (orderByComparator.isAscending() ^ previous) {
7142                                                    query.append(WHERE_GREATER_THAN);
7143                                            }
7144                                            else {
7145                                                    query.append(WHERE_LESSER_THAN);
7146                                            }
7147                                    }
7148                            }
7149    
7150                            query.append(ORDER_BY_CLAUSE);
7151    
7152                            String[] orderByFields = orderByComparator.getOrderByFields();
7153    
7154                            for (int i = 0; i < orderByFields.length; i++) {
7155                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7156                                    query.append(orderByFields[i]);
7157    
7158                                    if ((i + 1) < orderByFields.length) {
7159                                            if (orderByComparator.isAscending() ^ previous) {
7160                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7161                                            }
7162                                            else {
7163                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7164                                            }
7165                                    }
7166                                    else {
7167                                            if (orderByComparator.isAscending() ^ previous) {
7168                                                    query.append(ORDER_BY_ASC);
7169                                            }
7170                                            else {
7171                                                    query.append(ORDER_BY_DESC);
7172                                            }
7173                                    }
7174                            }
7175                    }
7176                    else {
7177                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
7178                    }
7179    
7180                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7181                                    BookmarksEntry.class.getName(),
7182                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
7183                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
7184    
7185                    Query q = session.createQuery(sql);
7186    
7187                    q.setFirstResult(0);
7188                    q.setMaxResults(2);
7189    
7190                    QueryPos qPos = QueryPos.getInstance(q);
7191    
7192                    qPos.add(groupId);
7193    
7194                    qPos.add(userId);
7195    
7196                    qPos.add(folderId);
7197    
7198                    qPos.add(status);
7199    
7200                    if (orderByComparator != null) {
7201                            Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry);
7202    
7203                            for (Object value : values) {
7204                                    qPos.add(value);
7205                            }
7206                    }
7207    
7208                    List<BookmarksEntry> list = q.list();
7209    
7210                    if (list.size() == 2) {
7211                            return list.get(1);
7212                    }
7213                    else {
7214                            return null;
7215                    }
7216            }
7217    
7218            /**
7219             * 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;.
7220             *
7221             * @param groupId the group ID
7222             * @param userId the user ID
7223             * @param folderIds the folder IDs
7224             * @param status the status
7225             * @return the matching bookmarks entries that the user has permission to view
7226             * @throws SystemException if a system exception occurred
7227             */
7228            public List<BookmarksEntry> filterFindByG_U_F_S(long groupId, long userId,
7229                    long[] folderIds, int status) throws SystemException {
7230                    return filterFindByG_U_F_S(groupId, userId, folderIds, status,
7231                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
7232            }
7233    
7234            /**
7235             * 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;.
7236             *
7237             * <p>
7238             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
7239             * </p>
7240             *
7241             * @param groupId the group ID
7242             * @param userId the user ID
7243             * @param folderIds the folder IDs
7244             * @param status the status
7245             * @param start the lower bound of the range of bookmarks entries
7246             * @param end the upper bound of the range of bookmarks entries (not inclusive)
7247             * @return the range of matching bookmarks entries that the user has permission to view
7248             * @throws SystemException if a system exception occurred
7249             */
7250            public List<BookmarksEntry> filterFindByG_U_F_S(long groupId, long userId,
7251                    long[] folderIds, int status, int start, int end)
7252                    throws SystemException {
7253                    return filterFindByG_U_F_S(groupId, userId, folderIds, status, start,
7254                            end, null);
7255            }
7256    
7257            /**
7258             * 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;.
7259             *
7260             * <p>
7261             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
7262             * </p>
7263             *
7264             * @param groupId the group ID
7265             * @param userId the user ID
7266             * @param folderIds the folder IDs
7267             * @param status the status
7268             * @param start the lower bound of the range of bookmarks entries
7269             * @param end the upper bound of the range of bookmarks entries (not inclusive)
7270             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7271             * @return the ordered range of matching bookmarks entries that the user has permission to view
7272             * @throws SystemException if a system exception occurred
7273             */
7274            public List<BookmarksEntry> filterFindByG_U_F_S(long groupId, long userId,
7275                    long[] folderIds, int status, int start, int end,
7276                    OrderByComparator orderByComparator) throws SystemException {
7277                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7278                            return findByG_U_F_S(groupId, userId, folderIds, status, start,
7279                                    end, orderByComparator);
7280                    }
7281    
7282                    StringBundler query = new StringBundler();
7283    
7284                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
7285    
7286                    boolean conjunctionable = false;
7287    
7288                    if (conjunctionable) {
7289                            query.append(WHERE_AND);
7290                    }
7291    
7292                    query.append(_FINDER_COLUMN_G_U_F_S_GROUPID_5);
7293    
7294                    conjunctionable = true;
7295    
7296                    if (conjunctionable) {
7297                            query.append(WHERE_AND);
7298                    }
7299    
7300                    query.append(_FINDER_COLUMN_G_U_F_S_USERID_5);
7301    
7302                    conjunctionable = true;
7303    
7304                    if ((folderIds == null) || (folderIds.length > 0)) {
7305                            if (conjunctionable) {
7306                                    query.append(WHERE_AND);
7307                            }
7308    
7309                            query.append(StringPool.OPEN_PARENTHESIS);
7310    
7311                            for (int i = 0; i < folderIds.length; i++) {
7312                                    query.append(_FINDER_COLUMN_G_U_F_S_FOLDERID_5);
7313    
7314                                    if ((i + 1) < folderIds.length) {
7315                                            query.append(WHERE_OR);
7316                                    }
7317                            }
7318    
7319                            query.append(StringPool.CLOSE_PARENTHESIS);
7320    
7321                            conjunctionable = true;
7322                    }
7323    
7324                    if (conjunctionable) {
7325                            query.append(WHERE_AND);
7326                    }
7327    
7328                    query.append(_FINDER_COLUMN_G_U_F_S_STATUS_5);
7329    
7330                    conjunctionable = true;
7331    
7332                    if (orderByComparator != null) {
7333                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7334                                    orderByComparator);
7335                    }
7336                    else {
7337                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
7338                    }
7339    
7340                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7341                                    BookmarksEntry.class.getName(),
7342                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
7343                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
7344    
7345                    Session session = null;
7346    
7347                    try {
7348                            session = openSession();
7349    
7350                            Query q = session.createQuery(sql);
7351    
7352                            QueryPos qPos = QueryPos.getInstance(q);
7353    
7354                            qPos.add(groupId);
7355    
7356                            qPos.add(userId);
7357    
7358                            if (folderIds != null) {
7359                                    qPos.add(folderIds);
7360                            }
7361    
7362                            qPos.add(status);
7363    
7364                            return (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start,
7365                                    end);
7366                    }
7367                    catch (Exception e) {
7368                            throw processException(e);
7369                    }
7370                    finally {
7371                            closeSession(session);
7372                    }
7373            }
7374    
7375            /**
7376             * Returns all the bookmarks entries where groupId = &#63; and userId = &#63; and folderId = any &#63; and status = &#63;.
7377             *
7378             * <p>
7379             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
7380             * </p>
7381             *
7382             * @param groupId the group ID
7383             * @param userId the user ID
7384             * @param folderIds the folder IDs
7385             * @param status the status
7386             * @return the matching bookmarks entries
7387             * @throws SystemException if a system exception occurred
7388             */
7389            public List<BookmarksEntry> findByG_U_F_S(long groupId, long userId,
7390                    long[] folderIds, int status) throws SystemException {
7391                    return findByG_U_F_S(groupId, userId, folderIds, status,
7392                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
7393            }
7394    
7395            /**
7396             * Returns a range of all the bookmarks entries where groupId = &#63; and userId = &#63; and folderId = any &#63; and status = &#63;.
7397             *
7398             * <p>
7399             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
7400             * </p>
7401             *
7402             * @param groupId the group ID
7403             * @param userId the user ID
7404             * @param folderIds the folder IDs
7405             * @param status the status
7406             * @param start the lower bound of the range of bookmarks entries
7407             * @param end the upper bound of the range of bookmarks entries (not inclusive)
7408             * @return the range of matching bookmarks entries
7409             * @throws SystemException if a system exception occurred
7410             */
7411            public List<BookmarksEntry> findByG_U_F_S(long groupId, long userId,
7412                    long[] folderIds, int status, int start, int end)
7413                    throws SystemException {
7414                    return findByG_U_F_S(groupId, userId, folderIds, status, start, end,
7415                            null);
7416            }
7417    
7418            /**
7419             * Returns an ordered range of all the bookmarks entries where groupId = &#63; and userId = &#63; and folderId = any &#63; and status = &#63;.
7420             *
7421             * <p>
7422             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
7423             * </p>
7424             *
7425             * @param groupId the group ID
7426             * @param userId the user ID
7427             * @param folderIds the folder IDs
7428             * @param status the status
7429             * @param start the lower bound of the range of bookmarks entries
7430             * @param end the upper bound of the range of bookmarks entries (not inclusive)
7431             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7432             * @return the ordered range of matching bookmarks entries
7433             * @throws SystemException if a system exception occurred
7434             */
7435            public List<BookmarksEntry> findByG_U_F_S(long groupId, long userId,
7436                    long[] folderIds, int status, int start, int end,
7437                    OrderByComparator orderByComparator) throws SystemException {
7438                    if ((folderIds != null) && (folderIds.length == 1)) {
7439                            return findByG_U_F_S(groupId, userId, folderIds[0], status, start,
7440                                    end, orderByComparator);
7441                    }
7442    
7443                    boolean pagination = true;
7444                    Object[] finderArgs = null;
7445    
7446                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
7447                                    (orderByComparator == null)) {
7448                            pagination = false;
7449                            finderArgs = new Object[] {
7450                                            groupId, userId, StringUtil.merge(folderIds), status
7451                                    };
7452                    }
7453                    else {
7454                            finderArgs = new Object[] {
7455                                            groupId, userId, StringUtil.merge(folderIds), status,
7456                                            
7457                                            start, end, orderByComparator
7458                                    };
7459                    }
7460    
7461                    List<BookmarksEntry> list = (List<BookmarksEntry>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_F_S,
7462                                    finderArgs, this);
7463    
7464                    if ((list != null) && !list.isEmpty()) {
7465                            for (BookmarksEntry bookmarksEntry : list) {
7466                                    if ((groupId != bookmarksEntry.getGroupId()) ||
7467                                                    (userId != bookmarksEntry.getUserId()) ||
7468                                                    !ArrayUtil.contains(folderIds,
7469                                                            bookmarksEntry.getFolderId()) ||
7470                                                    (status != bookmarksEntry.getStatus())) {
7471                                            list = null;
7472    
7473                                            break;
7474                                    }
7475                            }
7476                    }
7477    
7478                    if (list == null) {
7479                            StringBundler query = new StringBundler();
7480    
7481                            query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
7482    
7483                            boolean conjunctionable = false;
7484    
7485                            if (conjunctionable) {
7486                                    query.append(WHERE_AND);
7487                            }
7488    
7489                            query.append(_FINDER_COLUMN_G_U_F_S_GROUPID_5);
7490    
7491                            conjunctionable = true;
7492    
7493                            if (conjunctionable) {
7494                                    query.append(WHERE_AND);
7495                            }
7496    
7497                            query.append(_FINDER_COLUMN_G_U_F_S_USERID_5);
7498    
7499                            conjunctionable = true;
7500    
7501                            if ((folderIds == null) || (folderIds.length > 0)) {
7502                                    if (conjunctionable) {
7503                                            query.append(WHERE_AND);
7504                                    }
7505    
7506                                    query.append(StringPool.OPEN_PARENTHESIS);
7507    
7508                                    for (int i = 0; i < folderIds.length; i++) {
7509                                            query.append(_FINDER_COLUMN_G_U_F_S_FOLDERID_5);
7510    
7511                                            if ((i + 1) < folderIds.length) {
7512                                                    query.append(WHERE_OR);
7513                                            }
7514                                    }
7515    
7516                                    query.append(StringPool.CLOSE_PARENTHESIS);
7517    
7518                                    conjunctionable = true;
7519                            }
7520    
7521                            if (conjunctionable) {
7522                                    query.append(WHERE_AND);
7523                            }
7524    
7525                            query.append(_FINDER_COLUMN_G_U_F_S_STATUS_5);
7526    
7527                            conjunctionable = true;
7528    
7529                            if (orderByComparator != null) {
7530                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7531                                            orderByComparator);
7532                            }
7533                            else
7534                             if (pagination) {
7535                                    query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
7536                            }
7537    
7538                            String sql = query.toString();
7539    
7540                            Session session = null;
7541    
7542                            try {
7543                                    session = openSession();
7544    
7545                                    Query q = session.createQuery(sql);
7546    
7547                                    QueryPos qPos = QueryPos.getInstance(q);
7548    
7549                                    qPos.add(groupId);
7550    
7551                                    qPos.add(userId);
7552    
7553                                    if (folderIds != null) {
7554                                            qPos.add(folderIds);
7555                                    }
7556    
7557                                    qPos.add(status);
7558    
7559                                    if (!pagination) {
7560                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
7561                                                            getDialect(), start, end, false);
7562    
7563                                            Collections.sort(list);
7564    
7565                                            list = new UnmodifiableList<BookmarksEntry>(list);
7566                                    }
7567                                    else {
7568                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
7569                                                            getDialect(), start, end);
7570                                    }
7571    
7572                                    cacheResult(list);
7573    
7574                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_F_S,
7575                                            finderArgs, list);
7576                            }
7577                            catch (Exception e) {
7578                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_F_S,
7579                                            finderArgs);
7580    
7581                                    throw processException(e);
7582                            }
7583                            finally {
7584                                    closeSession(session);
7585                            }
7586                    }
7587    
7588                    return list;
7589            }
7590    
7591            /**
7592             * Removes all the bookmarks entries where groupId = &#63; and userId = &#63; and folderId = &#63; and status = &#63; from the database.
7593             *
7594             * @param groupId the group ID
7595             * @param userId the user ID
7596             * @param folderId the folder ID
7597             * @param status the status
7598             * @throws SystemException if a system exception occurred
7599             */
7600            public void removeByG_U_F_S(long groupId, long userId, long folderId,
7601                    int status) throws SystemException {
7602                    for (BookmarksEntry bookmarksEntry : findByG_U_F_S(groupId, userId,
7603                                    folderId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
7604                            remove(bookmarksEntry);
7605                    }
7606            }
7607    
7608            /**
7609             * Returns the number of bookmarks entries where groupId = &#63; and userId = &#63; and folderId = &#63; and status = &#63;.
7610             *
7611             * @param groupId the group ID
7612             * @param userId the user ID
7613             * @param folderId the folder ID
7614             * @param status the status
7615             * @return the number of matching bookmarks entries
7616             * @throws SystemException if a system exception occurred
7617             */
7618            public int countByG_U_F_S(long groupId, long userId, long folderId,
7619                    int status) throws SystemException {
7620                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_U_F_S;
7621    
7622                    Object[] finderArgs = new Object[] { groupId, userId, folderId, status };
7623    
7624                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
7625                                    this);
7626    
7627                    if (count == null) {
7628                            StringBundler query = new StringBundler(5);
7629    
7630                            query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
7631    
7632                            query.append(_FINDER_COLUMN_G_U_F_S_GROUPID_2);
7633    
7634                            query.append(_FINDER_COLUMN_G_U_F_S_USERID_2);
7635    
7636                            query.append(_FINDER_COLUMN_G_U_F_S_FOLDERID_2);
7637    
7638                            query.append(_FINDER_COLUMN_G_U_F_S_STATUS_2);
7639    
7640                            String sql = query.toString();
7641    
7642                            Session session = null;
7643    
7644                            try {
7645                                    session = openSession();
7646    
7647                                    Query q = session.createQuery(sql);
7648    
7649                                    QueryPos qPos = QueryPos.getInstance(q);
7650    
7651                                    qPos.add(groupId);
7652    
7653                                    qPos.add(userId);
7654    
7655                                    qPos.add(folderId);
7656    
7657                                    qPos.add(status);
7658    
7659                                    count = (Long)q.uniqueResult();
7660    
7661                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
7662                            }
7663                            catch (Exception e) {
7664                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
7665    
7666                                    throw processException(e);
7667                            }
7668                            finally {
7669                                    closeSession(session);
7670                            }
7671                    }
7672    
7673                    return count.intValue();
7674            }
7675    
7676            /**
7677             * Returns the number of bookmarks entries where groupId = &#63; and userId = &#63; and folderId = any &#63; and status = &#63;.
7678             *
7679             * @param groupId the group ID
7680             * @param userId the user ID
7681             * @param folderIds the folder IDs
7682             * @param status the status
7683             * @return the number of matching bookmarks entries
7684             * @throws SystemException if a system exception occurred
7685             */
7686            public int countByG_U_F_S(long groupId, long userId, long[] folderIds,
7687                    int status) throws SystemException {
7688                    Object[] finderArgs = new Object[] {
7689                                    groupId, userId, StringUtil.merge(folderIds), status
7690                            };
7691    
7692                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_F_S,
7693                                    finderArgs, this);
7694    
7695                    if (count == null) {
7696                            StringBundler query = new StringBundler();
7697    
7698                            query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
7699    
7700                            boolean conjunctionable = false;
7701    
7702                            if (conjunctionable) {
7703                                    query.append(WHERE_AND);
7704                            }
7705    
7706                            query.append(_FINDER_COLUMN_G_U_F_S_GROUPID_5);
7707    
7708                            conjunctionable = true;
7709    
7710                            if (conjunctionable) {
7711                                    query.append(WHERE_AND);
7712                            }
7713    
7714                            query.append(_FINDER_COLUMN_G_U_F_S_USERID_5);
7715    
7716                            conjunctionable = true;
7717    
7718                            if ((folderIds == null) || (folderIds.length > 0)) {
7719                                    if (conjunctionable) {
7720                                            query.append(WHERE_AND);
7721                                    }
7722    
7723                                    query.append(StringPool.OPEN_PARENTHESIS);
7724    
7725                                    for (int i = 0; i < folderIds.length; i++) {
7726                                            query.append(_FINDER_COLUMN_G_U_F_S_FOLDERID_5);
7727    
7728                                            if ((i + 1) < folderIds.length) {
7729                                                    query.append(WHERE_OR);
7730                                            }
7731                                    }
7732    
7733                                    query.append(StringPool.CLOSE_PARENTHESIS);
7734    
7735                                    conjunctionable = true;
7736                            }
7737    
7738                            if (conjunctionable) {
7739                                    query.append(WHERE_AND);
7740                            }
7741    
7742                            query.append(_FINDER_COLUMN_G_U_F_S_STATUS_5);
7743    
7744                            conjunctionable = true;
7745    
7746                            String sql = query.toString();
7747    
7748                            Session session = null;
7749    
7750                            try {
7751                                    session = openSession();
7752    
7753                                    Query q = session.createQuery(sql);
7754    
7755                                    QueryPos qPos = QueryPos.getInstance(q);
7756    
7757                                    qPos.add(groupId);
7758    
7759                                    qPos.add(userId);
7760    
7761                                    if (folderIds != null) {
7762                                            qPos.add(folderIds);
7763                                    }
7764    
7765                                    qPos.add(status);
7766    
7767                                    count = (Long)q.uniqueResult();
7768    
7769                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_F_S,
7770                                            finderArgs, count);
7771                            }
7772                            catch (Exception e) {
7773                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_U_F_S,
7774                                            finderArgs);
7775    
7776                                    throw processException(e);
7777                            }
7778                            finally {
7779                                    closeSession(session);
7780                            }
7781                    }
7782    
7783                    return count.intValue();
7784            }
7785    
7786            /**
7787             * 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;.
7788             *
7789             * @param groupId the group ID
7790             * @param userId the user ID
7791             * @param folderId the folder ID
7792             * @param status the status
7793             * @return the number of matching bookmarks entries that the user has permission to view
7794             * @throws SystemException if a system exception occurred
7795             */
7796            public int filterCountByG_U_F_S(long groupId, long userId, long folderId,
7797                    int status) throws SystemException {
7798                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7799                            return countByG_U_F_S(groupId, userId, folderId, status);
7800                    }
7801    
7802                    StringBundler query = new StringBundler(5);
7803    
7804                    query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
7805    
7806                    query.append(_FINDER_COLUMN_G_U_F_S_GROUPID_2);
7807    
7808                    query.append(_FINDER_COLUMN_G_U_F_S_USERID_2);
7809    
7810                    query.append(_FINDER_COLUMN_G_U_F_S_FOLDERID_2);
7811    
7812                    query.append(_FINDER_COLUMN_G_U_F_S_STATUS_2);
7813    
7814                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7815                                    BookmarksEntry.class.getName(),
7816                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
7817                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
7818    
7819                    Session session = null;
7820    
7821                    try {
7822                            session = openSession();
7823    
7824                            Query q = session.createQuery(sql);
7825    
7826                            QueryPos qPos = QueryPos.getInstance(q);
7827    
7828                            qPos.add(groupId);
7829    
7830                            qPos.add(userId);
7831    
7832                            qPos.add(folderId);
7833    
7834                            qPos.add(status);
7835    
7836                            Long count = (Long)q.uniqueResult();
7837    
7838                            return count.intValue();
7839                    }
7840                    catch (Exception e) {
7841                            throw processException(e);
7842                    }
7843                    finally {
7844                            closeSession(session);
7845                    }
7846            }
7847    
7848            /**
7849             * 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;.
7850             *
7851             * @param groupId the group ID
7852             * @param userId the user ID
7853             * @param folderIds the folder IDs
7854             * @param status the status
7855             * @return the number of matching bookmarks entries that the user has permission to view
7856             * @throws SystemException if a system exception occurred
7857             */
7858            public int filterCountByG_U_F_S(long groupId, long userId,
7859                    long[] folderIds, int status) throws SystemException {
7860                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7861                            return countByG_U_F_S(groupId, userId, folderIds, status);
7862                    }
7863    
7864                    StringBundler query = new StringBundler();
7865    
7866                    query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
7867    
7868                    boolean conjunctionable = false;
7869    
7870                    if (conjunctionable) {
7871                            query.append(WHERE_AND);
7872                    }
7873    
7874                    query.append(_FINDER_COLUMN_G_U_F_S_GROUPID_5);
7875    
7876                    conjunctionable = true;
7877    
7878                    if (conjunctionable) {
7879                            query.append(WHERE_AND);
7880                    }
7881    
7882                    query.append(_FINDER_COLUMN_G_U_F_S_USERID_5);
7883    
7884                    conjunctionable = true;
7885    
7886                    if ((folderIds == null) || (folderIds.length > 0)) {
7887                            if (conjunctionable) {
7888                                    query.append(WHERE_AND);
7889                            }
7890    
7891                            query.append(StringPool.OPEN_PARENTHESIS);
7892    
7893                            for (int i = 0; i < folderIds.length; i++) {
7894                                    query.append(_FINDER_COLUMN_G_U_F_S_FOLDERID_5);
7895    
7896                                    if ((i + 1) < folderIds.length) {
7897                                            query.append(WHERE_OR);
7898                                    }
7899                            }
7900    
7901                            query.append(StringPool.CLOSE_PARENTHESIS);
7902    
7903                            conjunctionable = true;
7904                    }
7905    
7906                    if (conjunctionable) {
7907                            query.append(WHERE_AND);
7908                    }
7909    
7910                    query.append(_FINDER_COLUMN_G_U_F_S_STATUS_5);
7911    
7912                    conjunctionable = true;
7913    
7914                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7915                                    BookmarksEntry.class.getName(),
7916                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
7917                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
7918    
7919                    Session session = null;
7920    
7921                    try {
7922                            session = openSession();
7923    
7924                            Query q = session.createQuery(sql);
7925    
7926                            QueryPos qPos = QueryPos.getInstance(q);
7927    
7928                            qPos.add(groupId);
7929    
7930                            qPos.add(userId);
7931    
7932                            if (folderIds != null) {
7933                                    qPos.add(folderIds);
7934                            }
7935    
7936                            qPos.add(status);
7937    
7938                            Long count = (Long)q.uniqueResult();
7939    
7940                            return count.intValue();
7941                    }
7942                    catch (Exception e) {
7943                            throw processException(e);
7944                    }
7945                    finally {
7946                            closeSession(session);
7947                    }
7948            }
7949    
7950            private static final String _FINDER_COLUMN_G_U_F_S_GROUPID_2 = "bookmarksEntry.groupId = ? AND ";
7951            private static final String _FINDER_COLUMN_G_U_F_S_GROUPID_5 = "(" +
7952                    removeConjunction(_FINDER_COLUMN_G_U_F_S_GROUPID_2) + ")";
7953            private static final String _FINDER_COLUMN_G_U_F_S_USERID_2 = "bookmarksEntry.userId = ? AND ";
7954            private static final String _FINDER_COLUMN_G_U_F_S_USERID_5 = "(" +
7955                    removeConjunction(_FINDER_COLUMN_G_U_F_S_USERID_2) + ")";
7956            private static final String _FINDER_COLUMN_G_U_F_S_FOLDERID_2 = "bookmarksEntry.folderId = ? AND ";
7957            private static final String _FINDER_COLUMN_G_U_F_S_FOLDERID_5 = "(" +
7958                    removeConjunction(_FINDER_COLUMN_G_U_F_S_FOLDERID_2) + ")";
7959            private static final String _FINDER_COLUMN_G_U_F_S_STATUS_2 = "bookmarksEntry.status = ?";
7960            private static final String _FINDER_COLUMN_G_U_F_S_STATUS_5 = "(" +
7961                    removeConjunction(_FINDER_COLUMN_G_U_F_S_STATUS_2) + ")";
7962    
7963            /**
7964             * Caches the bookmarks entry in the entity cache if it is enabled.
7965             *
7966             * @param bookmarksEntry the bookmarks entry
7967             */
7968            public void cacheResult(BookmarksEntry bookmarksEntry) {
7969                    EntityCacheUtil.putResult(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
7970                            BookmarksEntryImpl.class, bookmarksEntry.getPrimaryKey(),
7971                            bookmarksEntry);
7972    
7973                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
7974                            new Object[] { bookmarksEntry.getUuid(), bookmarksEntry.getGroupId() },
7975                            bookmarksEntry);
7976    
7977                    bookmarksEntry.resetOriginalValues();
7978            }
7979    
7980            /**
7981             * Caches the bookmarks entries in the entity cache if it is enabled.
7982             *
7983             * @param bookmarksEntries the bookmarks entries
7984             */
7985            public void cacheResult(List<BookmarksEntry> bookmarksEntries) {
7986                    for (BookmarksEntry bookmarksEntry : bookmarksEntries) {
7987                            if (EntityCacheUtil.getResult(
7988                                                    BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
7989                                                    BookmarksEntryImpl.class, bookmarksEntry.getPrimaryKey()) == null) {
7990                                    cacheResult(bookmarksEntry);
7991                            }
7992                            else {
7993                                    bookmarksEntry.resetOriginalValues();
7994                            }
7995                    }
7996            }
7997    
7998            /**
7999             * Clears the cache for all bookmarks entries.
8000             *
8001             * <p>
8002             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
8003             * </p>
8004             */
8005            @Override
8006            public void clearCache() {
8007                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
8008                            CacheRegistryUtil.clear(BookmarksEntryImpl.class.getName());
8009                    }
8010    
8011                    EntityCacheUtil.clearCache(BookmarksEntryImpl.class.getName());
8012    
8013                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
8014                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
8015                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
8016            }
8017    
8018            /**
8019             * Clears the cache for the bookmarks entry.
8020             *
8021             * <p>
8022             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
8023             * </p>
8024             */
8025            @Override
8026            public void clearCache(BookmarksEntry bookmarksEntry) {
8027                    EntityCacheUtil.removeResult(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
8028                            BookmarksEntryImpl.class, bookmarksEntry.getPrimaryKey());
8029    
8030                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
8031                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
8032    
8033                    clearUniqueFindersCache(bookmarksEntry);
8034            }
8035    
8036            @Override
8037            public void clearCache(List<BookmarksEntry> bookmarksEntries) {
8038                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
8039                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
8040    
8041                    for (BookmarksEntry bookmarksEntry : bookmarksEntries) {
8042                            EntityCacheUtil.removeResult(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
8043                                    BookmarksEntryImpl.class, bookmarksEntry.getPrimaryKey());
8044    
8045                            clearUniqueFindersCache(bookmarksEntry);
8046                    }
8047            }
8048    
8049            protected void cacheUniqueFindersCache(BookmarksEntry bookmarksEntry) {
8050                    if (bookmarksEntry.isNew()) {
8051                            Object[] args = new Object[] {
8052                                            bookmarksEntry.getUuid(), bookmarksEntry.getGroupId()
8053                                    };
8054    
8055                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
8056                                    Long.valueOf(1));
8057                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
8058                                    bookmarksEntry);
8059                    }
8060                    else {
8061                            BookmarksEntryModelImpl bookmarksEntryModelImpl = (BookmarksEntryModelImpl)bookmarksEntry;
8062    
8063                            if ((bookmarksEntryModelImpl.getColumnBitmask() &
8064                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
8065                                    Object[] args = new Object[] {
8066                                                    bookmarksEntry.getUuid(), bookmarksEntry.getGroupId()
8067                                            };
8068    
8069                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
8070                                            Long.valueOf(1));
8071                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
8072                                            bookmarksEntry);
8073                            }
8074                    }
8075            }
8076    
8077            protected void clearUniqueFindersCache(BookmarksEntry bookmarksEntry) {
8078                    BookmarksEntryModelImpl bookmarksEntryModelImpl = (BookmarksEntryModelImpl)bookmarksEntry;
8079    
8080                    Object[] args = new Object[] {
8081                                    bookmarksEntry.getUuid(), bookmarksEntry.getGroupId()
8082                            };
8083    
8084                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
8085                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
8086    
8087                    if ((bookmarksEntryModelImpl.getColumnBitmask() &
8088                                    FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
8089                            args = new Object[] {
8090                                            bookmarksEntryModelImpl.getOriginalUuid(),
8091                                            bookmarksEntryModelImpl.getOriginalGroupId()
8092                                    };
8093    
8094                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
8095                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
8096                    }
8097            }
8098    
8099            /**
8100             * Creates a new bookmarks entry with the primary key. Does not add the bookmarks entry to the database.
8101             *
8102             * @param entryId the primary key for the new bookmarks entry
8103             * @return the new bookmarks entry
8104             */
8105            public BookmarksEntry create(long entryId) {
8106                    BookmarksEntry bookmarksEntry = new BookmarksEntryImpl();
8107    
8108                    bookmarksEntry.setNew(true);
8109                    bookmarksEntry.setPrimaryKey(entryId);
8110    
8111                    String uuid = PortalUUIDUtil.generate();
8112    
8113                    bookmarksEntry.setUuid(uuid);
8114    
8115                    return bookmarksEntry;
8116            }
8117    
8118            /**
8119             * Removes the bookmarks entry with the primary key from the database. Also notifies the appropriate model listeners.
8120             *
8121             * @param entryId the primary key of the bookmarks entry
8122             * @return the bookmarks entry that was removed
8123             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
8124             * @throws SystemException if a system exception occurred
8125             */
8126            public BookmarksEntry remove(long entryId)
8127                    throws NoSuchEntryException, SystemException {
8128                    return remove((Serializable)entryId);
8129            }
8130    
8131            /**
8132             * Removes the bookmarks entry with the primary key from the database. Also notifies the appropriate model listeners.
8133             *
8134             * @param primaryKey the primary key of the bookmarks entry
8135             * @return the bookmarks entry that was removed
8136             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
8137             * @throws SystemException if a system exception occurred
8138             */
8139            @Override
8140            public BookmarksEntry remove(Serializable primaryKey)
8141                    throws NoSuchEntryException, SystemException {
8142                    Session session = null;
8143    
8144                    try {
8145                            session = openSession();
8146    
8147                            BookmarksEntry bookmarksEntry = (BookmarksEntry)session.get(BookmarksEntryImpl.class,
8148                                            primaryKey);
8149    
8150                            if (bookmarksEntry == null) {
8151                                    if (_log.isWarnEnabled()) {
8152                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
8153                                    }
8154    
8155                                    throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
8156                                            primaryKey);
8157                            }
8158    
8159                            return remove(bookmarksEntry);
8160                    }
8161                    catch (NoSuchEntryException nsee) {
8162                            throw nsee;
8163                    }
8164                    catch (Exception e) {
8165                            throw processException(e);
8166                    }
8167                    finally {
8168                            closeSession(session);
8169                    }
8170            }
8171    
8172            @Override
8173            protected BookmarksEntry removeImpl(BookmarksEntry bookmarksEntry)
8174                    throws SystemException {
8175                    bookmarksEntry = toUnwrappedModel(bookmarksEntry);
8176    
8177                    Session session = null;
8178    
8179                    try {
8180                            session = openSession();
8181    
8182                            if (!session.contains(bookmarksEntry)) {
8183                                    bookmarksEntry = (BookmarksEntry)session.get(BookmarksEntryImpl.class,
8184                                                    bookmarksEntry.getPrimaryKeyObj());
8185                            }
8186    
8187                            if (bookmarksEntry != null) {
8188                                    session.delete(bookmarksEntry);
8189                            }
8190                    }
8191                    catch (Exception e) {
8192                            throw processException(e);
8193                    }
8194                    finally {
8195                            closeSession(session);
8196                    }
8197    
8198                    if (bookmarksEntry != null) {
8199                            clearCache(bookmarksEntry);
8200                    }
8201    
8202                    return bookmarksEntry;
8203            }
8204    
8205            @Override
8206            public BookmarksEntry updateImpl(
8207                    com.liferay.portlet.bookmarks.model.BookmarksEntry bookmarksEntry)
8208                    throws SystemException {
8209                    bookmarksEntry = toUnwrappedModel(bookmarksEntry);
8210    
8211                    boolean isNew = bookmarksEntry.isNew();
8212    
8213                    BookmarksEntryModelImpl bookmarksEntryModelImpl = (BookmarksEntryModelImpl)bookmarksEntry;
8214    
8215                    if (Validator.isNull(bookmarksEntry.getUuid())) {
8216                            String uuid = PortalUUIDUtil.generate();
8217    
8218                            bookmarksEntry.setUuid(uuid);
8219                    }
8220    
8221                    Session session = null;
8222    
8223                    try {
8224                            session = openSession();
8225    
8226                            if (bookmarksEntry.isNew()) {
8227                                    session.save(bookmarksEntry);
8228    
8229                                    bookmarksEntry.setNew(false);
8230                            }
8231                            else {
8232                                    session.merge(bookmarksEntry);
8233                            }
8234                    }
8235                    catch (Exception e) {
8236                            throw processException(e);
8237                    }
8238                    finally {
8239                            closeSession(session);
8240                    }
8241    
8242                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
8243    
8244                    if (isNew || !BookmarksEntryModelImpl.COLUMN_BITMASK_ENABLED) {
8245                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
8246                    }
8247    
8248                    else {
8249                            if ((bookmarksEntryModelImpl.getColumnBitmask() &
8250                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEBLOCKID.getColumnBitmask()) != 0) {
8251                                    Object[] args = new Object[] {
8252                                                    bookmarksEntryModelImpl.getOriginalResourceBlockId()
8253                                            };
8254    
8255                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RESOURCEBLOCKID,
8256                                            args);
8257                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEBLOCKID,
8258                                            args);
8259    
8260                                    args = new Object[] { bookmarksEntryModelImpl.getResourceBlockId() };
8261    
8262                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RESOURCEBLOCKID,
8263                                            args);
8264                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEBLOCKID,
8265                                            args);
8266                            }
8267    
8268                            if ((bookmarksEntryModelImpl.getColumnBitmask() &
8269                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
8270                                    Object[] args = new Object[] {
8271                                                    bookmarksEntryModelImpl.getOriginalUuid()
8272                                            };
8273    
8274                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
8275                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
8276                                            args);
8277    
8278                                    args = new Object[] { bookmarksEntryModelImpl.getUuid() };
8279    
8280                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
8281                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
8282                                            args);
8283                            }
8284    
8285                            if ((bookmarksEntryModelImpl.getColumnBitmask() &
8286                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
8287                                    Object[] args = new Object[] {
8288                                                    bookmarksEntryModelImpl.getOriginalUuid(),
8289                                                    bookmarksEntryModelImpl.getOriginalCompanyId()
8290                                            };
8291    
8292                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
8293                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
8294                                            args);
8295    
8296                                    args = new Object[] {
8297                                                    bookmarksEntryModelImpl.getUuid(),
8298                                                    bookmarksEntryModelImpl.getCompanyId()
8299                                            };
8300    
8301                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
8302                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
8303                                            args);
8304                            }
8305    
8306                            if ((bookmarksEntryModelImpl.getColumnBitmask() &
8307                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F.getColumnBitmask()) != 0) {
8308                                    Object[] args = new Object[] {
8309                                                    bookmarksEntryModelImpl.getOriginalGroupId(),
8310                                                    bookmarksEntryModelImpl.getOriginalFolderId()
8311                                            };
8312    
8313                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F, args);
8314                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F,
8315                                            args);
8316    
8317                                    args = new Object[] {
8318                                                    bookmarksEntryModelImpl.getGroupId(),
8319                                                    bookmarksEntryModelImpl.getFolderId()
8320                                            };
8321    
8322                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F, args);
8323                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F,
8324                                            args);
8325                            }
8326    
8327                            if ((bookmarksEntryModelImpl.getColumnBitmask() &
8328                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S.getColumnBitmask()) != 0) {
8329                                    Object[] args = new Object[] {
8330                                                    bookmarksEntryModelImpl.getOriginalGroupId(),
8331                                                    bookmarksEntryModelImpl.getOriginalStatus()
8332                                            };
8333    
8334                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
8335                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
8336                                            args);
8337    
8338                                    args = new Object[] {
8339                                                    bookmarksEntryModelImpl.getGroupId(),
8340                                                    bookmarksEntryModelImpl.getStatus()
8341                                            };
8342    
8343                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
8344                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
8345                                            args);
8346                            }
8347    
8348                            if ((bookmarksEntryModelImpl.getColumnBitmask() &
8349                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S.getColumnBitmask()) != 0) {
8350                                    Object[] args = new Object[] {
8351                                                    bookmarksEntryModelImpl.getOriginalGroupId(),
8352                                                    bookmarksEntryModelImpl.getOriginalUserId(),
8353                                                    bookmarksEntryModelImpl.getOriginalStatus()
8354                                            };
8355    
8356                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_S, args);
8357                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S,
8358                                            args);
8359    
8360                                    args = new Object[] {
8361                                                    bookmarksEntryModelImpl.getGroupId(),
8362                                                    bookmarksEntryModelImpl.getUserId(),
8363                                                    bookmarksEntryModelImpl.getStatus()
8364                                            };
8365    
8366                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_S, args);
8367                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_S,
8368                                            args);
8369                            }
8370    
8371                            if ((bookmarksEntryModelImpl.getColumnBitmask() &
8372                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_S.getColumnBitmask()) != 0) {
8373                                    Object[] args = new Object[] {
8374                                                    bookmarksEntryModelImpl.getOriginalGroupId(),
8375                                                    bookmarksEntryModelImpl.getOriginalFolderId(),
8376                                                    bookmarksEntryModelImpl.getOriginalStatus()
8377                                            };
8378    
8379                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F_S, args);
8380                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_S,
8381                                            args);
8382    
8383                                    args = new Object[] {
8384                                                    bookmarksEntryModelImpl.getGroupId(),
8385                                                    bookmarksEntryModelImpl.getFolderId(),
8386                                                    bookmarksEntryModelImpl.getStatus()
8387                                            };
8388    
8389                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F_S, args);
8390                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F_S,
8391                                            args);
8392                            }
8393    
8394                            if ((bookmarksEntryModelImpl.getColumnBitmask() &
8395                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_F_S.getColumnBitmask()) != 0) {
8396                                    Object[] args = new Object[] {
8397                                                    bookmarksEntryModelImpl.getOriginalGroupId(),
8398                                                    bookmarksEntryModelImpl.getOriginalUserId(),
8399                                                    bookmarksEntryModelImpl.getOriginalFolderId(),
8400                                                    bookmarksEntryModelImpl.getOriginalStatus()
8401                                            };
8402    
8403                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_F_S, args);
8404                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_F_S,
8405                                            args);
8406    
8407                                    args = new Object[] {
8408                                                    bookmarksEntryModelImpl.getGroupId(),
8409                                                    bookmarksEntryModelImpl.getUserId(),
8410                                                    bookmarksEntryModelImpl.getFolderId(),
8411                                                    bookmarksEntryModelImpl.getStatus()
8412                                            };
8413    
8414                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_F_S, args);
8415                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_F_S,
8416                                            args);
8417                            }
8418                    }
8419    
8420                    EntityCacheUtil.putResult(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
8421                            BookmarksEntryImpl.class, bookmarksEntry.getPrimaryKey(),
8422                            bookmarksEntry);
8423    
8424                    clearUniqueFindersCache(bookmarksEntry);
8425                    cacheUniqueFindersCache(bookmarksEntry);
8426    
8427                    return bookmarksEntry;
8428            }
8429    
8430            protected BookmarksEntry toUnwrappedModel(BookmarksEntry bookmarksEntry) {
8431                    if (bookmarksEntry instanceof BookmarksEntryImpl) {
8432                            return bookmarksEntry;
8433                    }
8434    
8435                    BookmarksEntryImpl bookmarksEntryImpl = new BookmarksEntryImpl();
8436    
8437                    bookmarksEntryImpl.setNew(bookmarksEntry.isNew());
8438                    bookmarksEntryImpl.setPrimaryKey(bookmarksEntry.getPrimaryKey());
8439    
8440                    bookmarksEntryImpl.setUuid(bookmarksEntry.getUuid());
8441                    bookmarksEntryImpl.setEntryId(bookmarksEntry.getEntryId());
8442                    bookmarksEntryImpl.setGroupId(bookmarksEntry.getGroupId());
8443                    bookmarksEntryImpl.setCompanyId(bookmarksEntry.getCompanyId());
8444                    bookmarksEntryImpl.setUserId(bookmarksEntry.getUserId());
8445                    bookmarksEntryImpl.setUserName(bookmarksEntry.getUserName());
8446                    bookmarksEntryImpl.setCreateDate(bookmarksEntry.getCreateDate());
8447                    bookmarksEntryImpl.setModifiedDate(bookmarksEntry.getModifiedDate());
8448                    bookmarksEntryImpl.setResourceBlockId(bookmarksEntry.getResourceBlockId());
8449                    bookmarksEntryImpl.setFolderId(bookmarksEntry.getFolderId());
8450                    bookmarksEntryImpl.setName(bookmarksEntry.getName());
8451                    bookmarksEntryImpl.setUrl(bookmarksEntry.getUrl());
8452                    bookmarksEntryImpl.setDescription(bookmarksEntry.getDescription());
8453                    bookmarksEntryImpl.setVisits(bookmarksEntry.getVisits());
8454                    bookmarksEntryImpl.setPriority(bookmarksEntry.getPriority());
8455                    bookmarksEntryImpl.setStatus(bookmarksEntry.getStatus());
8456                    bookmarksEntryImpl.setStatusByUserId(bookmarksEntry.getStatusByUserId());
8457                    bookmarksEntryImpl.setStatusByUserName(bookmarksEntry.getStatusByUserName());
8458                    bookmarksEntryImpl.setStatusDate(bookmarksEntry.getStatusDate());
8459    
8460                    return bookmarksEntryImpl;
8461            }
8462    
8463            /**
8464             * Returns the bookmarks entry with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
8465             *
8466             * @param primaryKey the primary key of the bookmarks entry
8467             * @return the bookmarks entry
8468             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
8469             * @throws SystemException if a system exception occurred
8470             */
8471            @Override
8472            public BookmarksEntry findByPrimaryKey(Serializable primaryKey)
8473                    throws NoSuchEntryException, SystemException {
8474                    BookmarksEntry bookmarksEntry = fetchByPrimaryKey(primaryKey);
8475    
8476                    if (bookmarksEntry == null) {
8477                            if (_log.isWarnEnabled()) {
8478                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
8479                            }
8480    
8481                            throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
8482                                    primaryKey);
8483                    }
8484    
8485                    return bookmarksEntry;
8486            }
8487    
8488            /**
8489             * Returns the bookmarks entry with the primary key or throws a {@link com.liferay.portlet.bookmarks.NoSuchEntryException} if it could not be found.
8490             *
8491             * @param entryId the primary key of the bookmarks entry
8492             * @return the bookmarks entry
8493             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
8494             * @throws SystemException if a system exception occurred
8495             */
8496            public BookmarksEntry findByPrimaryKey(long entryId)
8497                    throws NoSuchEntryException, SystemException {
8498                    return findByPrimaryKey((Serializable)entryId);
8499            }
8500    
8501            /**
8502             * Returns the bookmarks entry with the primary key or returns <code>null</code> if it could not be found.
8503             *
8504             * @param primaryKey the primary key of the bookmarks entry
8505             * @return the bookmarks entry, or <code>null</code> if a bookmarks entry with the primary key could not be found
8506             * @throws SystemException if a system exception occurred
8507             */
8508            @Override
8509            public BookmarksEntry fetchByPrimaryKey(Serializable primaryKey)
8510                    throws SystemException {
8511                    BookmarksEntry bookmarksEntry = (BookmarksEntry)EntityCacheUtil.getResult(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
8512                                    BookmarksEntryImpl.class, primaryKey);
8513    
8514                    if (bookmarksEntry == _nullBookmarksEntry) {
8515                            return null;
8516                    }
8517    
8518                    if (bookmarksEntry == null) {
8519                            Session session = null;
8520    
8521                            try {
8522                                    session = openSession();
8523    
8524                                    bookmarksEntry = (BookmarksEntry)session.get(BookmarksEntryImpl.class,
8525                                                    primaryKey);
8526    
8527                                    if (bookmarksEntry != null) {
8528                                            cacheResult(bookmarksEntry);
8529                                    }
8530                                    else {
8531                                            EntityCacheUtil.putResult(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
8532                                                    BookmarksEntryImpl.class, primaryKey,
8533                                                    _nullBookmarksEntry);
8534                                    }
8535                            }
8536                            catch (Exception e) {
8537                                    EntityCacheUtil.removeResult(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
8538                                            BookmarksEntryImpl.class, primaryKey);
8539    
8540                                    throw processException(e);
8541                            }
8542                            finally {
8543                                    closeSession(session);
8544                            }
8545                    }
8546    
8547                    return bookmarksEntry;
8548            }
8549    
8550            /**
8551             * Returns the bookmarks entry with the primary key or returns <code>null</code> if it could not be found.
8552             *
8553             * @param entryId the primary key of the bookmarks entry
8554             * @return the bookmarks entry, or <code>null</code> if a bookmarks entry with the primary key could not be found
8555             * @throws SystemException if a system exception occurred
8556             */
8557            public BookmarksEntry fetchByPrimaryKey(long entryId)
8558                    throws SystemException {
8559                    return fetchByPrimaryKey((Serializable)entryId);
8560            }
8561    
8562            /**
8563             * Returns all the bookmarks entries.
8564             *
8565             * @return the bookmarks entries
8566             * @throws SystemException if a system exception occurred
8567             */
8568            public List<BookmarksEntry> findAll() throws SystemException {
8569                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
8570            }
8571    
8572            /**
8573             * Returns a range of all the bookmarks entries.
8574             *
8575             * <p>
8576             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
8577             * </p>
8578             *
8579             * @param start the lower bound of the range of bookmarks entries
8580             * @param end the upper bound of the range of bookmarks entries (not inclusive)
8581             * @return the range of bookmarks entries
8582             * @throws SystemException if a system exception occurred
8583             */
8584            public List<BookmarksEntry> findAll(int start, int end)
8585                    throws SystemException {
8586                    return findAll(start, end, null);
8587            }
8588    
8589            /**
8590             * Returns an ordered range of all the bookmarks entries.
8591             *
8592             * <p>
8593             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result 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.
8594             * </p>
8595             *
8596             * @param start the lower bound of the range of bookmarks entries
8597             * @param end the upper bound of the range of bookmarks entries (not inclusive)
8598             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8599             * @return the ordered range of bookmarks entries
8600             * @throws SystemException if a system exception occurred
8601             */
8602            public List<BookmarksEntry> findAll(int start, int end,
8603                    OrderByComparator orderByComparator) throws SystemException {
8604                    boolean pagination = true;
8605                    FinderPath finderPath = null;
8606                    Object[] finderArgs = null;
8607    
8608                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
8609                                    (orderByComparator == null)) {
8610                            pagination = false;
8611                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
8612                            finderArgs = FINDER_ARGS_EMPTY;
8613                    }
8614                    else {
8615                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
8616                            finderArgs = new Object[] { start, end, orderByComparator };
8617                    }
8618    
8619                    List<BookmarksEntry> list = (List<BookmarksEntry>)FinderCacheUtil.getResult(finderPath,
8620                                    finderArgs, this);
8621    
8622                    if (list == null) {
8623                            StringBundler query = null;
8624                            String sql = null;
8625    
8626                            if (orderByComparator != null) {
8627                                    query = new StringBundler(2 +
8628                                                    (orderByComparator.getOrderByFields().length * 3));
8629    
8630                                    query.append(_SQL_SELECT_BOOKMARKSENTRY);
8631    
8632                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8633                                            orderByComparator);
8634    
8635                                    sql = query.toString();
8636                            }
8637                            else {
8638                                    sql = _SQL_SELECT_BOOKMARKSENTRY;
8639    
8640                                    if (pagination) {
8641                                            sql = sql.concat(BookmarksEntryModelImpl.ORDER_BY_JPQL);
8642                                    }
8643                            }
8644    
8645                            Session session = null;
8646    
8647                            try {
8648                                    session = openSession();
8649    
8650                                    Query q = session.createQuery(sql);
8651    
8652                                    if (!pagination) {
8653                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
8654                                                            getDialect(), start, end, false);
8655    
8656                                            Collections.sort(list);
8657    
8658                                            list = new UnmodifiableList<BookmarksEntry>(list);
8659                                    }
8660                                    else {
8661                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
8662                                                            getDialect(), start, end);
8663                                    }
8664    
8665                                    cacheResult(list);
8666    
8667                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
8668                            }
8669                            catch (Exception e) {
8670                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
8671    
8672                                    throw processException(e);
8673                            }
8674                            finally {
8675                                    closeSession(session);
8676                            }
8677                    }
8678    
8679                    return list;
8680            }
8681    
8682            /**
8683             * Removes all the bookmarks entries from the database.
8684             *
8685             * @throws SystemException if a system exception occurred
8686             */
8687            public void removeAll() throws SystemException {
8688                    for (BookmarksEntry bookmarksEntry : findAll()) {
8689                            remove(bookmarksEntry);
8690                    }
8691            }
8692    
8693            /**
8694             * Returns the number of bookmarks entries.
8695             *
8696             * @return the number of bookmarks entries
8697             * @throws SystemException if a system exception occurred
8698             */
8699            public int countAll() throws SystemException {
8700                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
8701                                    FINDER_ARGS_EMPTY, this);
8702    
8703                    if (count == null) {
8704                            Session session = null;
8705    
8706                            try {
8707                                    session = openSession();
8708    
8709                                    Query q = session.createQuery(_SQL_COUNT_BOOKMARKSENTRY);
8710    
8711                                    count = (Long)q.uniqueResult();
8712    
8713                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
8714                                            FINDER_ARGS_EMPTY, count);
8715                            }
8716                            catch (Exception e) {
8717                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
8718                                            FINDER_ARGS_EMPTY);
8719    
8720                                    throw processException(e);
8721                            }
8722                            finally {
8723                                    closeSession(session);
8724                            }
8725                    }
8726    
8727                    return count.intValue();
8728            }
8729    
8730            @Override
8731            protected Set<String> getBadColumnNames() {
8732                    return _badColumnNames;
8733            }
8734    
8735            /**
8736             * Initializes the bookmarks entry persistence.
8737             */
8738            public void afterPropertiesSet() {
8739                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
8740                                            com.liferay.portal.util.PropsUtil.get(
8741                                                    "value.object.listener.com.liferay.portlet.bookmarks.model.BookmarksEntry")));
8742    
8743                    if (listenerClassNames.length > 0) {
8744                            try {
8745                                    List<ModelListener<BookmarksEntry>> listenersList = new ArrayList<ModelListener<BookmarksEntry>>();
8746    
8747                                    for (String listenerClassName : listenerClassNames) {
8748                                            listenersList.add((ModelListener<BookmarksEntry>)InstanceFactory.newInstance(
8749                                                            getClassLoader(), listenerClassName));
8750                                    }
8751    
8752                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
8753                            }
8754                            catch (Exception e) {
8755                                    _log.error(e);
8756                            }
8757                    }
8758            }
8759    
8760            public void destroy() {
8761                    EntityCacheUtil.removeCache(BookmarksEntryImpl.class.getName());
8762                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
8763                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
8764                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
8765            }
8766    
8767            private static final String _SQL_SELECT_BOOKMARKSENTRY = "SELECT bookmarksEntry FROM BookmarksEntry bookmarksEntry";
8768            private static final String _SQL_SELECT_BOOKMARKSENTRY_WHERE = "SELECT bookmarksEntry FROM BookmarksEntry bookmarksEntry WHERE ";
8769            private static final String _SQL_COUNT_BOOKMARKSENTRY = "SELECT COUNT(bookmarksEntry) FROM BookmarksEntry bookmarksEntry";
8770            private static final String _SQL_COUNT_BOOKMARKSENTRY_WHERE = "SELECT COUNT(bookmarksEntry) FROM BookmarksEntry bookmarksEntry WHERE ";
8771            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "bookmarksEntry.entryId";
8772            private static final String _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN = "bookmarksEntry.userId";
8773            private static final String _ORDER_BY_ENTITY_ALIAS = "bookmarksEntry.";
8774            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No BookmarksEntry exists with the primary key ";
8775            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No BookmarksEntry exists with the key {";
8776            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
8777            private static Log _log = LogFactoryUtil.getLog(BookmarksEntryPersistenceImpl.class);
8778            private static Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
8779                                    "uuid"
8780                            });
8781            private static BookmarksEntry _nullBookmarksEntry = new BookmarksEntryImpl() {
8782                            @Override
8783                            public Object clone() {
8784                                    return this;
8785                            }
8786    
8787                            @Override
8788                            public CacheModel<BookmarksEntry> toCacheModel() {
8789                                    return _nullBookmarksEntryCacheModel;
8790                            }
8791                    };
8792    
8793            private static CacheModel<BookmarksEntry> _nullBookmarksEntryCacheModel = new CacheModel<BookmarksEntry>() {
8794                            public BookmarksEntry toEntityModel() {
8795                                    return _nullBookmarksEntry;
8796                            }
8797                    };
8798    }