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