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