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