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