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