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