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