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