001    /**
002     * Copyright (c) 2000-2011 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.annotation.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.SQLQuery;
027    import com.liferay.portal.kernel.dao.orm.Session;
028    import com.liferay.portal.kernel.exception.SystemException;
029    import com.liferay.portal.kernel.log.Log;
030    import com.liferay.portal.kernel.log.LogFactoryUtil;
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.ModelListener;
040    import com.liferay.portal.security.permission.InlineSQLHelperUtil;
041    import com.liferay.portal.service.persistence.BatchSessionUtil;
042    import com.liferay.portal.service.persistence.GroupPersistence;
043    import com.liferay.portal.service.persistence.ResourcePersistence;
044    import com.liferay.portal.service.persistence.UserPersistence;
045    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
046    
047    import com.liferay.portlet.bookmarks.NoSuchFolderException;
048    import com.liferay.portlet.bookmarks.model.BookmarksFolder;
049    import com.liferay.portlet.bookmarks.model.impl.BookmarksFolderImpl;
050    import com.liferay.portlet.bookmarks.model.impl.BookmarksFolderModelImpl;
051    import com.liferay.portlet.expando.service.persistence.ExpandoValuePersistence;
052    
053    import java.io.Serializable;
054    
055    import java.util.ArrayList;
056    import java.util.Collections;
057    import java.util.List;
058    
059    /**
060     * The persistence implementation for the bookmarks folder service.
061     *
062     * <p>
063     * Never modify or reference this class directly. Always use {@link BookmarksFolderUtil} to access the bookmarks folder persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
064     * </p>
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 BookmarksFolderPersistence
072     * @see BookmarksFolderUtil
073     * @generated
074     */
075    public class BookmarksFolderPersistenceImpl extends BasePersistenceImpl<BookmarksFolder>
076            implements BookmarksFolderPersistence {
077            public static final String FINDER_CLASS_NAME_ENTITY = BookmarksFolderImpl.class.getName();
078            public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
079                    ".List";
080            public static final FinderPath FINDER_PATH_FIND_BY_UUID = new FinderPath(BookmarksFolderModelImpl.ENTITY_CACHE_ENABLED,
081                            BookmarksFolderModelImpl.FINDER_CACHE_ENABLED,
082                            FINDER_CLASS_NAME_LIST, "findByUuid",
083                            new String[] {
084                                    String.class.getName(),
085                                    
086                            "java.lang.Integer", "java.lang.Integer",
087                                    "com.liferay.portal.kernel.util.OrderByComparator"
088                            });
089            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(BookmarksFolderModelImpl.ENTITY_CACHE_ENABLED,
090                            BookmarksFolderModelImpl.FINDER_CACHE_ENABLED,
091                            FINDER_CLASS_NAME_LIST, "countByUuid",
092                            new String[] { String.class.getName() });
093            public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(BookmarksFolderModelImpl.ENTITY_CACHE_ENABLED,
094                            BookmarksFolderModelImpl.FINDER_CACHE_ENABLED,
095                            FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
096                            new String[] { String.class.getName(), Long.class.getName() });
097            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(BookmarksFolderModelImpl.ENTITY_CACHE_ENABLED,
098                            BookmarksFolderModelImpl.FINDER_CACHE_ENABLED,
099                            FINDER_CLASS_NAME_LIST, "countByUUID_G",
100                            new String[] { String.class.getName(), Long.class.getName() });
101            public static final FinderPath FINDER_PATH_FIND_BY_GROUPID = new FinderPath(BookmarksFolderModelImpl.ENTITY_CACHE_ENABLED,
102                            BookmarksFolderModelImpl.FINDER_CACHE_ENABLED,
103                            FINDER_CLASS_NAME_LIST, "findByGroupId",
104                            new String[] {
105                                    Long.class.getName(),
106                                    
107                            "java.lang.Integer", "java.lang.Integer",
108                                    "com.liferay.portal.kernel.util.OrderByComparator"
109                            });
110            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(BookmarksFolderModelImpl.ENTITY_CACHE_ENABLED,
111                            BookmarksFolderModelImpl.FINDER_CACHE_ENABLED,
112                            FINDER_CLASS_NAME_LIST, "countByGroupId",
113                            new String[] { Long.class.getName() });
114            public static final FinderPath FINDER_PATH_FIND_BY_COMPANYID = new FinderPath(BookmarksFolderModelImpl.ENTITY_CACHE_ENABLED,
115                            BookmarksFolderModelImpl.FINDER_CACHE_ENABLED,
116                            FINDER_CLASS_NAME_LIST, "findByCompanyId",
117                            new String[] {
118                                    Long.class.getName(),
119                                    
120                            "java.lang.Integer", "java.lang.Integer",
121                                    "com.liferay.portal.kernel.util.OrderByComparator"
122                            });
123            public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(BookmarksFolderModelImpl.ENTITY_CACHE_ENABLED,
124                            BookmarksFolderModelImpl.FINDER_CACHE_ENABLED,
125                            FINDER_CLASS_NAME_LIST, "countByCompanyId",
126                            new String[] { Long.class.getName() });
127            public static final FinderPath FINDER_PATH_FIND_BY_G_P = new FinderPath(BookmarksFolderModelImpl.ENTITY_CACHE_ENABLED,
128                            BookmarksFolderModelImpl.FINDER_CACHE_ENABLED,
129                            FINDER_CLASS_NAME_LIST, "findByG_P",
130                            new String[] {
131                                    Long.class.getName(), Long.class.getName(),
132                                    
133                            "java.lang.Integer", "java.lang.Integer",
134                                    "com.liferay.portal.kernel.util.OrderByComparator"
135                            });
136            public static final FinderPath FINDER_PATH_COUNT_BY_G_P = new FinderPath(BookmarksFolderModelImpl.ENTITY_CACHE_ENABLED,
137                            BookmarksFolderModelImpl.FINDER_CACHE_ENABLED,
138                            FINDER_CLASS_NAME_LIST, "countByG_P",
139                            new String[] { Long.class.getName(), Long.class.getName() });
140            public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(BookmarksFolderModelImpl.ENTITY_CACHE_ENABLED,
141                            BookmarksFolderModelImpl.FINDER_CACHE_ENABLED,
142                            FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
143            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(BookmarksFolderModelImpl.ENTITY_CACHE_ENABLED,
144                            BookmarksFolderModelImpl.FINDER_CACHE_ENABLED,
145                            FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
146    
147            /**
148             * Caches the bookmarks folder in the entity cache if it is enabled.
149             *
150             * @param bookmarksFolder the bookmarks folder to cache
151             */
152            public void cacheResult(BookmarksFolder bookmarksFolder) {
153                    EntityCacheUtil.putResult(BookmarksFolderModelImpl.ENTITY_CACHE_ENABLED,
154                            BookmarksFolderImpl.class, bookmarksFolder.getPrimaryKey(),
155                            bookmarksFolder);
156    
157                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
158                            new Object[] {
159                                    bookmarksFolder.getUuid(),
160                                    new Long(bookmarksFolder.getGroupId())
161                            }, bookmarksFolder);
162            }
163    
164            /**
165             * Caches the bookmarks folders in the entity cache if it is enabled.
166             *
167             * @param bookmarksFolders the bookmarks folders to cache
168             */
169            public void cacheResult(List<BookmarksFolder> bookmarksFolders) {
170                    for (BookmarksFolder bookmarksFolder : bookmarksFolders) {
171                            if (EntityCacheUtil.getResult(
172                                                    BookmarksFolderModelImpl.ENTITY_CACHE_ENABLED,
173                                                    BookmarksFolderImpl.class,
174                                                    bookmarksFolder.getPrimaryKey(), this) == null) {
175                                    cacheResult(bookmarksFolder);
176                            }
177                    }
178            }
179    
180            /**
181             * Clears the cache for all bookmarks folders.
182             *
183             * <p>
184             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
185             * </p>
186             */
187            public void clearCache() {
188                    CacheRegistryUtil.clear(BookmarksFolderImpl.class.getName());
189                    EntityCacheUtil.clearCache(BookmarksFolderImpl.class.getName());
190                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
191                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
192            }
193    
194            /**
195             * Clears the cache for the bookmarks folder.
196             *
197             * <p>
198             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
199             * </p>
200             */
201            public void clearCache(BookmarksFolder bookmarksFolder) {
202                    EntityCacheUtil.removeResult(BookmarksFolderModelImpl.ENTITY_CACHE_ENABLED,
203                            BookmarksFolderImpl.class, bookmarksFolder.getPrimaryKey());
204    
205                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
206                            new Object[] {
207                                    bookmarksFolder.getUuid(),
208                                    new Long(bookmarksFolder.getGroupId())
209                            });
210            }
211    
212            /**
213             * Creates a new bookmarks folder with the primary key. Does not add the bookmarks folder to the database.
214             *
215             * @param folderId the primary key for the new bookmarks folder
216             * @return the new bookmarks folder
217             */
218            public BookmarksFolder create(long folderId) {
219                    BookmarksFolder bookmarksFolder = new BookmarksFolderImpl();
220    
221                    bookmarksFolder.setNew(true);
222                    bookmarksFolder.setPrimaryKey(folderId);
223    
224                    String uuid = PortalUUIDUtil.generate();
225    
226                    bookmarksFolder.setUuid(uuid);
227    
228                    return bookmarksFolder;
229            }
230    
231            /**
232             * Removes the bookmarks folder with the primary key from the database. Also notifies the appropriate model listeners.
233             *
234             * @param primaryKey the primary key of the bookmarks folder to remove
235             * @return the bookmarks folder that was removed
236             * @throws com.liferay.portal.NoSuchModelException if a bookmarks folder with the primary key could not be found
237             * @throws SystemException if a system exception occurred
238             */
239            public BookmarksFolder remove(Serializable primaryKey)
240                    throws NoSuchModelException, SystemException {
241                    return remove(((Long)primaryKey).longValue());
242            }
243    
244            /**
245             * Removes the bookmarks folder with the primary key from the database. Also notifies the appropriate model listeners.
246             *
247             * @param folderId the primary key of the bookmarks folder to remove
248             * @return the bookmarks folder that was removed
249             * @throws com.liferay.portlet.bookmarks.NoSuchFolderException if a bookmarks folder with the primary key could not be found
250             * @throws SystemException if a system exception occurred
251             */
252            public BookmarksFolder remove(long folderId)
253                    throws NoSuchFolderException, SystemException {
254                    Session session = null;
255    
256                    try {
257                            session = openSession();
258    
259                            BookmarksFolder bookmarksFolder = (BookmarksFolder)session.get(BookmarksFolderImpl.class,
260                                            new Long(folderId));
261    
262                            if (bookmarksFolder == null) {
263                                    if (_log.isWarnEnabled()) {
264                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + folderId);
265                                    }
266    
267                                    throw new NoSuchFolderException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
268                                            folderId);
269                            }
270    
271                            return remove(bookmarksFolder);
272                    }
273                    catch (NoSuchFolderException nsee) {
274                            throw nsee;
275                    }
276                    catch (Exception e) {
277                            throw processException(e);
278                    }
279                    finally {
280                            closeSession(session);
281                    }
282            }
283    
284            protected BookmarksFolder removeImpl(BookmarksFolder bookmarksFolder)
285                    throws SystemException {
286                    bookmarksFolder = toUnwrappedModel(bookmarksFolder);
287    
288                    Session session = null;
289    
290                    try {
291                            session = openSession();
292    
293                            BatchSessionUtil.delete(session, bookmarksFolder);
294                    }
295                    catch (Exception e) {
296                            throw processException(e);
297                    }
298                    finally {
299                            closeSession(session);
300                    }
301    
302                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
303    
304                    BookmarksFolderModelImpl bookmarksFolderModelImpl = (BookmarksFolderModelImpl)bookmarksFolder;
305    
306                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
307                            new Object[] {
308                                    bookmarksFolderModelImpl.getUuid(),
309                                    new Long(bookmarksFolderModelImpl.getGroupId())
310                            });
311    
312                    EntityCacheUtil.removeResult(BookmarksFolderModelImpl.ENTITY_CACHE_ENABLED,
313                            BookmarksFolderImpl.class, bookmarksFolder.getPrimaryKey());
314    
315                    return bookmarksFolder;
316            }
317    
318            public BookmarksFolder updateImpl(
319                    com.liferay.portlet.bookmarks.model.BookmarksFolder bookmarksFolder,
320                    boolean merge) throws SystemException {
321                    bookmarksFolder = toUnwrappedModel(bookmarksFolder);
322    
323                    boolean isNew = bookmarksFolder.isNew();
324    
325                    BookmarksFolderModelImpl bookmarksFolderModelImpl = (BookmarksFolderModelImpl)bookmarksFolder;
326    
327                    if (Validator.isNull(bookmarksFolder.getUuid())) {
328                            String uuid = PortalUUIDUtil.generate();
329    
330                            bookmarksFolder.setUuid(uuid);
331                    }
332    
333                    Session session = null;
334    
335                    try {
336                            session = openSession();
337    
338                            BatchSessionUtil.update(session, bookmarksFolder, merge);
339    
340                            bookmarksFolder.setNew(false);
341                    }
342                    catch (Exception e) {
343                            throw processException(e);
344                    }
345                    finally {
346                            closeSession(session);
347                    }
348    
349                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
350    
351                    EntityCacheUtil.putResult(BookmarksFolderModelImpl.ENTITY_CACHE_ENABLED,
352                            BookmarksFolderImpl.class, bookmarksFolder.getPrimaryKey(),
353                            bookmarksFolder);
354    
355                    if (!isNew &&
356                                    (!Validator.equals(bookmarksFolder.getUuid(),
357                                            bookmarksFolderModelImpl.getOriginalUuid()) ||
358                                    (bookmarksFolder.getGroupId() != bookmarksFolderModelImpl.getOriginalGroupId()))) {
359                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
360                                    new Object[] {
361                                            bookmarksFolderModelImpl.getOriginalUuid(),
362                                            new Long(bookmarksFolderModelImpl.getOriginalGroupId())
363                                    });
364                    }
365    
366                    if (isNew ||
367                                    (!Validator.equals(bookmarksFolder.getUuid(),
368                                            bookmarksFolderModelImpl.getOriginalUuid()) ||
369                                    (bookmarksFolder.getGroupId() != bookmarksFolderModelImpl.getOriginalGroupId()))) {
370                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
371                                    new Object[] {
372                                            bookmarksFolder.getUuid(),
373                                            new Long(bookmarksFolder.getGroupId())
374                                    }, bookmarksFolder);
375                    }
376    
377                    return bookmarksFolder;
378            }
379    
380            protected BookmarksFolder toUnwrappedModel(BookmarksFolder bookmarksFolder) {
381                    if (bookmarksFolder instanceof BookmarksFolderImpl) {
382                            return bookmarksFolder;
383                    }
384    
385                    BookmarksFolderImpl bookmarksFolderImpl = new BookmarksFolderImpl();
386    
387                    bookmarksFolderImpl.setNew(bookmarksFolder.isNew());
388                    bookmarksFolderImpl.setPrimaryKey(bookmarksFolder.getPrimaryKey());
389    
390                    bookmarksFolderImpl.setUuid(bookmarksFolder.getUuid());
391                    bookmarksFolderImpl.setFolderId(bookmarksFolder.getFolderId());
392                    bookmarksFolderImpl.setGroupId(bookmarksFolder.getGroupId());
393                    bookmarksFolderImpl.setCompanyId(bookmarksFolder.getCompanyId());
394                    bookmarksFolderImpl.setUserId(bookmarksFolder.getUserId());
395                    bookmarksFolderImpl.setCreateDate(bookmarksFolder.getCreateDate());
396                    bookmarksFolderImpl.setModifiedDate(bookmarksFolder.getModifiedDate());
397                    bookmarksFolderImpl.setParentFolderId(bookmarksFolder.getParentFolderId());
398                    bookmarksFolderImpl.setName(bookmarksFolder.getName());
399                    bookmarksFolderImpl.setDescription(bookmarksFolder.getDescription());
400    
401                    return bookmarksFolderImpl;
402            }
403    
404            /**
405             * Finds the bookmarks folder with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
406             *
407             * @param primaryKey the primary key of the bookmarks folder to find
408             * @return the bookmarks folder
409             * @throws com.liferay.portal.NoSuchModelException if a bookmarks folder with the primary key could not be found
410             * @throws SystemException if a system exception occurred
411             */
412            public BookmarksFolder findByPrimaryKey(Serializable primaryKey)
413                    throws NoSuchModelException, SystemException {
414                    return findByPrimaryKey(((Long)primaryKey).longValue());
415            }
416    
417            /**
418             * Finds the bookmarks folder with the primary key or throws a {@link com.liferay.portlet.bookmarks.NoSuchFolderException} if it could not be found.
419             *
420             * @param folderId the primary key of the bookmarks folder to find
421             * @return the bookmarks folder
422             * @throws com.liferay.portlet.bookmarks.NoSuchFolderException if a bookmarks folder with the primary key could not be found
423             * @throws SystemException if a system exception occurred
424             */
425            public BookmarksFolder findByPrimaryKey(long folderId)
426                    throws NoSuchFolderException, SystemException {
427                    BookmarksFolder bookmarksFolder = fetchByPrimaryKey(folderId);
428    
429                    if (bookmarksFolder == null) {
430                            if (_log.isWarnEnabled()) {
431                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + folderId);
432                            }
433    
434                            throw new NoSuchFolderException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
435                                    folderId);
436                    }
437    
438                    return bookmarksFolder;
439            }
440    
441            /**
442             * Finds the bookmarks folder with the primary key or returns <code>null</code> if it could not be found.
443             *
444             * @param primaryKey the primary key of the bookmarks folder to find
445             * @return the bookmarks folder, or <code>null</code> if a bookmarks folder with the primary key could not be found
446             * @throws SystemException if a system exception occurred
447             */
448            public BookmarksFolder fetchByPrimaryKey(Serializable primaryKey)
449                    throws SystemException {
450                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
451            }
452    
453            /**
454             * Finds the bookmarks folder with the primary key or returns <code>null</code> if it could not be found.
455             *
456             * @param folderId the primary key of the bookmarks folder to find
457             * @return the bookmarks folder, or <code>null</code> if a bookmarks folder with the primary key could not be found
458             * @throws SystemException if a system exception occurred
459             */
460            public BookmarksFolder fetchByPrimaryKey(long folderId)
461                    throws SystemException {
462                    BookmarksFolder bookmarksFolder = (BookmarksFolder)EntityCacheUtil.getResult(BookmarksFolderModelImpl.ENTITY_CACHE_ENABLED,
463                                    BookmarksFolderImpl.class, folderId, this);
464    
465                    if (bookmarksFolder == null) {
466                            Session session = null;
467    
468                            try {
469                                    session = openSession();
470    
471                                    bookmarksFolder = (BookmarksFolder)session.get(BookmarksFolderImpl.class,
472                                                    new Long(folderId));
473                            }
474                            catch (Exception e) {
475                                    throw processException(e);
476                            }
477                            finally {
478                                    if (bookmarksFolder != null) {
479                                            cacheResult(bookmarksFolder);
480                                    }
481    
482                                    closeSession(session);
483                            }
484                    }
485    
486                    return bookmarksFolder;
487            }
488    
489            /**
490             * Finds all the bookmarks folders where uuid = &#63;.
491             *
492             * @param uuid the uuid to search with
493             * @return the matching bookmarks folders
494             * @throws SystemException if a system exception occurred
495             */
496            public List<BookmarksFolder> findByUuid(String uuid)
497                    throws SystemException {
498                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
499            }
500    
501            /**
502             * Finds a range of all the bookmarks folders where uuid = &#63;.
503             *
504             * <p>
505             * 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.
506             * </p>
507             *
508             * @param uuid the uuid to search with
509             * @param start the lower bound of the range of bookmarks folders to return
510             * @param end the upper bound of the range of bookmarks folders to return (not inclusive)
511             * @return the range of matching bookmarks folders
512             * @throws SystemException if a system exception occurred
513             */
514            public List<BookmarksFolder> findByUuid(String uuid, int start, int end)
515                    throws SystemException {
516                    return findByUuid(uuid, start, end, null);
517            }
518    
519            /**
520             * Finds an ordered range of all the bookmarks folders where uuid = &#63;.
521             *
522             * <p>
523             * 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.
524             * </p>
525             *
526             * @param uuid the uuid to search with
527             * @param start the lower bound of the range of bookmarks folders to return
528             * @param end the upper bound of the range of bookmarks folders to return (not inclusive)
529             * @param orderByComparator the comparator to order the results by
530             * @return the ordered range of matching bookmarks folders
531             * @throws SystemException if a system exception occurred
532             */
533            public List<BookmarksFolder> findByUuid(String uuid, int start, int end,
534                    OrderByComparator orderByComparator) throws SystemException {
535                    Object[] finderArgs = new Object[] {
536                                    uuid,
537                                    
538                                    String.valueOf(start), String.valueOf(end),
539                                    String.valueOf(orderByComparator)
540                            };
541    
542                    List<BookmarksFolder> list = (List<BookmarksFolder>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_UUID,
543                                    finderArgs, this);
544    
545                    if (list == null) {
546                            StringBundler query = null;
547    
548                            if (orderByComparator != null) {
549                                    query = new StringBundler(3 +
550                                                    (orderByComparator.getOrderByFields().length * 3));
551                            }
552                            else {
553                                    query = new StringBundler(3);
554                            }
555    
556                            query.append(_SQL_SELECT_BOOKMARKSFOLDER_WHERE);
557    
558                            if (uuid == null) {
559                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
560                            }
561                            else {
562                                    if (uuid.equals(StringPool.BLANK)) {
563                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
564                                    }
565                                    else {
566                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
567                                    }
568                            }
569    
570                            if (orderByComparator != null) {
571                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
572                                            orderByComparator);
573                            }
574    
575                            else {
576                                    query.append(BookmarksFolderModelImpl.ORDER_BY_JPQL);
577                            }
578    
579                            String sql = query.toString();
580    
581                            Session session = null;
582    
583                            try {
584                                    session = openSession();
585    
586                                    Query q = session.createQuery(sql);
587    
588                                    QueryPos qPos = QueryPos.getInstance(q);
589    
590                                    if (uuid != null) {
591                                            qPos.add(uuid);
592                                    }
593    
594                                    list = (List<BookmarksFolder>)QueryUtil.list(q, getDialect(),
595                                                    start, end);
596                            }
597                            catch (Exception e) {
598                                    throw processException(e);
599                            }
600                            finally {
601                                    if (list == null) {
602                                            FinderCacheUtil.removeResult(FINDER_PATH_FIND_BY_UUID,
603                                                    finderArgs);
604                                    }
605                                    else {
606                                            cacheResult(list);
607    
608                                            FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_UUID,
609                                                    finderArgs, list);
610                                    }
611    
612                                    closeSession(session);
613                            }
614                    }
615    
616                    return list;
617            }
618    
619            /**
620             * Finds the first bookmarks folder in the ordered set where uuid = &#63;.
621             *
622             * <p>
623             * 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.
624             * </p>
625             *
626             * @param uuid the uuid to search with
627             * @param orderByComparator the comparator to order the set by
628             * @return the first matching bookmarks folder
629             * @throws com.liferay.portlet.bookmarks.NoSuchFolderException if a matching bookmarks folder could not be found
630             * @throws SystemException if a system exception occurred
631             */
632            public BookmarksFolder findByUuid_First(String uuid,
633                    OrderByComparator orderByComparator)
634                    throws NoSuchFolderException, SystemException {
635                    List<BookmarksFolder> list = findByUuid(uuid, 0, 1, orderByComparator);
636    
637                    if (list.isEmpty()) {
638                            StringBundler msg = new StringBundler(4);
639    
640                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
641    
642                            msg.append("uuid=");
643                            msg.append(uuid);
644    
645                            msg.append(StringPool.CLOSE_CURLY_BRACE);
646    
647                            throw new NoSuchFolderException(msg.toString());
648                    }
649                    else {
650                            return list.get(0);
651                    }
652            }
653    
654            /**
655             * Finds the last bookmarks folder in the ordered set where uuid = &#63;.
656             *
657             * <p>
658             * 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.
659             * </p>
660             *
661             * @param uuid the uuid to search with
662             * @param orderByComparator the comparator to order the set by
663             * @return the last matching bookmarks folder
664             * @throws com.liferay.portlet.bookmarks.NoSuchFolderException if a matching bookmarks folder could not be found
665             * @throws SystemException if a system exception occurred
666             */
667            public BookmarksFolder findByUuid_Last(String uuid,
668                    OrderByComparator orderByComparator)
669                    throws NoSuchFolderException, SystemException {
670                    int count = countByUuid(uuid);
671    
672                    List<BookmarksFolder> list = findByUuid(uuid, count - 1, count,
673                                    orderByComparator);
674    
675                    if (list.isEmpty()) {
676                            StringBundler msg = new StringBundler(4);
677    
678                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
679    
680                            msg.append("uuid=");
681                            msg.append(uuid);
682    
683                            msg.append(StringPool.CLOSE_CURLY_BRACE);
684    
685                            throw new NoSuchFolderException(msg.toString());
686                    }
687                    else {
688                            return list.get(0);
689                    }
690            }
691    
692            /**
693             * Finds the bookmarks folders before and after the current bookmarks folder in the ordered set where uuid = &#63;.
694             *
695             * <p>
696             * 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.
697             * </p>
698             *
699             * @param folderId the primary key of the current bookmarks folder
700             * @param uuid the uuid to search with
701             * @param orderByComparator the comparator to order the set by
702             * @return the previous, current, and next bookmarks folder
703             * @throws com.liferay.portlet.bookmarks.NoSuchFolderException if a bookmarks folder with the primary key could not be found
704             * @throws SystemException if a system exception occurred
705             */
706            public BookmarksFolder[] findByUuid_PrevAndNext(long folderId, String uuid,
707                    OrderByComparator orderByComparator)
708                    throws NoSuchFolderException, SystemException {
709                    BookmarksFolder bookmarksFolder = findByPrimaryKey(folderId);
710    
711                    Session session = null;
712    
713                    try {
714                            session = openSession();
715    
716                            BookmarksFolder[] array = new BookmarksFolderImpl[3];
717    
718                            array[0] = getByUuid_PrevAndNext(session, bookmarksFolder, uuid,
719                                            orderByComparator, true);
720    
721                            array[1] = bookmarksFolder;
722    
723                            array[2] = getByUuid_PrevAndNext(session, bookmarksFolder, uuid,
724                                            orderByComparator, false);
725    
726                            return array;
727                    }
728                    catch (Exception e) {
729                            throw processException(e);
730                    }
731                    finally {
732                            closeSession(session);
733                    }
734            }
735    
736            protected BookmarksFolder getByUuid_PrevAndNext(Session session,
737                    BookmarksFolder bookmarksFolder, String uuid,
738                    OrderByComparator orderByComparator, boolean previous) {
739                    StringBundler query = null;
740    
741                    if (orderByComparator != null) {
742                            query = new StringBundler(6 +
743                                            (orderByComparator.getOrderByFields().length * 6));
744                    }
745                    else {
746                            query = new StringBundler(3);
747                    }
748    
749                    query.append(_SQL_SELECT_BOOKMARKSFOLDER_WHERE);
750    
751                    if (uuid == null) {
752                            query.append(_FINDER_COLUMN_UUID_UUID_1);
753                    }
754                    else {
755                            if (uuid.equals(StringPool.BLANK)) {
756                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
757                            }
758                            else {
759                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
760                            }
761                    }
762    
763                    if (orderByComparator != null) {
764                            String[] orderByFields = orderByComparator.getOrderByFields();
765    
766                            if (orderByFields.length > 0) {
767                                    query.append(WHERE_AND);
768                            }
769    
770                            for (int i = 0; i < orderByFields.length; i++) {
771                                    query.append(_ORDER_BY_ENTITY_ALIAS);
772                                    query.append(orderByFields[i]);
773    
774                                    if ((i + 1) < orderByFields.length) {
775                                            if (orderByComparator.isAscending() ^ previous) {
776                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
777                                            }
778                                            else {
779                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
780                                            }
781                                    }
782                                    else {
783                                            if (orderByComparator.isAscending() ^ previous) {
784                                                    query.append(WHERE_GREATER_THAN);
785                                            }
786                                            else {
787                                                    query.append(WHERE_LESSER_THAN);
788                                            }
789                                    }
790                            }
791    
792                            query.append(ORDER_BY_CLAUSE);
793    
794                            for (int i = 0; i < orderByFields.length; i++) {
795                                    query.append(_ORDER_BY_ENTITY_ALIAS);
796                                    query.append(orderByFields[i]);
797    
798                                    if ((i + 1) < orderByFields.length) {
799                                            if (orderByComparator.isAscending() ^ previous) {
800                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
801                                            }
802                                            else {
803                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
804                                            }
805                                    }
806                                    else {
807                                            if (orderByComparator.isAscending() ^ previous) {
808                                                    query.append(ORDER_BY_ASC);
809                                            }
810                                            else {
811                                                    query.append(ORDER_BY_DESC);
812                                            }
813                                    }
814                            }
815                    }
816    
817                    else {
818                            query.append(BookmarksFolderModelImpl.ORDER_BY_JPQL);
819                    }
820    
821                    String sql = query.toString();
822    
823                    Query q = session.createQuery(sql);
824    
825                    q.setFirstResult(0);
826                    q.setMaxResults(2);
827    
828                    QueryPos qPos = QueryPos.getInstance(q);
829    
830                    if (uuid != null) {
831                            qPos.add(uuid);
832                    }
833    
834                    if (orderByComparator != null) {
835                            Object[] values = orderByComparator.getOrderByValues(bookmarksFolder);
836    
837                            for (Object value : values) {
838                                    qPos.add(value);
839                            }
840                    }
841    
842                    List<BookmarksFolder> list = q.list();
843    
844                    if (list.size() == 2) {
845                            return list.get(1);
846                    }
847                    else {
848                            return null;
849                    }
850            }
851    
852            /**
853             * Finds the bookmarks folder where uuid = &#63; and groupId = &#63; or throws a {@link com.liferay.portlet.bookmarks.NoSuchFolderException} if it could not be found.
854             *
855             * @param uuid the uuid to search with
856             * @param groupId the group id to search with
857             * @return the matching bookmarks folder
858             * @throws com.liferay.portlet.bookmarks.NoSuchFolderException if a matching bookmarks folder could not be found
859             * @throws SystemException if a system exception occurred
860             */
861            public BookmarksFolder findByUUID_G(String uuid, long groupId)
862                    throws NoSuchFolderException, SystemException {
863                    BookmarksFolder bookmarksFolder = fetchByUUID_G(uuid, groupId);
864    
865                    if (bookmarksFolder == null) {
866                            StringBundler msg = new StringBundler(6);
867    
868                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
869    
870                            msg.append("uuid=");
871                            msg.append(uuid);
872    
873                            msg.append(", groupId=");
874                            msg.append(groupId);
875    
876                            msg.append(StringPool.CLOSE_CURLY_BRACE);
877    
878                            if (_log.isWarnEnabled()) {
879                                    _log.warn(msg.toString());
880                            }
881    
882                            throw new NoSuchFolderException(msg.toString());
883                    }
884    
885                    return bookmarksFolder;
886            }
887    
888            /**
889             * Finds the bookmarks folder where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
890             *
891             * @param uuid the uuid to search with
892             * @param groupId the group id to search with
893             * @return the matching bookmarks folder, or <code>null</code> if a matching bookmarks folder could not be found
894             * @throws SystemException if a system exception occurred
895             */
896            public BookmarksFolder fetchByUUID_G(String uuid, long groupId)
897                    throws SystemException {
898                    return fetchByUUID_G(uuid, groupId, true);
899            }
900    
901            /**
902             * Finds the bookmarks folder where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
903             *
904             * @param uuid the uuid to search with
905             * @param groupId the group id to search with
906             * @return the matching bookmarks folder, or <code>null</code> if a matching bookmarks folder could not be found
907             * @throws SystemException if a system exception occurred
908             */
909            public BookmarksFolder fetchByUUID_G(String uuid, long groupId,
910                    boolean retrieveFromCache) throws SystemException {
911                    Object[] finderArgs = new Object[] { uuid, groupId };
912    
913                    Object result = null;
914    
915                    if (retrieveFromCache) {
916                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
917                                            finderArgs, this);
918                    }
919    
920                    if (result == null) {
921                            StringBundler query = new StringBundler(4);
922    
923                            query.append(_SQL_SELECT_BOOKMARKSFOLDER_WHERE);
924    
925                            if (uuid == null) {
926                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
927                            }
928                            else {
929                                    if (uuid.equals(StringPool.BLANK)) {
930                                            query.append(_FINDER_COLUMN_UUID_G_UUID_3);
931                                    }
932                                    else {
933                                            query.append(_FINDER_COLUMN_UUID_G_UUID_2);
934                                    }
935                            }
936    
937                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
938    
939                            query.append(BookmarksFolderModelImpl.ORDER_BY_JPQL);
940    
941                            String sql = query.toString();
942    
943                            Session session = null;
944    
945                            try {
946                                    session = openSession();
947    
948                                    Query q = session.createQuery(sql);
949    
950                                    QueryPos qPos = QueryPos.getInstance(q);
951    
952                                    if (uuid != null) {
953                                            qPos.add(uuid);
954                                    }
955    
956                                    qPos.add(groupId);
957    
958                                    List<BookmarksFolder> list = q.list();
959    
960                                    result = list;
961    
962                                    BookmarksFolder bookmarksFolder = null;
963    
964                                    if (list.isEmpty()) {
965                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
966                                                    finderArgs, list);
967                                    }
968                                    else {
969                                            bookmarksFolder = list.get(0);
970    
971                                            cacheResult(bookmarksFolder);
972    
973                                            if ((bookmarksFolder.getUuid() == null) ||
974                                                            !bookmarksFolder.getUuid().equals(uuid) ||
975                                                            (bookmarksFolder.getGroupId() != groupId)) {
976                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
977                                                            finderArgs, bookmarksFolder);
978                                            }
979                                    }
980    
981                                    return bookmarksFolder;
982                            }
983                            catch (Exception e) {
984                                    throw processException(e);
985                            }
986                            finally {
987                                    if (result == null) {
988                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
989                                                    finderArgs);
990                                    }
991    
992                                    closeSession(session);
993                            }
994                    }
995                    else {
996                            if (result instanceof List<?>) {
997                                    return null;
998                            }
999                            else {
1000                                    return (BookmarksFolder)result;
1001                            }
1002                    }
1003            }
1004    
1005            /**
1006             * Finds all the bookmarks folders where groupId = &#63;.
1007             *
1008             * @param groupId the group id to search with
1009             * @return the matching bookmarks folders
1010             * @throws SystemException if a system exception occurred
1011             */
1012            public List<BookmarksFolder> findByGroupId(long groupId)
1013                    throws SystemException {
1014                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1015            }
1016    
1017            /**
1018             * Finds a range of all the bookmarks folders where groupId = &#63;.
1019             *
1020             * <p>
1021             * 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.
1022             * </p>
1023             *
1024             * @param groupId the group id to search with
1025             * @param start the lower bound of the range of bookmarks folders to return
1026             * @param end the upper bound of the range of bookmarks folders to return (not inclusive)
1027             * @return the range of matching bookmarks folders
1028             * @throws SystemException if a system exception occurred
1029             */
1030            public List<BookmarksFolder> findByGroupId(long groupId, int start, int end)
1031                    throws SystemException {
1032                    return findByGroupId(groupId, start, end, null);
1033            }
1034    
1035            /**
1036             * Finds an ordered range of all the bookmarks folders where groupId = &#63;.
1037             *
1038             * <p>
1039             * 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.
1040             * </p>
1041             *
1042             * @param groupId the group id to search with
1043             * @param start the lower bound of the range of bookmarks folders to return
1044             * @param end the upper bound of the range of bookmarks folders to return (not inclusive)
1045             * @param orderByComparator the comparator to order the results by
1046             * @return the ordered range of matching bookmarks folders
1047             * @throws SystemException if a system exception occurred
1048             */
1049            public List<BookmarksFolder> findByGroupId(long groupId, int start,
1050                    int end, OrderByComparator orderByComparator) throws SystemException {
1051                    Object[] finderArgs = new Object[] {
1052                                    groupId,
1053                                    
1054                                    String.valueOf(start), String.valueOf(end),
1055                                    String.valueOf(orderByComparator)
1056                            };
1057    
1058                    List<BookmarksFolder> list = (List<BookmarksFolder>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_GROUPID,
1059                                    finderArgs, this);
1060    
1061                    if (list == null) {
1062                            StringBundler query = null;
1063    
1064                            if (orderByComparator != null) {
1065                                    query = new StringBundler(3 +
1066                                                    (orderByComparator.getOrderByFields().length * 3));
1067                            }
1068                            else {
1069                                    query = new StringBundler(3);
1070                            }
1071    
1072                            query.append(_SQL_SELECT_BOOKMARKSFOLDER_WHERE);
1073    
1074                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1075    
1076                            if (orderByComparator != null) {
1077                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1078                                            orderByComparator);
1079                            }
1080    
1081                            else {
1082                                    query.append(BookmarksFolderModelImpl.ORDER_BY_JPQL);
1083                            }
1084    
1085                            String sql = query.toString();
1086    
1087                            Session session = null;
1088    
1089                            try {
1090                                    session = openSession();
1091    
1092                                    Query q = session.createQuery(sql);
1093    
1094                                    QueryPos qPos = QueryPos.getInstance(q);
1095    
1096                                    qPos.add(groupId);
1097    
1098                                    list = (List<BookmarksFolder>)QueryUtil.list(q, getDialect(),
1099                                                    start, end);
1100                            }
1101                            catch (Exception e) {
1102                                    throw processException(e);
1103                            }
1104                            finally {
1105                                    if (list == null) {
1106                                            FinderCacheUtil.removeResult(FINDER_PATH_FIND_BY_GROUPID,
1107                                                    finderArgs);
1108                                    }
1109                                    else {
1110                                            cacheResult(list);
1111    
1112                                            FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_GROUPID,
1113                                                    finderArgs, list);
1114                                    }
1115    
1116                                    closeSession(session);
1117                            }
1118                    }
1119    
1120                    return list;
1121            }
1122    
1123            /**
1124             * Finds the first bookmarks folder in the ordered set where groupId = &#63;.
1125             *
1126             * <p>
1127             * 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.
1128             * </p>
1129             *
1130             * @param groupId the group id to search with
1131             * @param orderByComparator the comparator to order the set by
1132             * @return the first matching bookmarks folder
1133             * @throws com.liferay.portlet.bookmarks.NoSuchFolderException if a matching bookmarks folder could not be found
1134             * @throws SystemException if a system exception occurred
1135             */
1136            public BookmarksFolder findByGroupId_First(long groupId,
1137                    OrderByComparator orderByComparator)
1138                    throws NoSuchFolderException, SystemException {
1139                    List<BookmarksFolder> list = findByGroupId(groupId, 0, 1,
1140                                    orderByComparator);
1141    
1142                    if (list.isEmpty()) {
1143                            StringBundler msg = new StringBundler(4);
1144    
1145                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1146    
1147                            msg.append("groupId=");
1148                            msg.append(groupId);
1149    
1150                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1151    
1152                            throw new NoSuchFolderException(msg.toString());
1153                    }
1154                    else {
1155                            return list.get(0);
1156                    }
1157            }
1158    
1159            /**
1160             * Finds the last bookmarks folder in the ordered set where groupId = &#63;.
1161             *
1162             * <p>
1163             * 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.
1164             * </p>
1165             *
1166             * @param groupId the group id to search with
1167             * @param orderByComparator the comparator to order the set by
1168             * @return the last matching bookmarks folder
1169             * @throws com.liferay.portlet.bookmarks.NoSuchFolderException if a matching bookmarks folder could not be found
1170             * @throws SystemException if a system exception occurred
1171             */
1172            public BookmarksFolder findByGroupId_Last(long groupId,
1173                    OrderByComparator orderByComparator)
1174                    throws NoSuchFolderException, SystemException {
1175                    int count = countByGroupId(groupId);
1176    
1177                    List<BookmarksFolder> list = findByGroupId(groupId, count - 1, count,
1178                                    orderByComparator);
1179    
1180                    if (list.isEmpty()) {
1181                            StringBundler msg = new StringBundler(4);
1182    
1183                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1184    
1185                            msg.append("groupId=");
1186                            msg.append(groupId);
1187    
1188                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1189    
1190                            throw new NoSuchFolderException(msg.toString());
1191                    }
1192                    else {
1193                            return list.get(0);
1194                    }
1195            }
1196    
1197            /**
1198             * Finds the bookmarks folders before and after the current bookmarks folder in the ordered set where groupId = &#63;.
1199             *
1200             * <p>
1201             * 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.
1202             * </p>
1203             *
1204             * @param folderId the primary key of the current bookmarks folder
1205             * @param groupId the group id to search with
1206             * @param orderByComparator the comparator to order the set by
1207             * @return the previous, current, and next bookmarks folder
1208             * @throws com.liferay.portlet.bookmarks.NoSuchFolderException if a bookmarks folder with the primary key could not be found
1209             * @throws SystemException if a system exception occurred
1210             */
1211            public BookmarksFolder[] findByGroupId_PrevAndNext(long folderId,
1212                    long groupId, OrderByComparator orderByComparator)
1213                    throws NoSuchFolderException, SystemException {
1214                    BookmarksFolder bookmarksFolder = findByPrimaryKey(folderId);
1215    
1216                    Session session = null;
1217    
1218                    try {
1219                            session = openSession();
1220    
1221                            BookmarksFolder[] array = new BookmarksFolderImpl[3];
1222    
1223                            array[0] = getByGroupId_PrevAndNext(session, bookmarksFolder,
1224                                            groupId, orderByComparator, true);
1225    
1226                            array[1] = bookmarksFolder;
1227    
1228                            array[2] = getByGroupId_PrevAndNext(session, bookmarksFolder,
1229                                            groupId, orderByComparator, false);
1230    
1231                            return array;
1232                    }
1233                    catch (Exception e) {
1234                            throw processException(e);
1235                    }
1236                    finally {
1237                            closeSession(session);
1238                    }
1239            }
1240    
1241            protected BookmarksFolder getByGroupId_PrevAndNext(Session session,
1242                    BookmarksFolder bookmarksFolder, long groupId,
1243                    OrderByComparator orderByComparator, boolean previous) {
1244                    StringBundler query = null;
1245    
1246                    if (orderByComparator != null) {
1247                            query = new StringBundler(6 +
1248                                            (orderByComparator.getOrderByFields().length * 6));
1249                    }
1250                    else {
1251                            query = new StringBundler(3);
1252                    }
1253    
1254                    query.append(_SQL_SELECT_BOOKMARKSFOLDER_WHERE);
1255    
1256                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1257    
1258                    if (orderByComparator != null) {
1259                            String[] orderByFields = orderByComparator.getOrderByFields();
1260    
1261                            if (orderByFields.length > 0) {
1262                                    query.append(WHERE_AND);
1263                            }
1264    
1265                            for (int i = 0; i < orderByFields.length; i++) {
1266                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1267                                    query.append(orderByFields[i]);
1268    
1269                                    if ((i + 1) < orderByFields.length) {
1270                                            if (orderByComparator.isAscending() ^ previous) {
1271                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1272                                            }
1273                                            else {
1274                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1275                                            }
1276                                    }
1277                                    else {
1278                                            if (orderByComparator.isAscending() ^ previous) {
1279                                                    query.append(WHERE_GREATER_THAN);
1280                                            }
1281                                            else {
1282                                                    query.append(WHERE_LESSER_THAN);
1283                                            }
1284                                    }
1285                            }
1286    
1287                            query.append(ORDER_BY_CLAUSE);
1288    
1289                            for (int i = 0; i < orderByFields.length; i++) {
1290                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1291                                    query.append(orderByFields[i]);
1292    
1293                                    if ((i + 1) < orderByFields.length) {
1294                                            if (orderByComparator.isAscending() ^ previous) {
1295                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1296                                            }
1297                                            else {
1298                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1299                                            }
1300                                    }
1301                                    else {
1302                                            if (orderByComparator.isAscending() ^ previous) {
1303                                                    query.append(ORDER_BY_ASC);
1304                                            }
1305                                            else {
1306                                                    query.append(ORDER_BY_DESC);
1307                                            }
1308                                    }
1309                            }
1310                    }
1311    
1312                    else {
1313                            query.append(BookmarksFolderModelImpl.ORDER_BY_JPQL);
1314                    }
1315    
1316                    String sql = query.toString();
1317    
1318                    Query q = session.createQuery(sql);
1319    
1320                    q.setFirstResult(0);
1321                    q.setMaxResults(2);
1322    
1323                    QueryPos qPos = QueryPos.getInstance(q);
1324    
1325                    qPos.add(groupId);
1326    
1327                    if (orderByComparator != null) {
1328                            Object[] values = orderByComparator.getOrderByValues(bookmarksFolder);
1329    
1330                            for (Object value : values) {
1331                                    qPos.add(value);
1332                            }
1333                    }
1334    
1335                    List<BookmarksFolder> list = q.list();
1336    
1337                    if (list.size() == 2) {
1338                            return list.get(1);
1339                    }
1340                    else {
1341                            return null;
1342                    }
1343            }
1344    
1345            /**
1346             * Filters by the user's permissions and finds all the bookmarks folders where groupId = &#63;.
1347             *
1348             * @param groupId the group id to search with
1349             * @return the matching bookmarks folders that the user has permission to view
1350             * @throws SystemException if a system exception occurred
1351             */
1352            public List<BookmarksFolder> filterFindByGroupId(long groupId)
1353                    throws SystemException {
1354                    return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1355                            QueryUtil.ALL_POS, null);
1356            }
1357    
1358            /**
1359             * Filters by the user's permissions and finds a range of all the bookmarks folders where groupId = &#63;.
1360             *
1361             * <p>
1362             * 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.
1363             * </p>
1364             *
1365             * @param groupId the group id to search with
1366             * @param start the lower bound of the range of bookmarks folders to return
1367             * @param end the upper bound of the range of bookmarks folders to return (not inclusive)
1368             * @return the range of matching bookmarks folders that the user has permission to view
1369             * @throws SystemException if a system exception occurred
1370             */
1371            public List<BookmarksFolder> filterFindByGroupId(long groupId, int start,
1372                    int end) throws SystemException {
1373                    return filterFindByGroupId(groupId, start, end, null);
1374            }
1375    
1376            /**
1377             * Filters by the user's permissions and finds an ordered range of all the bookmarks folders where groupId = &#63;.
1378             *
1379             * <p>
1380             * 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.
1381             * </p>
1382             *
1383             * @param groupId the group id to search with
1384             * @param start the lower bound of the range of bookmarks folders to return
1385             * @param end the upper bound of the range of bookmarks folders to return (not inclusive)
1386             * @param orderByComparator the comparator to order the results by
1387             * @return the ordered range of matching bookmarks folders that the user has permission to view
1388             * @throws SystemException if a system exception occurred
1389             */
1390            public List<BookmarksFolder> filterFindByGroupId(long groupId, int start,
1391                    int end, OrderByComparator orderByComparator) throws SystemException {
1392                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1393                            return findByGroupId(groupId, start, end, orderByComparator);
1394                    }
1395    
1396                    StringBundler query = null;
1397    
1398                    if (orderByComparator != null) {
1399                            query = new StringBundler(3 +
1400                                            (orderByComparator.getOrderByFields().length * 3));
1401                    }
1402                    else {
1403                            query = new StringBundler(3);
1404                    }
1405    
1406                    if (getDB().isSupportsInlineDistinct()) {
1407                            query.append(_FILTER_SQL_SELECT_BOOKMARKSFOLDER_WHERE);
1408                    }
1409                    else {
1410                            query.append(_FILTER_SQL_SELECT_BOOKMARKSFOLDER_NO_INLINE_DISTINCT_WHERE_1);
1411                    }
1412    
1413                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1414    
1415                    if (!getDB().isSupportsInlineDistinct()) {
1416                            query.append(_FILTER_SQL_SELECT_BOOKMARKSFOLDER_NO_INLINE_DISTINCT_WHERE_2);
1417                    }
1418    
1419                    if (orderByComparator != null) {
1420                            if (getDB().isSupportsInlineDistinct()) {
1421                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1422                                            orderByComparator);
1423                            }
1424                            else {
1425                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1426                                            orderByComparator);
1427                            }
1428                    }
1429    
1430                    else {
1431                            if (getDB().isSupportsInlineDistinct()) {
1432                                    query.append(BookmarksFolderModelImpl.ORDER_BY_JPQL);
1433                            }
1434                            else {
1435                                    query.append(BookmarksFolderModelImpl.ORDER_BY_SQL);
1436                            }
1437                    }
1438    
1439                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1440                                    BookmarksFolder.class.getName(), _FILTER_COLUMN_PK,
1441                                    _FILTER_COLUMN_USERID, groupId);
1442    
1443                    Session session = null;
1444    
1445                    try {
1446                            session = openSession();
1447    
1448                            SQLQuery q = session.createSQLQuery(sql);
1449    
1450                            if (getDB().isSupportsInlineDistinct()) {
1451                                    q.addEntity(_FILTER_ENTITY_ALIAS, BookmarksFolderImpl.class);
1452                            }
1453                            else {
1454                                    q.addEntity(_FILTER_ENTITY_TABLE, BookmarksFolderImpl.class);
1455                            }
1456    
1457                            QueryPos qPos = QueryPos.getInstance(q);
1458    
1459                            qPos.add(groupId);
1460    
1461                            return (List<BookmarksFolder>)QueryUtil.list(q, getDialect(),
1462                                    start, end);
1463                    }
1464                    catch (Exception e) {
1465                            throw processException(e);
1466                    }
1467                    finally {
1468                            closeSession(session);
1469                    }
1470            }
1471    
1472            /**
1473             * Finds all the bookmarks folders where companyId = &#63;.
1474             *
1475             * @param companyId the company id to search with
1476             * @return the matching bookmarks folders
1477             * @throws SystemException if a system exception occurred
1478             */
1479            public List<BookmarksFolder> findByCompanyId(long companyId)
1480                    throws SystemException {
1481                    return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1482                            null);
1483            }
1484    
1485            /**
1486             * Finds a range of all the bookmarks folders where companyId = &#63;.
1487             *
1488             * <p>
1489             * 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.
1490             * </p>
1491             *
1492             * @param companyId the company id to search with
1493             * @param start the lower bound of the range of bookmarks folders to return
1494             * @param end the upper bound of the range of bookmarks folders to return (not inclusive)
1495             * @return the range of matching bookmarks folders
1496             * @throws SystemException if a system exception occurred
1497             */
1498            public List<BookmarksFolder> findByCompanyId(long companyId, int start,
1499                    int end) throws SystemException {
1500                    return findByCompanyId(companyId, start, end, null);
1501            }
1502    
1503            /**
1504             * Finds an ordered range of all the bookmarks folders where companyId = &#63;.
1505             *
1506             * <p>
1507             * 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.
1508             * </p>
1509             *
1510             * @param companyId the company id to search with
1511             * @param start the lower bound of the range of bookmarks folders to return
1512             * @param end the upper bound of the range of bookmarks folders to return (not inclusive)
1513             * @param orderByComparator the comparator to order the results by
1514             * @return the ordered range of matching bookmarks folders
1515             * @throws SystemException if a system exception occurred
1516             */
1517            public List<BookmarksFolder> findByCompanyId(long companyId, int start,
1518                    int end, OrderByComparator orderByComparator) throws SystemException {
1519                    Object[] finderArgs = new Object[] {
1520                                    companyId,
1521                                    
1522                                    String.valueOf(start), String.valueOf(end),
1523                                    String.valueOf(orderByComparator)
1524                            };
1525    
1526                    List<BookmarksFolder> list = (List<BookmarksFolder>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_COMPANYID,
1527                                    finderArgs, this);
1528    
1529                    if (list == null) {
1530                            StringBundler query = null;
1531    
1532                            if (orderByComparator != null) {
1533                                    query = new StringBundler(3 +
1534                                                    (orderByComparator.getOrderByFields().length * 3));
1535                            }
1536                            else {
1537                                    query = new StringBundler(3);
1538                            }
1539    
1540                            query.append(_SQL_SELECT_BOOKMARKSFOLDER_WHERE);
1541    
1542                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1543    
1544                            if (orderByComparator != null) {
1545                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1546                                            orderByComparator);
1547                            }
1548    
1549                            else {
1550                                    query.append(BookmarksFolderModelImpl.ORDER_BY_JPQL);
1551                            }
1552    
1553                            String sql = query.toString();
1554    
1555                            Session session = null;
1556    
1557                            try {
1558                                    session = openSession();
1559    
1560                                    Query q = session.createQuery(sql);
1561    
1562                                    QueryPos qPos = QueryPos.getInstance(q);
1563    
1564                                    qPos.add(companyId);
1565    
1566                                    list = (List<BookmarksFolder>)QueryUtil.list(q, getDialect(),
1567                                                    start, end);
1568                            }
1569                            catch (Exception e) {
1570                                    throw processException(e);
1571                            }
1572                            finally {
1573                                    if (list == null) {
1574                                            FinderCacheUtil.removeResult(FINDER_PATH_FIND_BY_COMPANYID,
1575                                                    finderArgs);
1576                                    }
1577                                    else {
1578                                            cacheResult(list);
1579    
1580                                            FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_COMPANYID,
1581                                                    finderArgs, list);
1582                                    }
1583    
1584                                    closeSession(session);
1585                            }
1586                    }
1587    
1588                    return list;
1589            }
1590    
1591            /**
1592             * Finds the first bookmarks folder in the ordered set where companyId = &#63;.
1593             *
1594             * <p>
1595             * 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.
1596             * </p>
1597             *
1598             * @param companyId the company id to search with
1599             * @param orderByComparator the comparator to order the set by
1600             * @return the first matching bookmarks folder
1601             * @throws com.liferay.portlet.bookmarks.NoSuchFolderException if a matching bookmarks folder could not be found
1602             * @throws SystemException if a system exception occurred
1603             */
1604            public BookmarksFolder findByCompanyId_First(long companyId,
1605                    OrderByComparator orderByComparator)
1606                    throws NoSuchFolderException, SystemException {
1607                    List<BookmarksFolder> list = findByCompanyId(companyId, 0, 1,
1608                                    orderByComparator);
1609    
1610                    if (list.isEmpty()) {
1611                            StringBundler msg = new StringBundler(4);
1612    
1613                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1614    
1615                            msg.append("companyId=");
1616                            msg.append(companyId);
1617    
1618                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1619    
1620                            throw new NoSuchFolderException(msg.toString());
1621                    }
1622                    else {
1623                            return list.get(0);
1624                    }
1625            }
1626    
1627            /**
1628             * Finds the last bookmarks folder in the ordered set where companyId = &#63;.
1629             *
1630             * <p>
1631             * 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.
1632             * </p>
1633             *
1634             * @param companyId the company id to search with
1635             * @param orderByComparator the comparator to order the set by
1636             * @return the last matching bookmarks folder
1637             * @throws com.liferay.portlet.bookmarks.NoSuchFolderException if a matching bookmarks folder could not be found
1638             * @throws SystemException if a system exception occurred
1639             */
1640            public BookmarksFolder findByCompanyId_Last(long companyId,
1641                    OrderByComparator orderByComparator)
1642                    throws NoSuchFolderException, SystemException {
1643                    int count = countByCompanyId(companyId);
1644    
1645                    List<BookmarksFolder> list = findByCompanyId(companyId, count - 1,
1646                                    count, orderByComparator);
1647    
1648                    if (list.isEmpty()) {
1649                            StringBundler msg = new StringBundler(4);
1650    
1651                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1652    
1653                            msg.append("companyId=");
1654                            msg.append(companyId);
1655    
1656                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1657    
1658                            throw new NoSuchFolderException(msg.toString());
1659                    }
1660                    else {
1661                            return list.get(0);
1662                    }
1663            }
1664    
1665            /**
1666             * Finds the bookmarks folders before and after the current bookmarks folder in the ordered set where companyId = &#63;.
1667             *
1668             * <p>
1669             * 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.
1670             * </p>
1671             *
1672             * @param folderId the primary key of the current bookmarks folder
1673             * @param companyId the company id to search with
1674             * @param orderByComparator the comparator to order the set by
1675             * @return the previous, current, and next bookmarks folder
1676             * @throws com.liferay.portlet.bookmarks.NoSuchFolderException if a bookmarks folder with the primary key could not be found
1677             * @throws SystemException if a system exception occurred
1678             */
1679            public BookmarksFolder[] findByCompanyId_PrevAndNext(long folderId,
1680                    long companyId, OrderByComparator orderByComparator)
1681                    throws NoSuchFolderException, SystemException {
1682                    BookmarksFolder bookmarksFolder = findByPrimaryKey(folderId);
1683    
1684                    Session session = null;
1685    
1686                    try {
1687                            session = openSession();
1688    
1689                            BookmarksFolder[] array = new BookmarksFolderImpl[3];
1690    
1691                            array[0] = getByCompanyId_PrevAndNext(session, bookmarksFolder,
1692                                            companyId, orderByComparator, true);
1693    
1694                            array[1] = bookmarksFolder;
1695    
1696                            array[2] = getByCompanyId_PrevAndNext(session, bookmarksFolder,
1697                                            companyId, orderByComparator, false);
1698    
1699                            return array;
1700                    }
1701                    catch (Exception e) {
1702                            throw processException(e);
1703                    }
1704                    finally {
1705                            closeSession(session);
1706                    }
1707            }
1708    
1709            protected BookmarksFolder getByCompanyId_PrevAndNext(Session session,
1710                    BookmarksFolder bookmarksFolder, long companyId,
1711                    OrderByComparator orderByComparator, boolean previous) {
1712                    StringBundler query = null;
1713    
1714                    if (orderByComparator != null) {
1715                            query = new StringBundler(6 +
1716                                            (orderByComparator.getOrderByFields().length * 6));
1717                    }
1718                    else {
1719                            query = new StringBundler(3);
1720                    }
1721    
1722                    query.append(_SQL_SELECT_BOOKMARKSFOLDER_WHERE);
1723    
1724                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1725    
1726                    if (orderByComparator != null) {
1727                            String[] orderByFields = orderByComparator.getOrderByFields();
1728    
1729                            if (orderByFields.length > 0) {
1730                                    query.append(WHERE_AND);
1731                            }
1732    
1733                            for (int i = 0; i < orderByFields.length; i++) {
1734                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1735                                    query.append(orderByFields[i]);
1736    
1737                                    if ((i + 1) < orderByFields.length) {
1738                                            if (orderByComparator.isAscending() ^ previous) {
1739                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1740                                            }
1741                                            else {
1742                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1743                                            }
1744                                    }
1745                                    else {
1746                                            if (orderByComparator.isAscending() ^ previous) {
1747                                                    query.append(WHERE_GREATER_THAN);
1748                                            }
1749                                            else {
1750                                                    query.append(WHERE_LESSER_THAN);
1751                                            }
1752                                    }
1753                            }
1754    
1755                            query.append(ORDER_BY_CLAUSE);
1756    
1757                            for (int i = 0; i < orderByFields.length; i++) {
1758                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1759                                    query.append(orderByFields[i]);
1760    
1761                                    if ((i + 1) < orderByFields.length) {
1762                                            if (orderByComparator.isAscending() ^ previous) {
1763                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1764                                            }
1765                                            else {
1766                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1767                                            }
1768                                    }
1769                                    else {
1770                                            if (orderByComparator.isAscending() ^ previous) {
1771                                                    query.append(ORDER_BY_ASC);
1772                                            }
1773                                            else {
1774                                                    query.append(ORDER_BY_DESC);
1775                                            }
1776                                    }
1777                            }
1778                    }
1779    
1780                    else {
1781                            query.append(BookmarksFolderModelImpl.ORDER_BY_JPQL);
1782                    }
1783    
1784                    String sql = query.toString();
1785    
1786                    Query q = session.createQuery(sql);
1787    
1788                    q.setFirstResult(0);
1789                    q.setMaxResults(2);
1790    
1791                    QueryPos qPos = QueryPos.getInstance(q);
1792    
1793                    qPos.add(companyId);
1794    
1795                    if (orderByComparator != null) {
1796                            Object[] values = orderByComparator.getOrderByValues(bookmarksFolder);
1797    
1798                            for (Object value : values) {
1799                                    qPos.add(value);
1800                            }
1801                    }
1802    
1803                    List<BookmarksFolder> list = q.list();
1804    
1805                    if (list.size() == 2) {
1806                            return list.get(1);
1807                    }
1808                    else {
1809                            return null;
1810                    }
1811            }
1812    
1813            /**
1814             * Finds all the bookmarks folders where groupId = &#63; and parentFolderId = &#63;.
1815             *
1816             * @param groupId the group id to search with
1817             * @param parentFolderId the parent folder id to search with
1818             * @return the matching bookmarks folders
1819             * @throws SystemException if a system exception occurred
1820             */
1821            public List<BookmarksFolder> findByG_P(long groupId, long parentFolderId)
1822                    throws SystemException {
1823                    return findByG_P(groupId, parentFolderId, QueryUtil.ALL_POS,
1824                            QueryUtil.ALL_POS, null);
1825            }
1826    
1827            /**
1828             * Finds a range of all the bookmarks folders where groupId = &#63; and parentFolderId = &#63;.
1829             *
1830             * <p>
1831             * 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.
1832             * </p>
1833             *
1834             * @param groupId the group id to search with
1835             * @param parentFolderId the parent folder id to search with
1836             * @param start the lower bound of the range of bookmarks folders to return
1837             * @param end the upper bound of the range of bookmarks folders to return (not inclusive)
1838             * @return the range of matching bookmarks folders
1839             * @throws SystemException if a system exception occurred
1840             */
1841            public List<BookmarksFolder> findByG_P(long groupId, long parentFolderId,
1842                    int start, int end) throws SystemException {
1843                    return findByG_P(groupId, parentFolderId, start, end, null);
1844            }
1845    
1846            /**
1847             * Finds an ordered range of all the bookmarks folders where groupId = &#63; and parentFolderId = &#63;.
1848             *
1849             * <p>
1850             * 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.
1851             * </p>
1852             *
1853             * @param groupId the group id to search with
1854             * @param parentFolderId the parent folder id to search with
1855             * @param start the lower bound of the range of bookmarks folders to return
1856             * @param end the upper bound of the range of bookmarks folders to return (not inclusive)
1857             * @param orderByComparator the comparator to order the results by
1858             * @return the ordered range of matching bookmarks folders
1859             * @throws SystemException if a system exception occurred
1860             */
1861            public List<BookmarksFolder> findByG_P(long groupId, long parentFolderId,
1862                    int start, int end, OrderByComparator orderByComparator)
1863                    throws SystemException {
1864                    Object[] finderArgs = new Object[] {
1865                                    groupId, parentFolderId,
1866                                    
1867                                    String.valueOf(start), String.valueOf(end),
1868                                    String.valueOf(orderByComparator)
1869                            };
1870    
1871                    List<BookmarksFolder> list = (List<BookmarksFolder>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_P,
1872                                    finderArgs, this);
1873    
1874                    if (list == null) {
1875                            StringBundler query = null;
1876    
1877                            if (orderByComparator != null) {
1878                                    query = new StringBundler(4 +
1879                                                    (orderByComparator.getOrderByFields().length * 3));
1880                            }
1881                            else {
1882                                    query = new StringBundler(4);
1883                            }
1884    
1885                            query.append(_SQL_SELECT_BOOKMARKSFOLDER_WHERE);
1886    
1887                            query.append(_FINDER_COLUMN_G_P_GROUPID_2);
1888    
1889                            query.append(_FINDER_COLUMN_G_P_PARENTFOLDERID_2);
1890    
1891                            if (orderByComparator != null) {
1892                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1893                                            orderByComparator);
1894                            }
1895    
1896                            else {
1897                                    query.append(BookmarksFolderModelImpl.ORDER_BY_JPQL);
1898                            }
1899    
1900                            String sql = query.toString();
1901    
1902                            Session session = null;
1903    
1904                            try {
1905                                    session = openSession();
1906    
1907                                    Query q = session.createQuery(sql);
1908    
1909                                    QueryPos qPos = QueryPos.getInstance(q);
1910    
1911                                    qPos.add(groupId);
1912    
1913                                    qPos.add(parentFolderId);
1914    
1915                                    list = (List<BookmarksFolder>)QueryUtil.list(q, getDialect(),
1916                                                    start, end);
1917                            }
1918                            catch (Exception e) {
1919                                    throw processException(e);
1920                            }
1921                            finally {
1922                                    if (list == null) {
1923                                            FinderCacheUtil.removeResult(FINDER_PATH_FIND_BY_G_P,
1924                                                    finderArgs);
1925                                    }
1926                                    else {
1927                                            cacheResult(list);
1928    
1929                                            FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_P,
1930                                                    finderArgs, list);
1931                                    }
1932    
1933                                    closeSession(session);
1934                            }
1935                    }
1936    
1937                    return list;
1938            }
1939    
1940            /**
1941             * Finds the first bookmarks folder in the ordered set where groupId = &#63; and parentFolderId = &#63;.
1942             *
1943             * <p>
1944             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1945             * </p>
1946             *
1947             * @param groupId the group id to search with
1948             * @param parentFolderId the parent folder id to search with
1949             * @param orderByComparator the comparator to order the set by
1950             * @return the first matching bookmarks folder
1951             * @throws com.liferay.portlet.bookmarks.NoSuchFolderException if a matching bookmarks folder could not be found
1952             * @throws SystemException if a system exception occurred
1953             */
1954            public BookmarksFolder findByG_P_First(long groupId, long parentFolderId,
1955                    OrderByComparator orderByComparator)
1956                    throws NoSuchFolderException, SystemException {
1957                    List<BookmarksFolder> list = findByG_P(groupId, parentFolderId, 0, 1,
1958                                    orderByComparator);
1959    
1960                    if (list.isEmpty()) {
1961                            StringBundler msg = new StringBundler(6);
1962    
1963                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1964    
1965                            msg.append("groupId=");
1966                            msg.append(groupId);
1967    
1968                            msg.append(", parentFolderId=");
1969                            msg.append(parentFolderId);
1970    
1971                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1972    
1973                            throw new NoSuchFolderException(msg.toString());
1974                    }
1975                    else {
1976                            return list.get(0);
1977                    }
1978            }
1979    
1980            /**
1981             * Finds the last bookmarks folder in the ordered set where groupId = &#63; and parentFolderId = &#63;.
1982             *
1983             * <p>
1984             * 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.
1985             * </p>
1986             *
1987             * @param groupId the group id to search with
1988             * @param parentFolderId the parent folder id to search with
1989             * @param orderByComparator the comparator to order the set by
1990             * @return the last matching bookmarks folder
1991             * @throws com.liferay.portlet.bookmarks.NoSuchFolderException if a matching bookmarks folder could not be found
1992             * @throws SystemException if a system exception occurred
1993             */
1994            public BookmarksFolder findByG_P_Last(long groupId, long parentFolderId,
1995                    OrderByComparator orderByComparator)
1996                    throws NoSuchFolderException, SystemException {
1997                    int count = countByG_P(groupId, parentFolderId);
1998    
1999                    List<BookmarksFolder> list = findByG_P(groupId, parentFolderId,
2000                                    count - 1, count, orderByComparator);
2001    
2002                    if (list.isEmpty()) {
2003                            StringBundler msg = new StringBundler(6);
2004    
2005                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2006    
2007                            msg.append("groupId=");
2008                            msg.append(groupId);
2009    
2010                            msg.append(", parentFolderId=");
2011                            msg.append(parentFolderId);
2012    
2013                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2014    
2015                            throw new NoSuchFolderException(msg.toString());
2016                    }
2017                    else {
2018                            return list.get(0);
2019                    }
2020            }
2021    
2022            /**
2023             * Finds the bookmarks folders before and after the current bookmarks folder in the ordered set where groupId = &#63; and parentFolderId = &#63;.
2024             *
2025             * <p>
2026             * 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.
2027             * </p>
2028             *
2029             * @param folderId the primary key of the current bookmarks folder
2030             * @param groupId the group id to search with
2031             * @param parentFolderId the parent folder id to search with
2032             * @param orderByComparator the comparator to order the set by
2033             * @return the previous, current, and next bookmarks folder
2034             * @throws com.liferay.portlet.bookmarks.NoSuchFolderException if a bookmarks folder with the primary key could not be found
2035             * @throws SystemException if a system exception occurred
2036             */
2037            public BookmarksFolder[] findByG_P_PrevAndNext(long folderId, long groupId,
2038                    long parentFolderId, OrderByComparator orderByComparator)
2039                    throws NoSuchFolderException, SystemException {
2040                    BookmarksFolder bookmarksFolder = findByPrimaryKey(folderId);
2041    
2042                    Session session = null;
2043    
2044                    try {
2045                            session = openSession();
2046    
2047                            BookmarksFolder[] array = new BookmarksFolderImpl[3];
2048    
2049                            array[0] = getByG_P_PrevAndNext(session, bookmarksFolder, groupId,
2050                                            parentFolderId, orderByComparator, true);
2051    
2052                            array[1] = bookmarksFolder;
2053    
2054                            array[2] = getByG_P_PrevAndNext(session, bookmarksFolder, groupId,
2055                                            parentFolderId, orderByComparator, false);
2056    
2057                            return array;
2058                    }
2059                    catch (Exception e) {
2060                            throw processException(e);
2061                    }
2062                    finally {
2063                            closeSession(session);
2064                    }
2065            }
2066    
2067            protected BookmarksFolder getByG_P_PrevAndNext(Session session,
2068                    BookmarksFolder bookmarksFolder, long groupId, long parentFolderId,
2069                    OrderByComparator orderByComparator, boolean previous) {
2070                    StringBundler query = null;
2071    
2072                    if (orderByComparator != null) {
2073                            query = new StringBundler(6 +
2074                                            (orderByComparator.getOrderByFields().length * 6));
2075                    }
2076                    else {
2077                            query = new StringBundler(3);
2078                    }
2079    
2080                    query.append(_SQL_SELECT_BOOKMARKSFOLDER_WHERE);
2081    
2082                    query.append(_FINDER_COLUMN_G_P_GROUPID_2);
2083    
2084                    query.append(_FINDER_COLUMN_G_P_PARENTFOLDERID_2);
2085    
2086                    if (orderByComparator != null) {
2087                            String[] orderByFields = orderByComparator.getOrderByFields();
2088    
2089                            if (orderByFields.length > 0) {
2090                                    query.append(WHERE_AND);
2091                            }
2092    
2093                            for (int i = 0; i < orderByFields.length; i++) {
2094                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2095                                    query.append(orderByFields[i]);
2096    
2097                                    if ((i + 1) < orderByFields.length) {
2098                                            if (orderByComparator.isAscending() ^ previous) {
2099                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2100                                            }
2101                                            else {
2102                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2103                                            }
2104                                    }
2105                                    else {
2106                                            if (orderByComparator.isAscending() ^ previous) {
2107                                                    query.append(WHERE_GREATER_THAN);
2108                                            }
2109                                            else {
2110                                                    query.append(WHERE_LESSER_THAN);
2111                                            }
2112                                    }
2113                            }
2114    
2115                            query.append(ORDER_BY_CLAUSE);
2116    
2117                            for (int i = 0; i < orderByFields.length; i++) {
2118                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2119                                    query.append(orderByFields[i]);
2120    
2121                                    if ((i + 1) < orderByFields.length) {
2122                                            if (orderByComparator.isAscending() ^ previous) {
2123                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2124                                            }
2125                                            else {
2126                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2127                                            }
2128                                    }
2129                                    else {
2130                                            if (orderByComparator.isAscending() ^ previous) {
2131                                                    query.append(ORDER_BY_ASC);
2132                                            }
2133                                            else {
2134                                                    query.append(ORDER_BY_DESC);
2135                                            }
2136                                    }
2137                            }
2138                    }
2139    
2140                    else {
2141                            query.append(BookmarksFolderModelImpl.ORDER_BY_JPQL);
2142                    }
2143    
2144                    String sql = query.toString();
2145    
2146                    Query q = session.createQuery(sql);
2147    
2148                    q.setFirstResult(0);
2149                    q.setMaxResults(2);
2150    
2151                    QueryPos qPos = QueryPos.getInstance(q);
2152    
2153                    qPos.add(groupId);
2154    
2155                    qPos.add(parentFolderId);
2156    
2157                    if (orderByComparator != null) {
2158                            Object[] values = orderByComparator.getOrderByValues(bookmarksFolder);
2159    
2160                            for (Object value : values) {
2161                                    qPos.add(value);
2162                            }
2163                    }
2164    
2165                    List<BookmarksFolder> list = q.list();
2166    
2167                    if (list.size() == 2) {
2168                            return list.get(1);
2169                    }
2170                    else {
2171                            return null;
2172                    }
2173            }
2174    
2175            /**
2176             * Filters by the user's permissions and finds all the bookmarks folders where groupId = &#63; and parentFolderId = &#63;.
2177             *
2178             * @param groupId the group id to search with
2179             * @param parentFolderId the parent folder id to search with
2180             * @return the matching bookmarks folders that the user has permission to view
2181             * @throws SystemException if a system exception occurred
2182             */
2183            public List<BookmarksFolder> filterFindByG_P(long groupId,
2184                    long parentFolderId) throws SystemException {
2185                    return filterFindByG_P(groupId, parentFolderId, QueryUtil.ALL_POS,
2186                            QueryUtil.ALL_POS, null);
2187            }
2188    
2189            /**
2190             * Filters by the user's permissions and finds a range of all the bookmarks folders where groupId = &#63; and parentFolderId = &#63;.
2191             *
2192             * <p>
2193             * 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.
2194             * </p>
2195             *
2196             * @param groupId the group id to search with
2197             * @param parentFolderId the parent folder id to search with
2198             * @param start the lower bound of the range of bookmarks folders to return
2199             * @param end the upper bound of the range of bookmarks folders to return (not inclusive)
2200             * @return the range of matching bookmarks folders that the user has permission to view
2201             * @throws SystemException if a system exception occurred
2202             */
2203            public List<BookmarksFolder> filterFindByG_P(long groupId,
2204                    long parentFolderId, int start, int end) throws SystemException {
2205                    return filterFindByG_P(groupId, parentFolderId, start, end, null);
2206            }
2207    
2208            /**
2209             * Filters by the user's permissions and finds an ordered range of all the bookmarks folders where groupId = &#63; and parentFolderId = &#63;.
2210             *
2211             * <p>
2212             * 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.
2213             * </p>
2214             *
2215             * @param groupId the group id to search with
2216             * @param parentFolderId the parent folder id to search with
2217             * @param start the lower bound of the range of bookmarks folders to return
2218             * @param end the upper bound of the range of bookmarks folders to return (not inclusive)
2219             * @param orderByComparator the comparator to order the results by
2220             * @return the ordered range of matching bookmarks folders that the user has permission to view
2221             * @throws SystemException if a system exception occurred
2222             */
2223            public List<BookmarksFolder> filterFindByG_P(long groupId,
2224                    long parentFolderId, int start, int end,
2225                    OrderByComparator orderByComparator) throws SystemException {
2226                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2227                            return findByG_P(groupId, parentFolderId, start, end,
2228                                    orderByComparator);
2229                    }
2230    
2231                    StringBundler query = null;
2232    
2233                    if (orderByComparator != null) {
2234                            query = new StringBundler(4 +
2235                                            (orderByComparator.getOrderByFields().length * 3));
2236                    }
2237                    else {
2238                            query = new StringBundler(4);
2239                    }
2240    
2241                    if (getDB().isSupportsInlineDistinct()) {
2242                            query.append(_FILTER_SQL_SELECT_BOOKMARKSFOLDER_WHERE);
2243                    }
2244                    else {
2245                            query.append(_FILTER_SQL_SELECT_BOOKMARKSFOLDER_NO_INLINE_DISTINCT_WHERE_1);
2246                    }
2247    
2248                    query.append(_FINDER_COLUMN_G_P_GROUPID_2);
2249    
2250                    query.append(_FINDER_COLUMN_G_P_PARENTFOLDERID_2);
2251    
2252                    if (!getDB().isSupportsInlineDistinct()) {
2253                            query.append(_FILTER_SQL_SELECT_BOOKMARKSFOLDER_NO_INLINE_DISTINCT_WHERE_2);
2254                    }
2255    
2256                    if (orderByComparator != null) {
2257                            if (getDB().isSupportsInlineDistinct()) {
2258                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2259                                            orderByComparator);
2260                            }
2261                            else {
2262                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2263                                            orderByComparator);
2264                            }
2265                    }
2266    
2267                    else {
2268                            if (getDB().isSupportsInlineDistinct()) {
2269                                    query.append(BookmarksFolderModelImpl.ORDER_BY_JPQL);
2270                            }
2271                            else {
2272                                    query.append(BookmarksFolderModelImpl.ORDER_BY_SQL);
2273                            }
2274                    }
2275    
2276                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2277                                    BookmarksFolder.class.getName(), _FILTER_COLUMN_PK,
2278                                    _FILTER_COLUMN_USERID, groupId);
2279    
2280                    Session session = null;
2281    
2282                    try {
2283                            session = openSession();
2284    
2285                            SQLQuery q = session.createSQLQuery(sql);
2286    
2287                            if (getDB().isSupportsInlineDistinct()) {
2288                                    q.addEntity(_FILTER_ENTITY_ALIAS, BookmarksFolderImpl.class);
2289                            }
2290                            else {
2291                                    q.addEntity(_FILTER_ENTITY_TABLE, BookmarksFolderImpl.class);
2292                            }
2293    
2294                            QueryPos qPos = QueryPos.getInstance(q);
2295    
2296                            qPos.add(groupId);
2297    
2298                            qPos.add(parentFolderId);
2299    
2300                            return (List<BookmarksFolder>)QueryUtil.list(q, getDialect(),
2301                                    start, end);
2302                    }
2303                    catch (Exception e) {
2304                            throw processException(e);
2305                    }
2306                    finally {
2307                            closeSession(session);
2308                    }
2309            }
2310    
2311            /**
2312             * Finds all the bookmarks folders.
2313             *
2314             * @return the bookmarks folders
2315             * @throws SystemException if a system exception occurred
2316             */
2317            public List<BookmarksFolder> findAll() throws SystemException {
2318                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2319            }
2320    
2321            /**
2322             * Finds a range of all the bookmarks folders.
2323             *
2324             * <p>
2325             * 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.
2326             * </p>
2327             *
2328             * @param start the lower bound of the range of bookmarks folders to return
2329             * @param end the upper bound of the range of bookmarks folders to return (not inclusive)
2330             * @return the range of bookmarks folders
2331             * @throws SystemException if a system exception occurred
2332             */
2333            public List<BookmarksFolder> findAll(int start, int end)
2334                    throws SystemException {
2335                    return findAll(start, end, null);
2336            }
2337    
2338            /**
2339             * Finds an ordered range of all the bookmarks folders.
2340             *
2341             * <p>
2342             * 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.
2343             * </p>
2344             *
2345             * @param start the lower bound of the range of bookmarks folders to return
2346             * @param end the upper bound of the range of bookmarks folders to return (not inclusive)
2347             * @param orderByComparator the comparator to order the results by
2348             * @return the ordered range of bookmarks folders
2349             * @throws SystemException if a system exception occurred
2350             */
2351            public List<BookmarksFolder> findAll(int start, int end,
2352                    OrderByComparator orderByComparator) throws SystemException {
2353                    Object[] finderArgs = new Object[] {
2354                                    String.valueOf(start), String.valueOf(end),
2355                                    String.valueOf(orderByComparator)
2356                            };
2357    
2358                    List<BookmarksFolder> list = (List<BookmarksFolder>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
2359                                    finderArgs, this);
2360    
2361                    if (list == null) {
2362                            StringBundler query = null;
2363                            String sql = null;
2364    
2365                            if (orderByComparator != null) {
2366                                    query = new StringBundler(2 +
2367                                                    (orderByComparator.getOrderByFields().length * 3));
2368    
2369                                    query.append(_SQL_SELECT_BOOKMARKSFOLDER);
2370    
2371                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2372                                            orderByComparator);
2373    
2374                                    sql = query.toString();
2375                            }
2376                            else {
2377                                    sql = _SQL_SELECT_BOOKMARKSFOLDER.concat(BookmarksFolderModelImpl.ORDER_BY_JPQL);
2378                            }
2379    
2380                            Session session = null;
2381    
2382                            try {
2383                                    session = openSession();
2384    
2385                                    Query q = session.createQuery(sql);
2386    
2387                                    if (orderByComparator == null) {
2388                                            list = (List<BookmarksFolder>)QueryUtil.list(q,
2389                                                            getDialect(), start, end, false);
2390    
2391                                            Collections.sort(list);
2392                                    }
2393                                    else {
2394                                            list = (List<BookmarksFolder>)QueryUtil.list(q,
2395                                                            getDialect(), start, end);
2396                                    }
2397                            }
2398                            catch (Exception e) {
2399                                    throw processException(e);
2400                            }
2401                            finally {
2402                                    if (list == null) {
2403                                            FinderCacheUtil.removeResult(FINDER_PATH_FIND_ALL,
2404                                                    finderArgs);
2405                                    }
2406                                    else {
2407                                            cacheResult(list);
2408    
2409                                            FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs,
2410                                                    list);
2411                                    }
2412    
2413                                    closeSession(session);
2414                            }
2415                    }
2416    
2417                    return list;
2418            }
2419    
2420            /**
2421             * Removes all the bookmarks folders where uuid = &#63; from the database.
2422             *
2423             * @param uuid the uuid to search with
2424             * @throws SystemException if a system exception occurred
2425             */
2426            public void removeByUuid(String uuid) throws SystemException {
2427                    for (BookmarksFolder bookmarksFolder : findByUuid(uuid)) {
2428                            remove(bookmarksFolder);
2429                    }
2430            }
2431    
2432            /**
2433             * Removes the bookmarks folder where uuid = &#63; and groupId = &#63; from the database.
2434             *
2435             * @param uuid the uuid to search with
2436             * @param groupId the group id to search with
2437             * @throws SystemException if a system exception occurred
2438             */
2439            public void removeByUUID_G(String uuid, long groupId)
2440                    throws NoSuchFolderException, SystemException {
2441                    BookmarksFolder bookmarksFolder = findByUUID_G(uuid, groupId);
2442    
2443                    remove(bookmarksFolder);
2444            }
2445    
2446            /**
2447             * Removes all the bookmarks folders where groupId = &#63; from the database.
2448             *
2449             * @param groupId the group id to search with
2450             * @throws SystemException if a system exception occurred
2451             */
2452            public void removeByGroupId(long groupId) throws SystemException {
2453                    for (BookmarksFolder bookmarksFolder : findByGroupId(groupId)) {
2454                            remove(bookmarksFolder);
2455                    }
2456            }
2457    
2458            /**
2459             * Removes all the bookmarks folders where companyId = &#63; from the database.
2460             *
2461             * @param companyId the company id to search with
2462             * @throws SystemException if a system exception occurred
2463             */
2464            public void removeByCompanyId(long companyId) throws SystemException {
2465                    for (BookmarksFolder bookmarksFolder : findByCompanyId(companyId)) {
2466                            remove(bookmarksFolder);
2467                    }
2468            }
2469    
2470            /**
2471             * Removes all the bookmarks folders where groupId = &#63; and parentFolderId = &#63; from the database.
2472             *
2473             * @param groupId the group id to search with
2474             * @param parentFolderId the parent folder id to search with
2475             * @throws SystemException if a system exception occurred
2476             */
2477            public void removeByG_P(long groupId, long parentFolderId)
2478                    throws SystemException {
2479                    for (BookmarksFolder bookmarksFolder : findByG_P(groupId, parentFolderId)) {
2480                            remove(bookmarksFolder);
2481                    }
2482            }
2483    
2484            /**
2485             * Removes all the bookmarks folders from the database.
2486             *
2487             * @throws SystemException if a system exception occurred
2488             */
2489            public void removeAll() throws SystemException {
2490                    for (BookmarksFolder bookmarksFolder : findAll()) {
2491                            remove(bookmarksFolder);
2492                    }
2493            }
2494    
2495            /**
2496             * Counts all the bookmarks folders where uuid = &#63;.
2497             *
2498             * @param uuid the uuid to search with
2499             * @return the number of matching bookmarks folders
2500             * @throws SystemException if a system exception occurred
2501             */
2502            public int countByUuid(String uuid) throws SystemException {
2503                    Object[] finderArgs = new Object[] { uuid };
2504    
2505                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
2506                                    finderArgs, this);
2507    
2508                    if (count == null) {
2509                            StringBundler query = new StringBundler(2);
2510    
2511                            query.append(_SQL_COUNT_BOOKMARKSFOLDER_WHERE);
2512    
2513                            if (uuid == null) {
2514                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
2515                            }
2516                            else {
2517                                    if (uuid.equals(StringPool.BLANK)) {
2518                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
2519                                    }
2520                                    else {
2521                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
2522                                    }
2523                            }
2524    
2525                            String sql = query.toString();
2526    
2527                            Session session = null;
2528    
2529                            try {
2530                                    session = openSession();
2531    
2532                                    Query q = session.createQuery(sql);
2533    
2534                                    QueryPos qPos = QueryPos.getInstance(q);
2535    
2536                                    if (uuid != null) {
2537                                            qPos.add(uuid);
2538                                    }
2539    
2540                                    count = (Long)q.uniqueResult();
2541                            }
2542                            catch (Exception e) {
2543                                    throw processException(e);
2544                            }
2545                            finally {
2546                                    if (count == null) {
2547                                            count = Long.valueOf(0);
2548                                    }
2549    
2550                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
2551                                            finderArgs, count);
2552    
2553                                    closeSession(session);
2554                            }
2555                    }
2556    
2557                    return count.intValue();
2558            }
2559    
2560            /**
2561             * Counts all the bookmarks folders where uuid = &#63; and groupId = &#63;.
2562             *
2563             * @param uuid the uuid to search with
2564             * @param groupId the group id to search with
2565             * @return the number of matching bookmarks folders
2566             * @throws SystemException if a system exception occurred
2567             */
2568            public int countByUUID_G(String uuid, long groupId)
2569                    throws SystemException {
2570                    Object[] finderArgs = new Object[] { uuid, groupId };
2571    
2572                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
2573                                    finderArgs, this);
2574    
2575                    if (count == null) {
2576                            StringBundler query = new StringBundler(3);
2577    
2578                            query.append(_SQL_COUNT_BOOKMARKSFOLDER_WHERE);
2579    
2580                            if (uuid == null) {
2581                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
2582                            }
2583                            else {
2584                                    if (uuid.equals(StringPool.BLANK)) {
2585                                            query.append(_FINDER_COLUMN_UUID_G_UUID_3);
2586                                    }
2587                                    else {
2588                                            query.append(_FINDER_COLUMN_UUID_G_UUID_2);
2589                                    }
2590                            }
2591    
2592                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
2593    
2594                            String sql = query.toString();
2595    
2596                            Session session = null;
2597    
2598                            try {
2599                                    session = openSession();
2600    
2601                                    Query q = session.createQuery(sql);
2602    
2603                                    QueryPos qPos = QueryPos.getInstance(q);
2604    
2605                                    if (uuid != null) {
2606                                            qPos.add(uuid);
2607                                    }
2608    
2609                                    qPos.add(groupId);
2610    
2611                                    count = (Long)q.uniqueResult();
2612                            }
2613                            catch (Exception e) {
2614                                    throw processException(e);
2615                            }
2616                            finally {
2617                                    if (count == null) {
2618                                            count = Long.valueOf(0);
2619                                    }
2620    
2621                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
2622                                            finderArgs, count);
2623    
2624                                    closeSession(session);
2625                            }
2626                    }
2627    
2628                    return count.intValue();
2629            }
2630    
2631            /**
2632             * Counts all the bookmarks folders where groupId = &#63;.
2633             *
2634             * @param groupId the group id to search with
2635             * @return the number of matching bookmarks folders
2636             * @throws SystemException if a system exception occurred
2637             */
2638            public int countByGroupId(long groupId) throws SystemException {
2639                    Object[] finderArgs = new Object[] { groupId };
2640    
2641                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
2642                                    finderArgs, this);
2643    
2644                    if (count == null) {
2645                            StringBundler query = new StringBundler(2);
2646    
2647                            query.append(_SQL_COUNT_BOOKMARKSFOLDER_WHERE);
2648    
2649                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2650    
2651                            String sql = query.toString();
2652    
2653                            Session session = null;
2654    
2655                            try {
2656                                    session = openSession();
2657    
2658                                    Query q = session.createQuery(sql);
2659    
2660                                    QueryPos qPos = QueryPos.getInstance(q);
2661    
2662                                    qPos.add(groupId);
2663    
2664                                    count = (Long)q.uniqueResult();
2665                            }
2666                            catch (Exception e) {
2667                                    throw processException(e);
2668                            }
2669                            finally {
2670                                    if (count == null) {
2671                                            count = Long.valueOf(0);
2672                                    }
2673    
2674                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
2675                                            finderArgs, count);
2676    
2677                                    closeSession(session);
2678                            }
2679                    }
2680    
2681                    return count.intValue();
2682            }
2683    
2684            /**
2685             * Filters by the user's permissions and counts all the bookmarks folders where groupId = &#63;.
2686             *
2687             * @param groupId the group id to search with
2688             * @return the number of matching bookmarks folders that the user has permission to view
2689             * @throws SystemException if a system exception occurred
2690             */
2691            public int filterCountByGroupId(long groupId) throws SystemException {
2692                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2693                            return countByGroupId(groupId);
2694                    }
2695    
2696                    StringBundler query = new StringBundler(2);
2697    
2698                    query.append(_FILTER_SQL_COUNT_BOOKMARKSFOLDER_WHERE);
2699    
2700                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2701    
2702                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2703                                    BookmarksFolder.class.getName(), _FILTER_COLUMN_PK,
2704                                    _FILTER_COLUMN_USERID, groupId);
2705    
2706                    Session session = null;
2707    
2708                    try {
2709                            session = openSession();
2710    
2711                            SQLQuery q = session.createSQLQuery(sql);
2712    
2713                            q.addScalar(COUNT_COLUMN_NAME,
2714                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
2715    
2716                            QueryPos qPos = QueryPos.getInstance(q);
2717    
2718                            qPos.add(groupId);
2719    
2720                            Long count = (Long)q.uniqueResult();
2721    
2722                            return count.intValue();
2723                    }
2724                    catch (Exception e) {
2725                            throw processException(e);
2726                    }
2727                    finally {
2728                            closeSession(session);
2729                    }
2730            }
2731    
2732            /**
2733             * Counts all the bookmarks folders where companyId = &#63;.
2734             *
2735             * @param companyId the company id to search with
2736             * @return the number of matching bookmarks folders
2737             * @throws SystemException if a system exception occurred
2738             */
2739            public int countByCompanyId(long companyId) throws SystemException {
2740                    Object[] finderArgs = new Object[] { companyId };
2741    
2742                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
2743                                    finderArgs, this);
2744    
2745                    if (count == null) {
2746                            StringBundler query = new StringBundler(2);
2747    
2748                            query.append(_SQL_COUNT_BOOKMARKSFOLDER_WHERE);
2749    
2750                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2751    
2752                            String sql = query.toString();
2753    
2754                            Session session = null;
2755    
2756                            try {
2757                                    session = openSession();
2758    
2759                                    Query q = session.createQuery(sql);
2760    
2761                                    QueryPos qPos = QueryPos.getInstance(q);
2762    
2763                                    qPos.add(companyId);
2764    
2765                                    count = (Long)q.uniqueResult();
2766                            }
2767                            catch (Exception e) {
2768                                    throw processException(e);
2769                            }
2770                            finally {
2771                                    if (count == null) {
2772                                            count = Long.valueOf(0);
2773                                    }
2774    
2775                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
2776                                            finderArgs, count);
2777    
2778                                    closeSession(session);
2779                            }
2780                    }
2781    
2782                    return count.intValue();
2783            }
2784    
2785            /**
2786             * Counts all the bookmarks folders where groupId = &#63; and parentFolderId = &#63;.
2787             *
2788             * @param groupId the group id to search with
2789             * @param parentFolderId the parent folder id to search with
2790             * @return the number of matching bookmarks folders
2791             * @throws SystemException if a system exception occurred
2792             */
2793            public int countByG_P(long groupId, long parentFolderId)
2794                    throws SystemException {
2795                    Object[] finderArgs = new Object[] { groupId, parentFolderId };
2796    
2797                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P,
2798                                    finderArgs, this);
2799    
2800                    if (count == null) {
2801                            StringBundler query = new StringBundler(3);
2802    
2803                            query.append(_SQL_COUNT_BOOKMARKSFOLDER_WHERE);
2804    
2805                            query.append(_FINDER_COLUMN_G_P_GROUPID_2);
2806    
2807                            query.append(_FINDER_COLUMN_G_P_PARENTFOLDERID_2);
2808    
2809                            String sql = query.toString();
2810    
2811                            Session session = null;
2812    
2813                            try {
2814                                    session = openSession();
2815    
2816                                    Query q = session.createQuery(sql);
2817    
2818                                    QueryPos qPos = QueryPos.getInstance(q);
2819    
2820                                    qPos.add(groupId);
2821    
2822                                    qPos.add(parentFolderId);
2823    
2824                                    count = (Long)q.uniqueResult();
2825                            }
2826                            catch (Exception e) {
2827                                    throw processException(e);
2828                            }
2829                            finally {
2830                                    if (count == null) {
2831                                            count = Long.valueOf(0);
2832                                    }
2833    
2834                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P, finderArgs,
2835                                            count);
2836    
2837                                    closeSession(session);
2838                            }
2839                    }
2840    
2841                    return count.intValue();
2842            }
2843    
2844            /**
2845             * Filters by the user's permissions and counts all the bookmarks folders where groupId = &#63; and parentFolderId = &#63;.
2846             *
2847             * @param groupId the group id to search with
2848             * @param parentFolderId the parent folder id to search with
2849             * @return the number of matching bookmarks folders that the user has permission to view
2850             * @throws SystemException if a system exception occurred
2851             */
2852            public int filterCountByG_P(long groupId, long parentFolderId)
2853                    throws SystemException {
2854                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2855                            return countByG_P(groupId, parentFolderId);
2856                    }
2857    
2858                    StringBundler query = new StringBundler(3);
2859    
2860                    query.append(_FILTER_SQL_COUNT_BOOKMARKSFOLDER_WHERE);
2861    
2862                    query.append(_FINDER_COLUMN_G_P_GROUPID_2);
2863    
2864                    query.append(_FINDER_COLUMN_G_P_PARENTFOLDERID_2);
2865    
2866                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2867                                    BookmarksFolder.class.getName(), _FILTER_COLUMN_PK,
2868                                    _FILTER_COLUMN_USERID, groupId);
2869    
2870                    Session session = null;
2871    
2872                    try {
2873                            session = openSession();
2874    
2875                            SQLQuery q = session.createSQLQuery(sql);
2876    
2877                            q.addScalar(COUNT_COLUMN_NAME,
2878                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
2879    
2880                            QueryPos qPos = QueryPos.getInstance(q);
2881    
2882                            qPos.add(groupId);
2883    
2884                            qPos.add(parentFolderId);
2885    
2886                            Long count = (Long)q.uniqueResult();
2887    
2888                            return count.intValue();
2889                    }
2890                    catch (Exception e) {
2891                            throw processException(e);
2892                    }
2893                    finally {
2894                            closeSession(session);
2895                    }
2896            }
2897    
2898            /**
2899             * Counts all the bookmarks folders.
2900             *
2901             * @return the number of bookmarks folders
2902             * @throws SystemException if a system exception occurred
2903             */
2904            public int countAll() throws SystemException {
2905                    Object[] finderArgs = new Object[0];
2906    
2907                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2908                                    finderArgs, this);
2909    
2910                    if (count == null) {
2911                            Session session = null;
2912    
2913                            try {
2914                                    session = openSession();
2915    
2916                                    Query q = session.createQuery(_SQL_COUNT_BOOKMARKSFOLDER);
2917    
2918                                    count = (Long)q.uniqueResult();
2919                            }
2920                            catch (Exception e) {
2921                                    throw processException(e);
2922                            }
2923                            finally {
2924                                    if (count == null) {
2925                                            count = Long.valueOf(0);
2926                                    }
2927    
2928                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
2929                                            count);
2930    
2931                                    closeSession(session);
2932                            }
2933                    }
2934    
2935                    return count.intValue();
2936            }
2937    
2938            /**
2939             * Initializes the bookmarks folder persistence.
2940             */
2941            public void afterPropertiesSet() {
2942                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2943                                            com.liferay.portal.util.PropsUtil.get(
2944                                                    "value.object.listener.com.liferay.portlet.bookmarks.model.BookmarksFolder")));
2945    
2946                    if (listenerClassNames.length > 0) {
2947                            try {
2948                                    List<ModelListener<BookmarksFolder>> listenersList = new ArrayList<ModelListener<BookmarksFolder>>();
2949    
2950                                    for (String listenerClassName : listenerClassNames) {
2951                                            listenersList.add((ModelListener<BookmarksFolder>)InstanceFactory.newInstance(
2952                                                            listenerClassName));
2953                                    }
2954    
2955                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2956                            }
2957                            catch (Exception e) {
2958                                    _log.error(e);
2959                            }
2960                    }
2961            }
2962    
2963            public void destroy() {
2964                    EntityCacheUtil.removeCache(BookmarksFolderImpl.class.getName());
2965                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2966                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST);
2967            }
2968    
2969            @BeanReference(type = BookmarksEntryPersistence.class)
2970            protected BookmarksEntryPersistence bookmarksEntryPersistence;
2971            @BeanReference(type = BookmarksFolderPersistence.class)
2972            protected BookmarksFolderPersistence bookmarksFolderPersistence;
2973            @BeanReference(type = GroupPersistence.class)
2974            protected GroupPersistence groupPersistence;
2975            @BeanReference(type = ResourcePersistence.class)
2976            protected ResourcePersistence resourcePersistence;
2977            @BeanReference(type = UserPersistence.class)
2978            protected UserPersistence userPersistence;
2979            @BeanReference(type = ExpandoValuePersistence.class)
2980            protected ExpandoValuePersistence expandoValuePersistence;
2981            private static final String _SQL_SELECT_BOOKMARKSFOLDER = "SELECT bookmarksFolder FROM BookmarksFolder bookmarksFolder";
2982            private static final String _SQL_SELECT_BOOKMARKSFOLDER_WHERE = "SELECT bookmarksFolder FROM BookmarksFolder bookmarksFolder WHERE ";
2983            private static final String _SQL_COUNT_BOOKMARKSFOLDER = "SELECT COUNT(bookmarksFolder) FROM BookmarksFolder bookmarksFolder";
2984            private static final String _SQL_COUNT_BOOKMARKSFOLDER_WHERE = "SELECT COUNT(bookmarksFolder) FROM BookmarksFolder bookmarksFolder WHERE ";
2985            private static final String _FINDER_COLUMN_UUID_UUID_1 = "bookmarksFolder.uuid IS NULL";
2986            private static final String _FINDER_COLUMN_UUID_UUID_2 = "bookmarksFolder.uuid = ?";
2987            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(bookmarksFolder.uuid IS NULL OR bookmarksFolder.uuid = ?)";
2988            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "bookmarksFolder.uuid IS NULL AND ";
2989            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "bookmarksFolder.uuid = ? AND ";
2990            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(bookmarksFolder.uuid IS NULL OR bookmarksFolder.uuid = ?) AND ";
2991            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "bookmarksFolder.groupId = ?";
2992            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "bookmarksFolder.groupId = ?";
2993            private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "bookmarksFolder.companyId = ?";
2994            private static final String _FINDER_COLUMN_G_P_GROUPID_2 = "bookmarksFolder.groupId = ? AND ";
2995            private static final String _FINDER_COLUMN_G_P_PARENTFOLDERID_2 = "bookmarksFolder.parentFolderId = ?";
2996            private static final String _FILTER_SQL_SELECT_BOOKMARKSFOLDER_WHERE = "SELECT DISTINCT {bookmarksFolder.*} FROM BookmarksFolder bookmarksFolder WHERE ";
2997            private static final String _FILTER_SQL_SELECT_BOOKMARKSFOLDER_NO_INLINE_DISTINCT_WHERE_1 =
2998                    "SELECT {BookmarksFolder.*} FROM (SELECT DISTINCT bookmarksFolder.folderId FROM BookmarksFolder bookmarksFolder WHERE ";
2999            private static final String _FILTER_SQL_SELECT_BOOKMARKSFOLDER_NO_INLINE_DISTINCT_WHERE_2 =
3000                    ") TEMP_TABLE INNER JOIN BookmarksFolder ON TEMP_TABLE.folderId = BookmarksFolder.folderId";
3001            private static final String _FILTER_SQL_COUNT_BOOKMARKSFOLDER_WHERE = "SELECT COUNT(DISTINCT bookmarksFolder.folderId) AS COUNT_VALUE FROM BookmarksFolder bookmarksFolder WHERE ";
3002            private static final String _FILTER_COLUMN_PK = "bookmarksFolder.folderId";
3003            private static final String _FILTER_COLUMN_USERID = "bookmarksFolder.userId";
3004            private static final String _FILTER_ENTITY_ALIAS = "bookmarksFolder";
3005            private static final String _FILTER_ENTITY_TABLE = "BookmarksFolder";
3006            private static final String _ORDER_BY_ENTITY_ALIAS = "bookmarksFolder.";
3007            private static final String _ORDER_BY_ENTITY_TABLE = "BookmarksFolder.";
3008            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No BookmarksFolder exists with the primary key ";
3009            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No BookmarksFolder exists with the key {";
3010            private static Log _log = LogFactoryUtil.getLog(BookmarksFolderPersistenceImpl.class);
3011    }