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