001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.bookmarks.service.persistence;
016    
017    import com.liferay.portal.NoSuchModelException;
018    import com.liferay.portal.kernel.bean.BeanReference;
019    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022    import com.liferay.portal.kernel.dao.orm.FinderPath;
023    import com.liferay.portal.kernel.dao.orm.Query;
024    import com.liferay.portal.kernel.dao.orm.QueryPos;
025    import com.liferay.portal.kernel.dao.orm.QueryUtil;
026    import com.liferay.portal.kernel.dao.orm.Session;
027    import com.liferay.portal.kernel.exception.SystemException;
028    import com.liferay.portal.kernel.log.Log;
029    import com.liferay.portal.kernel.log.LogFactoryUtil;
030    import com.liferay.portal.kernel.util.ArrayUtil;
031    import com.liferay.portal.kernel.util.GetterUtil;
032    import com.liferay.portal.kernel.util.InstanceFactory;
033    import com.liferay.portal.kernel.util.OrderByComparator;
034    import com.liferay.portal.kernel.util.StringBundler;
035    import com.liferay.portal.kernel.util.StringPool;
036    import com.liferay.portal.kernel.util.StringUtil;
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.BatchSessionUtil;
043    import com.liferay.portal.service.persistence.ResourcePersistence;
044    import com.liferay.portal.service.persistence.UserPersistence;
045    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
046    
047    import com.liferay.portlet.asset.service.persistence.AssetEntryPersistence;
048    import com.liferay.portlet.asset.service.persistence.AssetLinkPersistence;
049    import com.liferay.portlet.asset.service.persistence.AssetTagPersistence;
050    import com.liferay.portlet.bookmarks.NoSuchEntryException;
051    import com.liferay.portlet.bookmarks.model.BookmarksEntry;
052    import com.liferay.portlet.bookmarks.model.impl.BookmarksEntryImpl;
053    import com.liferay.portlet.bookmarks.model.impl.BookmarksEntryModelImpl;
054    import com.liferay.portlet.expando.service.persistence.ExpandoValuePersistence;
055    import com.liferay.portlet.social.service.persistence.SocialActivityPersistence;
056    
057    import java.io.Serializable;
058    
059    import java.util.ArrayList;
060    import java.util.Collections;
061    import java.util.List;
062    
063    /**
064     * The persistence implementation for the bookmarks entry service.
065     *
066     * <p>
067     * Caching information and settings can be found in <code>portal.properties</code>
068     * </p>
069     *
070     * @author Brian Wing Shun Chan
071     * @see BookmarksEntryPersistence
072     * @see BookmarksEntryUtil
073     * @generated
074     */
075    public class BookmarksEntryPersistenceImpl extends BasePersistenceImpl<BookmarksEntry>
076            implements BookmarksEntryPersistence {
077            /*
078             * NOTE FOR DEVELOPERS:
079             *
080             * 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.
081             */
082            public static final String FINDER_CLASS_NAME_ENTITY = BookmarksEntryImpl.class.getName();
083            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
084                    ".List1";
085            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
086                    ".List2";
087            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_RESOURCEBLOCKID =
088                    new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
089                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
090                            BookmarksEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
091                            "findByResourceBlockId",
092                            new String[] {
093                                    Long.class.getName(),
094                                    
095                            "java.lang.Integer", "java.lang.Integer",
096                                    "com.liferay.portal.kernel.util.OrderByComparator"
097                            });
098            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEBLOCKID =
099                    new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
100                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
101                            BookmarksEntryImpl.class,
102                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByResourceBlockId",
103                            new String[] { Long.class.getName() },
104                            BookmarksEntryModelImpl.RESOURCEBLOCKID_COLUMN_BITMASK);
105            public static final FinderPath FINDER_PATH_COUNT_BY_RESOURCEBLOCKID = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
106                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
107                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
108                            "countByResourceBlockId", new String[] { Long.class.getName() });
109            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
110                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
111                            BookmarksEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
112                            "findByUuid",
113                            new String[] {
114                                    String.class.getName(),
115                                    
116                            "java.lang.Integer", "java.lang.Integer",
117                                    "com.liferay.portal.kernel.util.OrderByComparator"
118                            });
119            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
120                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
121                            BookmarksEntryImpl.class,
122                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
123                            new String[] { String.class.getName() },
124                            BookmarksEntryModelImpl.UUID_COLUMN_BITMASK);
125            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
126                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
127                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
128                            new String[] { String.class.getName() });
129            public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
130                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
131                            BookmarksEntryImpl.class, FINDER_CLASS_NAME_ENTITY,
132                            "fetchByUUID_G",
133                            new String[] { String.class.getName(), Long.class.getName() },
134                            BookmarksEntryModelImpl.UUID_COLUMN_BITMASK |
135                            BookmarksEntryModelImpl.GROUPID_COLUMN_BITMASK);
136            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
137                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
138                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
139                            new String[] { String.class.getName(), Long.class.getName() });
140            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
141                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
142                            BookmarksEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
143                            "findByGroupId",
144                            new String[] {
145                                    Long.class.getName(),
146                                    
147                            "java.lang.Integer", "java.lang.Integer",
148                                    "com.liferay.portal.kernel.util.OrderByComparator"
149                            });
150            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
151                    new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
152                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
153                            BookmarksEntryImpl.class,
154                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
155                            new String[] { Long.class.getName() },
156                            BookmarksEntryModelImpl.GROUPID_COLUMN_BITMASK);
157            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
158                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
159                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
160                            new String[] { Long.class.getName() });
161            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
162                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
163                            BookmarksEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
164                            "findByG_U",
165                            new String[] {
166                                    Long.class.getName(), Long.class.getName(),
167                                    
168                            "java.lang.Integer", "java.lang.Integer",
169                                    "com.liferay.portal.kernel.util.OrderByComparator"
170                            });
171            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
172                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
173                            BookmarksEntryImpl.class,
174                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U",
175                            new String[] { Long.class.getName(), Long.class.getName() },
176                            BookmarksEntryModelImpl.GROUPID_COLUMN_BITMASK |
177                            BookmarksEntryModelImpl.USERID_COLUMN_BITMASK);
178            public static final FinderPath FINDER_PATH_COUNT_BY_G_U = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
179                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
180                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U",
181                            new String[] { Long.class.getName(), Long.class.getName() });
182            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
183                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
184                            BookmarksEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
185                            "findByG_F",
186                            new String[] {
187                                    Long.class.getName(), Long.class.getName(),
188                                    
189                            "java.lang.Integer", "java.lang.Integer",
190                                    "com.liferay.portal.kernel.util.OrderByComparator"
191                            });
192            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
193                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
194                            BookmarksEntryImpl.class,
195                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_F",
196                            new String[] { Long.class.getName(), Long.class.getName() },
197                            BookmarksEntryModelImpl.GROUPID_COLUMN_BITMASK |
198                            BookmarksEntryModelImpl.FOLDERID_COLUMN_BITMASK);
199            public static final FinderPath FINDER_PATH_COUNT_BY_G_F = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
200                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
201                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_F",
202                            new String[] { Long.class.getName(), Long.class.getName() });
203            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
204                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
205                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_F",
206                            new String[] { Long.class.getName(), Long.class.getName() });
207            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
208                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
209                            BookmarksEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
210                            "findAll", new String[0]);
211            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
212                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
213                            BookmarksEntryImpl.class,
214                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
215            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
216                            BookmarksEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
217                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
218    
219            /**
220             * Caches the bookmarks entry in the entity cache if it is enabled.
221             *
222             * @param bookmarksEntry the bookmarks entry
223             */
224            public void cacheResult(BookmarksEntry bookmarksEntry) {
225                    EntityCacheUtil.putResult(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
226                            BookmarksEntryImpl.class, bookmarksEntry.getPrimaryKey(),
227                            bookmarksEntry);
228    
229                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
230                            new Object[] {
231                                    bookmarksEntry.getUuid(),
232                                    Long.valueOf(bookmarksEntry.getGroupId())
233                            }, bookmarksEntry);
234    
235                    bookmarksEntry.resetOriginalValues();
236            }
237    
238            /**
239             * Caches the bookmarks entries in the entity cache if it is enabled.
240             *
241             * @param bookmarksEntries the bookmarks entries
242             */
243            public void cacheResult(List<BookmarksEntry> bookmarksEntries) {
244                    for (BookmarksEntry bookmarksEntry : bookmarksEntries) {
245                            if (EntityCacheUtil.getResult(
246                                                    BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
247                                                    BookmarksEntryImpl.class, bookmarksEntry.getPrimaryKey()) == null) {
248                                    cacheResult(bookmarksEntry);
249                            }
250                            else {
251                                    bookmarksEntry.resetOriginalValues();
252                            }
253                    }
254            }
255    
256            /**
257             * Clears the cache for all bookmarks entries.
258             *
259             * <p>
260             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
261             * </p>
262             */
263            @Override
264            public void clearCache() {
265                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
266                            CacheRegistryUtil.clear(BookmarksEntryImpl.class.getName());
267                    }
268    
269                    EntityCacheUtil.clearCache(BookmarksEntryImpl.class.getName());
270    
271                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
272                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
273                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
274            }
275    
276            /**
277             * Clears the cache for the bookmarks entry.
278             *
279             * <p>
280             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
281             * </p>
282             */
283            @Override
284            public void clearCache(BookmarksEntry bookmarksEntry) {
285                    EntityCacheUtil.removeResult(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
286                            BookmarksEntryImpl.class, bookmarksEntry.getPrimaryKey());
287    
288                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
289                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
290    
291                    clearUniqueFindersCache(bookmarksEntry);
292            }
293    
294            @Override
295            public void clearCache(List<BookmarksEntry> bookmarksEntries) {
296                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
297                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
298    
299                    for (BookmarksEntry bookmarksEntry : bookmarksEntries) {
300                            EntityCacheUtil.removeResult(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
301                                    BookmarksEntryImpl.class, bookmarksEntry.getPrimaryKey());
302    
303                            clearUniqueFindersCache(bookmarksEntry);
304                    }
305            }
306    
307            protected void clearUniqueFindersCache(BookmarksEntry bookmarksEntry) {
308                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
309                            new Object[] {
310                                    bookmarksEntry.getUuid(),
311                                    Long.valueOf(bookmarksEntry.getGroupId())
312                            });
313            }
314    
315            /**
316             * Creates a new bookmarks entry with the primary key. Does not add the bookmarks entry to the database.
317             *
318             * @param entryId the primary key for the new bookmarks entry
319             * @return the new bookmarks entry
320             */
321            public BookmarksEntry create(long entryId) {
322                    BookmarksEntry bookmarksEntry = new BookmarksEntryImpl();
323    
324                    bookmarksEntry.setNew(true);
325                    bookmarksEntry.setPrimaryKey(entryId);
326    
327                    String uuid = PortalUUIDUtil.generate();
328    
329                    bookmarksEntry.setUuid(uuid);
330    
331                    return bookmarksEntry;
332            }
333    
334            /**
335             * Removes the bookmarks entry with the primary key from the database. Also notifies the appropriate model listeners.
336             *
337             * @param entryId the primary key of the bookmarks entry
338             * @return the bookmarks entry that was removed
339             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
340             * @throws SystemException if a system exception occurred
341             */
342            public BookmarksEntry remove(long entryId)
343                    throws NoSuchEntryException, SystemException {
344                    return remove(Long.valueOf(entryId));
345            }
346    
347            /**
348             * Removes the bookmarks entry with the primary key from the database. Also notifies the appropriate model listeners.
349             *
350             * @param primaryKey the primary key of the bookmarks entry
351             * @return the bookmarks entry that was removed
352             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
353             * @throws SystemException if a system exception occurred
354             */
355            @Override
356            public BookmarksEntry remove(Serializable primaryKey)
357                    throws NoSuchEntryException, SystemException {
358                    Session session = null;
359    
360                    try {
361                            session = openSession();
362    
363                            BookmarksEntry bookmarksEntry = (BookmarksEntry)session.get(BookmarksEntryImpl.class,
364                                            primaryKey);
365    
366                            if (bookmarksEntry == null) {
367                                    if (_log.isWarnEnabled()) {
368                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
369                                    }
370    
371                                    throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
372                                            primaryKey);
373                            }
374    
375                            return remove(bookmarksEntry);
376                    }
377                    catch (NoSuchEntryException nsee) {
378                            throw nsee;
379                    }
380                    catch (Exception e) {
381                            throw processException(e);
382                    }
383                    finally {
384                            closeSession(session);
385                    }
386            }
387    
388            @Override
389            protected BookmarksEntry removeImpl(BookmarksEntry bookmarksEntry)
390                    throws SystemException {
391                    bookmarksEntry = toUnwrappedModel(bookmarksEntry);
392    
393                    Session session = null;
394    
395                    try {
396                            session = openSession();
397    
398                            BatchSessionUtil.delete(session, bookmarksEntry);
399                    }
400                    catch (Exception e) {
401                            throw processException(e);
402                    }
403                    finally {
404                            closeSession(session);
405                    }
406    
407                    clearCache(bookmarksEntry);
408    
409                    return bookmarksEntry;
410            }
411    
412            @Override
413            public BookmarksEntry updateImpl(
414                    com.liferay.portlet.bookmarks.model.BookmarksEntry bookmarksEntry,
415                    boolean merge) throws SystemException {
416                    bookmarksEntry = toUnwrappedModel(bookmarksEntry);
417    
418                    boolean isNew = bookmarksEntry.isNew();
419    
420                    BookmarksEntryModelImpl bookmarksEntryModelImpl = (BookmarksEntryModelImpl)bookmarksEntry;
421    
422                    if (Validator.isNull(bookmarksEntry.getUuid())) {
423                            String uuid = PortalUUIDUtil.generate();
424    
425                            bookmarksEntry.setUuid(uuid);
426                    }
427    
428                    Session session = null;
429    
430                    try {
431                            session = openSession();
432    
433                            BatchSessionUtil.update(session, bookmarksEntry, merge);
434    
435                            bookmarksEntry.setNew(false);
436                    }
437                    catch (Exception e) {
438                            throw processException(e);
439                    }
440                    finally {
441                            closeSession(session);
442                    }
443    
444                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
445    
446                    if (isNew || !BookmarksEntryModelImpl.COLUMN_BITMASK_ENABLED) {
447                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
448                    }
449                    else {
450                            if ((bookmarksEntryModelImpl.getColumnBitmask() &
451                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEBLOCKID.getColumnBitmask()) != 0) {
452                                    Object[] args = new Object[] {
453                                                    Long.valueOf(bookmarksEntryModelImpl.getOriginalResourceBlockId())
454                                            };
455    
456                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RESOURCEBLOCKID,
457                                            args);
458                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEBLOCKID,
459                                            args);
460    
461                                    args = new Object[] {
462                                                    Long.valueOf(bookmarksEntryModelImpl.getResourceBlockId())
463                                            };
464    
465                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RESOURCEBLOCKID,
466                                            args);
467                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEBLOCKID,
468                                            args);
469                            }
470    
471                            if ((bookmarksEntryModelImpl.getColumnBitmask() &
472                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
473                                    Object[] args = new Object[] {
474                                                    bookmarksEntryModelImpl.getOriginalUuid()
475                                            };
476    
477                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
478                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
479                                            args);
480    
481                                    args = new Object[] { bookmarksEntryModelImpl.getUuid() };
482    
483                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
484                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
485                                            args);
486                            }
487    
488                            if ((bookmarksEntryModelImpl.getColumnBitmask() &
489                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
490                                    Object[] args = new Object[] {
491                                                    Long.valueOf(bookmarksEntryModelImpl.getOriginalGroupId())
492                                            };
493    
494                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
495                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
496                                            args);
497    
498                                    args = new Object[] {
499                                                    Long.valueOf(bookmarksEntryModelImpl.getGroupId())
500                                            };
501    
502                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
503                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
504                                            args);
505                            }
506    
507                            if ((bookmarksEntryModelImpl.getColumnBitmask() &
508                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U.getColumnBitmask()) != 0) {
509                                    Object[] args = new Object[] {
510                                                    Long.valueOf(bookmarksEntryModelImpl.getOriginalGroupId()),
511                                                    Long.valueOf(bookmarksEntryModelImpl.getOriginalUserId())
512                                            };
513    
514                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U, args);
515                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U,
516                                            args);
517    
518                                    args = new Object[] {
519                                                    Long.valueOf(bookmarksEntryModelImpl.getGroupId()),
520                                                    Long.valueOf(bookmarksEntryModelImpl.getUserId())
521                                            };
522    
523                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U, args);
524                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U,
525                                            args);
526                            }
527    
528                            if ((bookmarksEntryModelImpl.getColumnBitmask() &
529                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F.getColumnBitmask()) != 0) {
530                                    Object[] args = new Object[] {
531                                                    Long.valueOf(bookmarksEntryModelImpl.getOriginalGroupId()),
532                                                    Long.valueOf(bookmarksEntryModelImpl.getOriginalFolderId())
533                                            };
534    
535                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F, args);
536                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F,
537                                            args);
538    
539                                    args = new Object[] {
540                                                    Long.valueOf(bookmarksEntryModelImpl.getGroupId()),
541                                                    Long.valueOf(bookmarksEntryModelImpl.getFolderId())
542                                            };
543    
544                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_F, args);
545                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F,
546                                            args);
547                            }
548                    }
549    
550                    EntityCacheUtil.putResult(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
551                            BookmarksEntryImpl.class, bookmarksEntry.getPrimaryKey(),
552                            bookmarksEntry);
553    
554                    if (isNew) {
555                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
556                                    new Object[] {
557                                            bookmarksEntry.getUuid(),
558                                            Long.valueOf(bookmarksEntry.getGroupId())
559                                    }, bookmarksEntry);
560                    }
561                    else {
562                            if ((bookmarksEntryModelImpl.getColumnBitmask() &
563                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
564                                    Object[] args = new Object[] {
565                                                    bookmarksEntryModelImpl.getOriginalUuid(),
566                                                    Long.valueOf(bookmarksEntryModelImpl.getOriginalGroupId())
567                                            };
568    
569                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
570                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
571    
572                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
573                                            new Object[] {
574                                                    bookmarksEntry.getUuid(),
575                                                    Long.valueOf(bookmarksEntry.getGroupId())
576                                            }, bookmarksEntry);
577                            }
578                    }
579    
580                    return bookmarksEntry;
581            }
582    
583            protected BookmarksEntry toUnwrappedModel(BookmarksEntry bookmarksEntry) {
584                    if (bookmarksEntry instanceof BookmarksEntryImpl) {
585                            return bookmarksEntry;
586                    }
587    
588                    BookmarksEntryImpl bookmarksEntryImpl = new BookmarksEntryImpl();
589    
590                    bookmarksEntryImpl.setNew(bookmarksEntry.isNew());
591                    bookmarksEntryImpl.setPrimaryKey(bookmarksEntry.getPrimaryKey());
592    
593                    bookmarksEntryImpl.setUuid(bookmarksEntry.getUuid());
594                    bookmarksEntryImpl.setEntryId(bookmarksEntry.getEntryId());
595                    bookmarksEntryImpl.setGroupId(bookmarksEntry.getGroupId());
596                    bookmarksEntryImpl.setCompanyId(bookmarksEntry.getCompanyId());
597                    bookmarksEntryImpl.setUserId(bookmarksEntry.getUserId());
598                    bookmarksEntryImpl.setUserName(bookmarksEntry.getUserName());
599                    bookmarksEntryImpl.setCreateDate(bookmarksEntry.getCreateDate());
600                    bookmarksEntryImpl.setModifiedDate(bookmarksEntry.getModifiedDate());
601                    bookmarksEntryImpl.setResourceBlockId(bookmarksEntry.getResourceBlockId());
602                    bookmarksEntryImpl.setFolderId(bookmarksEntry.getFolderId());
603                    bookmarksEntryImpl.setName(bookmarksEntry.getName());
604                    bookmarksEntryImpl.setUrl(bookmarksEntry.getUrl());
605                    bookmarksEntryImpl.setDescription(bookmarksEntry.getDescription());
606                    bookmarksEntryImpl.setVisits(bookmarksEntry.getVisits());
607                    bookmarksEntryImpl.setPriority(bookmarksEntry.getPriority());
608    
609                    return bookmarksEntryImpl;
610            }
611    
612            /**
613             * Returns the bookmarks entry with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
614             *
615             * @param primaryKey the primary key of the bookmarks entry
616             * @return the bookmarks entry
617             * @throws com.liferay.portal.NoSuchModelException if a bookmarks entry with the primary key could not be found
618             * @throws SystemException if a system exception occurred
619             */
620            @Override
621            public BookmarksEntry findByPrimaryKey(Serializable primaryKey)
622                    throws NoSuchModelException, SystemException {
623                    return findByPrimaryKey(((Long)primaryKey).longValue());
624            }
625    
626            /**
627             * Returns the bookmarks entry with the primary key or throws a {@link com.liferay.portlet.bookmarks.NoSuchEntryException} if it could not be found.
628             *
629             * @param entryId the primary key of the bookmarks entry
630             * @return the bookmarks entry
631             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
632             * @throws SystemException if a system exception occurred
633             */
634            public BookmarksEntry findByPrimaryKey(long entryId)
635                    throws NoSuchEntryException, SystemException {
636                    BookmarksEntry bookmarksEntry = fetchByPrimaryKey(entryId);
637    
638                    if (bookmarksEntry == null) {
639                            if (_log.isWarnEnabled()) {
640                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + entryId);
641                            }
642    
643                            throw new NoSuchEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
644                                    entryId);
645                    }
646    
647                    return bookmarksEntry;
648            }
649    
650            /**
651             * Returns the bookmarks entry with the primary key or returns <code>null</code> if it could not be found.
652             *
653             * @param primaryKey the primary key of the bookmarks entry
654             * @return the bookmarks entry, or <code>null</code> if a bookmarks entry with the primary key could not be found
655             * @throws SystemException if a system exception occurred
656             */
657            @Override
658            public BookmarksEntry fetchByPrimaryKey(Serializable primaryKey)
659                    throws SystemException {
660                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
661            }
662    
663            /**
664             * Returns the bookmarks entry with the primary key or returns <code>null</code> if it could not be found.
665             *
666             * @param entryId the primary key of the bookmarks entry
667             * @return the bookmarks entry, or <code>null</code> if a bookmarks entry with the primary key could not be found
668             * @throws SystemException if a system exception occurred
669             */
670            public BookmarksEntry fetchByPrimaryKey(long entryId)
671                    throws SystemException {
672                    BookmarksEntry bookmarksEntry = (BookmarksEntry)EntityCacheUtil.getResult(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
673                                    BookmarksEntryImpl.class, entryId);
674    
675                    if (bookmarksEntry == _nullBookmarksEntry) {
676                            return null;
677                    }
678    
679                    if (bookmarksEntry == null) {
680                            Session session = null;
681    
682                            boolean hasException = false;
683    
684                            try {
685                                    session = openSession();
686    
687                                    bookmarksEntry = (BookmarksEntry)session.get(BookmarksEntryImpl.class,
688                                                    Long.valueOf(entryId));
689                            }
690                            catch (Exception e) {
691                                    hasException = true;
692    
693                                    throw processException(e);
694                            }
695                            finally {
696                                    if (bookmarksEntry != null) {
697                                            cacheResult(bookmarksEntry);
698                                    }
699                                    else if (!hasException) {
700                                            EntityCacheUtil.putResult(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
701                                                    BookmarksEntryImpl.class, entryId, _nullBookmarksEntry);
702                                    }
703    
704                                    closeSession(session);
705                            }
706                    }
707    
708                    return bookmarksEntry;
709            }
710    
711            /**
712             * Returns all the bookmarks entries where resourceBlockId = &#63;.
713             *
714             * @param resourceBlockId the resource block ID
715             * @return the matching bookmarks entries
716             * @throws SystemException if a system exception occurred
717             */
718            public List<BookmarksEntry> findByResourceBlockId(long resourceBlockId)
719                    throws SystemException {
720                    return findByResourceBlockId(resourceBlockId, QueryUtil.ALL_POS,
721                            QueryUtil.ALL_POS, null);
722            }
723    
724            /**
725             * Returns a range of all the bookmarks entries where resourceBlockId = &#63;.
726             *
727             * <p>
728             * 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.
729             * </p>
730             *
731             * @param resourceBlockId the resource block ID
732             * @param start the lower bound of the range of bookmarks entries
733             * @param end the upper bound of the range of bookmarks entries (not inclusive)
734             * @return the range of matching bookmarks entries
735             * @throws SystemException if a system exception occurred
736             */
737            public List<BookmarksEntry> findByResourceBlockId(long resourceBlockId,
738                    int start, int end) throws SystemException {
739                    return findByResourceBlockId(resourceBlockId, start, end, null);
740            }
741    
742            /**
743             * Returns an ordered range of all the bookmarks entries where resourceBlockId = &#63;.
744             *
745             * <p>
746             * 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.
747             * </p>
748             *
749             * @param resourceBlockId the resource block ID
750             * @param start the lower bound of the range of bookmarks entries
751             * @param end the upper bound of the range of bookmarks entries (not inclusive)
752             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
753             * @return the ordered range of matching bookmarks entries
754             * @throws SystemException if a system exception occurred
755             */
756            public List<BookmarksEntry> findByResourceBlockId(long resourceBlockId,
757                    int start, int end, OrderByComparator orderByComparator)
758                    throws SystemException {
759                    FinderPath finderPath = null;
760                    Object[] finderArgs = null;
761    
762                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
763                                    (orderByComparator == null)) {
764                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RESOURCEBLOCKID;
765                            finderArgs = new Object[] { resourceBlockId };
766                    }
767                    else {
768                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_RESOURCEBLOCKID;
769                            finderArgs = new Object[] {
770                                            resourceBlockId,
771                                            
772                                            start, end, orderByComparator
773                                    };
774                    }
775    
776                    List<BookmarksEntry> list = (List<BookmarksEntry>)FinderCacheUtil.getResult(finderPath,
777                                    finderArgs, this);
778    
779                    if ((list != null) && !list.isEmpty()) {
780                            for (BookmarksEntry bookmarksEntry : list) {
781                                    if ((resourceBlockId != bookmarksEntry.getResourceBlockId())) {
782                                            list = null;
783    
784                                            break;
785                                    }
786                            }
787                    }
788    
789                    if (list == null) {
790                            StringBundler query = null;
791    
792                            if (orderByComparator != null) {
793                                    query = new StringBundler(3 +
794                                                    (orderByComparator.getOrderByFields().length * 3));
795                            }
796                            else {
797                                    query = new StringBundler(3);
798                            }
799    
800                            query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
801    
802                            query.append(_FINDER_COLUMN_RESOURCEBLOCKID_RESOURCEBLOCKID_2);
803    
804                            if (orderByComparator != null) {
805                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
806                                            orderByComparator);
807                            }
808    
809                            else {
810                                    query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
811                            }
812    
813                            String sql = query.toString();
814    
815                            Session session = null;
816    
817                            try {
818                                    session = openSession();
819    
820                                    Query q = session.createQuery(sql);
821    
822                                    QueryPos qPos = QueryPos.getInstance(q);
823    
824                                    qPos.add(resourceBlockId);
825    
826                                    list = (List<BookmarksEntry>)QueryUtil.list(q, getDialect(),
827                                                    start, end);
828                            }
829                            catch (Exception e) {
830                                    throw processException(e);
831                            }
832                            finally {
833                                    if (list == null) {
834                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
835                                    }
836                                    else {
837                                            cacheResult(list);
838    
839                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
840                                    }
841    
842                                    closeSession(session);
843                            }
844                    }
845    
846                    return list;
847            }
848    
849            /**
850             * Returns the first bookmarks entry in the ordered set where resourceBlockId = &#63;.
851             *
852             * <p>
853             * 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.
854             * </p>
855             *
856             * @param resourceBlockId the resource block ID
857             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
858             * @return the first matching bookmarks entry
859             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
860             * @throws SystemException if a system exception occurred
861             */
862            public BookmarksEntry findByResourceBlockId_First(long resourceBlockId,
863                    OrderByComparator orderByComparator)
864                    throws NoSuchEntryException, SystemException {
865                    List<BookmarksEntry> list = findByResourceBlockId(resourceBlockId, 0,
866                                    1, orderByComparator);
867    
868                    if (list.isEmpty()) {
869                            StringBundler msg = new StringBundler(4);
870    
871                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
872    
873                            msg.append("resourceBlockId=");
874                            msg.append(resourceBlockId);
875    
876                            msg.append(StringPool.CLOSE_CURLY_BRACE);
877    
878                            throw new NoSuchEntryException(msg.toString());
879                    }
880                    else {
881                            return list.get(0);
882                    }
883            }
884    
885            /**
886             * Returns the last bookmarks entry in the ordered set where resourceBlockId = &#63;.
887             *
888             * <p>
889             * 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.
890             * </p>
891             *
892             * @param resourceBlockId the resource block ID
893             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
894             * @return the last matching bookmarks entry
895             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
896             * @throws SystemException if a system exception occurred
897             */
898            public BookmarksEntry findByResourceBlockId_Last(long resourceBlockId,
899                    OrderByComparator orderByComparator)
900                    throws NoSuchEntryException, SystemException {
901                    int count = countByResourceBlockId(resourceBlockId);
902    
903                    List<BookmarksEntry> list = findByResourceBlockId(resourceBlockId,
904                                    count - 1, count, orderByComparator);
905    
906                    if (list.isEmpty()) {
907                            StringBundler msg = new StringBundler(4);
908    
909                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
910    
911                            msg.append("resourceBlockId=");
912                            msg.append(resourceBlockId);
913    
914                            msg.append(StringPool.CLOSE_CURLY_BRACE);
915    
916                            throw new NoSuchEntryException(msg.toString());
917                    }
918                    else {
919                            return list.get(0);
920                    }
921            }
922    
923            /**
924             * Returns the bookmarks entries before and after the current bookmarks entry in the ordered set where resourceBlockId = &#63;.
925             *
926             * <p>
927             * 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.
928             * </p>
929             *
930             * @param entryId the primary key of the current bookmarks entry
931             * @param resourceBlockId the resource block ID
932             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
933             * @return the previous, current, and next bookmarks entry
934             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
935             * @throws SystemException if a system exception occurred
936             */
937            public BookmarksEntry[] findByResourceBlockId_PrevAndNext(long entryId,
938                    long resourceBlockId, OrderByComparator orderByComparator)
939                    throws NoSuchEntryException, SystemException {
940                    BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
941    
942                    Session session = null;
943    
944                    try {
945                            session = openSession();
946    
947                            BookmarksEntry[] array = new BookmarksEntryImpl[3];
948    
949                            array[0] = getByResourceBlockId_PrevAndNext(session,
950                                            bookmarksEntry, resourceBlockId, orderByComparator, true);
951    
952                            array[1] = bookmarksEntry;
953    
954                            array[2] = getByResourceBlockId_PrevAndNext(session,
955                                            bookmarksEntry, resourceBlockId, orderByComparator, false);
956    
957                            return array;
958                    }
959                    catch (Exception e) {
960                            throw processException(e);
961                    }
962                    finally {
963                            closeSession(session);
964                    }
965            }
966    
967            protected BookmarksEntry getByResourceBlockId_PrevAndNext(Session session,
968                    BookmarksEntry bookmarksEntry, long resourceBlockId,
969                    OrderByComparator orderByComparator, boolean previous) {
970                    StringBundler query = null;
971    
972                    if (orderByComparator != null) {
973                            query = new StringBundler(6 +
974                                            (orderByComparator.getOrderByFields().length * 6));
975                    }
976                    else {
977                            query = new StringBundler(3);
978                    }
979    
980                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
981    
982                    query.append(_FINDER_COLUMN_RESOURCEBLOCKID_RESOURCEBLOCKID_2);
983    
984                    if (orderByComparator != null) {
985                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
986    
987                            if (orderByConditionFields.length > 0) {
988                                    query.append(WHERE_AND);
989                            }
990    
991                            for (int i = 0; i < orderByConditionFields.length; i++) {
992                                    query.append(_ORDER_BY_ENTITY_ALIAS);
993                                    query.append(orderByConditionFields[i]);
994    
995                                    if ((i + 1) < orderByConditionFields.length) {
996                                            if (orderByComparator.isAscending() ^ previous) {
997                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
998                                            }
999                                            else {
1000                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1001                                            }
1002                                    }
1003                                    else {
1004                                            if (orderByComparator.isAscending() ^ previous) {
1005                                                    query.append(WHERE_GREATER_THAN);
1006                                            }
1007                                            else {
1008                                                    query.append(WHERE_LESSER_THAN);
1009                                            }
1010                                    }
1011                            }
1012    
1013                            query.append(ORDER_BY_CLAUSE);
1014    
1015                            String[] orderByFields = orderByComparator.getOrderByFields();
1016    
1017                            for (int i = 0; i < orderByFields.length; i++) {
1018                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1019                                    query.append(orderByFields[i]);
1020    
1021                                    if ((i + 1) < orderByFields.length) {
1022                                            if (orderByComparator.isAscending() ^ previous) {
1023                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1024                                            }
1025                                            else {
1026                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1027                                            }
1028                                    }
1029                                    else {
1030                                            if (orderByComparator.isAscending() ^ previous) {
1031                                                    query.append(ORDER_BY_ASC);
1032                                            }
1033                                            else {
1034                                                    query.append(ORDER_BY_DESC);
1035                                            }
1036                                    }
1037                            }
1038                    }
1039    
1040                    else {
1041                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
1042                    }
1043    
1044                    String sql = query.toString();
1045    
1046                    Query q = session.createQuery(sql);
1047    
1048                    q.setFirstResult(0);
1049                    q.setMaxResults(2);
1050    
1051                    QueryPos qPos = QueryPos.getInstance(q);
1052    
1053                    qPos.add(resourceBlockId);
1054    
1055                    if (orderByComparator != null) {
1056                            Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry);
1057    
1058                            for (Object value : values) {
1059                                    qPos.add(value);
1060                            }
1061                    }
1062    
1063                    List<BookmarksEntry> list = q.list();
1064    
1065                    if (list.size() == 2) {
1066                            return list.get(1);
1067                    }
1068                    else {
1069                            return null;
1070                    }
1071            }
1072    
1073            /**
1074             * Returns all the bookmarks entries where uuid = &#63;.
1075             *
1076             * @param uuid the uuid
1077             * @return the matching bookmarks entries
1078             * @throws SystemException if a system exception occurred
1079             */
1080            public List<BookmarksEntry> findByUuid(String uuid)
1081                    throws SystemException {
1082                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1083            }
1084    
1085            /**
1086             * Returns a range of all the bookmarks entries where uuid = &#63;.
1087             *
1088             * <p>
1089             * 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.
1090             * </p>
1091             *
1092             * @param uuid the uuid
1093             * @param start the lower bound of the range of bookmarks entries
1094             * @param end the upper bound of the range of bookmarks entries (not inclusive)
1095             * @return the range of matching bookmarks entries
1096             * @throws SystemException if a system exception occurred
1097             */
1098            public List<BookmarksEntry> findByUuid(String uuid, int start, int end)
1099                    throws SystemException {
1100                    return findByUuid(uuid, start, end, null);
1101            }
1102    
1103            /**
1104             * Returns an ordered range of all the bookmarks entries where uuid = &#63;.
1105             *
1106             * <p>
1107             * 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.
1108             * </p>
1109             *
1110             * @param uuid the uuid
1111             * @param start the lower bound of the range of bookmarks entries
1112             * @param end the upper bound of the range of bookmarks entries (not inclusive)
1113             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1114             * @return the ordered range of matching bookmarks entries
1115             * @throws SystemException if a system exception occurred
1116             */
1117            public List<BookmarksEntry> findByUuid(String uuid, int start, int end,
1118                    OrderByComparator orderByComparator) throws SystemException {
1119                    FinderPath finderPath = null;
1120                    Object[] finderArgs = null;
1121    
1122                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1123                                    (orderByComparator == null)) {
1124                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
1125                            finderArgs = new Object[] { uuid };
1126                    }
1127                    else {
1128                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
1129                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
1130                    }
1131    
1132                    List<BookmarksEntry> list = (List<BookmarksEntry>)FinderCacheUtil.getResult(finderPath,
1133                                    finderArgs, this);
1134    
1135                    if ((list != null) && !list.isEmpty()) {
1136                            for (BookmarksEntry bookmarksEntry : list) {
1137                                    if (!Validator.equals(uuid, bookmarksEntry.getUuid())) {
1138                                            list = null;
1139    
1140                                            break;
1141                                    }
1142                            }
1143                    }
1144    
1145                    if (list == null) {
1146                            StringBundler query = null;
1147    
1148                            if (orderByComparator != null) {
1149                                    query = new StringBundler(3 +
1150                                                    (orderByComparator.getOrderByFields().length * 3));
1151                            }
1152                            else {
1153                                    query = new StringBundler(3);
1154                            }
1155    
1156                            query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
1157    
1158                            if (uuid == null) {
1159                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
1160                            }
1161                            else {
1162                                    if (uuid.equals(StringPool.BLANK)) {
1163                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
1164                                    }
1165                                    else {
1166                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
1167                                    }
1168                            }
1169    
1170                            if (orderByComparator != null) {
1171                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1172                                            orderByComparator);
1173                            }
1174    
1175                            else {
1176                                    query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
1177                            }
1178    
1179                            String sql = query.toString();
1180    
1181                            Session session = null;
1182    
1183                            try {
1184                                    session = openSession();
1185    
1186                                    Query q = session.createQuery(sql);
1187    
1188                                    QueryPos qPos = QueryPos.getInstance(q);
1189    
1190                                    if (uuid != null) {
1191                                            qPos.add(uuid);
1192                                    }
1193    
1194                                    list = (List<BookmarksEntry>)QueryUtil.list(q, getDialect(),
1195                                                    start, end);
1196                            }
1197                            catch (Exception e) {
1198                                    throw processException(e);
1199                            }
1200                            finally {
1201                                    if (list == null) {
1202                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1203                                    }
1204                                    else {
1205                                            cacheResult(list);
1206    
1207                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1208                                    }
1209    
1210                                    closeSession(session);
1211                            }
1212                    }
1213    
1214                    return list;
1215            }
1216    
1217            /**
1218             * Returns the first bookmarks entry in the ordered set where uuid = &#63;.
1219             *
1220             * <p>
1221             * 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.
1222             * </p>
1223             *
1224             * @param uuid the uuid
1225             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1226             * @return the first matching bookmarks entry
1227             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
1228             * @throws SystemException if a system exception occurred
1229             */
1230            public BookmarksEntry findByUuid_First(String uuid,
1231                    OrderByComparator orderByComparator)
1232                    throws NoSuchEntryException, SystemException {
1233                    List<BookmarksEntry> list = findByUuid(uuid, 0, 1, orderByComparator);
1234    
1235                    if (list.isEmpty()) {
1236                            StringBundler msg = new StringBundler(4);
1237    
1238                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1239    
1240                            msg.append("uuid=");
1241                            msg.append(uuid);
1242    
1243                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1244    
1245                            throw new NoSuchEntryException(msg.toString());
1246                    }
1247                    else {
1248                            return list.get(0);
1249                    }
1250            }
1251    
1252            /**
1253             * Returns the last bookmarks entry in the ordered set where uuid = &#63;.
1254             *
1255             * <p>
1256             * 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.
1257             * </p>
1258             *
1259             * @param uuid the uuid
1260             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1261             * @return the last matching bookmarks entry
1262             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
1263             * @throws SystemException if a system exception occurred
1264             */
1265            public BookmarksEntry findByUuid_Last(String uuid,
1266                    OrderByComparator orderByComparator)
1267                    throws NoSuchEntryException, SystemException {
1268                    int count = countByUuid(uuid);
1269    
1270                    List<BookmarksEntry> list = findByUuid(uuid, count - 1, count,
1271                                    orderByComparator);
1272    
1273                    if (list.isEmpty()) {
1274                            StringBundler msg = new StringBundler(4);
1275    
1276                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1277    
1278                            msg.append("uuid=");
1279                            msg.append(uuid);
1280    
1281                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1282    
1283                            throw new NoSuchEntryException(msg.toString());
1284                    }
1285                    else {
1286                            return list.get(0);
1287                    }
1288            }
1289    
1290            /**
1291             * Returns the bookmarks entries before and after the current bookmarks entry in the ordered set where uuid = &#63;.
1292             *
1293             * <p>
1294             * 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.
1295             * </p>
1296             *
1297             * @param entryId the primary key of the current bookmarks entry
1298             * @param uuid the uuid
1299             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1300             * @return the previous, current, and next bookmarks entry
1301             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
1302             * @throws SystemException if a system exception occurred
1303             */
1304            public BookmarksEntry[] findByUuid_PrevAndNext(long entryId, String uuid,
1305                    OrderByComparator orderByComparator)
1306                    throws NoSuchEntryException, SystemException {
1307                    BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
1308    
1309                    Session session = null;
1310    
1311                    try {
1312                            session = openSession();
1313    
1314                            BookmarksEntry[] array = new BookmarksEntryImpl[3];
1315    
1316                            array[0] = getByUuid_PrevAndNext(session, bookmarksEntry, uuid,
1317                                            orderByComparator, true);
1318    
1319                            array[1] = bookmarksEntry;
1320    
1321                            array[2] = getByUuid_PrevAndNext(session, bookmarksEntry, uuid,
1322                                            orderByComparator, false);
1323    
1324                            return array;
1325                    }
1326                    catch (Exception e) {
1327                            throw processException(e);
1328                    }
1329                    finally {
1330                            closeSession(session);
1331                    }
1332            }
1333    
1334            protected BookmarksEntry getByUuid_PrevAndNext(Session session,
1335                    BookmarksEntry bookmarksEntry, String uuid,
1336                    OrderByComparator orderByComparator, boolean previous) {
1337                    StringBundler query = null;
1338    
1339                    if (orderByComparator != null) {
1340                            query = new StringBundler(6 +
1341                                            (orderByComparator.getOrderByFields().length * 6));
1342                    }
1343                    else {
1344                            query = new StringBundler(3);
1345                    }
1346    
1347                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
1348    
1349                    if (uuid == null) {
1350                            query.append(_FINDER_COLUMN_UUID_UUID_1);
1351                    }
1352                    else {
1353                            if (uuid.equals(StringPool.BLANK)) {
1354                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
1355                            }
1356                            else {
1357                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
1358                            }
1359                    }
1360    
1361                    if (orderByComparator != null) {
1362                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1363    
1364                            if (orderByConditionFields.length > 0) {
1365                                    query.append(WHERE_AND);
1366                            }
1367    
1368                            for (int i = 0; i < orderByConditionFields.length; i++) {
1369                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1370                                    query.append(orderByConditionFields[i]);
1371    
1372                                    if ((i + 1) < orderByConditionFields.length) {
1373                                            if (orderByComparator.isAscending() ^ previous) {
1374                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1375                                            }
1376                                            else {
1377                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1378                                            }
1379                                    }
1380                                    else {
1381                                            if (orderByComparator.isAscending() ^ previous) {
1382                                                    query.append(WHERE_GREATER_THAN);
1383                                            }
1384                                            else {
1385                                                    query.append(WHERE_LESSER_THAN);
1386                                            }
1387                                    }
1388                            }
1389    
1390                            query.append(ORDER_BY_CLAUSE);
1391    
1392                            String[] orderByFields = orderByComparator.getOrderByFields();
1393    
1394                            for (int i = 0; i < orderByFields.length; i++) {
1395                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1396                                    query.append(orderByFields[i]);
1397    
1398                                    if ((i + 1) < orderByFields.length) {
1399                                            if (orderByComparator.isAscending() ^ previous) {
1400                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1401                                            }
1402                                            else {
1403                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1404                                            }
1405                                    }
1406                                    else {
1407                                            if (orderByComparator.isAscending() ^ previous) {
1408                                                    query.append(ORDER_BY_ASC);
1409                                            }
1410                                            else {
1411                                                    query.append(ORDER_BY_DESC);
1412                                            }
1413                                    }
1414                            }
1415                    }
1416    
1417                    else {
1418                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
1419                    }
1420    
1421                    String sql = query.toString();
1422    
1423                    Query q = session.createQuery(sql);
1424    
1425                    q.setFirstResult(0);
1426                    q.setMaxResults(2);
1427    
1428                    QueryPos qPos = QueryPos.getInstance(q);
1429    
1430                    if (uuid != null) {
1431                            qPos.add(uuid);
1432                    }
1433    
1434                    if (orderByComparator != null) {
1435                            Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry);
1436    
1437                            for (Object value : values) {
1438                                    qPos.add(value);
1439                            }
1440                    }
1441    
1442                    List<BookmarksEntry> list = q.list();
1443    
1444                    if (list.size() == 2) {
1445                            return list.get(1);
1446                    }
1447                    else {
1448                            return null;
1449                    }
1450            }
1451    
1452            /**
1453             * 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.
1454             *
1455             * @param uuid the uuid
1456             * @param groupId the group ID
1457             * @return the matching bookmarks entry
1458             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
1459             * @throws SystemException if a system exception occurred
1460             */
1461            public BookmarksEntry findByUUID_G(String uuid, long groupId)
1462                    throws NoSuchEntryException, SystemException {
1463                    BookmarksEntry bookmarksEntry = fetchByUUID_G(uuid, groupId);
1464    
1465                    if (bookmarksEntry == null) {
1466                            StringBundler msg = new StringBundler(6);
1467    
1468                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1469    
1470                            msg.append("uuid=");
1471                            msg.append(uuid);
1472    
1473                            msg.append(", groupId=");
1474                            msg.append(groupId);
1475    
1476                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1477    
1478                            if (_log.isWarnEnabled()) {
1479                                    _log.warn(msg.toString());
1480                            }
1481    
1482                            throw new NoSuchEntryException(msg.toString());
1483                    }
1484    
1485                    return bookmarksEntry;
1486            }
1487    
1488            /**
1489             * 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.
1490             *
1491             * @param uuid the uuid
1492             * @param groupId the group ID
1493             * @return the matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
1494             * @throws SystemException if a system exception occurred
1495             */
1496            public BookmarksEntry fetchByUUID_G(String uuid, long groupId)
1497                    throws SystemException {
1498                    return fetchByUUID_G(uuid, groupId, true);
1499            }
1500    
1501            /**
1502             * 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.
1503             *
1504             * @param uuid the uuid
1505             * @param groupId the group ID
1506             * @param retrieveFromCache whether to use the finder cache
1507             * @return the matching bookmarks entry, or <code>null</code> if a matching bookmarks entry could not be found
1508             * @throws SystemException if a system exception occurred
1509             */
1510            public BookmarksEntry fetchByUUID_G(String uuid, long groupId,
1511                    boolean retrieveFromCache) throws SystemException {
1512                    Object[] finderArgs = new Object[] { uuid, groupId };
1513    
1514                    Object result = null;
1515    
1516                    if (retrieveFromCache) {
1517                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
1518                                            finderArgs, this);
1519                    }
1520    
1521                    if (result instanceof BookmarksEntry) {
1522                            BookmarksEntry bookmarksEntry = (BookmarksEntry)result;
1523    
1524                            if (!Validator.equals(uuid, bookmarksEntry.getUuid()) ||
1525                                            (groupId != bookmarksEntry.getGroupId())) {
1526                                    result = null;
1527                            }
1528                    }
1529    
1530                    if (result == null) {
1531                            StringBundler query = new StringBundler(4);
1532    
1533                            query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
1534    
1535                            if (uuid == null) {
1536                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1537                            }
1538                            else {
1539                                    if (uuid.equals(StringPool.BLANK)) {
1540                                            query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1541                                    }
1542                                    else {
1543                                            query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1544                                    }
1545                            }
1546    
1547                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1548    
1549                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
1550    
1551                            String sql = query.toString();
1552    
1553                            Session session = null;
1554    
1555                            try {
1556                                    session = openSession();
1557    
1558                                    Query q = session.createQuery(sql);
1559    
1560                                    QueryPos qPos = QueryPos.getInstance(q);
1561    
1562                                    if (uuid != null) {
1563                                            qPos.add(uuid);
1564                                    }
1565    
1566                                    qPos.add(groupId);
1567    
1568                                    List<BookmarksEntry> list = q.list();
1569    
1570                                    result = list;
1571    
1572                                    BookmarksEntry bookmarksEntry = null;
1573    
1574                                    if (list.isEmpty()) {
1575                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1576                                                    finderArgs, list);
1577                                    }
1578                                    else {
1579                                            bookmarksEntry = list.get(0);
1580    
1581                                            cacheResult(bookmarksEntry);
1582    
1583                                            if ((bookmarksEntry.getUuid() == null) ||
1584                                                            !bookmarksEntry.getUuid().equals(uuid) ||
1585                                                            (bookmarksEntry.getGroupId() != groupId)) {
1586                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1587                                                            finderArgs, bookmarksEntry);
1588                                            }
1589                                    }
1590    
1591                                    return bookmarksEntry;
1592                            }
1593                            catch (Exception e) {
1594                                    throw processException(e);
1595                            }
1596                            finally {
1597                                    if (result == null) {
1598                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
1599                                                    finderArgs);
1600                                    }
1601    
1602                                    closeSession(session);
1603                            }
1604                    }
1605                    else {
1606                            if (result instanceof List<?>) {
1607                                    return null;
1608                            }
1609                            else {
1610                                    return (BookmarksEntry)result;
1611                            }
1612                    }
1613            }
1614    
1615            /**
1616             * Returns all the bookmarks entries where groupId = &#63;.
1617             *
1618             * @param groupId the group ID
1619             * @return the matching bookmarks entries
1620             * @throws SystemException if a system exception occurred
1621             */
1622            public List<BookmarksEntry> findByGroupId(long groupId)
1623                    throws SystemException {
1624                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1625            }
1626    
1627            /**
1628             * Returns a range of all the bookmarks entries where groupId = &#63;.
1629             *
1630             * <p>
1631             * 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.
1632             * </p>
1633             *
1634             * @param groupId the group ID
1635             * @param start the lower bound of the range of bookmarks entries
1636             * @param end the upper bound of the range of bookmarks entries (not inclusive)
1637             * @return the range of matching bookmarks entries
1638             * @throws SystemException if a system exception occurred
1639             */
1640            public List<BookmarksEntry> findByGroupId(long groupId, int start, int end)
1641                    throws SystemException {
1642                    return findByGroupId(groupId, start, end, null);
1643            }
1644    
1645            /**
1646             * Returns an ordered range of all the bookmarks entries where groupId = &#63;.
1647             *
1648             * <p>
1649             * 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.
1650             * </p>
1651             *
1652             * @param groupId the group ID
1653             * @param start the lower bound of the range of bookmarks entries
1654             * @param end the upper bound of the range of bookmarks entries (not inclusive)
1655             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1656             * @return the ordered range of matching bookmarks entries
1657             * @throws SystemException if a system exception occurred
1658             */
1659            public List<BookmarksEntry> findByGroupId(long groupId, int start, int end,
1660                    OrderByComparator orderByComparator) throws SystemException {
1661                    FinderPath finderPath = null;
1662                    Object[] finderArgs = null;
1663    
1664                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1665                                    (orderByComparator == null)) {
1666                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1667                            finderArgs = new Object[] { groupId };
1668                    }
1669                    else {
1670                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1671                            finderArgs = new Object[] { groupId, start, end, orderByComparator };
1672                    }
1673    
1674                    List<BookmarksEntry> list = (List<BookmarksEntry>)FinderCacheUtil.getResult(finderPath,
1675                                    finderArgs, this);
1676    
1677                    if ((list != null) && !list.isEmpty()) {
1678                            for (BookmarksEntry bookmarksEntry : list) {
1679                                    if ((groupId != bookmarksEntry.getGroupId())) {
1680                                            list = null;
1681    
1682                                            break;
1683                                    }
1684                            }
1685                    }
1686    
1687                    if (list == null) {
1688                            StringBundler query = null;
1689    
1690                            if (orderByComparator != null) {
1691                                    query = new StringBundler(3 +
1692                                                    (orderByComparator.getOrderByFields().length * 3));
1693                            }
1694                            else {
1695                                    query = new StringBundler(3);
1696                            }
1697    
1698                            query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
1699    
1700                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1701    
1702                            if (orderByComparator != null) {
1703                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1704                                            orderByComparator);
1705                            }
1706    
1707                            else {
1708                                    query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
1709                            }
1710    
1711                            String sql = query.toString();
1712    
1713                            Session session = null;
1714    
1715                            try {
1716                                    session = openSession();
1717    
1718                                    Query q = session.createQuery(sql);
1719    
1720                                    QueryPos qPos = QueryPos.getInstance(q);
1721    
1722                                    qPos.add(groupId);
1723    
1724                                    list = (List<BookmarksEntry>)QueryUtil.list(q, getDialect(),
1725                                                    start, end);
1726                            }
1727                            catch (Exception e) {
1728                                    throw processException(e);
1729                            }
1730                            finally {
1731                                    if (list == null) {
1732                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1733                                    }
1734                                    else {
1735                                            cacheResult(list);
1736    
1737                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1738                                    }
1739    
1740                                    closeSession(session);
1741                            }
1742                    }
1743    
1744                    return list;
1745            }
1746    
1747            /**
1748             * Returns the first bookmarks entry in the ordered set where groupId = &#63;.
1749             *
1750             * <p>
1751             * 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.
1752             * </p>
1753             *
1754             * @param groupId the group ID
1755             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1756             * @return the first matching bookmarks entry
1757             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
1758             * @throws SystemException if a system exception occurred
1759             */
1760            public BookmarksEntry findByGroupId_First(long groupId,
1761                    OrderByComparator orderByComparator)
1762                    throws NoSuchEntryException, SystemException {
1763                    List<BookmarksEntry> list = findByGroupId(groupId, 0, 1,
1764                                    orderByComparator);
1765    
1766                    if (list.isEmpty()) {
1767                            StringBundler msg = new StringBundler(4);
1768    
1769                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1770    
1771                            msg.append("groupId=");
1772                            msg.append(groupId);
1773    
1774                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1775    
1776                            throw new NoSuchEntryException(msg.toString());
1777                    }
1778                    else {
1779                            return list.get(0);
1780                    }
1781            }
1782    
1783            /**
1784             * Returns the last bookmarks entry in the ordered set where groupId = &#63;.
1785             *
1786             * <p>
1787             * 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.
1788             * </p>
1789             *
1790             * @param groupId the group ID
1791             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1792             * @return the last matching bookmarks entry
1793             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
1794             * @throws SystemException if a system exception occurred
1795             */
1796            public BookmarksEntry findByGroupId_Last(long groupId,
1797                    OrderByComparator orderByComparator)
1798                    throws NoSuchEntryException, SystemException {
1799                    int count = countByGroupId(groupId);
1800    
1801                    List<BookmarksEntry> list = findByGroupId(groupId, count - 1, count,
1802                                    orderByComparator);
1803    
1804                    if (list.isEmpty()) {
1805                            StringBundler msg = new StringBundler(4);
1806    
1807                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1808    
1809                            msg.append("groupId=");
1810                            msg.append(groupId);
1811    
1812                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1813    
1814                            throw new NoSuchEntryException(msg.toString());
1815                    }
1816                    else {
1817                            return list.get(0);
1818                    }
1819            }
1820    
1821            /**
1822             * Returns the bookmarks entries before and after the current bookmarks entry in the ordered set where groupId = &#63;.
1823             *
1824             * <p>
1825             * 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.
1826             * </p>
1827             *
1828             * @param entryId the primary key of the current bookmarks entry
1829             * @param groupId the group ID
1830             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1831             * @return the previous, current, and next bookmarks entry
1832             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
1833             * @throws SystemException if a system exception occurred
1834             */
1835            public BookmarksEntry[] findByGroupId_PrevAndNext(long entryId,
1836                    long groupId, OrderByComparator orderByComparator)
1837                    throws NoSuchEntryException, SystemException {
1838                    BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
1839    
1840                    Session session = null;
1841    
1842                    try {
1843                            session = openSession();
1844    
1845                            BookmarksEntry[] array = new BookmarksEntryImpl[3];
1846    
1847                            array[0] = getByGroupId_PrevAndNext(session, bookmarksEntry,
1848                                            groupId, orderByComparator, true);
1849    
1850                            array[1] = bookmarksEntry;
1851    
1852                            array[2] = getByGroupId_PrevAndNext(session, bookmarksEntry,
1853                                            groupId, orderByComparator, false);
1854    
1855                            return array;
1856                    }
1857                    catch (Exception e) {
1858                            throw processException(e);
1859                    }
1860                    finally {
1861                            closeSession(session);
1862                    }
1863            }
1864    
1865            protected BookmarksEntry getByGroupId_PrevAndNext(Session session,
1866                    BookmarksEntry bookmarksEntry, long groupId,
1867                    OrderByComparator orderByComparator, boolean previous) {
1868                    StringBundler query = null;
1869    
1870                    if (orderByComparator != null) {
1871                            query = new StringBundler(6 +
1872                                            (orderByComparator.getOrderByFields().length * 6));
1873                    }
1874                    else {
1875                            query = new StringBundler(3);
1876                    }
1877    
1878                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
1879    
1880                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1881    
1882                    if (orderByComparator != null) {
1883                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1884    
1885                            if (orderByConditionFields.length > 0) {
1886                                    query.append(WHERE_AND);
1887                            }
1888    
1889                            for (int i = 0; i < orderByConditionFields.length; i++) {
1890                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1891                                    query.append(orderByConditionFields[i]);
1892    
1893                                    if ((i + 1) < orderByConditionFields.length) {
1894                                            if (orderByComparator.isAscending() ^ previous) {
1895                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1896                                            }
1897                                            else {
1898                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1899                                            }
1900                                    }
1901                                    else {
1902                                            if (orderByComparator.isAscending() ^ previous) {
1903                                                    query.append(WHERE_GREATER_THAN);
1904                                            }
1905                                            else {
1906                                                    query.append(WHERE_LESSER_THAN);
1907                                            }
1908                                    }
1909                            }
1910    
1911                            query.append(ORDER_BY_CLAUSE);
1912    
1913                            String[] orderByFields = orderByComparator.getOrderByFields();
1914    
1915                            for (int i = 0; i < orderByFields.length; i++) {
1916                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1917                                    query.append(orderByFields[i]);
1918    
1919                                    if ((i + 1) < orderByFields.length) {
1920                                            if (orderByComparator.isAscending() ^ previous) {
1921                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1922                                            }
1923                                            else {
1924                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1925                                            }
1926                                    }
1927                                    else {
1928                                            if (orderByComparator.isAscending() ^ previous) {
1929                                                    query.append(ORDER_BY_ASC);
1930                                            }
1931                                            else {
1932                                                    query.append(ORDER_BY_DESC);
1933                                            }
1934                                    }
1935                            }
1936                    }
1937    
1938                    else {
1939                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
1940                    }
1941    
1942                    String sql = query.toString();
1943    
1944                    Query q = session.createQuery(sql);
1945    
1946                    q.setFirstResult(0);
1947                    q.setMaxResults(2);
1948    
1949                    QueryPos qPos = QueryPos.getInstance(q);
1950    
1951                    qPos.add(groupId);
1952    
1953                    if (orderByComparator != null) {
1954                            Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry);
1955    
1956                            for (Object value : values) {
1957                                    qPos.add(value);
1958                            }
1959                    }
1960    
1961                    List<BookmarksEntry> list = q.list();
1962    
1963                    if (list.size() == 2) {
1964                            return list.get(1);
1965                    }
1966                    else {
1967                            return null;
1968                    }
1969            }
1970    
1971            /**
1972             * Returns all the bookmarks entries that the user has permission to view where groupId = &#63;.
1973             *
1974             * @param groupId the group ID
1975             * @return the matching bookmarks entries that the user has permission to view
1976             * @throws SystemException if a system exception occurred
1977             */
1978            public List<BookmarksEntry> filterFindByGroupId(long groupId)
1979                    throws SystemException {
1980                    return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1981                            QueryUtil.ALL_POS, null);
1982            }
1983    
1984            /**
1985             * Returns a range of all the bookmarks entries that the user has permission to view where groupId = &#63;.
1986             *
1987             * <p>
1988             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1989             * </p>
1990             *
1991             * @param groupId the group ID
1992             * @param start the lower bound of the range of bookmarks entries
1993             * @param end the upper bound of the range of bookmarks entries (not inclusive)
1994             * @return the range of matching bookmarks entries that the user has permission to view
1995             * @throws SystemException if a system exception occurred
1996             */
1997            public List<BookmarksEntry> filterFindByGroupId(long groupId, int start,
1998                    int end) throws SystemException {
1999                    return filterFindByGroupId(groupId, start, end, null);
2000            }
2001    
2002            /**
2003             * Returns an ordered range of all the bookmarks entries that the user has permissions to view where groupId = &#63;.
2004             *
2005             * <p>
2006             * 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.
2007             * </p>
2008             *
2009             * @param groupId the group ID
2010             * @param start the lower bound of the range of bookmarks entries
2011             * @param end the upper bound of the range of bookmarks entries (not inclusive)
2012             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2013             * @return the ordered range of matching bookmarks entries that the user has permission to view
2014             * @throws SystemException if a system exception occurred
2015             */
2016            public List<BookmarksEntry> filterFindByGroupId(long groupId, int start,
2017                    int end, OrderByComparator orderByComparator) throws SystemException {
2018                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2019                            return findByGroupId(groupId, start, end, orderByComparator);
2020                    }
2021    
2022                    StringBundler query = null;
2023    
2024                    if (orderByComparator != null) {
2025                            query = new StringBundler(3 +
2026                                            (orderByComparator.getOrderByFields().length * 3));
2027                    }
2028                    else {
2029                            query = new StringBundler(3);
2030                    }
2031    
2032                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
2033    
2034                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2035    
2036                    if (orderByComparator != null) {
2037                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2038                                    orderByComparator);
2039                    }
2040    
2041                    else {
2042                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
2043                    }
2044    
2045                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2046                                    BookmarksEntry.class.getName(),
2047                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
2048                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
2049    
2050                    Session session = null;
2051    
2052                    try {
2053                            session = openSession();
2054    
2055                            Query q = session.createQuery(sql);
2056    
2057                            QueryPos qPos = QueryPos.getInstance(q);
2058    
2059                            qPos.add(groupId);
2060    
2061                            return (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start,
2062                                    end);
2063                    }
2064                    catch (Exception e) {
2065                            throw processException(e);
2066                    }
2067                    finally {
2068                            closeSession(session);
2069                    }
2070            }
2071    
2072            /**
2073             * 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;.
2074             *
2075             * @param entryId the primary key of the current bookmarks entry
2076             * @param groupId the group ID
2077             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2078             * @return the previous, current, and next bookmarks entry
2079             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
2080             * @throws SystemException if a system exception occurred
2081             */
2082            public BookmarksEntry[] filterFindByGroupId_PrevAndNext(long entryId,
2083                    long groupId, OrderByComparator orderByComparator)
2084                    throws NoSuchEntryException, SystemException {
2085                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2086                            return findByGroupId_PrevAndNext(entryId, groupId, orderByComparator);
2087                    }
2088    
2089                    BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
2090    
2091                    Session session = null;
2092    
2093                    try {
2094                            session = openSession();
2095    
2096                            BookmarksEntry[] array = new BookmarksEntryImpl[3];
2097    
2098                            array[0] = filterGetByGroupId_PrevAndNext(session, bookmarksEntry,
2099                                            groupId, orderByComparator, true);
2100    
2101                            array[1] = bookmarksEntry;
2102    
2103                            array[2] = filterGetByGroupId_PrevAndNext(session, bookmarksEntry,
2104                                            groupId, orderByComparator, false);
2105    
2106                            return array;
2107                    }
2108                    catch (Exception e) {
2109                            throw processException(e);
2110                    }
2111                    finally {
2112                            closeSession(session);
2113                    }
2114            }
2115    
2116            protected BookmarksEntry filterGetByGroupId_PrevAndNext(Session session,
2117                    BookmarksEntry bookmarksEntry, long groupId,
2118                    OrderByComparator orderByComparator, boolean previous) {
2119                    StringBundler query = null;
2120    
2121                    if (orderByComparator != null) {
2122                            query = new StringBundler(6 +
2123                                            (orderByComparator.getOrderByFields().length * 6));
2124                    }
2125                    else {
2126                            query = new StringBundler(3);
2127                    }
2128    
2129                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
2130    
2131                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2132    
2133                    if (orderByComparator != null) {
2134                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2135    
2136                            if (orderByConditionFields.length > 0) {
2137                                    query.append(WHERE_AND);
2138                            }
2139    
2140                            for (int i = 0; i < orderByConditionFields.length; i++) {
2141                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2142                                    query.append(orderByConditionFields[i]);
2143    
2144                                    if ((i + 1) < orderByConditionFields.length) {
2145                                            if (orderByComparator.isAscending() ^ previous) {
2146                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2147                                            }
2148                                            else {
2149                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2150                                            }
2151                                    }
2152                                    else {
2153                                            if (orderByComparator.isAscending() ^ previous) {
2154                                                    query.append(WHERE_GREATER_THAN);
2155                                            }
2156                                            else {
2157                                                    query.append(WHERE_LESSER_THAN);
2158                                            }
2159                                    }
2160                            }
2161    
2162                            query.append(ORDER_BY_CLAUSE);
2163    
2164                            String[] orderByFields = orderByComparator.getOrderByFields();
2165    
2166                            for (int i = 0; i < orderByFields.length; i++) {
2167                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2168                                    query.append(orderByFields[i]);
2169    
2170                                    if ((i + 1) < orderByFields.length) {
2171                                            if (orderByComparator.isAscending() ^ previous) {
2172                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2173                                            }
2174                                            else {
2175                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2176                                            }
2177                                    }
2178                                    else {
2179                                            if (orderByComparator.isAscending() ^ previous) {
2180                                                    query.append(ORDER_BY_ASC);
2181                                            }
2182                                            else {
2183                                                    query.append(ORDER_BY_DESC);
2184                                            }
2185                                    }
2186                            }
2187                    }
2188    
2189                    else {
2190                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
2191                    }
2192    
2193                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2194                                    BookmarksEntry.class.getName(),
2195                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
2196                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
2197    
2198                    Query q = session.createQuery(sql);
2199    
2200                    q.setFirstResult(0);
2201                    q.setMaxResults(2);
2202    
2203                    QueryPos qPos = QueryPos.getInstance(q);
2204    
2205                    qPos.add(groupId);
2206    
2207                    if (orderByComparator != null) {
2208                            Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry);
2209    
2210                            for (Object value : values) {
2211                                    qPos.add(value);
2212                            }
2213                    }
2214    
2215                    List<BookmarksEntry> list = q.list();
2216    
2217                    if (list.size() == 2) {
2218                            return list.get(1);
2219                    }
2220                    else {
2221                            return null;
2222                    }
2223            }
2224    
2225            /**
2226             * Returns all the bookmarks entries where groupId = &#63; and userId = &#63;.
2227             *
2228             * @param groupId the group ID
2229             * @param userId the user ID
2230             * @return the matching bookmarks entries
2231             * @throws SystemException if a system exception occurred
2232             */
2233            public List<BookmarksEntry> findByG_U(long groupId, long userId)
2234                    throws SystemException {
2235                    return findByG_U(groupId, userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2236                            null);
2237            }
2238    
2239            /**
2240             * Returns a range of all the bookmarks entries where groupId = &#63; and userId = &#63;.
2241             *
2242             * <p>
2243             * 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.
2244             * </p>
2245             *
2246             * @param groupId the group ID
2247             * @param userId the user ID
2248             * @param start the lower bound of the range of bookmarks entries
2249             * @param end the upper bound of the range of bookmarks entries (not inclusive)
2250             * @return the range of matching bookmarks entries
2251             * @throws SystemException if a system exception occurred
2252             */
2253            public List<BookmarksEntry> findByG_U(long groupId, long userId, int start,
2254                    int end) throws SystemException {
2255                    return findByG_U(groupId, userId, start, end, null);
2256            }
2257    
2258            /**
2259             * Returns an ordered range of all the bookmarks entries where groupId = &#63; and userId = &#63;.
2260             *
2261             * <p>
2262             * 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.
2263             * </p>
2264             *
2265             * @param groupId the group ID
2266             * @param userId the user ID
2267             * @param start the lower bound of the range of bookmarks entries
2268             * @param end the upper bound of the range of bookmarks entries (not inclusive)
2269             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2270             * @return the ordered range of matching bookmarks entries
2271             * @throws SystemException if a system exception occurred
2272             */
2273            public List<BookmarksEntry> findByG_U(long groupId, long userId, int start,
2274                    int end, OrderByComparator orderByComparator) throws SystemException {
2275                    FinderPath finderPath = null;
2276                    Object[] finderArgs = null;
2277    
2278                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2279                                    (orderByComparator == null)) {
2280                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U;
2281                            finderArgs = new Object[] { groupId, userId };
2282                    }
2283                    else {
2284                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U;
2285                            finderArgs = new Object[] {
2286                                            groupId, userId,
2287                                            
2288                                            start, end, orderByComparator
2289                                    };
2290                    }
2291    
2292                    List<BookmarksEntry> list = (List<BookmarksEntry>)FinderCacheUtil.getResult(finderPath,
2293                                    finderArgs, this);
2294    
2295                    if ((list != null) && !list.isEmpty()) {
2296                            for (BookmarksEntry bookmarksEntry : list) {
2297                                    if ((groupId != bookmarksEntry.getGroupId()) ||
2298                                                    (userId != bookmarksEntry.getUserId())) {
2299                                            list = null;
2300    
2301                                            break;
2302                                    }
2303                            }
2304                    }
2305    
2306                    if (list == null) {
2307                            StringBundler query = null;
2308    
2309                            if (orderByComparator != null) {
2310                                    query = new StringBundler(4 +
2311                                                    (orderByComparator.getOrderByFields().length * 3));
2312                            }
2313                            else {
2314                                    query = new StringBundler(4);
2315                            }
2316    
2317                            query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
2318    
2319                            query.append(_FINDER_COLUMN_G_U_GROUPID_2);
2320    
2321                            query.append(_FINDER_COLUMN_G_U_USERID_2);
2322    
2323                            if (orderByComparator != null) {
2324                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2325                                            orderByComparator);
2326                            }
2327    
2328                            else {
2329                                    query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
2330                            }
2331    
2332                            String sql = query.toString();
2333    
2334                            Session session = null;
2335    
2336                            try {
2337                                    session = openSession();
2338    
2339                                    Query q = session.createQuery(sql);
2340    
2341                                    QueryPos qPos = QueryPos.getInstance(q);
2342    
2343                                    qPos.add(groupId);
2344    
2345                                    qPos.add(userId);
2346    
2347                                    list = (List<BookmarksEntry>)QueryUtil.list(q, getDialect(),
2348                                                    start, end);
2349                            }
2350                            catch (Exception e) {
2351                                    throw processException(e);
2352                            }
2353                            finally {
2354                                    if (list == null) {
2355                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
2356                                    }
2357                                    else {
2358                                            cacheResult(list);
2359    
2360                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
2361                                    }
2362    
2363                                    closeSession(session);
2364                            }
2365                    }
2366    
2367                    return list;
2368            }
2369    
2370            /**
2371             * Returns the first bookmarks entry in the ordered set where groupId = &#63; and userId = &#63;.
2372             *
2373             * <p>
2374             * 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.
2375             * </p>
2376             *
2377             * @param groupId the group ID
2378             * @param userId the user ID
2379             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2380             * @return the first matching bookmarks entry
2381             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
2382             * @throws SystemException if a system exception occurred
2383             */
2384            public BookmarksEntry findByG_U_First(long groupId, long userId,
2385                    OrderByComparator orderByComparator)
2386                    throws NoSuchEntryException, SystemException {
2387                    List<BookmarksEntry> list = findByG_U(groupId, userId, 0, 1,
2388                                    orderByComparator);
2389    
2390                    if (list.isEmpty()) {
2391                            StringBundler msg = new StringBundler(6);
2392    
2393                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2394    
2395                            msg.append("groupId=");
2396                            msg.append(groupId);
2397    
2398                            msg.append(", userId=");
2399                            msg.append(userId);
2400    
2401                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2402    
2403                            throw new NoSuchEntryException(msg.toString());
2404                    }
2405                    else {
2406                            return list.get(0);
2407                    }
2408            }
2409    
2410            /**
2411             * Returns the last bookmarks entry in the ordered set where groupId = &#63; and userId = &#63;.
2412             *
2413             * <p>
2414             * 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.
2415             * </p>
2416             *
2417             * @param groupId the group ID
2418             * @param userId the user ID
2419             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2420             * @return the last matching bookmarks entry
2421             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
2422             * @throws SystemException if a system exception occurred
2423             */
2424            public BookmarksEntry findByG_U_Last(long groupId, long userId,
2425                    OrderByComparator orderByComparator)
2426                    throws NoSuchEntryException, SystemException {
2427                    int count = countByG_U(groupId, userId);
2428    
2429                    List<BookmarksEntry> list = findByG_U(groupId, userId, count - 1,
2430                                    count, orderByComparator);
2431    
2432                    if (list.isEmpty()) {
2433                            StringBundler msg = new StringBundler(6);
2434    
2435                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2436    
2437                            msg.append("groupId=");
2438                            msg.append(groupId);
2439    
2440                            msg.append(", userId=");
2441                            msg.append(userId);
2442    
2443                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2444    
2445                            throw new NoSuchEntryException(msg.toString());
2446                    }
2447                    else {
2448                            return list.get(0);
2449                    }
2450            }
2451    
2452            /**
2453             * Returns the bookmarks entries before and after the current bookmarks entry in the ordered set where groupId = &#63; and userId = &#63;.
2454             *
2455             * <p>
2456             * 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.
2457             * </p>
2458             *
2459             * @param entryId the primary key of the current bookmarks entry
2460             * @param groupId the group ID
2461             * @param userId the user ID
2462             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2463             * @return the previous, current, and next bookmarks entry
2464             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
2465             * @throws SystemException if a system exception occurred
2466             */
2467            public BookmarksEntry[] findByG_U_PrevAndNext(long entryId, long groupId,
2468                    long userId, OrderByComparator orderByComparator)
2469                    throws NoSuchEntryException, SystemException {
2470                    BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
2471    
2472                    Session session = null;
2473    
2474                    try {
2475                            session = openSession();
2476    
2477                            BookmarksEntry[] array = new BookmarksEntryImpl[3];
2478    
2479                            array[0] = getByG_U_PrevAndNext(session, bookmarksEntry, groupId,
2480                                            userId, orderByComparator, true);
2481    
2482                            array[1] = bookmarksEntry;
2483    
2484                            array[2] = getByG_U_PrevAndNext(session, bookmarksEntry, groupId,
2485                                            userId, orderByComparator, false);
2486    
2487                            return array;
2488                    }
2489                    catch (Exception e) {
2490                            throw processException(e);
2491                    }
2492                    finally {
2493                            closeSession(session);
2494                    }
2495            }
2496    
2497            protected BookmarksEntry getByG_U_PrevAndNext(Session session,
2498                    BookmarksEntry bookmarksEntry, long groupId, long userId,
2499                    OrderByComparator orderByComparator, boolean previous) {
2500                    StringBundler query = null;
2501    
2502                    if (orderByComparator != null) {
2503                            query = new StringBundler(6 +
2504                                            (orderByComparator.getOrderByFields().length * 6));
2505                    }
2506                    else {
2507                            query = new StringBundler(3);
2508                    }
2509    
2510                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
2511    
2512                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
2513    
2514                    query.append(_FINDER_COLUMN_G_U_USERID_2);
2515    
2516                    if (orderByComparator != null) {
2517                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2518    
2519                            if (orderByConditionFields.length > 0) {
2520                                    query.append(WHERE_AND);
2521                            }
2522    
2523                            for (int i = 0; i < orderByConditionFields.length; i++) {
2524                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2525                                    query.append(orderByConditionFields[i]);
2526    
2527                                    if ((i + 1) < orderByConditionFields.length) {
2528                                            if (orderByComparator.isAscending() ^ previous) {
2529                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2530                                            }
2531                                            else {
2532                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2533                                            }
2534                                    }
2535                                    else {
2536                                            if (orderByComparator.isAscending() ^ previous) {
2537                                                    query.append(WHERE_GREATER_THAN);
2538                                            }
2539                                            else {
2540                                                    query.append(WHERE_LESSER_THAN);
2541                                            }
2542                                    }
2543                            }
2544    
2545                            query.append(ORDER_BY_CLAUSE);
2546    
2547                            String[] orderByFields = orderByComparator.getOrderByFields();
2548    
2549                            for (int i = 0; i < orderByFields.length; i++) {
2550                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2551                                    query.append(orderByFields[i]);
2552    
2553                                    if ((i + 1) < orderByFields.length) {
2554                                            if (orderByComparator.isAscending() ^ previous) {
2555                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2556                                            }
2557                                            else {
2558                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2559                                            }
2560                                    }
2561                                    else {
2562                                            if (orderByComparator.isAscending() ^ previous) {
2563                                                    query.append(ORDER_BY_ASC);
2564                                            }
2565                                            else {
2566                                                    query.append(ORDER_BY_DESC);
2567                                            }
2568                                    }
2569                            }
2570                    }
2571    
2572                    else {
2573                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
2574                    }
2575    
2576                    String sql = query.toString();
2577    
2578                    Query q = session.createQuery(sql);
2579    
2580                    q.setFirstResult(0);
2581                    q.setMaxResults(2);
2582    
2583                    QueryPos qPos = QueryPos.getInstance(q);
2584    
2585                    qPos.add(groupId);
2586    
2587                    qPos.add(userId);
2588    
2589                    if (orderByComparator != null) {
2590                            Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry);
2591    
2592                            for (Object value : values) {
2593                                    qPos.add(value);
2594                            }
2595                    }
2596    
2597                    List<BookmarksEntry> list = q.list();
2598    
2599                    if (list.size() == 2) {
2600                            return list.get(1);
2601                    }
2602                    else {
2603                            return null;
2604                    }
2605            }
2606    
2607            /**
2608             * Returns all the bookmarks entries that the user has permission to view where groupId = &#63; and userId = &#63;.
2609             *
2610             * @param groupId the group ID
2611             * @param userId the user ID
2612             * @return the matching bookmarks entries that the user has permission to view
2613             * @throws SystemException if a system exception occurred
2614             */
2615            public List<BookmarksEntry> filterFindByG_U(long groupId, long userId)
2616                    throws SystemException {
2617                    return filterFindByG_U(groupId, userId, QueryUtil.ALL_POS,
2618                            QueryUtil.ALL_POS, null);
2619            }
2620    
2621            /**
2622             * Returns a range of all the bookmarks entries that the user has permission to view where groupId = &#63; and userId = &#63;.
2623             *
2624             * <p>
2625             * 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.
2626             * </p>
2627             *
2628             * @param groupId the group ID
2629             * @param userId the user ID
2630             * @param start the lower bound of the range of bookmarks entries
2631             * @param end the upper bound of the range of bookmarks entries (not inclusive)
2632             * @return the range of matching bookmarks entries that the user has permission to view
2633             * @throws SystemException if a system exception occurred
2634             */
2635            public List<BookmarksEntry> filterFindByG_U(long groupId, long userId,
2636                    int start, int end) throws SystemException {
2637                    return filterFindByG_U(groupId, userId, start, end, null);
2638            }
2639    
2640            /**
2641             * Returns an ordered range of all the bookmarks entries that the user has permissions to view where groupId = &#63; and userId = &#63;.
2642             *
2643             * <p>
2644             * 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.
2645             * </p>
2646             *
2647             * @param groupId the group ID
2648             * @param userId the user ID
2649             * @param start the lower bound of the range of bookmarks entries
2650             * @param end the upper bound of the range of bookmarks entries (not inclusive)
2651             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2652             * @return the ordered range of matching bookmarks entries that the user has permission to view
2653             * @throws SystemException if a system exception occurred
2654             */
2655            public List<BookmarksEntry> filterFindByG_U(long groupId, long userId,
2656                    int start, int end, OrderByComparator orderByComparator)
2657                    throws SystemException {
2658                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2659                            return findByG_U(groupId, userId, start, end, orderByComparator);
2660                    }
2661    
2662                    StringBundler query = null;
2663    
2664                    if (orderByComparator != null) {
2665                            query = new StringBundler(4 +
2666                                            (orderByComparator.getOrderByFields().length * 3));
2667                    }
2668                    else {
2669                            query = new StringBundler(4);
2670                    }
2671    
2672                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
2673    
2674                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
2675    
2676                    query.append(_FINDER_COLUMN_G_U_USERID_2);
2677    
2678                    if (orderByComparator != null) {
2679                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2680                                    orderByComparator);
2681                    }
2682    
2683                    else {
2684                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
2685                    }
2686    
2687                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2688                                    BookmarksEntry.class.getName(),
2689                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
2690                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
2691    
2692                    Session session = null;
2693    
2694                    try {
2695                            session = openSession();
2696    
2697                            Query q = session.createQuery(sql);
2698    
2699                            QueryPos qPos = QueryPos.getInstance(q);
2700    
2701                            qPos.add(groupId);
2702    
2703                            qPos.add(userId);
2704    
2705                            return (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start,
2706                                    end);
2707                    }
2708                    catch (Exception e) {
2709                            throw processException(e);
2710                    }
2711                    finally {
2712                            closeSession(session);
2713                    }
2714            }
2715    
2716            /**
2717             * 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;.
2718             *
2719             * @param entryId the primary key of the current bookmarks entry
2720             * @param groupId the group ID
2721             * @param userId the user ID
2722             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2723             * @return the previous, current, and next bookmarks entry
2724             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
2725             * @throws SystemException if a system exception occurred
2726             */
2727            public BookmarksEntry[] filterFindByG_U_PrevAndNext(long entryId,
2728                    long groupId, long userId, OrderByComparator orderByComparator)
2729                    throws NoSuchEntryException, SystemException {
2730                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2731                            return findByG_U_PrevAndNext(entryId, groupId, userId,
2732                                    orderByComparator);
2733                    }
2734    
2735                    BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
2736    
2737                    Session session = null;
2738    
2739                    try {
2740                            session = openSession();
2741    
2742                            BookmarksEntry[] array = new BookmarksEntryImpl[3];
2743    
2744                            array[0] = filterGetByG_U_PrevAndNext(session, bookmarksEntry,
2745                                            groupId, userId, orderByComparator, true);
2746    
2747                            array[1] = bookmarksEntry;
2748    
2749                            array[2] = filterGetByG_U_PrevAndNext(session, bookmarksEntry,
2750                                            groupId, userId, orderByComparator, false);
2751    
2752                            return array;
2753                    }
2754                    catch (Exception e) {
2755                            throw processException(e);
2756                    }
2757                    finally {
2758                            closeSession(session);
2759                    }
2760            }
2761    
2762            protected BookmarksEntry filterGetByG_U_PrevAndNext(Session session,
2763                    BookmarksEntry bookmarksEntry, long groupId, long userId,
2764                    OrderByComparator orderByComparator, boolean previous) {
2765                    StringBundler query = null;
2766    
2767                    if (orderByComparator != null) {
2768                            query = new StringBundler(6 +
2769                                            (orderByComparator.getOrderByFields().length * 6));
2770                    }
2771                    else {
2772                            query = new StringBundler(3);
2773                    }
2774    
2775                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
2776    
2777                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
2778    
2779                    query.append(_FINDER_COLUMN_G_U_USERID_2);
2780    
2781                    if (orderByComparator != null) {
2782                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2783    
2784                            if (orderByConditionFields.length > 0) {
2785                                    query.append(WHERE_AND);
2786                            }
2787    
2788                            for (int i = 0; i < orderByConditionFields.length; i++) {
2789                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2790                                    query.append(orderByConditionFields[i]);
2791    
2792                                    if ((i + 1) < orderByConditionFields.length) {
2793                                            if (orderByComparator.isAscending() ^ previous) {
2794                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2795                                            }
2796                                            else {
2797                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2798                                            }
2799                                    }
2800                                    else {
2801                                            if (orderByComparator.isAscending() ^ previous) {
2802                                                    query.append(WHERE_GREATER_THAN);
2803                                            }
2804                                            else {
2805                                                    query.append(WHERE_LESSER_THAN);
2806                                            }
2807                                    }
2808                            }
2809    
2810                            query.append(ORDER_BY_CLAUSE);
2811    
2812                            String[] orderByFields = orderByComparator.getOrderByFields();
2813    
2814                            for (int i = 0; i < orderByFields.length; i++) {
2815                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2816                                    query.append(orderByFields[i]);
2817    
2818                                    if ((i + 1) < orderByFields.length) {
2819                                            if (orderByComparator.isAscending() ^ previous) {
2820                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2821                                            }
2822                                            else {
2823                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2824                                            }
2825                                    }
2826                                    else {
2827                                            if (orderByComparator.isAscending() ^ previous) {
2828                                                    query.append(ORDER_BY_ASC);
2829                                            }
2830                                            else {
2831                                                    query.append(ORDER_BY_DESC);
2832                                            }
2833                                    }
2834                            }
2835                    }
2836    
2837                    else {
2838                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
2839                    }
2840    
2841                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2842                                    BookmarksEntry.class.getName(),
2843                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
2844                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
2845    
2846                    Query q = session.createQuery(sql);
2847    
2848                    q.setFirstResult(0);
2849                    q.setMaxResults(2);
2850    
2851                    QueryPos qPos = QueryPos.getInstance(q);
2852    
2853                    qPos.add(groupId);
2854    
2855                    qPos.add(userId);
2856    
2857                    if (orderByComparator != null) {
2858                            Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry);
2859    
2860                            for (Object value : values) {
2861                                    qPos.add(value);
2862                            }
2863                    }
2864    
2865                    List<BookmarksEntry> list = q.list();
2866    
2867                    if (list.size() == 2) {
2868                            return list.get(1);
2869                    }
2870                    else {
2871                            return null;
2872                    }
2873            }
2874    
2875            /**
2876             * Returns all the bookmarks entries where groupId = &#63; and folderId = &#63;.
2877             *
2878             * @param groupId the group ID
2879             * @param folderId the folder ID
2880             * @return the matching bookmarks entries
2881             * @throws SystemException if a system exception occurred
2882             */
2883            public List<BookmarksEntry> findByG_F(long groupId, long folderId)
2884                    throws SystemException {
2885                    return findByG_F(groupId, folderId, QueryUtil.ALL_POS,
2886                            QueryUtil.ALL_POS, null);
2887            }
2888    
2889            /**
2890             * Returns a range of all the bookmarks entries where groupId = &#63; and folderId = &#63;.
2891             *
2892             * <p>
2893             * 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.
2894             * </p>
2895             *
2896             * @param groupId the group ID
2897             * @param folderId the folder ID
2898             * @param start the lower bound of the range of bookmarks entries
2899             * @param end the upper bound of the range of bookmarks entries (not inclusive)
2900             * @return the range of matching bookmarks entries
2901             * @throws SystemException if a system exception occurred
2902             */
2903            public List<BookmarksEntry> findByG_F(long groupId, long folderId,
2904                    int start, int end) throws SystemException {
2905                    return findByG_F(groupId, folderId, start, end, null);
2906            }
2907    
2908            /**
2909             * Returns an ordered range of all the bookmarks entries where groupId = &#63; and folderId = &#63;.
2910             *
2911             * <p>
2912             * 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.
2913             * </p>
2914             *
2915             * @param groupId the group ID
2916             * @param folderId the folder ID
2917             * @param start the lower bound of the range of bookmarks entries
2918             * @param end the upper bound of the range of bookmarks entries (not inclusive)
2919             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2920             * @return the ordered range of matching bookmarks entries
2921             * @throws SystemException if a system exception occurred
2922             */
2923            public List<BookmarksEntry> findByG_F(long groupId, long folderId,
2924                    int start, int end, OrderByComparator orderByComparator)
2925                    throws SystemException {
2926                    FinderPath finderPath = null;
2927                    Object[] finderArgs = null;
2928    
2929                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2930                                    (orderByComparator == null)) {
2931                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_F;
2932                            finderArgs = new Object[] { groupId, folderId };
2933                    }
2934                    else {
2935                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F;
2936                            finderArgs = new Object[] {
2937                                            groupId, folderId,
2938                                            
2939                                            start, end, orderByComparator
2940                                    };
2941                    }
2942    
2943                    List<BookmarksEntry> list = (List<BookmarksEntry>)FinderCacheUtil.getResult(finderPath,
2944                                    finderArgs, this);
2945    
2946                    if ((list != null) && !list.isEmpty()) {
2947                            for (BookmarksEntry bookmarksEntry : list) {
2948                                    if ((groupId != bookmarksEntry.getGroupId()) ||
2949                                                    (folderId != bookmarksEntry.getFolderId())) {
2950                                            list = null;
2951    
2952                                            break;
2953                                    }
2954                            }
2955                    }
2956    
2957                    if (list == null) {
2958                            StringBundler query = null;
2959    
2960                            if (orderByComparator != null) {
2961                                    query = new StringBundler(4 +
2962                                                    (orderByComparator.getOrderByFields().length * 3));
2963                            }
2964                            else {
2965                                    query = new StringBundler(4);
2966                            }
2967    
2968                            query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
2969    
2970                            query.append(_FINDER_COLUMN_G_F_GROUPID_2);
2971    
2972                            query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
2973    
2974                            if (orderByComparator != null) {
2975                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2976                                            orderByComparator);
2977                            }
2978    
2979                            else {
2980                                    query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
2981                            }
2982    
2983                            String sql = query.toString();
2984    
2985                            Session session = null;
2986    
2987                            try {
2988                                    session = openSession();
2989    
2990                                    Query q = session.createQuery(sql);
2991    
2992                                    QueryPos qPos = QueryPos.getInstance(q);
2993    
2994                                    qPos.add(groupId);
2995    
2996                                    qPos.add(folderId);
2997    
2998                                    list = (List<BookmarksEntry>)QueryUtil.list(q, getDialect(),
2999                                                    start, end);
3000                            }
3001                            catch (Exception e) {
3002                                    throw processException(e);
3003                            }
3004                            finally {
3005                                    if (list == null) {
3006                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
3007                                    }
3008                                    else {
3009                                            cacheResult(list);
3010    
3011                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
3012                                    }
3013    
3014                                    closeSession(session);
3015                            }
3016                    }
3017    
3018                    return list;
3019            }
3020    
3021            /**
3022             * Returns the first bookmarks entry in the ordered set where groupId = &#63; and folderId = &#63;.
3023             *
3024             * <p>
3025             * 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.
3026             * </p>
3027             *
3028             * @param groupId the group ID
3029             * @param folderId the folder ID
3030             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3031             * @return the first matching bookmarks entry
3032             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
3033             * @throws SystemException if a system exception occurred
3034             */
3035            public BookmarksEntry findByG_F_First(long groupId, long folderId,
3036                    OrderByComparator orderByComparator)
3037                    throws NoSuchEntryException, SystemException {
3038                    List<BookmarksEntry> list = findByG_F(groupId, folderId, 0, 1,
3039                                    orderByComparator);
3040    
3041                    if (list.isEmpty()) {
3042                            StringBundler msg = new StringBundler(6);
3043    
3044                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3045    
3046                            msg.append("groupId=");
3047                            msg.append(groupId);
3048    
3049                            msg.append(", folderId=");
3050                            msg.append(folderId);
3051    
3052                            msg.append(StringPool.CLOSE_CURLY_BRACE);
3053    
3054                            throw new NoSuchEntryException(msg.toString());
3055                    }
3056                    else {
3057                            return list.get(0);
3058                    }
3059            }
3060    
3061            /**
3062             * Returns the last bookmarks entry in the ordered set where groupId = &#63; and folderId = &#63;.
3063             *
3064             * <p>
3065             * 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.
3066             * </p>
3067             *
3068             * @param groupId the group ID
3069             * @param folderId the folder ID
3070             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3071             * @return the last matching bookmarks entry
3072             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a matching bookmarks entry could not be found
3073             * @throws SystemException if a system exception occurred
3074             */
3075            public BookmarksEntry findByG_F_Last(long groupId, long folderId,
3076                    OrderByComparator orderByComparator)
3077                    throws NoSuchEntryException, SystemException {
3078                    int count = countByG_F(groupId, folderId);
3079    
3080                    List<BookmarksEntry> list = findByG_F(groupId, folderId, count - 1,
3081                                    count, orderByComparator);
3082    
3083                    if (list.isEmpty()) {
3084                            StringBundler msg = new StringBundler(6);
3085    
3086                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3087    
3088                            msg.append("groupId=");
3089                            msg.append(groupId);
3090    
3091                            msg.append(", folderId=");
3092                            msg.append(folderId);
3093    
3094                            msg.append(StringPool.CLOSE_CURLY_BRACE);
3095    
3096                            throw new NoSuchEntryException(msg.toString());
3097                    }
3098                    else {
3099                            return list.get(0);
3100                    }
3101            }
3102    
3103            /**
3104             * Returns the bookmarks entries before and after the current bookmarks entry in the ordered set where groupId = &#63; and folderId = &#63;.
3105             *
3106             * <p>
3107             * 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.
3108             * </p>
3109             *
3110             * @param entryId the primary key of the current bookmarks entry
3111             * @param groupId the group ID
3112             * @param folderId the folder ID
3113             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3114             * @return the previous, current, and next bookmarks entry
3115             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
3116             * @throws SystemException if a system exception occurred
3117             */
3118            public BookmarksEntry[] findByG_F_PrevAndNext(long entryId, long groupId,
3119                    long folderId, OrderByComparator orderByComparator)
3120                    throws NoSuchEntryException, SystemException {
3121                    BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
3122    
3123                    Session session = null;
3124    
3125                    try {
3126                            session = openSession();
3127    
3128                            BookmarksEntry[] array = new BookmarksEntryImpl[3];
3129    
3130                            array[0] = getByG_F_PrevAndNext(session, bookmarksEntry, groupId,
3131                                            folderId, orderByComparator, true);
3132    
3133                            array[1] = bookmarksEntry;
3134    
3135                            array[2] = getByG_F_PrevAndNext(session, bookmarksEntry, groupId,
3136                                            folderId, orderByComparator, false);
3137    
3138                            return array;
3139                    }
3140                    catch (Exception e) {
3141                            throw processException(e);
3142                    }
3143                    finally {
3144                            closeSession(session);
3145                    }
3146            }
3147    
3148            protected BookmarksEntry getByG_F_PrevAndNext(Session session,
3149                    BookmarksEntry bookmarksEntry, long groupId, long folderId,
3150                    OrderByComparator orderByComparator, boolean previous) {
3151                    StringBundler query = null;
3152    
3153                    if (orderByComparator != null) {
3154                            query = new StringBundler(6 +
3155                                            (orderByComparator.getOrderByFields().length * 6));
3156                    }
3157                    else {
3158                            query = new StringBundler(3);
3159                    }
3160    
3161                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
3162    
3163                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
3164    
3165                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
3166    
3167                    if (orderByComparator != null) {
3168                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3169    
3170                            if (orderByConditionFields.length > 0) {
3171                                    query.append(WHERE_AND);
3172                            }
3173    
3174                            for (int i = 0; i < orderByConditionFields.length; i++) {
3175                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3176                                    query.append(orderByConditionFields[i]);
3177    
3178                                    if ((i + 1) < orderByConditionFields.length) {
3179                                            if (orderByComparator.isAscending() ^ previous) {
3180                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3181                                            }
3182                                            else {
3183                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3184                                            }
3185                                    }
3186                                    else {
3187                                            if (orderByComparator.isAscending() ^ previous) {
3188                                                    query.append(WHERE_GREATER_THAN);
3189                                            }
3190                                            else {
3191                                                    query.append(WHERE_LESSER_THAN);
3192                                            }
3193                                    }
3194                            }
3195    
3196                            query.append(ORDER_BY_CLAUSE);
3197    
3198                            String[] orderByFields = orderByComparator.getOrderByFields();
3199    
3200                            for (int i = 0; i < orderByFields.length; i++) {
3201                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3202                                    query.append(orderByFields[i]);
3203    
3204                                    if ((i + 1) < orderByFields.length) {
3205                                            if (orderByComparator.isAscending() ^ previous) {
3206                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3207                                            }
3208                                            else {
3209                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3210                                            }
3211                                    }
3212                                    else {
3213                                            if (orderByComparator.isAscending() ^ previous) {
3214                                                    query.append(ORDER_BY_ASC);
3215                                            }
3216                                            else {
3217                                                    query.append(ORDER_BY_DESC);
3218                                            }
3219                                    }
3220                            }
3221                    }
3222    
3223                    else {
3224                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
3225                    }
3226    
3227                    String sql = query.toString();
3228    
3229                    Query q = session.createQuery(sql);
3230    
3231                    q.setFirstResult(0);
3232                    q.setMaxResults(2);
3233    
3234                    QueryPos qPos = QueryPos.getInstance(q);
3235    
3236                    qPos.add(groupId);
3237    
3238                    qPos.add(folderId);
3239    
3240                    if (orderByComparator != null) {
3241                            Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry);
3242    
3243                            for (Object value : values) {
3244                                    qPos.add(value);
3245                            }
3246                    }
3247    
3248                    List<BookmarksEntry> list = q.list();
3249    
3250                    if (list.size() == 2) {
3251                            return list.get(1);
3252                    }
3253                    else {
3254                            return null;
3255                    }
3256            }
3257    
3258            /**
3259             * Returns all the bookmarks entries where groupId = &#63; and folderId = any &#63;.
3260             *
3261             * <p>
3262             * 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.
3263             * </p>
3264             *
3265             * @param groupId the group ID
3266             * @param folderIds the folder IDs
3267             * @return the matching bookmarks entries
3268             * @throws SystemException if a system exception occurred
3269             */
3270            public List<BookmarksEntry> findByG_F(long groupId, long[] folderIds)
3271                    throws SystemException {
3272                    return findByG_F(groupId, folderIds, QueryUtil.ALL_POS,
3273                            QueryUtil.ALL_POS, null);
3274            }
3275    
3276            /**
3277             * Returns a range of all the bookmarks entries where groupId = &#63; and folderId = any &#63;.
3278             *
3279             * <p>
3280             * 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.
3281             * </p>
3282             *
3283             * @param groupId the group ID
3284             * @param folderIds the folder IDs
3285             * @param start the lower bound of the range of bookmarks entries
3286             * @param end the upper bound of the range of bookmarks entries (not inclusive)
3287             * @return the range of matching bookmarks entries
3288             * @throws SystemException if a system exception occurred
3289             */
3290            public List<BookmarksEntry> findByG_F(long groupId, long[] folderIds,
3291                    int start, int end) throws SystemException {
3292                    return findByG_F(groupId, folderIds, start, end, null);
3293            }
3294    
3295            /**
3296             * Returns an ordered range of all the bookmarks entries where groupId = &#63; and folderId = any &#63;.
3297             *
3298             * <p>
3299             * 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.
3300             * </p>
3301             *
3302             * @param groupId the group ID
3303             * @param folderIds the folder IDs
3304             * @param start the lower bound of the range of bookmarks entries
3305             * @param end the upper bound of the range of bookmarks entries (not inclusive)
3306             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3307             * @return the ordered range of matching bookmarks entries
3308             * @throws SystemException if a system exception occurred
3309             */
3310            public List<BookmarksEntry> findByG_F(long groupId, long[] folderIds,
3311                    int start, int end, OrderByComparator orderByComparator)
3312                    throws SystemException {
3313                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_F;
3314                    Object[] finderArgs = null;
3315    
3316                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3317                                    (orderByComparator == null)) {
3318                            finderArgs = new Object[] { groupId, StringUtil.merge(folderIds) };
3319                    }
3320                    else {
3321                            finderArgs = new Object[] {
3322                                            groupId, StringUtil.merge(folderIds),
3323                                            
3324                                            start, end, orderByComparator
3325                                    };
3326                    }
3327    
3328                    List<BookmarksEntry> list = (List<BookmarksEntry>)FinderCacheUtil.getResult(finderPath,
3329                                    finderArgs, this);
3330    
3331                    if ((list != null) && !list.isEmpty()) {
3332                            for (BookmarksEntry bookmarksEntry : list) {
3333                                    if ((groupId != bookmarksEntry.getGroupId()) ||
3334                                                    !ArrayUtil.contains(folderIds,
3335                                                            bookmarksEntry.getFolderId())) {
3336                                            list = null;
3337    
3338                                            break;
3339                                    }
3340                            }
3341                    }
3342    
3343                    if (list == null) {
3344                            StringBundler query = new StringBundler();
3345    
3346                            query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
3347    
3348                            boolean conjunctionable = false;
3349    
3350                            if (conjunctionable) {
3351                                    query.append(WHERE_AND);
3352                            }
3353    
3354                            query.append(_FINDER_COLUMN_G_F_GROUPID_5);
3355    
3356                            conjunctionable = true;
3357    
3358                            if ((folderIds == null) || (folderIds.length > 0)) {
3359                                    if (conjunctionable) {
3360                                            query.append(WHERE_AND);
3361                                    }
3362    
3363                                    query.append(StringPool.OPEN_PARENTHESIS);
3364    
3365                                    for (int i = 0; i < folderIds.length; i++) {
3366                                            query.append(_FINDER_COLUMN_G_F_FOLDERID_5);
3367    
3368                                            if ((i + 1) < folderIds.length) {
3369                                                    query.append(WHERE_OR);
3370                                            }
3371                                    }
3372    
3373                                    query.append(StringPool.CLOSE_PARENTHESIS);
3374    
3375                                    conjunctionable = true;
3376                            }
3377    
3378                            if (orderByComparator != null) {
3379                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3380                                            orderByComparator);
3381                            }
3382    
3383                            else {
3384                                    query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
3385                            }
3386    
3387                            String sql = query.toString();
3388    
3389                            Session session = null;
3390    
3391                            try {
3392                                    session = openSession();
3393    
3394                                    Query q = session.createQuery(sql);
3395    
3396                                    QueryPos qPos = QueryPos.getInstance(q);
3397    
3398                                    qPos.add(groupId);
3399    
3400                                    if (folderIds != null) {
3401                                            qPos.add(folderIds);
3402                                    }
3403    
3404                                    list = (List<BookmarksEntry>)QueryUtil.list(q, getDialect(),
3405                                                    start, end);
3406                            }
3407                            catch (Exception e) {
3408                                    throw processException(e);
3409                            }
3410                            finally {
3411                                    if (list == null) {
3412                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
3413                                    }
3414                                    else {
3415                                            cacheResult(list);
3416    
3417                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
3418                                    }
3419    
3420                                    closeSession(session);
3421                            }
3422                    }
3423    
3424                    return list;
3425            }
3426    
3427            /**
3428             * Returns all the bookmarks entries that the user has permission to view where groupId = &#63; and folderId = &#63;.
3429             *
3430             * @param groupId the group ID
3431             * @param folderId the folder ID
3432             * @return the matching bookmarks entries that the user has permission to view
3433             * @throws SystemException if a system exception occurred
3434             */
3435            public List<BookmarksEntry> filterFindByG_F(long groupId, long folderId)
3436                    throws SystemException {
3437                    return filterFindByG_F(groupId, folderId, QueryUtil.ALL_POS,
3438                            QueryUtil.ALL_POS, null);
3439            }
3440    
3441            /**
3442             * Returns a range of all the bookmarks entries that the user has permission to view where groupId = &#63; and folderId = &#63;.
3443             *
3444             * <p>
3445             * 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.
3446             * </p>
3447             *
3448             * @param groupId the group ID
3449             * @param folderId the folder ID
3450             * @param start the lower bound of the range of bookmarks entries
3451             * @param end the upper bound of the range of bookmarks entries (not inclusive)
3452             * @return the range of matching bookmarks entries that the user has permission to view
3453             * @throws SystemException if a system exception occurred
3454             */
3455            public List<BookmarksEntry> filterFindByG_F(long groupId, long folderId,
3456                    int start, int end) throws SystemException {
3457                    return filterFindByG_F(groupId, folderId, start, end, null);
3458            }
3459    
3460            /**
3461             * Returns an ordered range of all the bookmarks entries that the user has permissions to view where groupId = &#63; and folderId = &#63;.
3462             *
3463             * <p>
3464             * 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.
3465             * </p>
3466             *
3467             * @param groupId the group ID
3468             * @param folderId the folder ID
3469             * @param start the lower bound of the range of bookmarks entries
3470             * @param end the upper bound of the range of bookmarks entries (not inclusive)
3471             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3472             * @return the ordered range of matching bookmarks entries that the user has permission to view
3473             * @throws SystemException if a system exception occurred
3474             */
3475            public List<BookmarksEntry> filterFindByG_F(long groupId, long folderId,
3476                    int start, int end, OrderByComparator orderByComparator)
3477                    throws SystemException {
3478                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3479                            return findByG_F(groupId, folderId, start, end, orderByComparator);
3480                    }
3481    
3482                    StringBundler query = null;
3483    
3484                    if (orderByComparator != null) {
3485                            query = new StringBundler(4 +
3486                                            (orderByComparator.getOrderByFields().length * 3));
3487                    }
3488                    else {
3489                            query = new StringBundler(4);
3490                    }
3491    
3492                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
3493    
3494                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
3495    
3496                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
3497    
3498                    if (orderByComparator != null) {
3499                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3500                                    orderByComparator);
3501                    }
3502    
3503                    else {
3504                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
3505                    }
3506    
3507                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3508                                    BookmarksEntry.class.getName(),
3509                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
3510                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
3511    
3512                    Session session = null;
3513    
3514                    try {
3515                            session = openSession();
3516    
3517                            Query q = session.createQuery(sql);
3518    
3519                            QueryPos qPos = QueryPos.getInstance(q);
3520    
3521                            qPos.add(groupId);
3522    
3523                            qPos.add(folderId);
3524    
3525                            return (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start,
3526                                    end);
3527                    }
3528                    catch (Exception e) {
3529                            throw processException(e);
3530                    }
3531                    finally {
3532                            closeSession(session);
3533                    }
3534            }
3535    
3536            /**
3537             * 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;.
3538             *
3539             * @param entryId the primary key of the current bookmarks entry
3540             * @param groupId the group ID
3541             * @param folderId the folder ID
3542             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3543             * @return the previous, current, and next bookmarks entry
3544             * @throws com.liferay.portlet.bookmarks.NoSuchEntryException if a bookmarks entry with the primary key could not be found
3545             * @throws SystemException if a system exception occurred
3546             */
3547            public BookmarksEntry[] filterFindByG_F_PrevAndNext(long entryId,
3548                    long groupId, long folderId, OrderByComparator orderByComparator)
3549                    throws NoSuchEntryException, SystemException {
3550                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3551                            return findByG_F_PrevAndNext(entryId, groupId, folderId,
3552                                    orderByComparator);
3553                    }
3554    
3555                    BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
3556    
3557                    Session session = null;
3558    
3559                    try {
3560                            session = openSession();
3561    
3562                            BookmarksEntry[] array = new BookmarksEntryImpl[3];
3563    
3564                            array[0] = filterGetByG_F_PrevAndNext(session, bookmarksEntry,
3565                                            groupId, folderId, orderByComparator, true);
3566    
3567                            array[1] = bookmarksEntry;
3568    
3569                            array[2] = filterGetByG_F_PrevAndNext(session, bookmarksEntry,
3570                                            groupId, folderId, orderByComparator, false);
3571    
3572                            return array;
3573                    }
3574                    catch (Exception e) {
3575                            throw processException(e);
3576                    }
3577                    finally {
3578                            closeSession(session);
3579                    }
3580            }
3581    
3582            protected BookmarksEntry filterGetByG_F_PrevAndNext(Session session,
3583                    BookmarksEntry bookmarksEntry, long groupId, long folderId,
3584                    OrderByComparator orderByComparator, boolean previous) {
3585                    StringBundler query = null;
3586    
3587                    if (orderByComparator != null) {
3588                            query = new StringBundler(6 +
3589                                            (orderByComparator.getOrderByFields().length * 6));
3590                    }
3591                    else {
3592                            query = new StringBundler(3);
3593                    }
3594    
3595                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
3596    
3597                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
3598    
3599                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
3600    
3601                    if (orderByComparator != null) {
3602                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3603    
3604                            if (orderByConditionFields.length > 0) {
3605                                    query.append(WHERE_AND);
3606                            }
3607    
3608                            for (int i = 0; i < orderByConditionFields.length; i++) {
3609                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3610                                    query.append(orderByConditionFields[i]);
3611    
3612                                    if ((i + 1) < orderByConditionFields.length) {
3613                                            if (orderByComparator.isAscending() ^ previous) {
3614                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3615                                            }
3616                                            else {
3617                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3618                                            }
3619                                    }
3620                                    else {
3621                                            if (orderByComparator.isAscending() ^ previous) {
3622                                                    query.append(WHERE_GREATER_THAN);
3623                                            }
3624                                            else {
3625                                                    query.append(WHERE_LESSER_THAN);
3626                                            }
3627                                    }
3628                            }
3629    
3630                            query.append(ORDER_BY_CLAUSE);
3631    
3632                            String[] orderByFields = orderByComparator.getOrderByFields();
3633    
3634                            for (int i = 0; i < orderByFields.length; i++) {
3635                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3636                                    query.append(orderByFields[i]);
3637    
3638                                    if ((i + 1) < orderByFields.length) {
3639                                            if (orderByComparator.isAscending() ^ previous) {
3640                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3641                                            }
3642                                            else {
3643                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3644                                            }
3645                                    }
3646                                    else {
3647                                            if (orderByComparator.isAscending() ^ previous) {
3648                                                    query.append(ORDER_BY_ASC);
3649                                            }
3650                                            else {
3651                                                    query.append(ORDER_BY_DESC);
3652                                            }
3653                                    }
3654                            }
3655                    }
3656    
3657                    else {
3658                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
3659                    }
3660    
3661                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3662                                    BookmarksEntry.class.getName(),
3663                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
3664                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
3665    
3666                    Query q = session.createQuery(sql);
3667    
3668                    q.setFirstResult(0);
3669                    q.setMaxResults(2);
3670    
3671                    QueryPos qPos = QueryPos.getInstance(q);
3672    
3673                    qPos.add(groupId);
3674    
3675                    qPos.add(folderId);
3676    
3677                    if (orderByComparator != null) {
3678                            Object[] values = orderByComparator.getOrderByConditionValues(bookmarksEntry);
3679    
3680                            for (Object value : values) {
3681                                    qPos.add(value);
3682                            }
3683                    }
3684    
3685                    List<BookmarksEntry> list = q.list();
3686    
3687                    if (list.size() == 2) {
3688                            return list.get(1);
3689                    }
3690                    else {
3691                            return null;
3692                    }
3693            }
3694    
3695            /**
3696             * Returns all the bookmarks entries that the user has permission to view where groupId = &#63; and folderId = any &#63;.
3697             *
3698             * @param groupId the group ID
3699             * @param folderIds the folder IDs
3700             * @return the matching bookmarks entries that the user has permission to view
3701             * @throws SystemException if a system exception occurred
3702             */
3703            public List<BookmarksEntry> filterFindByG_F(long groupId, long[] folderIds)
3704                    throws SystemException {
3705                    return filterFindByG_F(groupId, folderIds, QueryUtil.ALL_POS,
3706                            QueryUtil.ALL_POS, null);
3707            }
3708    
3709            /**
3710             * Returns a range of all the bookmarks entries that the user has permission to view where groupId = &#63; and folderId = any &#63;.
3711             *
3712             * <p>
3713             * 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.
3714             * </p>
3715             *
3716             * @param groupId the group ID
3717             * @param folderIds the folder IDs
3718             * @param start the lower bound of the range of bookmarks entries
3719             * @param end the upper bound of the range of bookmarks entries (not inclusive)
3720             * @return the range of matching bookmarks entries that the user has permission to view
3721             * @throws SystemException if a system exception occurred
3722             */
3723            public List<BookmarksEntry> filterFindByG_F(long groupId, long[] folderIds,
3724                    int start, int end) throws SystemException {
3725                    return filterFindByG_F(groupId, folderIds, start, end, null);
3726            }
3727    
3728            /**
3729             * Returns an ordered range of all the bookmarks entries that the user has permission to view where groupId = &#63; and folderId = any &#63;.
3730             *
3731             * <p>
3732             * 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.
3733             * </p>
3734             *
3735             * @param groupId the group ID
3736             * @param folderIds the folder IDs
3737             * @param start the lower bound of the range of bookmarks entries
3738             * @param end the upper bound of the range of bookmarks entries (not inclusive)
3739             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3740             * @return the ordered range of matching bookmarks entries that the user has permission to view
3741             * @throws SystemException if a system exception occurred
3742             */
3743            public List<BookmarksEntry> filterFindByG_F(long groupId, long[] folderIds,
3744                    int start, int end, OrderByComparator orderByComparator)
3745                    throws SystemException {
3746                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3747                            return findByG_F(groupId, folderIds, start, end, orderByComparator);
3748                    }
3749    
3750                    StringBundler query = new StringBundler();
3751    
3752                    query.append(_SQL_SELECT_BOOKMARKSENTRY_WHERE);
3753    
3754                    boolean conjunctionable = false;
3755    
3756                    if (conjunctionable) {
3757                            query.append(WHERE_AND);
3758                    }
3759    
3760                    query.append(_FINDER_COLUMN_G_F_GROUPID_5);
3761    
3762                    conjunctionable = true;
3763    
3764                    if ((folderIds == null) || (folderIds.length > 0)) {
3765                            if (conjunctionable) {
3766                                    query.append(WHERE_AND);
3767                            }
3768    
3769                            query.append(StringPool.OPEN_PARENTHESIS);
3770    
3771                            for (int i = 0; i < folderIds.length; i++) {
3772                                    query.append(_FINDER_COLUMN_G_F_FOLDERID_5);
3773    
3774                                    if ((i + 1) < folderIds.length) {
3775                                            query.append(WHERE_OR);
3776                                    }
3777                            }
3778    
3779                            query.append(StringPool.CLOSE_PARENTHESIS);
3780    
3781                            conjunctionable = true;
3782                    }
3783    
3784                    if (orderByComparator != null) {
3785                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3786                                    orderByComparator);
3787                    }
3788    
3789                    else {
3790                            query.append(BookmarksEntryModelImpl.ORDER_BY_JPQL);
3791                    }
3792    
3793                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3794                                    BookmarksEntry.class.getName(),
3795                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
3796                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
3797    
3798                    Session session = null;
3799    
3800                    try {
3801                            session = openSession();
3802    
3803                            Query q = session.createQuery(sql);
3804    
3805                            QueryPos qPos = QueryPos.getInstance(q);
3806    
3807                            qPos.add(groupId);
3808    
3809                            if (folderIds != null) {
3810                                    qPos.add(folderIds);
3811                            }
3812    
3813                            return (List<BookmarksEntry>)QueryUtil.list(q, getDialect(), start,
3814                                    end);
3815                    }
3816                    catch (Exception e) {
3817                            throw processException(e);
3818                    }
3819                    finally {
3820                            closeSession(session);
3821                    }
3822            }
3823    
3824            /**
3825             * Returns all the bookmarks entries.
3826             *
3827             * @return the bookmarks entries
3828             * @throws SystemException if a system exception occurred
3829             */
3830            public List<BookmarksEntry> findAll() throws SystemException {
3831                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3832            }
3833    
3834            /**
3835             * Returns a range of all the bookmarks entries.
3836             *
3837             * <p>
3838             * 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.
3839             * </p>
3840             *
3841             * @param start the lower bound of the range of bookmarks entries
3842             * @param end the upper bound of the range of bookmarks entries (not inclusive)
3843             * @return the range of bookmarks entries
3844             * @throws SystemException if a system exception occurred
3845             */
3846            public List<BookmarksEntry> findAll(int start, int end)
3847                    throws SystemException {
3848                    return findAll(start, end, null);
3849            }
3850    
3851            /**
3852             * Returns an ordered range of all the bookmarks entries.
3853             *
3854             * <p>
3855             * 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.
3856             * </p>
3857             *
3858             * @param start the lower bound of the range of bookmarks entries
3859             * @param end the upper bound of the range of bookmarks entries (not inclusive)
3860             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3861             * @return the ordered range of bookmarks entries
3862             * @throws SystemException if a system exception occurred
3863             */
3864            public List<BookmarksEntry> findAll(int start, int end,
3865                    OrderByComparator orderByComparator) throws SystemException {
3866                    FinderPath finderPath = null;
3867                    Object[] finderArgs = new Object[] { start, end, orderByComparator };
3868    
3869                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3870                                    (orderByComparator == null)) {
3871                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
3872                            finderArgs = FINDER_ARGS_EMPTY;
3873                    }
3874                    else {
3875                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
3876                            finderArgs = new Object[] { start, end, orderByComparator };
3877                    }
3878    
3879                    List<BookmarksEntry> list = (List<BookmarksEntry>)FinderCacheUtil.getResult(finderPath,
3880                                    finderArgs, this);
3881    
3882                    if (list == null) {
3883                            StringBundler query = null;
3884                            String sql = null;
3885    
3886                            if (orderByComparator != null) {
3887                                    query = new StringBundler(2 +
3888                                                    (orderByComparator.getOrderByFields().length * 3));
3889    
3890                                    query.append(_SQL_SELECT_BOOKMARKSENTRY);
3891    
3892                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3893                                            orderByComparator);
3894    
3895                                    sql = query.toString();
3896                            }
3897                            else {
3898                                    sql = _SQL_SELECT_BOOKMARKSENTRY.concat(BookmarksEntryModelImpl.ORDER_BY_JPQL);
3899                            }
3900    
3901                            Session session = null;
3902    
3903                            try {
3904                                    session = openSession();
3905    
3906                                    Query q = session.createQuery(sql);
3907    
3908                                    if (orderByComparator == null) {
3909                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
3910                                                            getDialect(), start, end, false);
3911    
3912                                            Collections.sort(list);
3913                                    }
3914                                    else {
3915                                            list = (List<BookmarksEntry>)QueryUtil.list(q,
3916                                                            getDialect(), start, end);
3917                                    }
3918                            }
3919                            catch (Exception e) {
3920                                    throw processException(e);
3921                            }
3922                            finally {
3923                                    if (list == null) {
3924                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
3925                                    }
3926                                    else {
3927                                            cacheResult(list);
3928    
3929                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
3930                                    }
3931    
3932                                    closeSession(session);
3933                            }
3934                    }
3935    
3936                    return list;
3937            }
3938    
3939            /**
3940             * Removes all the bookmarks entries where resourceBlockId = &#63; from the database.
3941             *
3942             * @param resourceBlockId the resource block ID
3943             * @throws SystemException if a system exception occurred
3944             */
3945            public void removeByResourceBlockId(long resourceBlockId)
3946                    throws SystemException {
3947                    for (BookmarksEntry bookmarksEntry : findByResourceBlockId(
3948                                    resourceBlockId)) {
3949                            remove(bookmarksEntry);
3950                    }
3951            }
3952    
3953            /**
3954             * Removes all the bookmarks entries where uuid = &#63; from the database.
3955             *
3956             * @param uuid the uuid
3957             * @throws SystemException if a system exception occurred
3958             */
3959            public void removeByUuid(String uuid) throws SystemException {
3960                    for (BookmarksEntry bookmarksEntry : findByUuid(uuid)) {
3961                            remove(bookmarksEntry);
3962                    }
3963            }
3964    
3965            /**
3966             * Removes the bookmarks entry where uuid = &#63; and groupId = &#63; from the database.
3967             *
3968             * @param uuid the uuid
3969             * @param groupId the group ID
3970             * @throws SystemException if a system exception occurred
3971             */
3972            public void removeByUUID_G(String uuid, long groupId)
3973                    throws NoSuchEntryException, SystemException {
3974                    BookmarksEntry bookmarksEntry = findByUUID_G(uuid, groupId);
3975    
3976                    remove(bookmarksEntry);
3977            }
3978    
3979            /**
3980             * Removes all the bookmarks entries where groupId = &#63; from the database.
3981             *
3982             * @param groupId the group ID
3983             * @throws SystemException if a system exception occurred
3984             */
3985            public void removeByGroupId(long groupId) throws SystemException {
3986                    for (BookmarksEntry bookmarksEntry : findByGroupId(groupId)) {
3987                            remove(bookmarksEntry);
3988                    }
3989            }
3990    
3991            /**
3992             * Removes all the bookmarks entries where groupId = &#63; and userId = &#63; from the database.
3993             *
3994             * @param groupId the group ID
3995             * @param userId the user ID
3996             * @throws SystemException if a system exception occurred
3997             */
3998            public void removeByG_U(long groupId, long userId)
3999                    throws SystemException {
4000                    for (BookmarksEntry bookmarksEntry : findByG_U(groupId, userId)) {
4001                            remove(bookmarksEntry);
4002                    }
4003            }
4004    
4005            /**
4006             * Removes all the bookmarks entries where groupId = &#63; and folderId = &#63; from the database.
4007             *
4008             * @param groupId the group ID
4009             * @param folderId the folder ID
4010             * @throws SystemException if a system exception occurred
4011             */
4012            public void removeByG_F(long groupId, long folderId)
4013                    throws SystemException {
4014                    for (BookmarksEntry bookmarksEntry : findByG_F(groupId, folderId)) {
4015                            remove(bookmarksEntry);
4016                    }
4017            }
4018    
4019            /**
4020             * Removes all the bookmarks entries from the database.
4021             *
4022             * @throws SystemException if a system exception occurred
4023             */
4024            public void removeAll() throws SystemException {
4025                    for (BookmarksEntry bookmarksEntry : findAll()) {
4026                            remove(bookmarksEntry);
4027                    }
4028            }
4029    
4030            /**
4031             * Returns the number of bookmarks entries where resourceBlockId = &#63;.
4032             *
4033             * @param resourceBlockId the resource block ID
4034             * @return the number of matching bookmarks entries
4035             * @throws SystemException if a system exception occurred
4036             */
4037            public int countByResourceBlockId(long resourceBlockId)
4038                    throws SystemException {
4039                    Object[] finderArgs = new Object[] { resourceBlockId };
4040    
4041                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_RESOURCEBLOCKID,
4042                                    finderArgs, this);
4043    
4044                    if (count == null) {
4045                            StringBundler query = new StringBundler(2);
4046    
4047                            query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
4048    
4049                            query.append(_FINDER_COLUMN_RESOURCEBLOCKID_RESOURCEBLOCKID_2);
4050    
4051                            String sql = query.toString();
4052    
4053                            Session session = null;
4054    
4055                            try {
4056                                    session = openSession();
4057    
4058                                    Query q = session.createQuery(sql);
4059    
4060                                    QueryPos qPos = QueryPos.getInstance(q);
4061    
4062                                    qPos.add(resourceBlockId);
4063    
4064                                    count = (Long)q.uniqueResult();
4065                            }
4066                            catch (Exception e) {
4067                                    throw processException(e);
4068                            }
4069                            finally {
4070                                    if (count == null) {
4071                                            count = Long.valueOf(0);
4072                                    }
4073    
4074                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_RESOURCEBLOCKID,
4075                                            finderArgs, count);
4076    
4077                                    closeSession(session);
4078                            }
4079                    }
4080    
4081                    return count.intValue();
4082            }
4083    
4084            /**
4085             * Returns the number of bookmarks entries where uuid = &#63;.
4086             *
4087             * @param uuid the uuid
4088             * @return the number of matching bookmarks entries
4089             * @throws SystemException if a system exception occurred
4090             */
4091            public int countByUuid(String uuid) throws SystemException {
4092                    Object[] finderArgs = new Object[] { uuid };
4093    
4094                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
4095                                    finderArgs, this);
4096    
4097                    if (count == null) {
4098                            StringBundler query = new StringBundler(2);
4099    
4100                            query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
4101    
4102                            if (uuid == null) {
4103                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
4104                            }
4105                            else {
4106                                    if (uuid.equals(StringPool.BLANK)) {
4107                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
4108                                    }
4109                                    else {
4110                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
4111                                    }
4112                            }
4113    
4114                            String sql = query.toString();
4115    
4116                            Session session = null;
4117    
4118                            try {
4119                                    session = openSession();
4120    
4121                                    Query q = session.createQuery(sql);
4122    
4123                                    QueryPos qPos = QueryPos.getInstance(q);
4124    
4125                                    if (uuid != null) {
4126                                            qPos.add(uuid);
4127                                    }
4128    
4129                                    count = (Long)q.uniqueResult();
4130                            }
4131                            catch (Exception e) {
4132                                    throw processException(e);
4133                            }
4134                            finally {
4135                                    if (count == null) {
4136                                            count = Long.valueOf(0);
4137                                    }
4138    
4139                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
4140                                            finderArgs, count);
4141    
4142                                    closeSession(session);
4143                            }
4144                    }
4145    
4146                    return count.intValue();
4147            }
4148    
4149            /**
4150             * Returns the number of bookmarks entries where uuid = &#63; and groupId = &#63;.
4151             *
4152             * @param uuid the uuid
4153             * @param groupId the group ID
4154             * @return the number of matching bookmarks entries
4155             * @throws SystemException if a system exception occurred
4156             */
4157            public int countByUUID_G(String uuid, long groupId)
4158                    throws SystemException {
4159                    Object[] finderArgs = new Object[] { uuid, groupId };
4160    
4161                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
4162                                    finderArgs, this);
4163    
4164                    if (count == null) {
4165                            StringBundler query = new StringBundler(3);
4166    
4167                            query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
4168    
4169                            if (uuid == null) {
4170                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
4171                            }
4172                            else {
4173                                    if (uuid.equals(StringPool.BLANK)) {
4174                                            query.append(_FINDER_COLUMN_UUID_G_UUID_3);
4175                                    }
4176                                    else {
4177                                            query.append(_FINDER_COLUMN_UUID_G_UUID_2);
4178                                    }
4179                            }
4180    
4181                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
4182    
4183                            String sql = query.toString();
4184    
4185                            Session session = null;
4186    
4187                            try {
4188                                    session = openSession();
4189    
4190                                    Query q = session.createQuery(sql);
4191    
4192                                    QueryPos qPos = QueryPos.getInstance(q);
4193    
4194                                    if (uuid != null) {
4195                                            qPos.add(uuid);
4196                                    }
4197    
4198                                    qPos.add(groupId);
4199    
4200                                    count = (Long)q.uniqueResult();
4201                            }
4202                            catch (Exception e) {
4203                                    throw processException(e);
4204                            }
4205                            finally {
4206                                    if (count == null) {
4207                                            count = Long.valueOf(0);
4208                                    }
4209    
4210                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
4211                                            finderArgs, count);
4212    
4213                                    closeSession(session);
4214                            }
4215                    }
4216    
4217                    return count.intValue();
4218            }
4219    
4220            /**
4221             * Returns the number of bookmarks entries where groupId = &#63;.
4222             *
4223             * @param groupId the group ID
4224             * @return the number of matching bookmarks entries
4225             * @throws SystemException if a system exception occurred
4226             */
4227            public int countByGroupId(long groupId) throws SystemException {
4228                    Object[] finderArgs = new Object[] { groupId };
4229    
4230                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
4231                                    finderArgs, this);
4232    
4233                    if (count == null) {
4234                            StringBundler query = new StringBundler(2);
4235    
4236                            query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
4237    
4238                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
4239    
4240                            String sql = query.toString();
4241    
4242                            Session session = null;
4243    
4244                            try {
4245                                    session = openSession();
4246    
4247                                    Query q = session.createQuery(sql);
4248    
4249                                    QueryPos qPos = QueryPos.getInstance(q);
4250    
4251                                    qPos.add(groupId);
4252    
4253                                    count = (Long)q.uniqueResult();
4254                            }
4255                            catch (Exception e) {
4256                                    throw processException(e);
4257                            }
4258                            finally {
4259                                    if (count == null) {
4260                                            count = Long.valueOf(0);
4261                                    }
4262    
4263                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
4264                                            finderArgs, count);
4265    
4266                                    closeSession(session);
4267                            }
4268                    }
4269    
4270                    return count.intValue();
4271            }
4272    
4273            /**
4274             * Returns the number of bookmarks entries that the user has permission to view where groupId = &#63;.
4275             *
4276             * @param groupId the group ID
4277             * @return the number of matching bookmarks entries that the user has permission to view
4278             * @throws SystemException if a system exception occurred
4279             */
4280            public int filterCountByGroupId(long groupId) throws SystemException {
4281                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4282                            return countByGroupId(groupId);
4283                    }
4284    
4285                    StringBundler query = new StringBundler(2);
4286    
4287                    query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
4288    
4289                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
4290    
4291                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4292                                    BookmarksEntry.class.getName(),
4293                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
4294                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
4295    
4296                    Session session = null;
4297    
4298                    try {
4299                            session = openSession();
4300    
4301                            Query q = session.createQuery(sql);
4302    
4303                            QueryPos qPos = QueryPos.getInstance(q);
4304    
4305                            qPos.add(groupId);
4306    
4307                            Long count = (Long)q.uniqueResult();
4308    
4309                            return count.intValue();
4310                    }
4311                    catch (Exception e) {
4312                            throw processException(e);
4313                    }
4314                    finally {
4315                            closeSession(session);
4316                    }
4317            }
4318    
4319            /**
4320             * Returns the number of bookmarks entries where groupId = &#63; and userId = &#63;.
4321             *
4322             * @param groupId the group ID
4323             * @param userId the user ID
4324             * @return the number of matching bookmarks entries
4325             * @throws SystemException if a system exception occurred
4326             */
4327            public int countByG_U(long groupId, long userId) throws SystemException {
4328                    Object[] finderArgs = new Object[] { groupId, userId };
4329    
4330                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_U,
4331                                    finderArgs, this);
4332    
4333                    if (count == null) {
4334                            StringBundler query = new StringBundler(3);
4335    
4336                            query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
4337    
4338                            query.append(_FINDER_COLUMN_G_U_GROUPID_2);
4339    
4340                            query.append(_FINDER_COLUMN_G_U_USERID_2);
4341    
4342                            String sql = query.toString();
4343    
4344                            Session session = null;
4345    
4346                            try {
4347                                    session = openSession();
4348    
4349                                    Query q = session.createQuery(sql);
4350    
4351                                    QueryPos qPos = QueryPos.getInstance(q);
4352    
4353                                    qPos.add(groupId);
4354    
4355                                    qPos.add(userId);
4356    
4357                                    count = (Long)q.uniqueResult();
4358                            }
4359                            catch (Exception e) {
4360                                    throw processException(e);
4361                            }
4362                            finally {
4363                                    if (count == null) {
4364                                            count = Long.valueOf(0);
4365                                    }
4366    
4367                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_U, finderArgs,
4368                                            count);
4369    
4370                                    closeSession(session);
4371                            }
4372                    }
4373    
4374                    return count.intValue();
4375            }
4376    
4377            /**
4378             * Returns the number of bookmarks entries that the user has permission to view where groupId = &#63; and userId = &#63;.
4379             *
4380             * @param groupId the group ID
4381             * @param userId the user ID
4382             * @return the number of matching bookmarks entries that the user has permission to view
4383             * @throws SystemException if a system exception occurred
4384             */
4385            public int filterCountByG_U(long groupId, long userId)
4386                    throws SystemException {
4387                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4388                            return countByG_U(groupId, userId);
4389                    }
4390    
4391                    StringBundler query = new StringBundler(3);
4392    
4393                    query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
4394    
4395                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
4396    
4397                    query.append(_FINDER_COLUMN_G_U_USERID_2);
4398    
4399                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4400                                    BookmarksEntry.class.getName(),
4401                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
4402                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
4403    
4404                    Session session = null;
4405    
4406                    try {
4407                            session = openSession();
4408    
4409                            Query q = session.createQuery(sql);
4410    
4411                            QueryPos qPos = QueryPos.getInstance(q);
4412    
4413                            qPos.add(groupId);
4414    
4415                            qPos.add(userId);
4416    
4417                            Long count = (Long)q.uniqueResult();
4418    
4419                            return count.intValue();
4420                    }
4421                    catch (Exception e) {
4422                            throw processException(e);
4423                    }
4424                    finally {
4425                            closeSession(session);
4426                    }
4427            }
4428    
4429            /**
4430             * Returns the number of bookmarks entries where groupId = &#63; and folderId = &#63;.
4431             *
4432             * @param groupId the group ID
4433             * @param folderId the folder ID
4434             * @return the number of matching bookmarks entries
4435             * @throws SystemException if a system exception occurred
4436             */
4437            public int countByG_F(long groupId, long folderId)
4438                    throws SystemException {
4439                    Object[] finderArgs = new Object[] { groupId, folderId };
4440    
4441                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_F,
4442                                    finderArgs, this);
4443    
4444                    if (count == null) {
4445                            StringBundler query = new StringBundler(3);
4446    
4447                            query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
4448    
4449                            query.append(_FINDER_COLUMN_G_F_GROUPID_2);
4450    
4451                            query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
4452    
4453                            String sql = query.toString();
4454    
4455                            Session session = null;
4456    
4457                            try {
4458                                    session = openSession();
4459    
4460                                    Query q = session.createQuery(sql);
4461    
4462                                    QueryPos qPos = QueryPos.getInstance(q);
4463    
4464                                    qPos.add(groupId);
4465    
4466                                    qPos.add(folderId);
4467    
4468                                    count = (Long)q.uniqueResult();
4469                            }
4470                            catch (Exception e) {
4471                                    throw processException(e);
4472                            }
4473                            finally {
4474                                    if (count == null) {
4475                                            count = Long.valueOf(0);
4476                                    }
4477    
4478                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_F, finderArgs,
4479                                            count);
4480    
4481                                    closeSession(session);
4482                            }
4483                    }
4484    
4485                    return count.intValue();
4486            }
4487    
4488            /**
4489             * Returns the number of bookmarks entries where groupId = &#63; and folderId = any &#63;.
4490             *
4491             * @param groupId the group ID
4492             * @param folderIds the folder IDs
4493             * @return the number of matching bookmarks entries
4494             * @throws SystemException if a system exception occurred
4495             */
4496            public int countByG_F(long groupId, long[] folderIds)
4497                    throws SystemException {
4498                    Object[] finderArgs = new Object[] { groupId, StringUtil.merge(folderIds) };
4499    
4500                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F,
4501                                    finderArgs, this);
4502    
4503                    if (count == null) {
4504                            StringBundler query = new StringBundler();
4505    
4506                            query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
4507    
4508                            boolean conjunctionable = false;
4509    
4510                            if (conjunctionable) {
4511                                    query.append(WHERE_AND);
4512                            }
4513    
4514                            query.append(_FINDER_COLUMN_G_F_GROUPID_5);
4515    
4516                            conjunctionable = true;
4517    
4518                            if ((folderIds == null) || (folderIds.length > 0)) {
4519                                    if (conjunctionable) {
4520                                            query.append(WHERE_AND);
4521                                    }
4522    
4523                                    query.append(StringPool.OPEN_PARENTHESIS);
4524    
4525                                    for (int i = 0; i < folderIds.length; i++) {
4526                                            query.append(_FINDER_COLUMN_G_F_FOLDERID_5);
4527    
4528                                            if ((i + 1) < folderIds.length) {
4529                                                    query.append(WHERE_OR);
4530                                            }
4531                                    }
4532    
4533                                    query.append(StringPool.CLOSE_PARENTHESIS);
4534    
4535                                    conjunctionable = true;
4536                            }
4537    
4538                            String sql = query.toString();
4539    
4540                            Session session = null;
4541    
4542                            try {
4543                                    session = openSession();
4544    
4545                                    Query q = session.createQuery(sql);
4546    
4547                                    QueryPos qPos = QueryPos.getInstance(q);
4548    
4549                                    qPos.add(groupId);
4550    
4551                                    if (folderIds != null) {
4552                                            qPos.add(folderIds);
4553                                    }
4554    
4555                                    count = (Long)q.uniqueResult();
4556                            }
4557                            catch (Exception e) {
4558                                    throw processException(e);
4559                            }
4560                            finally {
4561                                    if (count == null) {
4562                                            count = Long.valueOf(0);
4563                                    }
4564    
4565                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_F,
4566                                            finderArgs, count);
4567    
4568                                    closeSession(session);
4569                            }
4570                    }
4571    
4572                    return count.intValue();
4573            }
4574    
4575            /**
4576             * Returns the number of bookmarks entries that the user has permission to view where groupId = &#63; and folderId = &#63;.
4577             *
4578             * @param groupId the group ID
4579             * @param folderId the folder ID
4580             * @return the number of matching bookmarks entries that the user has permission to view
4581             * @throws SystemException if a system exception occurred
4582             */
4583            public int filterCountByG_F(long groupId, long folderId)
4584                    throws SystemException {
4585                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4586                            return countByG_F(groupId, folderId);
4587                    }
4588    
4589                    StringBundler query = new StringBundler(3);
4590    
4591                    query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
4592    
4593                    query.append(_FINDER_COLUMN_G_F_GROUPID_2);
4594    
4595                    query.append(_FINDER_COLUMN_G_F_FOLDERID_2);
4596    
4597                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4598                                    BookmarksEntry.class.getName(),
4599                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
4600                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
4601    
4602                    Session session = null;
4603    
4604                    try {
4605                            session = openSession();
4606    
4607                            Query q = session.createQuery(sql);
4608    
4609                            QueryPos qPos = QueryPos.getInstance(q);
4610    
4611                            qPos.add(groupId);
4612    
4613                            qPos.add(folderId);
4614    
4615                            Long count = (Long)q.uniqueResult();
4616    
4617                            return count.intValue();
4618                    }
4619                    catch (Exception e) {
4620                            throw processException(e);
4621                    }
4622                    finally {
4623                            closeSession(session);
4624                    }
4625            }
4626    
4627            /**
4628             * Returns the number of bookmarks entries that the user has permission to view where groupId = &#63; and folderId = any &#63;.
4629             *
4630             * @param groupId the group ID
4631             * @param folderIds the folder IDs
4632             * @return the number of matching bookmarks entries that the user has permission to view
4633             * @throws SystemException if a system exception occurred
4634             */
4635            public int filterCountByG_F(long groupId, long[] folderIds)
4636                    throws SystemException {
4637                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4638                            return countByG_F(groupId, folderIds);
4639                    }
4640    
4641                    StringBundler query = new StringBundler();
4642    
4643                    query.append(_SQL_COUNT_BOOKMARKSENTRY_WHERE);
4644    
4645                    boolean conjunctionable = false;
4646    
4647                    if (conjunctionable) {
4648                            query.append(WHERE_AND);
4649                    }
4650    
4651                    query.append(_FINDER_COLUMN_G_F_GROUPID_5);
4652    
4653                    conjunctionable = true;
4654    
4655                    if ((folderIds == null) || (folderIds.length > 0)) {
4656                            if (conjunctionable) {
4657                                    query.append(WHERE_AND);
4658                            }
4659    
4660                            query.append(StringPool.OPEN_PARENTHESIS);
4661    
4662                            for (int i = 0; i < folderIds.length; i++) {
4663                                    query.append(_FINDER_COLUMN_G_F_FOLDERID_5);
4664    
4665                                    if ((i + 1) < folderIds.length) {
4666                                            query.append(WHERE_OR);
4667                                    }
4668                            }
4669    
4670                            query.append(StringPool.CLOSE_PARENTHESIS);
4671    
4672                            conjunctionable = true;
4673                    }
4674    
4675                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4676                                    BookmarksEntry.class.getName(),
4677                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
4678                                    _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN, groupId);
4679    
4680                    Session session = null;
4681    
4682                    try {
4683                            session = openSession();
4684    
4685                            Query q = session.createQuery(sql);
4686    
4687                            QueryPos qPos = QueryPos.getInstance(q);
4688    
4689                            qPos.add(groupId);
4690    
4691                            if (folderIds != null) {
4692                                    qPos.add(folderIds);
4693                            }
4694    
4695                            Long count = (Long)q.uniqueResult();
4696    
4697                            return count.intValue();
4698                    }
4699                    catch (Exception e) {
4700                            throw processException(e);
4701                    }
4702                    finally {
4703                            closeSession(session);
4704                    }
4705            }
4706    
4707            /**
4708             * Returns the number of bookmarks entries.
4709             *
4710             * @return the number of bookmarks entries
4711             * @throws SystemException if a system exception occurred
4712             */
4713            public int countAll() throws SystemException {
4714                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
4715                                    FINDER_ARGS_EMPTY, this);
4716    
4717                    if (count == null) {
4718                            Session session = null;
4719    
4720                            try {
4721                                    session = openSession();
4722    
4723                                    Query q = session.createQuery(_SQL_COUNT_BOOKMARKSENTRY);
4724    
4725                                    count = (Long)q.uniqueResult();
4726                            }
4727                            catch (Exception e) {
4728                                    throw processException(e);
4729                            }
4730                            finally {
4731                                    if (count == null) {
4732                                            count = Long.valueOf(0);
4733                                    }
4734    
4735                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
4736                                            FINDER_ARGS_EMPTY, count);
4737    
4738                                    closeSession(session);
4739                            }
4740                    }
4741    
4742                    return count.intValue();
4743            }
4744    
4745            /**
4746             * Initializes the bookmarks entry persistence.
4747             */
4748            public void afterPropertiesSet() {
4749                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
4750                                            com.liferay.portal.util.PropsUtil.get(
4751                                                    "value.object.listener.com.liferay.portlet.bookmarks.model.BookmarksEntry")));
4752    
4753                    if (listenerClassNames.length > 0) {
4754                            try {
4755                                    List<ModelListener<BookmarksEntry>> listenersList = new ArrayList<ModelListener<BookmarksEntry>>();
4756    
4757                                    for (String listenerClassName : listenerClassNames) {
4758                                            listenersList.add((ModelListener<BookmarksEntry>)InstanceFactory.newInstance(
4759                                                            listenerClassName));
4760                                    }
4761    
4762                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
4763                            }
4764                            catch (Exception e) {
4765                                    _log.error(e);
4766                            }
4767                    }
4768            }
4769    
4770            public void destroy() {
4771                    EntityCacheUtil.removeCache(BookmarksEntryImpl.class.getName());
4772                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
4773                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4774            }
4775    
4776            @BeanReference(type = BookmarksEntryPersistence.class)
4777            protected BookmarksEntryPersistence bookmarksEntryPersistence;
4778            @BeanReference(type = BookmarksFolderPersistence.class)
4779            protected BookmarksFolderPersistence bookmarksFolderPersistence;
4780            @BeanReference(type = ResourcePersistence.class)
4781            protected ResourcePersistence resourcePersistence;
4782            @BeanReference(type = UserPersistence.class)
4783            protected UserPersistence userPersistence;
4784            @BeanReference(type = AssetEntryPersistence.class)
4785            protected AssetEntryPersistence assetEntryPersistence;
4786            @BeanReference(type = AssetLinkPersistence.class)
4787            protected AssetLinkPersistence assetLinkPersistence;
4788            @BeanReference(type = AssetTagPersistence.class)
4789            protected AssetTagPersistence assetTagPersistence;
4790            @BeanReference(type = ExpandoValuePersistence.class)
4791            protected ExpandoValuePersistence expandoValuePersistence;
4792            @BeanReference(type = SocialActivityPersistence.class)
4793            protected SocialActivityPersistence socialActivityPersistence;
4794            private static final String _SQL_SELECT_BOOKMARKSENTRY = "SELECT bookmarksEntry FROM BookmarksEntry bookmarksEntry";
4795            private static final String _SQL_SELECT_BOOKMARKSENTRY_WHERE = "SELECT bookmarksEntry FROM BookmarksEntry bookmarksEntry WHERE ";
4796            private static final String _SQL_COUNT_BOOKMARKSENTRY = "SELECT COUNT(bookmarksEntry) FROM BookmarksEntry bookmarksEntry";
4797            private static final String _SQL_COUNT_BOOKMARKSENTRY_WHERE = "SELECT COUNT(bookmarksEntry) FROM BookmarksEntry bookmarksEntry WHERE ";
4798            private static final String _FINDER_COLUMN_RESOURCEBLOCKID_RESOURCEBLOCKID_2 =
4799                    "bookmarksEntry.resourceBlockId = ?";
4800            private static final String _FINDER_COLUMN_UUID_UUID_1 = "bookmarksEntry.uuid IS NULL";
4801            private static final String _FINDER_COLUMN_UUID_UUID_2 = "bookmarksEntry.uuid = ?";
4802            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(bookmarksEntry.uuid IS NULL OR bookmarksEntry.uuid = ?)";
4803            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "bookmarksEntry.uuid IS NULL AND ";
4804            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "bookmarksEntry.uuid = ? AND ";
4805            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(bookmarksEntry.uuid IS NULL OR bookmarksEntry.uuid = ?) AND ";
4806            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "bookmarksEntry.groupId = ?";
4807            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "bookmarksEntry.groupId = ?";
4808            private static final String _FINDER_COLUMN_G_U_GROUPID_2 = "bookmarksEntry.groupId = ? AND ";
4809            private static final String _FINDER_COLUMN_G_U_USERID_2 = "bookmarksEntry.userId = ?";
4810            private static final String _FINDER_COLUMN_G_F_GROUPID_2 = "bookmarksEntry.groupId = ? AND ";
4811            private static final String _FINDER_COLUMN_G_F_GROUPID_5 = "(" +
4812                    _removeConjunction(_FINDER_COLUMN_G_F_GROUPID_2) + ")";
4813            private static final String _FINDER_COLUMN_G_F_FOLDERID_2 = "bookmarksEntry.folderId = ?";
4814            private static final String _FINDER_COLUMN_G_F_FOLDERID_5 = "(" +
4815                    _removeConjunction(_FINDER_COLUMN_G_F_FOLDERID_2) + ")";
4816    
4817            private static String _removeConjunction(String sql) {
4818                    int pos = sql.indexOf(" AND ");
4819    
4820                    if (pos != -1) {
4821                            sql = sql.substring(0, pos);
4822                    }
4823    
4824                    return sql;
4825            }
4826    
4827            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "bookmarksEntry.entryId";
4828            private static final String _FILTER_ENTITY_TABLE_FILTER_USERID_COLUMN = "bookmarksEntry.userId";
4829            private static final String _ORDER_BY_ENTITY_ALIAS = "bookmarksEntry.";
4830            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No BookmarksEntry exists with the primary key ";
4831            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No BookmarksEntry exists with the key {";
4832            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
4833            private static Log _log = LogFactoryUtil.getLog(BookmarksEntryPersistenceImpl.class);
4834            private static BookmarksEntry _nullBookmarksEntry = new BookmarksEntryImpl() {
4835                            @Override
4836                            public Object clone() {
4837                                    return this;
4838                            }
4839    
4840                            @Override
4841                            public CacheModel<BookmarksEntry> toCacheModel() {
4842                                    return _nullBookmarksEntryCacheModel;
4843                            }
4844                    };
4845    
4846            private static CacheModel<BookmarksEntry> _nullBookmarksEntryCacheModel = new CacheModel<BookmarksEntry>() {
4847                            public BookmarksEntry toEntityModel() {
4848                                    return _nullBookmarksEntry;
4849                            }
4850                    };
4851    }