001    /**
002     * Copyright (c) 2000-present 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.social.service.persistence.impl;
016    
017    import aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022    import com.liferay.portal.kernel.dao.orm.FinderPath;
023    import com.liferay.portal.kernel.dao.orm.Query;
024    import com.liferay.portal.kernel.dao.orm.QueryPos;
025    import com.liferay.portal.kernel.dao.orm.QueryUtil;
026    import com.liferay.portal.kernel.dao.orm.Session;
027    import com.liferay.portal.kernel.log.Log;
028    import com.liferay.portal.kernel.log.LogFactoryUtil;
029    import com.liferay.portal.kernel.util.OrderByComparator;
030    import com.liferay.portal.kernel.util.SetUtil;
031    import com.liferay.portal.kernel.util.StringBundler;
032    import com.liferay.portal.kernel.util.StringPool;
033    import com.liferay.portal.model.CacheModel;
034    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
035    
036    import com.liferay.portlet.social.NoSuchActivitySetException;
037    import com.liferay.portlet.social.model.SocialActivitySet;
038    import com.liferay.portlet.social.model.impl.SocialActivitySetImpl;
039    import com.liferay.portlet.social.model.impl.SocialActivitySetModelImpl;
040    import com.liferay.portlet.social.service.persistence.SocialActivitySetPersistence;
041    
042    import java.io.Serializable;
043    
044    import java.util.Collections;
045    import java.util.HashMap;
046    import java.util.HashSet;
047    import java.util.Iterator;
048    import java.util.List;
049    import java.util.Map;
050    import java.util.Set;
051    
052    /**
053     * The persistence implementation for the social activity set service.
054     *
055     * <p>
056     * Caching information and settings can be found in <code>portal.properties</code>
057     * </p>
058     *
059     * @author Brian Wing Shun Chan
060     * @see SocialActivitySetPersistence
061     * @see SocialActivitySetUtil
062     * @generated
063     */
064    @ProviderType
065    public class SocialActivitySetPersistenceImpl extends BasePersistenceImpl<SocialActivitySet>
066            implements SocialActivitySetPersistence {
067            /*
068             * NOTE FOR DEVELOPERS:
069             *
070             * Never modify or reference this class directly. Always use {@link SocialActivitySetUtil} to access the social activity set persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
071             */
072            public static final String FINDER_CLASS_NAME_ENTITY = SocialActivitySetImpl.class.getName();
073            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
074                    ".List1";
075            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
076                    ".List2";
077            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(SocialActivitySetModelImpl.ENTITY_CACHE_ENABLED,
078                            SocialActivitySetModelImpl.FINDER_CACHE_ENABLED,
079                            SocialActivitySetImpl.class,
080                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
081            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(SocialActivitySetModelImpl.ENTITY_CACHE_ENABLED,
082                            SocialActivitySetModelImpl.FINDER_CACHE_ENABLED,
083                            SocialActivitySetImpl.class,
084                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
085            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(SocialActivitySetModelImpl.ENTITY_CACHE_ENABLED,
086                            SocialActivitySetModelImpl.FINDER_CACHE_ENABLED, Long.class,
087                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
088            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(SocialActivitySetModelImpl.ENTITY_CACHE_ENABLED,
089                            SocialActivitySetModelImpl.FINDER_CACHE_ENABLED,
090                            SocialActivitySetImpl.class,
091                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId",
092                            new String[] {
093                                    Long.class.getName(),
094                                    
095                            Integer.class.getName(), Integer.class.getName(),
096                                    OrderByComparator.class.getName()
097                            });
098            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
099                    new FinderPath(SocialActivitySetModelImpl.ENTITY_CACHE_ENABLED,
100                            SocialActivitySetModelImpl.FINDER_CACHE_ENABLED,
101                            SocialActivitySetImpl.class,
102                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
103                            new String[] { Long.class.getName() },
104                            SocialActivitySetModelImpl.GROUPID_COLUMN_BITMASK |
105                            SocialActivitySetModelImpl.MODIFIEDDATE_COLUMN_BITMASK);
106            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(SocialActivitySetModelImpl.ENTITY_CACHE_ENABLED,
107                            SocialActivitySetModelImpl.FINDER_CACHE_ENABLED, Long.class,
108                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
109                            new String[] { Long.class.getName() });
110    
111            /**
112             * Returns all the social activity sets where groupId = &#63;.
113             *
114             * @param groupId the group ID
115             * @return the matching social activity sets
116             */
117            @Override
118            public List<SocialActivitySet> findByGroupId(long groupId) {
119                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
120            }
121    
122            /**
123             * Returns a range of all the social activity sets where groupId = &#63;.
124             *
125             * <p>
126             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.social.model.impl.SocialActivitySetModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
127             * </p>
128             *
129             * @param groupId the group ID
130             * @param start the lower bound of the range of social activity sets
131             * @param end the upper bound of the range of social activity sets (not inclusive)
132             * @return the range of matching social activity sets
133             */
134            @Override
135            public List<SocialActivitySet> findByGroupId(long groupId, int start,
136                    int end) {
137                    return findByGroupId(groupId, start, end, null);
138            }
139    
140            /**
141             * Returns an ordered range of all the social activity sets where groupId = &#63;.
142             *
143             * <p>
144             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.social.model.impl.SocialActivitySetModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
145             * </p>
146             *
147             * @param groupId the group ID
148             * @param start the lower bound of the range of social activity sets
149             * @param end the upper bound of the range of social activity sets (not inclusive)
150             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
151             * @return the ordered range of matching social activity sets
152             */
153            @Override
154            public List<SocialActivitySet> findByGroupId(long groupId, int start,
155                    int end, OrderByComparator<SocialActivitySet> orderByComparator) {
156                    boolean pagination = true;
157                    FinderPath finderPath = null;
158                    Object[] finderArgs = null;
159    
160                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
161                                    (orderByComparator == null)) {
162                            pagination = false;
163                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
164                            finderArgs = new Object[] { groupId };
165                    }
166                    else {
167                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
168                            finderArgs = new Object[] { groupId, start, end, orderByComparator };
169                    }
170    
171                    List<SocialActivitySet> list = (List<SocialActivitySet>)FinderCacheUtil.getResult(finderPath,
172                                    finderArgs, this);
173    
174                    if ((list != null) && !list.isEmpty()) {
175                            for (SocialActivitySet socialActivitySet : list) {
176                                    if ((groupId != socialActivitySet.getGroupId())) {
177                                            list = null;
178    
179                                            break;
180                                    }
181                            }
182                    }
183    
184                    if (list == null) {
185                            StringBundler query = null;
186    
187                            if (orderByComparator != null) {
188                                    query = new StringBundler(3 +
189                                                    (orderByComparator.getOrderByFields().length * 3));
190                            }
191                            else {
192                                    query = new StringBundler(3);
193                            }
194    
195                            query.append(_SQL_SELECT_SOCIALACTIVITYSET_WHERE);
196    
197                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
198    
199                            if (orderByComparator != null) {
200                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
201                                            orderByComparator);
202                            }
203                            else
204                             if (pagination) {
205                                    query.append(SocialActivitySetModelImpl.ORDER_BY_JPQL);
206                            }
207    
208                            String sql = query.toString();
209    
210                            Session session = null;
211    
212                            try {
213                                    session = openSession();
214    
215                                    Query q = session.createQuery(sql);
216    
217                                    QueryPos qPos = QueryPos.getInstance(q);
218    
219                                    qPos.add(groupId);
220    
221                                    if (!pagination) {
222                                            list = (List<SocialActivitySet>)QueryUtil.list(q,
223                                                            getDialect(), start, end, false);
224    
225                                            Collections.sort(list);
226    
227                                            list = Collections.unmodifiableList(list);
228                                    }
229                                    else {
230                                            list = (List<SocialActivitySet>)QueryUtil.list(q,
231                                                            getDialect(), start, end);
232                                    }
233    
234                                    cacheResult(list);
235    
236                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
237                            }
238                            catch (Exception e) {
239                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
240    
241                                    throw processException(e);
242                            }
243                            finally {
244                                    closeSession(session);
245                            }
246                    }
247    
248                    return list;
249            }
250    
251            /**
252             * Returns the first social activity set in the ordered set where groupId = &#63;.
253             *
254             * @param groupId the group ID
255             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
256             * @return the first matching social activity set
257             * @throws com.liferay.portlet.social.NoSuchActivitySetException if a matching social activity set could not be found
258             */
259            @Override
260            public SocialActivitySet findByGroupId_First(long groupId,
261                    OrderByComparator<SocialActivitySet> orderByComparator)
262                    throws NoSuchActivitySetException {
263                    SocialActivitySet socialActivitySet = fetchByGroupId_First(groupId,
264                                    orderByComparator);
265    
266                    if (socialActivitySet != null) {
267                            return socialActivitySet;
268                    }
269    
270                    StringBundler msg = new StringBundler(4);
271    
272                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
273    
274                    msg.append("groupId=");
275                    msg.append(groupId);
276    
277                    msg.append(StringPool.CLOSE_CURLY_BRACE);
278    
279                    throw new NoSuchActivitySetException(msg.toString());
280            }
281    
282            /**
283             * Returns the first social activity set in the ordered set where groupId = &#63;.
284             *
285             * @param groupId the group ID
286             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
287             * @return the first matching social activity set, or <code>null</code> if a matching social activity set could not be found
288             */
289            @Override
290            public SocialActivitySet fetchByGroupId_First(long groupId,
291                    OrderByComparator<SocialActivitySet> orderByComparator) {
292                    List<SocialActivitySet> list = findByGroupId(groupId, 0, 1,
293                                    orderByComparator);
294    
295                    if (!list.isEmpty()) {
296                            return list.get(0);
297                    }
298    
299                    return null;
300            }
301    
302            /**
303             * Returns the last social activity set in the ordered set where groupId = &#63;.
304             *
305             * @param groupId the group ID
306             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
307             * @return the last matching social activity set
308             * @throws com.liferay.portlet.social.NoSuchActivitySetException if a matching social activity set could not be found
309             */
310            @Override
311            public SocialActivitySet findByGroupId_Last(long groupId,
312                    OrderByComparator<SocialActivitySet> orderByComparator)
313                    throws NoSuchActivitySetException {
314                    SocialActivitySet socialActivitySet = fetchByGroupId_Last(groupId,
315                                    orderByComparator);
316    
317                    if (socialActivitySet != null) {
318                            return socialActivitySet;
319                    }
320    
321                    StringBundler msg = new StringBundler(4);
322    
323                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
324    
325                    msg.append("groupId=");
326                    msg.append(groupId);
327    
328                    msg.append(StringPool.CLOSE_CURLY_BRACE);
329    
330                    throw new NoSuchActivitySetException(msg.toString());
331            }
332    
333            /**
334             * Returns the last social activity set in the ordered set where groupId = &#63;.
335             *
336             * @param groupId the group ID
337             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
338             * @return the last matching social activity set, or <code>null</code> if a matching social activity set could not be found
339             */
340            @Override
341            public SocialActivitySet fetchByGroupId_Last(long groupId,
342                    OrderByComparator<SocialActivitySet> orderByComparator) {
343                    int count = countByGroupId(groupId);
344    
345                    if (count == 0) {
346                            return null;
347                    }
348    
349                    List<SocialActivitySet> list = findByGroupId(groupId, count - 1, count,
350                                    orderByComparator);
351    
352                    if (!list.isEmpty()) {
353                            return list.get(0);
354                    }
355    
356                    return null;
357            }
358    
359            /**
360             * Returns the social activity sets before and after the current social activity set in the ordered set where groupId = &#63;.
361             *
362             * @param activitySetId the primary key of the current social activity set
363             * @param groupId the group ID
364             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
365             * @return the previous, current, and next social activity set
366             * @throws com.liferay.portlet.social.NoSuchActivitySetException if a social activity set with the primary key could not be found
367             */
368            @Override
369            public SocialActivitySet[] findByGroupId_PrevAndNext(long activitySetId,
370                    long groupId, OrderByComparator<SocialActivitySet> orderByComparator)
371                    throws NoSuchActivitySetException {
372                    SocialActivitySet socialActivitySet = findByPrimaryKey(activitySetId);
373    
374                    Session session = null;
375    
376                    try {
377                            session = openSession();
378    
379                            SocialActivitySet[] array = new SocialActivitySetImpl[3];
380    
381                            array[0] = getByGroupId_PrevAndNext(session, socialActivitySet,
382                                            groupId, orderByComparator, true);
383    
384                            array[1] = socialActivitySet;
385    
386                            array[2] = getByGroupId_PrevAndNext(session, socialActivitySet,
387                                            groupId, orderByComparator, false);
388    
389                            return array;
390                    }
391                    catch (Exception e) {
392                            throw processException(e);
393                    }
394                    finally {
395                            closeSession(session);
396                    }
397            }
398    
399            protected SocialActivitySet getByGroupId_PrevAndNext(Session session,
400                    SocialActivitySet socialActivitySet, long groupId,
401                    OrderByComparator<SocialActivitySet> orderByComparator, boolean previous) {
402                    StringBundler query = null;
403    
404                    if (orderByComparator != null) {
405                            query = new StringBundler(6 +
406                                            (orderByComparator.getOrderByFields().length * 6));
407                    }
408                    else {
409                            query = new StringBundler(3);
410                    }
411    
412                    query.append(_SQL_SELECT_SOCIALACTIVITYSET_WHERE);
413    
414                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
415    
416                    if (orderByComparator != null) {
417                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
418    
419                            if (orderByConditionFields.length > 0) {
420                                    query.append(WHERE_AND);
421                            }
422    
423                            for (int i = 0; i < orderByConditionFields.length; i++) {
424                                    query.append(_ORDER_BY_ENTITY_ALIAS);
425                                    query.append(orderByConditionFields[i]);
426    
427                                    if ((i + 1) < orderByConditionFields.length) {
428                                            if (orderByComparator.isAscending() ^ previous) {
429                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
430                                            }
431                                            else {
432                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
433                                            }
434                                    }
435                                    else {
436                                            if (orderByComparator.isAscending() ^ previous) {
437                                                    query.append(WHERE_GREATER_THAN);
438                                            }
439                                            else {
440                                                    query.append(WHERE_LESSER_THAN);
441                                            }
442                                    }
443                            }
444    
445                            query.append(ORDER_BY_CLAUSE);
446    
447                            String[] orderByFields = orderByComparator.getOrderByFields();
448    
449                            for (int i = 0; i < orderByFields.length; i++) {
450                                    query.append(_ORDER_BY_ENTITY_ALIAS);
451                                    query.append(orderByFields[i]);
452    
453                                    if ((i + 1) < orderByFields.length) {
454                                            if (orderByComparator.isAscending() ^ previous) {
455                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
456                                            }
457                                            else {
458                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
459                                            }
460                                    }
461                                    else {
462                                            if (orderByComparator.isAscending() ^ previous) {
463                                                    query.append(ORDER_BY_ASC);
464                                            }
465                                            else {
466                                                    query.append(ORDER_BY_DESC);
467                                            }
468                                    }
469                            }
470                    }
471                    else {
472                            query.append(SocialActivitySetModelImpl.ORDER_BY_JPQL);
473                    }
474    
475                    String sql = query.toString();
476    
477                    Query q = session.createQuery(sql);
478    
479                    q.setFirstResult(0);
480                    q.setMaxResults(2);
481    
482                    QueryPos qPos = QueryPos.getInstance(q);
483    
484                    qPos.add(groupId);
485    
486                    if (orderByComparator != null) {
487                            Object[] values = orderByComparator.getOrderByConditionValues(socialActivitySet);
488    
489                            for (Object value : values) {
490                                    qPos.add(value);
491                            }
492                    }
493    
494                    List<SocialActivitySet> list = q.list();
495    
496                    if (list.size() == 2) {
497                            return list.get(1);
498                    }
499                    else {
500                            return null;
501                    }
502            }
503    
504            /**
505             * Removes all the social activity sets where groupId = &#63; from the database.
506             *
507             * @param groupId the group ID
508             */
509            @Override
510            public void removeByGroupId(long groupId) {
511                    for (SocialActivitySet socialActivitySet : findByGroupId(groupId,
512                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
513                            remove(socialActivitySet);
514                    }
515            }
516    
517            /**
518             * Returns the number of social activity sets where groupId = &#63;.
519             *
520             * @param groupId the group ID
521             * @return the number of matching social activity sets
522             */
523            @Override
524            public int countByGroupId(long groupId) {
525                    FinderPath finderPath = FINDER_PATH_COUNT_BY_GROUPID;
526    
527                    Object[] finderArgs = new Object[] { groupId };
528    
529                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
530                                    this);
531    
532                    if (count == null) {
533                            StringBundler query = new StringBundler(2);
534    
535                            query.append(_SQL_COUNT_SOCIALACTIVITYSET_WHERE);
536    
537                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
538    
539                            String sql = query.toString();
540    
541                            Session session = null;
542    
543                            try {
544                                    session = openSession();
545    
546                                    Query q = session.createQuery(sql);
547    
548                                    QueryPos qPos = QueryPos.getInstance(q);
549    
550                                    qPos.add(groupId);
551    
552                                    count = (Long)q.uniqueResult();
553    
554                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
555                            }
556                            catch (Exception e) {
557                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
558    
559                                    throw processException(e);
560                            }
561                            finally {
562                                    closeSession(session);
563                            }
564                    }
565    
566                    return count.intValue();
567            }
568    
569            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "socialActivitySet.groupId = ?";
570            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID = new FinderPath(SocialActivitySetModelImpl.ENTITY_CACHE_ENABLED,
571                            SocialActivitySetModelImpl.FINDER_CACHE_ENABLED,
572                            SocialActivitySetImpl.class,
573                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUserId",
574                            new String[] {
575                                    Long.class.getName(),
576                                    
577                            Integer.class.getName(), Integer.class.getName(),
578                                    OrderByComparator.class.getName()
579                            });
580            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID =
581                    new FinderPath(SocialActivitySetModelImpl.ENTITY_CACHE_ENABLED,
582                            SocialActivitySetModelImpl.FINDER_CACHE_ENABLED,
583                            SocialActivitySetImpl.class,
584                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUserId",
585                            new String[] { Long.class.getName() },
586                            SocialActivitySetModelImpl.USERID_COLUMN_BITMASK |
587                            SocialActivitySetModelImpl.MODIFIEDDATE_COLUMN_BITMASK);
588            public static final FinderPath FINDER_PATH_COUNT_BY_USERID = new FinderPath(SocialActivitySetModelImpl.ENTITY_CACHE_ENABLED,
589                            SocialActivitySetModelImpl.FINDER_CACHE_ENABLED, Long.class,
590                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUserId",
591                            new String[] { Long.class.getName() });
592    
593            /**
594             * Returns all the social activity sets where userId = &#63;.
595             *
596             * @param userId the user ID
597             * @return the matching social activity sets
598             */
599            @Override
600            public List<SocialActivitySet> findByUserId(long userId) {
601                    return findByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
602            }
603    
604            /**
605             * Returns a range of all the social activity sets where userId = &#63;.
606             *
607             * <p>
608             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.social.model.impl.SocialActivitySetModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
609             * </p>
610             *
611             * @param userId the user ID
612             * @param start the lower bound of the range of social activity sets
613             * @param end the upper bound of the range of social activity sets (not inclusive)
614             * @return the range of matching social activity sets
615             */
616            @Override
617            public List<SocialActivitySet> findByUserId(long userId, int start, int end) {
618                    return findByUserId(userId, start, end, null);
619            }
620    
621            /**
622             * Returns an ordered range of all the social activity sets where userId = &#63;.
623             *
624             * <p>
625             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.social.model.impl.SocialActivitySetModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
626             * </p>
627             *
628             * @param userId the user ID
629             * @param start the lower bound of the range of social activity sets
630             * @param end the upper bound of the range of social activity sets (not inclusive)
631             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
632             * @return the ordered range of matching social activity sets
633             */
634            @Override
635            public List<SocialActivitySet> findByUserId(long userId, int start,
636                    int end, OrderByComparator<SocialActivitySet> orderByComparator) {
637                    boolean pagination = true;
638                    FinderPath finderPath = null;
639                    Object[] finderArgs = null;
640    
641                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
642                                    (orderByComparator == null)) {
643                            pagination = false;
644                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID;
645                            finderArgs = new Object[] { userId };
646                    }
647                    else {
648                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID;
649                            finderArgs = new Object[] { userId, start, end, orderByComparator };
650                    }
651    
652                    List<SocialActivitySet> list = (List<SocialActivitySet>)FinderCacheUtil.getResult(finderPath,
653                                    finderArgs, this);
654    
655                    if ((list != null) && !list.isEmpty()) {
656                            for (SocialActivitySet socialActivitySet : list) {
657                                    if ((userId != socialActivitySet.getUserId())) {
658                                            list = null;
659    
660                                            break;
661                                    }
662                            }
663                    }
664    
665                    if (list == null) {
666                            StringBundler query = null;
667    
668                            if (orderByComparator != null) {
669                                    query = new StringBundler(3 +
670                                                    (orderByComparator.getOrderByFields().length * 3));
671                            }
672                            else {
673                                    query = new StringBundler(3);
674                            }
675    
676                            query.append(_SQL_SELECT_SOCIALACTIVITYSET_WHERE);
677    
678                            query.append(_FINDER_COLUMN_USERID_USERID_2);
679    
680                            if (orderByComparator != null) {
681                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
682                                            orderByComparator);
683                            }
684                            else
685                             if (pagination) {
686                                    query.append(SocialActivitySetModelImpl.ORDER_BY_JPQL);
687                            }
688    
689                            String sql = query.toString();
690    
691                            Session session = null;
692    
693                            try {
694                                    session = openSession();
695    
696                                    Query q = session.createQuery(sql);
697    
698                                    QueryPos qPos = QueryPos.getInstance(q);
699    
700                                    qPos.add(userId);
701    
702                                    if (!pagination) {
703                                            list = (List<SocialActivitySet>)QueryUtil.list(q,
704                                                            getDialect(), start, end, false);
705    
706                                            Collections.sort(list);
707    
708                                            list = Collections.unmodifiableList(list);
709                                    }
710                                    else {
711                                            list = (List<SocialActivitySet>)QueryUtil.list(q,
712                                                            getDialect(), start, end);
713                                    }
714    
715                                    cacheResult(list);
716    
717                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
718                            }
719                            catch (Exception e) {
720                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
721    
722                                    throw processException(e);
723                            }
724                            finally {
725                                    closeSession(session);
726                            }
727                    }
728    
729                    return list;
730            }
731    
732            /**
733             * Returns the first social activity set in the ordered set where userId = &#63;.
734             *
735             * @param userId the user ID
736             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
737             * @return the first matching social activity set
738             * @throws com.liferay.portlet.social.NoSuchActivitySetException if a matching social activity set could not be found
739             */
740            @Override
741            public SocialActivitySet findByUserId_First(long userId,
742                    OrderByComparator<SocialActivitySet> orderByComparator)
743                    throws NoSuchActivitySetException {
744                    SocialActivitySet socialActivitySet = fetchByUserId_First(userId,
745                                    orderByComparator);
746    
747                    if (socialActivitySet != null) {
748                            return socialActivitySet;
749                    }
750    
751                    StringBundler msg = new StringBundler(4);
752    
753                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
754    
755                    msg.append("userId=");
756                    msg.append(userId);
757    
758                    msg.append(StringPool.CLOSE_CURLY_BRACE);
759    
760                    throw new NoSuchActivitySetException(msg.toString());
761            }
762    
763            /**
764             * Returns the first social activity set in the ordered set where userId = &#63;.
765             *
766             * @param userId the user ID
767             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
768             * @return the first matching social activity set, or <code>null</code> if a matching social activity set could not be found
769             */
770            @Override
771            public SocialActivitySet fetchByUserId_First(long userId,
772                    OrderByComparator<SocialActivitySet> orderByComparator) {
773                    List<SocialActivitySet> list = findByUserId(userId, 0, 1,
774                                    orderByComparator);
775    
776                    if (!list.isEmpty()) {
777                            return list.get(0);
778                    }
779    
780                    return null;
781            }
782    
783            /**
784             * Returns the last social activity set in the ordered set where userId = &#63;.
785             *
786             * @param userId the user ID
787             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
788             * @return the last matching social activity set
789             * @throws com.liferay.portlet.social.NoSuchActivitySetException if a matching social activity set could not be found
790             */
791            @Override
792            public SocialActivitySet findByUserId_Last(long userId,
793                    OrderByComparator<SocialActivitySet> orderByComparator)
794                    throws NoSuchActivitySetException {
795                    SocialActivitySet socialActivitySet = fetchByUserId_Last(userId,
796                                    orderByComparator);
797    
798                    if (socialActivitySet != null) {
799                            return socialActivitySet;
800                    }
801    
802                    StringBundler msg = new StringBundler(4);
803    
804                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
805    
806                    msg.append("userId=");
807                    msg.append(userId);
808    
809                    msg.append(StringPool.CLOSE_CURLY_BRACE);
810    
811                    throw new NoSuchActivitySetException(msg.toString());
812            }
813    
814            /**
815             * Returns the last social activity set in the ordered set where userId = &#63;.
816             *
817             * @param userId the user ID
818             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
819             * @return the last matching social activity set, or <code>null</code> if a matching social activity set could not be found
820             */
821            @Override
822            public SocialActivitySet fetchByUserId_Last(long userId,
823                    OrderByComparator<SocialActivitySet> orderByComparator) {
824                    int count = countByUserId(userId);
825    
826                    if (count == 0) {
827                            return null;
828                    }
829    
830                    List<SocialActivitySet> list = findByUserId(userId, count - 1, count,
831                                    orderByComparator);
832    
833                    if (!list.isEmpty()) {
834                            return list.get(0);
835                    }
836    
837                    return null;
838            }
839    
840            /**
841             * Returns the social activity sets before and after the current social activity set in the ordered set where userId = &#63;.
842             *
843             * @param activitySetId the primary key of the current social activity set
844             * @param userId the user ID
845             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
846             * @return the previous, current, and next social activity set
847             * @throws com.liferay.portlet.social.NoSuchActivitySetException if a social activity set with the primary key could not be found
848             */
849            @Override
850            public SocialActivitySet[] findByUserId_PrevAndNext(long activitySetId,
851                    long userId, OrderByComparator<SocialActivitySet> orderByComparator)
852                    throws NoSuchActivitySetException {
853                    SocialActivitySet socialActivitySet = findByPrimaryKey(activitySetId);
854    
855                    Session session = null;
856    
857                    try {
858                            session = openSession();
859    
860                            SocialActivitySet[] array = new SocialActivitySetImpl[3];
861    
862                            array[0] = getByUserId_PrevAndNext(session, socialActivitySet,
863                                            userId, orderByComparator, true);
864    
865                            array[1] = socialActivitySet;
866    
867                            array[2] = getByUserId_PrevAndNext(session, socialActivitySet,
868                                            userId, orderByComparator, false);
869    
870                            return array;
871                    }
872                    catch (Exception e) {
873                            throw processException(e);
874                    }
875                    finally {
876                            closeSession(session);
877                    }
878            }
879    
880            protected SocialActivitySet getByUserId_PrevAndNext(Session session,
881                    SocialActivitySet socialActivitySet, long userId,
882                    OrderByComparator<SocialActivitySet> orderByComparator, boolean previous) {
883                    StringBundler query = null;
884    
885                    if (orderByComparator != null) {
886                            query = new StringBundler(6 +
887                                            (orderByComparator.getOrderByFields().length * 6));
888                    }
889                    else {
890                            query = new StringBundler(3);
891                    }
892    
893                    query.append(_SQL_SELECT_SOCIALACTIVITYSET_WHERE);
894    
895                    query.append(_FINDER_COLUMN_USERID_USERID_2);
896    
897                    if (orderByComparator != null) {
898                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
899    
900                            if (orderByConditionFields.length > 0) {
901                                    query.append(WHERE_AND);
902                            }
903    
904                            for (int i = 0; i < orderByConditionFields.length; i++) {
905                                    query.append(_ORDER_BY_ENTITY_ALIAS);
906                                    query.append(orderByConditionFields[i]);
907    
908                                    if ((i + 1) < orderByConditionFields.length) {
909                                            if (orderByComparator.isAscending() ^ previous) {
910                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
911                                            }
912                                            else {
913                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
914                                            }
915                                    }
916                                    else {
917                                            if (orderByComparator.isAscending() ^ previous) {
918                                                    query.append(WHERE_GREATER_THAN);
919                                            }
920                                            else {
921                                                    query.append(WHERE_LESSER_THAN);
922                                            }
923                                    }
924                            }
925    
926                            query.append(ORDER_BY_CLAUSE);
927    
928                            String[] orderByFields = orderByComparator.getOrderByFields();
929    
930                            for (int i = 0; i < orderByFields.length; i++) {
931                                    query.append(_ORDER_BY_ENTITY_ALIAS);
932                                    query.append(orderByFields[i]);
933    
934                                    if ((i + 1) < orderByFields.length) {
935                                            if (orderByComparator.isAscending() ^ previous) {
936                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
937                                            }
938                                            else {
939                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
940                                            }
941                                    }
942                                    else {
943                                            if (orderByComparator.isAscending() ^ previous) {
944                                                    query.append(ORDER_BY_ASC);
945                                            }
946                                            else {
947                                                    query.append(ORDER_BY_DESC);
948                                            }
949                                    }
950                            }
951                    }
952                    else {
953                            query.append(SocialActivitySetModelImpl.ORDER_BY_JPQL);
954                    }
955    
956                    String sql = query.toString();
957    
958                    Query q = session.createQuery(sql);
959    
960                    q.setFirstResult(0);
961                    q.setMaxResults(2);
962    
963                    QueryPos qPos = QueryPos.getInstance(q);
964    
965                    qPos.add(userId);
966    
967                    if (orderByComparator != null) {
968                            Object[] values = orderByComparator.getOrderByConditionValues(socialActivitySet);
969    
970                            for (Object value : values) {
971                                    qPos.add(value);
972                            }
973                    }
974    
975                    List<SocialActivitySet> list = q.list();
976    
977                    if (list.size() == 2) {
978                            return list.get(1);
979                    }
980                    else {
981                            return null;
982                    }
983            }
984    
985            /**
986             * Removes all the social activity sets where userId = &#63; from the database.
987             *
988             * @param userId the user ID
989             */
990            @Override
991            public void removeByUserId(long userId) {
992                    for (SocialActivitySet socialActivitySet : findByUserId(userId,
993                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
994                            remove(socialActivitySet);
995                    }
996            }
997    
998            /**
999             * Returns the number of social activity sets where userId = &#63;.
1000             *
1001             * @param userId the user ID
1002             * @return the number of matching social activity sets
1003             */
1004            @Override
1005            public int countByUserId(long userId) {
1006                    FinderPath finderPath = FINDER_PATH_COUNT_BY_USERID;
1007    
1008                    Object[] finderArgs = new Object[] { userId };
1009    
1010                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1011                                    this);
1012    
1013                    if (count == null) {
1014                            StringBundler query = new StringBundler(2);
1015    
1016                            query.append(_SQL_COUNT_SOCIALACTIVITYSET_WHERE);
1017    
1018                            query.append(_FINDER_COLUMN_USERID_USERID_2);
1019    
1020                            String sql = query.toString();
1021    
1022                            Session session = null;
1023    
1024                            try {
1025                                    session = openSession();
1026    
1027                                    Query q = session.createQuery(sql);
1028    
1029                                    QueryPos qPos = QueryPos.getInstance(q);
1030    
1031                                    qPos.add(userId);
1032    
1033                                    count = (Long)q.uniqueResult();
1034    
1035                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
1036                            }
1037                            catch (Exception e) {
1038                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1039    
1040                                    throw processException(e);
1041                            }
1042                            finally {
1043                                    closeSession(session);
1044                            }
1045                    }
1046    
1047                    return count.intValue();
1048            }
1049    
1050            private static final String _FINDER_COLUMN_USERID_USERID_2 = "socialActivitySet.userId = ?";
1051            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_T = new FinderPath(SocialActivitySetModelImpl.ENTITY_CACHE_ENABLED,
1052                            SocialActivitySetModelImpl.FINDER_CACHE_ENABLED,
1053                            SocialActivitySetImpl.class,
1054                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_T",
1055                            new String[] {
1056                                    Long.class.getName(), Long.class.getName(),
1057                                    Integer.class.getName(),
1058                                    
1059                            Integer.class.getName(), Integer.class.getName(),
1060                                    OrderByComparator.class.getName()
1061                            });
1062            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_T = new FinderPath(SocialActivitySetModelImpl.ENTITY_CACHE_ENABLED,
1063                            SocialActivitySetModelImpl.FINDER_CACHE_ENABLED,
1064                            SocialActivitySetImpl.class,
1065                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U_T",
1066                            new String[] {
1067                                    Long.class.getName(), Long.class.getName(),
1068                                    Integer.class.getName()
1069                            },
1070                            SocialActivitySetModelImpl.GROUPID_COLUMN_BITMASK |
1071                            SocialActivitySetModelImpl.USERID_COLUMN_BITMASK |
1072                            SocialActivitySetModelImpl.TYPE_COLUMN_BITMASK |
1073                            SocialActivitySetModelImpl.MODIFIEDDATE_COLUMN_BITMASK);
1074            public static final FinderPath FINDER_PATH_COUNT_BY_G_U_T = new FinderPath(SocialActivitySetModelImpl.ENTITY_CACHE_ENABLED,
1075                            SocialActivitySetModelImpl.FINDER_CACHE_ENABLED, Long.class,
1076                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U_T",
1077                            new String[] {
1078                                    Long.class.getName(), Long.class.getName(),
1079                                    Integer.class.getName()
1080                            });
1081    
1082            /**
1083             * Returns all the social activity sets where groupId = &#63; and userId = &#63; and type = &#63;.
1084             *
1085             * @param groupId the group ID
1086             * @param userId the user ID
1087             * @param type the type
1088             * @return the matching social activity sets
1089             */
1090            @Override
1091            public List<SocialActivitySet> findByG_U_T(long groupId, long userId,
1092                    int type) {
1093                    return findByG_U_T(groupId, userId, type, QueryUtil.ALL_POS,
1094                            QueryUtil.ALL_POS, null);
1095            }
1096    
1097            /**
1098             * Returns a range of all the social activity sets where groupId = &#63; and userId = &#63; and type = &#63;.
1099             *
1100             * <p>
1101             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.social.model.impl.SocialActivitySetModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1102             * </p>
1103             *
1104             * @param groupId the group ID
1105             * @param userId the user ID
1106             * @param type the type
1107             * @param start the lower bound of the range of social activity sets
1108             * @param end the upper bound of the range of social activity sets (not inclusive)
1109             * @return the range of matching social activity sets
1110             */
1111            @Override
1112            public List<SocialActivitySet> findByG_U_T(long groupId, long userId,
1113                    int type, int start, int end) {
1114                    return findByG_U_T(groupId, userId, type, start, end, null);
1115            }
1116    
1117            /**
1118             * Returns an ordered range of all the social activity sets where groupId = &#63; and userId = &#63; and type = &#63;.
1119             *
1120             * <p>
1121             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.social.model.impl.SocialActivitySetModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1122             * </p>
1123             *
1124             * @param groupId the group ID
1125             * @param userId the user ID
1126             * @param type the type
1127             * @param start the lower bound of the range of social activity sets
1128             * @param end the upper bound of the range of social activity sets (not inclusive)
1129             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1130             * @return the ordered range of matching social activity sets
1131             */
1132            @Override
1133            public List<SocialActivitySet> findByG_U_T(long groupId, long userId,
1134                    int type, int start, int end,
1135                    OrderByComparator<SocialActivitySet> orderByComparator) {
1136                    boolean pagination = true;
1137                    FinderPath finderPath = null;
1138                    Object[] finderArgs = null;
1139    
1140                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1141                                    (orderByComparator == null)) {
1142                            pagination = false;
1143                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_T;
1144                            finderArgs = new Object[] { groupId, userId, type };
1145                    }
1146                    else {
1147                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_T;
1148                            finderArgs = new Object[] {
1149                                            groupId, userId, type,
1150                                            
1151                                            start, end, orderByComparator
1152                                    };
1153                    }
1154    
1155                    List<SocialActivitySet> list = (List<SocialActivitySet>)FinderCacheUtil.getResult(finderPath,
1156                                    finderArgs, this);
1157    
1158                    if ((list != null) && !list.isEmpty()) {
1159                            for (SocialActivitySet socialActivitySet : list) {
1160                                    if ((groupId != socialActivitySet.getGroupId()) ||
1161                                                    (userId != socialActivitySet.getUserId()) ||
1162                                                    (type != socialActivitySet.getType())) {
1163                                            list = null;
1164    
1165                                            break;
1166                                    }
1167                            }
1168                    }
1169    
1170                    if (list == null) {
1171                            StringBundler query = null;
1172    
1173                            if (orderByComparator != null) {
1174                                    query = new StringBundler(5 +
1175                                                    (orderByComparator.getOrderByFields().length * 3));
1176                            }
1177                            else {
1178                                    query = new StringBundler(5);
1179                            }
1180    
1181                            query.append(_SQL_SELECT_SOCIALACTIVITYSET_WHERE);
1182    
1183                            query.append(_FINDER_COLUMN_G_U_T_GROUPID_2);
1184    
1185                            query.append(_FINDER_COLUMN_G_U_T_USERID_2);
1186    
1187                            query.append(_FINDER_COLUMN_G_U_T_TYPE_2);
1188    
1189                            if (orderByComparator != null) {
1190                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1191                                            orderByComparator);
1192                            }
1193                            else
1194                             if (pagination) {
1195                                    query.append(SocialActivitySetModelImpl.ORDER_BY_JPQL);
1196                            }
1197    
1198                            String sql = query.toString();
1199    
1200                            Session session = null;
1201    
1202                            try {
1203                                    session = openSession();
1204    
1205                                    Query q = session.createQuery(sql);
1206    
1207                                    QueryPos qPos = QueryPos.getInstance(q);
1208    
1209                                    qPos.add(groupId);
1210    
1211                                    qPos.add(userId);
1212    
1213                                    qPos.add(type);
1214    
1215                                    if (!pagination) {
1216                                            list = (List<SocialActivitySet>)QueryUtil.list(q,
1217                                                            getDialect(), start, end, false);
1218    
1219                                            Collections.sort(list);
1220    
1221                                            list = Collections.unmodifiableList(list);
1222                                    }
1223                                    else {
1224                                            list = (List<SocialActivitySet>)QueryUtil.list(q,
1225                                                            getDialect(), start, end);
1226                                    }
1227    
1228                                    cacheResult(list);
1229    
1230                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1231                            }
1232                            catch (Exception e) {
1233                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1234    
1235                                    throw processException(e);
1236                            }
1237                            finally {
1238                                    closeSession(session);
1239                            }
1240                    }
1241    
1242                    return list;
1243            }
1244    
1245            /**
1246             * Returns the first social activity set in the ordered set where groupId = &#63; and userId = &#63; and type = &#63;.
1247             *
1248             * @param groupId the group ID
1249             * @param userId the user ID
1250             * @param type the type
1251             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1252             * @return the first matching social activity set
1253             * @throws com.liferay.portlet.social.NoSuchActivitySetException if a matching social activity set could not be found
1254             */
1255            @Override
1256            public SocialActivitySet findByG_U_T_First(long groupId, long userId,
1257                    int type, OrderByComparator<SocialActivitySet> orderByComparator)
1258                    throws NoSuchActivitySetException {
1259                    SocialActivitySet socialActivitySet = fetchByG_U_T_First(groupId,
1260                                    userId, type, orderByComparator);
1261    
1262                    if (socialActivitySet != null) {
1263                            return socialActivitySet;
1264                    }
1265    
1266                    StringBundler msg = new StringBundler(8);
1267    
1268                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1269    
1270                    msg.append("groupId=");
1271                    msg.append(groupId);
1272    
1273                    msg.append(", userId=");
1274                    msg.append(userId);
1275    
1276                    msg.append(", type=");
1277                    msg.append(type);
1278    
1279                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1280    
1281                    throw new NoSuchActivitySetException(msg.toString());
1282            }
1283    
1284            /**
1285             * Returns the first social activity set in the ordered set where groupId = &#63; and userId = &#63; and type = &#63;.
1286             *
1287             * @param groupId the group ID
1288             * @param userId the user ID
1289             * @param type the type
1290             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1291             * @return the first matching social activity set, or <code>null</code> if a matching social activity set could not be found
1292             */
1293            @Override
1294            public SocialActivitySet fetchByG_U_T_First(long groupId, long userId,
1295                    int type, OrderByComparator<SocialActivitySet> orderByComparator) {
1296                    List<SocialActivitySet> list = findByG_U_T(groupId, userId, type, 0, 1,
1297                                    orderByComparator);
1298    
1299                    if (!list.isEmpty()) {
1300                            return list.get(0);
1301                    }
1302    
1303                    return null;
1304            }
1305    
1306            /**
1307             * Returns the last social activity set in the ordered set where groupId = &#63; and userId = &#63; and type = &#63;.
1308             *
1309             * @param groupId the group ID
1310             * @param userId the user ID
1311             * @param type the type
1312             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1313             * @return the last matching social activity set
1314             * @throws com.liferay.portlet.social.NoSuchActivitySetException if a matching social activity set could not be found
1315             */
1316            @Override
1317            public SocialActivitySet findByG_U_T_Last(long groupId, long userId,
1318                    int type, OrderByComparator<SocialActivitySet> orderByComparator)
1319                    throws NoSuchActivitySetException {
1320                    SocialActivitySet socialActivitySet = fetchByG_U_T_Last(groupId,
1321                                    userId, type, orderByComparator);
1322    
1323                    if (socialActivitySet != null) {
1324                            return socialActivitySet;
1325                    }
1326    
1327                    StringBundler msg = new StringBundler(8);
1328    
1329                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1330    
1331                    msg.append("groupId=");
1332                    msg.append(groupId);
1333    
1334                    msg.append(", userId=");
1335                    msg.append(userId);
1336    
1337                    msg.append(", type=");
1338                    msg.append(type);
1339    
1340                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1341    
1342                    throw new NoSuchActivitySetException(msg.toString());
1343            }
1344    
1345            /**
1346             * Returns the last social activity set in the ordered set where groupId = &#63; and userId = &#63; and type = &#63;.
1347             *
1348             * @param groupId the group ID
1349             * @param userId the user ID
1350             * @param type the type
1351             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1352             * @return the last matching social activity set, or <code>null</code> if a matching social activity set could not be found
1353             */
1354            @Override
1355            public SocialActivitySet fetchByG_U_T_Last(long groupId, long userId,
1356                    int type, OrderByComparator<SocialActivitySet> orderByComparator) {
1357                    int count = countByG_U_T(groupId, userId, type);
1358    
1359                    if (count == 0) {
1360                            return null;
1361                    }
1362    
1363                    List<SocialActivitySet> list = findByG_U_T(groupId, userId, type,
1364                                    count - 1, count, orderByComparator);
1365    
1366                    if (!list.isEmpty()) {
1367                            return list.get(0);
1368                    }
1369    
1370                    return null;
1371            }
1372    
1373            /**
1374             * Returns the social activity sets before and after the current social activity set in the ordered set where groupId = &#63; and userId = &#63; and type = &#63;.
1375             *
1376             * @param activitySetId the primary key of the current social activity set
1377             * @param groupId the group ID
1378             * @param userId the user ID
1379             * @param type the type
1380             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1381             * @return the previous, current, and next social activity set
1382             * @throws com.liferay.portlet.social.NoSuchActivitySetException if a social activity set with the primary key could not be found
1383             */
1384            @Override
1385            public SocialActivitySet[] findByG_U_T_PrevAndNext(long activitySetId,
1386                    long groupId, long userId, int type,
1387                    OrderByComparator<SocialActivitySet> orderByComparator)
1388                    throws NoSuchActivitySetException {
1389                    SocialActivitySet socialActivitySet = findByPrimaryKey(activitySetId);
1390    
1391                    Session session = null;
1392    
1393                    try {
1394                            session = openSession();
1395    
1396                            SocialActivitySet[] array = new SocialActivitySetImpl[3];
1397    
1398                            array[0] = getByG_U_T_PrevAndNext(session, socialActivitySet,
1399                                            groupId, userId, type, orderByComparator, true);
1400    
1401                            array[1] = socialActivitySet;
1402    
1403                            array[2] = getByG_U_T_PrevAndNext(session, socialActivitySet,
1404                                            groupId, userId, type, orderByComparator, false);
1405    
1406                            return array;
1407                    }
1408                    catch (Exception e) {
1409                            throw processException(e);
1410                    }
1411                    finally {
1412                            closeSession(session);
1413                    }
1414            }
1415    
1416            protected SocialActivitySet getByG_U_T_PrevAndNext(Session session,
1417                    SocialActivitySet socialActivitySet, long groupId, long userId,
1418                    int type, OrderByComparator<SocialActivitySet> orderByComparator,
1419                    boolean previous) {
1420                    StringBundler query = null;
1421    
1422                    if (orderByComparator != null) {
1423                            query = new StringBundler(6 +
1424                                            (orderByComparator.getOrderByFields().length * 6));
1425                    }
1426                    else {
1427                            query = new StringBundler(3);
1428                    }
1429    
1430                    query.append(_SQL_SELECT_SOCIALACTIVITYSET_WHERE);
1431    
1432                    query.append(_FINDER_COLUMN_G_U_T_GROUPID_2);
1433    
1434                    query.append(_FINDER_COLUMN_G_U_T_USERID_2);
1435    
1436                    query.append(_FINDER_COLUMN_G_U_T_TYPE_2);
1437    
1438                    if (orderByComparator != null) {
1439                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1440    
1441                            if (orderByConditionFields.length > 0) {
1442                                    query.append(WHERE_AND);
1443                            }
1444    
1445                            for (int i = 0; i < orderByConditionFields.length; i++) {
1446                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1447                                    query.append(orderByConditionFields[i]);
1448    
1449                                    if ((i + 1) < orderByConditionFields.length) {
1450                                            if (orderByComparator.isAscending() ^ previous) {
1451                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1452                                            }
1453                                            else {
1454                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1455                                            }
1456                                    }
1457                                    else {
1458                                            if (orderByComparator.isAscending() ^ previous) {
1459                                                    query.append(WHERE_GREATER_THAN);
1460                                            }
1461                                            else {
1462                                                    query.append(WHERE_LESSER_THAN);
1463                                            }
1464                                    }
1465                            }
1466    
1467                            query.append(ORDER_BY_CLAUSE);
1468    
1469                            String[] orderByFields = orderByComparator.getOrderByFields();
1470    
1471                            for (int i = 0; i < orderByFields.length; i++) {
1472                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1473                                    query.append(orderByFields[i]);
1474    
1475                                    if ((i + 1) < orderByFields.length) {
1476                                            if (orderByComparator.isAscending() ^ previous) {
1477                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1478                                            }
1479                                            else {
1480                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1481                                            }
1482                                    }
1483                                    else {
1484                                            if (orderByComparator.isAscending() ^ previous) {
1485                                                    query.append(ORDER_BY_ASC);
1486                                            }
1487                                            else {
1488                                                    query.append(ORDER_BY_DESC);
1489                                            }
1490                                    }
1491                            }
1492                    }
1493                    else {
1494                            query.append(SocialActivitySetModelImpl.ORDER_BY_JPQL);
1495                    }
1496    
1497                    String sql = query.toString();
1498    
1499                    Query q = session.createQuery(sql);
1500    
1501                    q.setFirstResult(0);
1502                    q.setMaxResults(2);
1503    
1504                    QueryPos qPos = QueryPos.getInstance(q);
1505    
1506                    qPos.add(groupId);
1507    
1508                    qPos.add(userId);
1509    
1510                    qPos.add(type);
1511    
1512                    if (orderByComparator != null) {
1513                            Object[] values = orderByComparator.getOrderByConditionValues(socialActivitySet);
1514    
1515                            for (Object value : values) {
1516                                    qPos.add(value);
1517                            }
1518                    }
1519    
1520                    List<SocialActivitySet> list = q.list();
1521    
1522                    if (list.size() == 2) {
1523                            return list.get(1);
1524                    }
1525                    else {
1526                            return null;
1527                    }
1528            }
1529    
1530            /**
1531             * Removes all the social activity sets where groupId = &#63; and userId = &#63; and type = &#63; from the database.
1532             *
1533             * @param groupId the group ID
1534             * @param userId the user ID
1535             * @param type the type
1536             */
1537            @Override
1538            public void removeByG_U_T(long groupId, long userId, int type) {
1539                    for (SocialActivitySet socialActivitySet : findByG_U_T(groupId, userId,
1540                                    type, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1541                            remove(socialActivitySet);
1542                    }
1543            }
1544    
1545            /**
1546             * Returns the number of social activity sets where groupId = &#63; and userId = &#63; and type = &#63;.
1547             *
1548             * @param groupId the group ID
1549             * @param userId the user ID
1550             * @param type the type
1551             * @return the number of matching social activity sets
1552             */
1553            @Override
1554            public int countByG_U_T(long groupId, long userId, int type) {
1555                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_U_T;
1556    
1557                    Object[] finderArgs = new Object[] { groupId, userId, type };
1558    
1559                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1560                                    this);
1561    
1562                    if (count == null) {
1563                            StringBundler query = new StringBundler(4);
1564    
1565                            query.append(_SQL_COUNT_SOCIALACTIVITYSET_WHERE);
1566    
1567                            query.append(_FINDER_COLUMN_G_U_T_GROUPID_2);
1568    
1569                            query.append(_FINDER_COLUMN_G_U_T_USERID_2);
1570    
1571                            query.append(_FINDER_COLUMN_G_U_T_TYPE_2);
1572    
1573                            String sql = query.toString();
1574    
1575                            Session session = null;
1576    
1577                            try {
1578                                    session = openSession();
1579    
1580                                    Query q = session.createQuery(sql);
1581    
1582                                    QueryPos qPos = QueryPos.getInstance(q);
1583    
1584                                    qPos.add(groupId);
1585    
1586                                    qPos.add(userId);
1587    
1588                                    qPos.add(type);
1589    
1590                                    count = (Long)q.uniqueResult();
1591    
1592                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
1593                            }
1594                            catch (Exception e) {
1595                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1596    
1597                                    throw processException(e);
1598                            }
1599                            finally {
1600                                    closeSession(session);
1601                            }
1602                    }
1603    
1604                    return count.intValue();
1605            }
1606    
1607            private static final String _FINDER_COLUMN_G_U_T_GROUPID_2 = "socialActivitySet.groupId = ? AND ";
1608            private static final String _FINDER_COLUMN_G_U_T_USERID_2 = "socialActivitySet.userId = ? AND ";
1609            private static final String _FINDER_COLUMN_G_U_T_TYPE_2 = "socialActivitySet.type = ?";
1610            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C_T = new FinderPath(SocialActivitySetModelImpl.ENTITY_CACHE_ENABLED,
1611                            SocialActivitySetModelImpl.FINDER_CACHE_ENABLED,
1612                            SocialActivitySetImpl.class,
1613                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_C_T",
1614                            new String[] {
1615                                    Long.class.getName(), Long.class.getName(),
1616                                    Integer.class.getName(),
1617                                    
1618                            Integer.class.getName(), Integer.class.getName(),
1619                                    OrderByComparator.class.getName()
1620                            });
1621            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_T = new FinderPath(SocialActivitySetModelImpl.ENTITY_CACHE_ENABLED,
1622                            SocialActivitySetModelImpl.FINDER_CACHE_ENABLED,
1623                            SocialActivitySetImpl.class,
1624                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_C_T",
1625                            new String[] {
1626                                    Long.class.getName(), Long.class.getName(),
1627                                    Integer.class.getName()
1628                            },
1629                            SocialActivitySetModelImpl.CLASSNAMEID_COLUMN_BITMASK |
1630                            SocialActivitySetModelImpl.CLASSPK_COLUMN_BITMASK |
1631                            SocialActivitySetModelImpl.TYPE_COLUMN_BITMASK |
1632                            SocialActivitySetModelImpl.MODIFIEDDATE_COLUMN_BITMASK);
1633            public static final FinderPath FINDER_PATH_COUNT_BY_C_C_T = new FinderPath(SocialActivitySetModelImpl.ENTITY_CACHE_ENABLED,
1634                            SocialActivitySetModelImpl.FINDER_CACHE_ENABLED, Long.class,
1635                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C_T",
1636                            new String[] {
1637                                    Long.class.getName(), Long.class.getName(),
1638                                    Integer.class.getName()
1639                            });
1640    
1641            /**
1642             * Returns all the social activity sets where classNameId = &#63; and classPK = &#63; and type = &#63;.
1643             *
1644             * @param classNameId the class name ID
1645             * @param classPK the class p k
1646             * @param type the type
1647             * @return the matching social activity sets
1648             */
1649            @Override
1650            public List<SocialActivitySet> findByC_C_T(long classNameId, long classPK,
1651                    int type) {
1652                    return findByC_C_T(classNameId, classPK, type, QueryUtil.ALL_POS,
1653                            QueryUtil.ALL_POS, null);
1654            }
1655    
1656            /**
1657             * Returns a range of all the social activity sets where classNameId = &#63; and classPK = &#63; and type = &#63;.
1658             *
1659             * <p>
1660             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.social.model.impl.SocialActivitySetModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1661             * </p>
1662             *
1663             * @param classNameId the class name ID
1664             * @param classPK the class p k
1665             * @param type the type
1666             * @param start the lower bound of the range of social activity sets
1667             * @param end the upper bound of the range of social activity sets (not inclusive)
1668             * @return the range of matching social activity sets
1669             */
1670            @Override
1671            public List<SocialActivitySet> findByC_C_T(long classNameId, long classPK,
1672                    int type, int start, int end) {
1673                    return findByC_C_T(classNameId, classPK, type, start, end, null);
1674            }
1675    
1676            /**
1677             * Returns an ordered range of all the social activity sets where classNameId = &#63; and classPK = &#63; and type = &#63;.
1678             *
1679             * <p>
1680             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.social.model.impl.SocialActivitySetModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1681             * </p>
1682             *
1683             * @param classNameId the class name ID
1684             * @param classPK the class p k
1685             * @param type the type
1686             * @param start the lower bound of the range of social activity sets
1687             * @param end the upper bound of the range of social activity sets (not inclusive)
1688             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1689             * @return the ordered range of matching social activity sets
1690             */
1691            @Override
1692            public List<SocialActivitySet> findByC_C_T(long classNameId, long classPK,
1693                    int type, int start, int end,
1694                    OrderByComparator<SocialActivitySet> orderByComparator) {
1695                    boolean pagination = true;
1696                    FinderPath finderPath = null;
1697                    Object[] finderArgs = null;
1698    
1699                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1700                                    (orderByComparator == null)) {
1701                            pagination = false;
1702                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_T;
1703                            finderArgs = new Object[] { classNameId, classPK, type };
1704                    }
1705                    else {
1706                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C_T;
1707                            finderArgs = new Object[] {
1708                                            classNameId, classPK, type,
1709                                            
1710                                            start, end, orderByComparator
1711                                    };
1712                    }
1713    
1714                    List<SocialActivitySet> list = (List<SocialActivitySet>)FinderCacheUtil.getResult(finderPath,
1715                                    finderArgs, this);
1716    
1717                    if ((list != null) && !list.isEmpty()) {
1718                            for (SocialActivitySet socialActivitySet : list) {
1719                                    if ((classNameId != socialActivitySet.getClassNameId()) ||
1720                                                    (classPK != socialActivitySet.getClassPK()) ||
1721                                                    (type != socialActivitySet.getType())) {
1722                                            list = null;
1723    
1724                                            break;
1725                                    }
1726                            }
1727                    }
1728    
1729                    if (list == null) {
1730                            StringBundler query = null;
1731    
1732                            if (orderByComparator != null) {
1733                                    query = new StringBundler(5 +
1734                                                    (orderByComparator.getOrderByFields().length * 3));
1735                            }
1736                            else {
1737                                    query = new StringBundler(5);
1738                            }
1739    
1740                            query.append(_SQL_SELECT_SOCIALACTIVITYSET_WHERE);
1741    
1742                            query.append(_FINDER_COLUMN_C_C_T_CLASSNAMEID_2);
1743    
1744                            query.append(_FINDER_COLUMN_C_C_T_CLASSPK_2);
1745    
1746                            query.append(_FINDER_COLUMN_C_C_T_TYPE_2);
1747    
1748                            if (orderByComparator != null) {
1749                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1750                                            orderByComparator);
1751                            }
1752                            else
1753                             if (pagination) {
1754                                    query.append(SocialActivitySetModelImpl.ORDER_BY_JPQL);
1755                            }
1756    
1757                            String sql = query.toString();
1758    
1759                            Session session = null;
1760    
1761                            try {
1762                                    session = openSession();
1763    
1764                                    Query q = session.createQuery(sql);
1765    
1766                                    QueryPos qPos = QueryPos.getInstance(q);
1767    
1768                                    qPos.add(classNameId);
1769    
1770                                    qPos.add(classPK);
1771    
1772                                    qPos.add(type);
1773    
1774                                    if (!pagination) {
1775                                            list = (List<SocialActivitySet>)QueryUtil.list(q,
1776                                                            getDialect(), start, end, false);
1777    
1778                                            Collections.sort(list);
1779    
1780                                            list = Collections.unmodifiableList(list);
1781                                    }
1782                                    else {
1783                                            list = (List<SocialActivitySet>)QueryUtil.list(q,
1784                                                            getDialect(), start, end);
1785                                    }
1786    
1787                                    cacheResult(list);
1788    
1789                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1790                            }
1791                            catch (Exception e) {
1792                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1793    
1794                                    throw processException(e);
1795                            }
1796                            finally {
1797                                    closeSession(session);
1798                            }
1799                    }
1800    
1801                    return list;
1802            }
1803    
1804            /**
1805             * Returns the first social activity set in the ordered set where classNameId = &#63; and classPK = &#63; and type = &#63;.
1806             *
1807             * @param classNameId the class name ID
1808             * @param classPK the class p k
1809             * @param type the type
1810             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1811             * @return the first matching social activity set
1812             * @throws com.liferay.portlet.social.NoSuchActivitySetException if a matching social activity set could not be found
1813             */
1814            @Override
1815            public SocialActivitySet findByC_C_T_First(long classNameId, long classPK,
1816                    int type, OrderByComparator<SocialActivitySet> orderByComparator)
1817                    throws NoSuchActivitySetException {
1818                    SocialActivitySet socialActivitySet = fetchByC_C_T_First(classNameId,
1819                                    classPK, type, orderByComparator);
1820    
1821                    if (socialActivitySet != null) {
1822                            return socialActivitySet;
1823                    }
1824    
1825                    StringBundler msg = new StringBundler(8);
1826    
1827                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1828    
1829                    msg.append("classNameId=");
1830                    msg.append(classNameId);
1831    
1832                    msg.append(", classPK=");
1833                    msg.append(classPK);
1834    
1835                    msg.append(", type=");
1836                    msg.append(type);
1837    
1838                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1839    
1840                    throw new NoSuchActivitySetException(msg.toString());
1841            }
1842    
1843            /**
1844             * Returns the first social activity set in the ordered set where classNameId = &#63; and classPK = &#63; and type = &#63;.
1845             *
1846             * @param classNameId the class name ID
1847             * @param classPK the class p k
1848             * @param type the type
1849             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1850             * @return the first matching social activity set, or <code>null</code> if a matching social activity set could not be found
1851             */
1852            @Override
1853            public SocialActivitySet fetchByC_C_T_First(long classNameId, long classPK,
1854                    int type, OrderByComparator<SocialActivitySet> orderByComparator) {
1855                    List<SocialActivitySet> list = findByC_C_T(classNameId, classPK, type,
1856                                    0, 1, orderByComparator);
1857    
1858                    if (!list.isEmpty()) {
1859                            return list.get(0);
1860                    }
1861    
1862                    return null;
1863            }
1864    
1865            /**
1866             * Returns the last social activity set in the ordered set where classNameId = &#63; and classPK = &#63; and type = &#63;.
1867             *
1868             * @param classNameId the class name ID
1869             * @param classPK the class p k
1870             * @param type the type
1871             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1872             * @return the last matching social activity set
1873             * @throws com.liferay.portlet.social.NoSuchActivitySetException if a matching social activity set could not be found
1874             */
1875            @Override
1876            public SocialActivitySet findByC_C_T_Last(long classNameId, long classPK,
1877                    int type, OrderByComparator<SocialActivitySet> orderByComparator)
1878                    throws NoSuchActivitySetException {
1879                    SocialActivitySet socialActivitySet = fetchByC_C_T_Last(classNameId,
1880                                    classPK, type, orderByComparator);
1881    
1882                    if (socialActivitySet != null) {
1883                            return socialActivitySet;
1884                    }
1885    
1886                    StringBundler msg = new StringBundler(8);
1887    
1888                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1889    
1890                    msg.append("classNameId=");
1891                    msg.append(classNameId);
1892    
1893                    msg.append(", classPK=");
1894                    msg.append(classPK);
1895    
1896                    msg.append(", type=");
1897                    msg.append(type);
1898    
1899                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1900    
1901                    throw new NoSuchActivitySetException(msg.toString());
1902            }
1903    
1904            /**
1905             * Returns the last social activity set in the ordered set where classNameId = &#63; and classPK = &#63; and type = &#63;.
1906             *
1907             * @param classNameId the class name ID
1908             * @param classPK the class p k
1909             * @param type the type
1910             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1911             * @return the last matching social activity set, or <code>null</code> if a matching social activity set could not be found
1912             */
1913            @Override
1914            public SocialActivitySet fetchByC_C_T_Last(long classNameId, long classPK,
1915                    int type, OrderByComparator<SocialActivitySet> orderByComparator) {
1916                    int count = countByC_C_T(classNameId, classPK, type);
1917    
1918                    if (count == 0) {
1919                            return null;
1920                    }
1921    
1922                    List<SocialActivitySet> list = findByC_C_T(classNameId, classPK, type,
1923                                    count - 1, count, orderByComparator);
1924    
1925                    if (!list.isEmpty()) {
1926                            return list.get(0);
1927                    }
1928    
1929                    return null;
1930            }
1931    
1932            /**
1933             * Returns the social activity sets before and after the current social activity set in the ordered set where classNameId = &#63; and classPK = &#63; and type = &#63;.
1934             *
1935             * @param activitySetId the primary key of the current social activity set
1936             * @param classNameId the class name ID
1937             * @param classPK the class p k
1938             * @param type the type
1939             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1940             * @return the previous, current, and next social activity set
1941             * @throws com.liferay.portlet.social.NoSuchActivitySetException if a social activity set with the primary key could not be found
1942             */
1943            @Override
1944            public SocialActivitySet[] findByC_C_T_PrevAndNext(long activitySetId,
1945                    long classNameId, long classPK, int type,
1946                    OrderByComparator<SocialActivitySet> orderByComparator)
1947                    throws NoSuchActivitySetException {
1948                    SocialActivitySet socialActivitySet = findByPrimaryKey(activitySetId);
1949    
1950                    Session session = null;
1951    
1952                    try {
1953                            session = openSession();
1954    
1955                            SocialActivitySet[] array = new SocialActivitySetImpl[3];
1956    
1957                            array[0] = getByC_C_T_PrevAndNext(session, socialActivitySet,
1958                                            classNameId, classPK, type, orderByComparator, true);
1959    
1960                            array[1] = socialActivitySet;
1961    
1962                            array[2] = getByC_C_T_PrevAndNext(session, socialActivitySet,
1963                                            classNameId, classPK, type, orderByComparator, false);
1964    
1965                            return array;
1966                    }
1967                    catch (Exception e) {
1968                            throw processException(e);
1969                    }
1970                    finally {
1971                            closeSession(session);
1972                    }
1973            }
1974    
1975            protected SocialActivitySet getByC_C_T_PrevAndNext(Session session,
1976                    SocialActivitySet socialActivitySet, long classNameId, long classPK,
1977                    int type, OrderByComparator<SocialActivitySet> orderByComparator,
1978                    boolean previous) {
1979                    StringBundler query = null;
1980    
1981                    if (orderByComparator != null) {
1982                            query = new StringBundler(6 +
1983                                            (orderByComparator.getOrderByFields().length * 6));
1984                    }
1985                    else {
1986                            query = new StringBundler(3);
1987                    }
1988    
1989                    query.append(_SQL_SELECT_SOCIALACTIVITYSET_WHERE);
1990    
1991                    query.append(_FINDER_COLUMN_C_C_T_CLASSNAMEID_2);
1992    
1993                    query.append(_FINDER_COLUMN_C_C_T_CLASSPK_2);
1994    
1995                    query.append(_FINDER_COLUMN_C_C_T_TYPE_2);
1996    
1997                    if (orderByComparator != null) {
1998                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1999    
2000                            if (orderByConditionFields.length > 0) {
2001                                    query.append(WHERE_AND);
2002                            }
2003    
2004                            for (int i = 0; i < orderByConditionFields.length; i++) {
2005                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2006                                    query.append(orderByConditionFields[i]);
2007    
2008                                    if ((i + 1) < orderByConditionFields.length) {
2009                                            if (orderByComparator.isAscending() ^ previous) {
2010                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2011                                            }
2012                                            else {
2013                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2014                                            }
2015                                    }
2016                                    else {
2017                                            if (orderByComparator.isAscending() ^ previous) {
2018                                                    query.append(WHERE_GREATER_THAN);
2019                                            }
2020                                            else {
2021                                                    query.append(WHERE_LESSER_THAN);
2022                                            }
2023                                    }
2024                            }
2025    
2026                            query.append(ORDER_BY_CLAUSE);
2027    
2028                            String[] orderByFields = orderByComparator.getOrderByFields();
2029    
2030                            for (int i = 0; i < orderByFields.length; i++) {
2031                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2032                                    query.append(orderByFields[i]);
2033    
2034                                    if ((i + 1) < orderByFields.length) {
2035                                            if (orderByComparator.isAscending() ^ previous) {
2036                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2037                                            }
2038                                            else {
2039                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2040                                            }
2041                                    }
2042                                    else {
2043                                            if (orderByComparator.isAscending() ^ previous) {
2044                                                    query.append(ORDER_BY_ASC);
2045                                            }
2046                                            else {
2047                                                    query.append(ORDER_BY_DESC);
2048                                            }
2049                                    }
2050                            }
2051                    }
2052                    else {
2053                            query.append(SocialActivitySetModelImpl.ORDER_BY_JPQL);
2054                    }
2055    
2056                    String sql = query.toString();
2057    
2058                    Query q = session.createQuery(sql);
2059    
2060                    q.setFirstResult(0);
2061                    q.setMaxResults(2);
2062    
2063                    QueryPos qPos = QueryPos.getInstance(q);
2064    
2065                    qPos.add(classNameId);
2066    
2067                    qPos.add(classPK);
2068    
2069                    qPos.add(type);
2070    
2071                    if (orderByComparator != null) {
2072                            Object[] values = orderByComparator.getOrderByConditionValues(socialActivitySet);
2073    
2074                            for (Object value : values) {
2075                                    qPos.add(value);
2076                            }
2077                    }
2078    
2079                    List<SocialActivitySet> list = q.list();
2080    
2081                    if (list.size() == 2) {
2082                            return list.get(1);
2083                    }
2084                    else {
2085                            return null;
2086                    }
2087            }
2088    
2089            /**
2090             * Removes all the social activity sets where classNameId = &#63; and classPK = &#63; and type = &#63; from the database.
2091             *
2092             * @param classNameId the class name ID
2093             * @param classPK the class p k
2094             * @param type the type
2095             */
2096            @Override
2097            public void removeByC_C_T(long classNameId, long classPK, int type) {
2098                    for (SocialActivitySet socialActivitySet : findByC_C_T(classNameId,
2099                                    classPK, type, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2100                            remove(socialActivitySet);
2101                    }
2102            }
2103    
2104            /**
2105             * Returns the number of social activity sets where classNameId = &#63; and classPK = &#63; and type = &#63;.
2106             *
2107             * @param classNameId the class name ID
2108             * @param classPK the class p k
2109             * @param type the type
2110             * @return the number of matching social activity sets
2111             */
2112            @Override
2113            public int countByC_C_T(long classNameId, long classPK, int type) {
2114                    FinderPath finderPath = FINDER_PATH_COUNT_BY_C_C_T;
2115    
2116                    Object[] finderArgs = new Object[] { classNameId, classPK, type };
2117    
2118                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2119                                    this);
2120    
2121                    if (count == null) {
2122                            StringBundler query = new StringBundler(4);
2123    
2124                            query.append(_SQL_COUNT_SOCIALACTIVITYSET_WHERE);
2125    
2126                            query.append(_FINDER_COLUMN_C_C_T_CLASSNAMEID_2);
2127    
2128                            query.append(_FINDER_COLUMN_C_C_T_CLASSPK_2);
2129    
2130                            query.append(_FINDER_COLUMN_C_C_T_TYPE_2);
2131    
2132                            String sql = query.toString();
2133    
2134                            Session session = null;
2135    
2136                            try {
2137                                    session = openSession();
2138    
2139                                    Query q = session.createQuery(sql);
2140    
2141                                    QueryPos qPos = QueryPos.getInstance(q);
2142    
2143                                    qPos.add(classNameId);
2144    
2145                                    qPos.add(classPK);
2146    
2147                                    qPos.add(type);
2148    
2149                                    count = (Long)q.uniqueResult();
2150    
2151                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
2152                            }
2153                            catch (Exception e) {
2154                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2155    
2156                                    throw processException(e);
2157                            }
2158                            finally {
2159                                    closeSession(session);
2160                            }
2161                    }
2162    
2163                    return count.intValue();
2164            }
2165    
2166            private static final String _FINDER_COLUMN_C_C_T_CLASSNAMEID_2 = "socialActivitySet.classNameId = ? AND ";
2167            private static final String _FINDER_COLUMN_C_C_T_CLASSPK_2 = "socialActivitySet.classPK = ? AND ";
2168            private static final String _FINDER_COLUMN_C_C_T_TYPE_2 = "socialActivitySet.type = ?";
2169            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_C_T = new FinderPath(SocialActivitySetModelImpl.ENTITY_CACHE_ENABLED,
2170                            SocialActivitySetModelImpl.FINDER_CACHE_ENABLED,
2171                            SocialActivitySetImpl.class,
2172                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_C_T",
2173                            new String[] {
2174                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
2175                                    Integer.class.getName(),
2176                                    
2177                            Integer.class.getName(), Integer.class.getName(),
2178                                    OrderByComparator.class.getName()
2179                            });
2180            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_C_T =
2181                    new FinderPath(SocialActivitySetModelImpl.ENTITY_CACHE_ENABLED,
2182                            SocialActivitySetModelImpl.FINDER_CACHE_ENABLED,
2183                            SocialActivitySetImpl.class,
2184                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U_C_T",
2185                            new String[] {
2186                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
2187                                    Integer.class.getName()
2188                            },
2189                            SocialActivitySetModelImpl.GROUPID_COLUMN_BITMASK |
2190                            SocialActivitySetModelImpl.USERID_COLUMN_BITMASK |
2191                            SocialActivitySetModelImpl.CLASSNAMEID_COLUMN_BITMASK |
2192                            SocialActivitySetModelImpl.TYPE_COLUMN_BITMASK |
2193                            SocialActivitySetModelImpl.MODIFIEDDATE_COLUMN_BITMASK);
2194            public static final FinderPath FINDER_PATH_COUNT_BY_G_U_C_T = new FinderPath(SocialActivitySetModelImpl.ENTITY_CACHE_ENABLED,
2195                            SocialActivitySetModelImpl.FINDER_CACHE_ENABLED, Long.class,
2196                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U_C_T",
2197                            new String[] {
2198                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
2199                                    Integer.class.getName()
2200                            });
2201    
2202            /**
2203             * Returns all the social activity sets where groupId = &#63; and userId = &#63; and classNameId = &#63; and type = &#63;.
2204             *
2205             * @param groupId the group ID
2206             * @param userId the user ID
2207             * @param classNameId the class name ID
2208             * @param type the type
2209             * @return the matching social activity sets
2210             */
2211            @Override
2212            public List<SocialActivitySet> findByG_U_C_T(long groupId, long userId,
2213                    long classNameId, int type) {
2214                    return findByG_U_C_T(groupId, userId, classNameId, type,
2215                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2216            }
2217    
2218            /**
2219             * Returns a range of all the social activity sets where groupId = &#63; and userId = &#63; and classNameId = &#63; and type = &#63;.
2220             *
2221             * <p>
2222             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.social.model.impl.SocialActivitySetModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2223             * </p>
2224             *
2225             * @param groupId the group ID
2226             * @param userId the user ID
2227             * @param classNameId the class name ID
2228             * @param type the type
2229             * @param start the lower bound of the range of social activity sets
2230             * @param end the upper bound of the range of social activity sets (not inclusive)
2231             * @return the range of matching social activity sets
2232             */
2233            @Override
2234            public List<SocialActivitySet> findByG_U_C_T(long groupId, long userId,
2235                    long classNameId, int type, int start, int end) {
2236                    return findByG_U_C_T(groupId, userId, classNameId, type, start, end,
2237                            null);
2238            }
2239    
2240            /**
2241             * Returns an ordered range of all the social activity sets where groupId = &#63; and userId = &#63; and classNameId = &#63; and type = &#63;.
2242             *
2243             * <p>
2244             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.social.model.impl.SocialActivitySetModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2245             * </p>
2246             *
2247             * @param groupId the group ID
2248             * @param userId the user ID
2249             * @param classNameId the class name ID
2250             * @param type the type
2251             * @param start the lower bound of the range of social activity sets
2252             * @param end the upper bound of the range of social activity sets (not inclusive)
2253             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2254             * @return the ordered range of matching social activity sets
2255             */
2256            @Override
2257            public List<SocialActivitySet> findByG_U_C_T(long groupId, long userId,
2258                    long classNameId, int type, int start, int end,
2259                    OrderByComparator<SocialActivitySet> orderByComparator) {
2260                    boolean pagination = true;
2261                    FinderPath finderPath = null;
2262                    Object[] finderArgs = null;
2263    
2264                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2265                                    (orderByComparator == null)) {
2266                            pagination = false;
2267                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_C_T;
2268                            finderArgs = new Object[] { groupId, userId, classNameId, type };
2269                    }
2270                    else {
2271                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_C_T;
2272                            finderArgs = new Object[] {
2273                                            groupId, userId, classNameId, type,
2274                                            
2275                                            start, end, orderByComparator
2276                                    };
2277                    }
2278    
2279                    List<SocialActivitySet> list = (List<SocialActivitySet>)FinderCacheUtil.getResult(finderPath,
2280                                    finderArgs, this);
2281    
2282                    if ((list != null) && !list.isEmpty()) {
2283                            for (SocialActivitySet socialActivitySet : list) {
2284                                    if ((groupId != socialActivitySet.getGroupId()) ||
2285                                                    (userId != socialActivitySet.getUserId()) ||
2286                                                    (classNameId != socialActivitySet.getClassNameId()) ||
2287                                                    (type != socialActivitySet.getType())) {
2288                                            list = null;
2289    
2290                                            break;
2291                                    }
2292                            }
2293                    }
2294    
2295                    if (list == null) {
2296                            StringBundler query = null;
2297    
2298                            if (orderByComparator != null) {
2299                                    query = new StringBundler(6 +
2300                                                    (orderByComparator.getOrderByFields().length * 3));
2301                            }
2302                            else {
2303                                    query = new StringBundler(6);
2304                            }
2305    
2306                            query.append(_SQL_SELECT_SOCIALACTIVITYSET_WHERE);
2307    
2308                            query.append(_FINDER_COLUMN_G_U_C_T_GROUPID_2);
2309    
2310                            query.append(_FINDER_COLUMN_G_U_C_T_USERID_2);
2311    
2312                            query.append(_FINDER_COLUMN_G_U_C_T_CLASSNAMEID_2);
2313    
2314                            query.append(_FINDER_COLUMN_G_U_C_T_TYPE_2);
2315    
2316                            if (orderByComparator != null) {
2317                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2318                                            orderByComparator);
2319                            }
2320                            else
2321                             if (pagination) {
2322                                    query.append(SocialActivitySetModelImpl.ORDER_BY_JPQL);
2323                            }
2324    
2325                            String sql = query.toString();
2326    
2327                            Session session = null;
2328    
2329                            try {
2330                                    session = openSession();
2331    
2332                                    Query q = session.createQuery(sql);
2333    
2334                                    QueryPos qPos = QueryPos.getInstance(q);
2335    
2336                                    qPos.add(groupId);
2337    
2338                                    qPos.add(userId);
2339    
2340                                    qPos.add(classNameId);
2341    
2342                                    qPos.add(type);
2343    
2344                                    if (!pagination) {
2345                                            list = (List<SocialActivitySet>)QueryUtil.list(q,
2346                                                            getDialect(), start, end, false);
2347    
2348                                            Collections.sort(list);
2349    
2350                                            list = Collections.unmodifiableList(list);
2351                                    }
2352                                    else {
2353                                            list = (List<SocialActivitySet>)QueryUtil.list(q,
2354                                                            getDialect(), start, end);
2355                                    }
2356    
2357                                    cacheResult(list);
2358    
2359                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
2360                            }
2361                            catch (Exception e) {
2362                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2363    
2364                                    throw processException(e);
2365                            }
2366                            finally {
2367                                    closeSession(session);
2368                            }
2369                    }
2370    
2371                    return list;
2372            }
2373    
2374            /**
2375             * Returns the first social activity set in the ordered set where groupId = &#63; and userId = &#63; and classNameId = &#63; and type = &#63;.
2376             *
2377             * @param groupId the group ID
2378             * @param userId the user ID
2379             * @param classNameId the class name ID
2380             * @param type the type
2381             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2382             * @return the first matching social activity set
2383             * @throws com.liferay.portlet.social.NoSuchActivitySetException if a matching social activity set could not be found
2384             */
2385            @Override
2386            public SocialActivitySet findByG_U_C_T_First(long groupId, long userId,
2387                    long classNameId, int type,
2388                    OrderByComparator<SocialActivitySet> orderByComparator)
2389                    throws NoSuchActivitySetException {
2390                    SocialActivitySet socialActivitySet = fetchByG_U_C_T_First(groupId,
2391                                    userId, classNameId, type, orderByComparator);
2392    
2393                    if (socialActivitySet != null) {
2394                            return socialActivitySet;
2395                    }
2396    
2397                    StringBundler msg = new StringBundler(10);
2398    
2399                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2400    
2401                    msg.append("groupId=");
2402                    msg.append(groupId);
2403    
2404                    msg.append(", userId=");
2405                    msg.append(userId);
2406    
2407                    msg.append(", classNameId=");
2408                    msg.append(classNameId);
2409    
2410                    msg.append(", type=");
2411                    msg.append(type);
2412    
2413                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2414    
2415                    throw new NoSuchActivitySetException(msg.toString());
2416            }
2417    
2418            /**
2419             * Returns the first social activity set in the ordered set where groupId = &#63; and userId = &#63; and classNameId = &#63; and type = &#63;.
2420             *
2421             * @param groupId the group ID
2422             * @param userId the user ID
2423             * @param classNameId the class name ID
2424             * @param type the type
2425             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2426             * @return the first matching social activity set, or <code>null</code> if a matching social activity set could not be found
2427             */
2428            @Override
2429            public SocialActivitySet fetchByG_U_C_T_First(long groupId, long userId,
2430                    long classNameId, int type,
2431                    OrderByComparator<SocialActivitySet> orderByComparator) {
2432                    List<SocialActivitySet> list = findByG_U_C_T(groupId, userId,
2433                                    classNameId, type, 0, 1, orderByComparator);
2434    
2435                    if (!list.isEmpty()) {
2436                            return list.get(0);
2437                    }
2438    
2439                    return null;
2440            }
2441    
2442            /**
2443             * Returns the last social activity set in the ordered set where groupId = &#63; and userId = &#63; and classNameId = &#63; and type = &#63;.
2444             *
2445             * @param groupId the group ID
2446             * @param userId the user ID
2447             * @param classNameId the class name ID
2448             * @param type the type
2449             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2450             * @return the last matching social activity set
2451             * @throws com.liferay.portlet.social.NoSuchActivitySetException if a matching social activity set could not be found
2452             */
2453            @Override
2454            public SocialActivitySet findByG_U_C_T_Last(long groupId, long userId,
2455                    long classNameId, int type,
2456                    OrderByComparator<SocialActivitySet> orderByComparator)
2457                    throws NoSuchActivitySetException {
2458                    SocialActivitySet socialActivitySet = fetchByG_U_C_T_Last(groupId,
2459                                    userId, classNameId, type, orderByComparator);
2460    
2461                    if (socialActivitySet != null) {
2462                            return socialActivitySet;
2463                    }
2464    
2465                    StringBundler msg = new StringBundler(10);
2466    
2467                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2468    
2469                    msg.append("groupId=");
2470                    msg.append(groupId);
2471    
2472                    msg.append(", userId=");
2473                    msg.append(userId);
2474    
2475                    msg.append(", classNameId=");
2476                    msg.append(classNameId);
2477    
2478                    msg.append(", type=");
2479                    msg.append(type);
2480    
2481                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2482    
2483                    throw new NoSuchActivitySetException(msg.toString());
2484            }
2485    
2486            /**
2487             * Returns the last social activity set in the ordered set where groupId = &#63; and userId = &#63; and classNameId = &#63; and type = &#63;.
2488             *
2489             * @param groupId the group ID
2490             * @param userId the user ID
2491             * @param classNameId the class name ID
2492             * @param type the type
2493             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2494             * @return the last matching social activity set, or <code>null</code> if a matching social activity set could not be found
2495             */
2496            @Override
2497            public SocialActivitySet fetchByG_U_C_T_Last(long groupId, long userId,
2498                    long classNameId, int type,
2499                    OrderByComparator<SocialActivitySet> orderByComparator) {
2500                    int count = countByG_U_C_T(groupId, userId, classNameId, type);
2501    
2502                    if (count == 0) {
2503                            return null;
2504                    }
2505    
2506                    List<SocialActivitySet> list = findByG_U_C_T(groupId, userId,
2507                                    classNameId, type, count - 1, count, orderByComparator);
2508    
2509                    if (!list.isEmpty()) {
2510                            return list.get(0);
2511                    }
2512    
2513                    return null;
2514            }
2515    
2516            /**
2517             * Returns the social activity sets before and after the current social activity set in the ordered set where groupId = &#63; and userId = &#63; and classNameId = &#63; and type = &#63;.
2518             *
2519             * @param activitySetId the primary key of the current social activity set
2520             * @param groupId the group ID
2521             * @param userId the user ID
2522             * @param classNameId the class name ID
2523             * @param type the type
2524             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2525             * @return the previous, current, and next social activity set
2526             * @throws com.liferay.portlet.social.NoSuchActivitySetException if a social activity set with the primary key could not be found
2527             */
2528            @Override
2529            public SocialActivitySet[] findByG_U_C_T_PrevAndNext(long activitySetId,
2530                    long groupId, long userId, long classNameId, int type,
2531                    OrderByComparator<SocialActivitySet> orderByComparator)
2532                    throws NoSuchActivitySetException {
2533                    SocialActivitySet socialActivitySet = findByPrimaryKey(activitySetId);
2534    
2535                    Session session = null;
2536    
2537                    try {
2538                            session = openSession();
2539    
2540                            SocialActivitySet[] array = new SocialActivitySetImpl[3];
2541    
2542                            array[0] = getByG_U_C_T_PrevAndNext(session, socialActivitySet,
2543                                            groupId, userId, classNameId, type, orderByComparator, true);
2544    
2545                            array[1] = socialActivitySet;
2546    
2547                            array[2] = getByG_U_C_T_PrevAndNext(session, socialActivitySet,
2548                                            groupId, userId, classNameId, type, orderByComparator, false);
2549    
2550                            return array;
2551                    }
2552                    catch (Exception e) {
2553                            throw processException(e);
2554                    }
2555                    finally {
2556                            closeSession(session);
2557                    }
2558            }
2559    
2560            protected SocialActivitySet getByG_U_C_T_PrevAndNext(Session session,
2561                    SocialActivitySet socialActivitySet, long groupId, long userId,
2562                    long classNameId, int type,
2563                    OrderByComparator<SocialActivitySet> orderByComparator, boolean previous) {
2564                    StringBundler query = null;
2565    
2566                    if (orderByComparator != null) {
2567                            query = new StringBundler(6 +
2568                                            (orderByComparator.getOrderByFields().length * 6));
2569                    }
2570                    else {
2571                            query = new StringBundler(3);
2572                    }
2573    
2574                    query.append(_SQL_SELECT_SOCIALACTIVITYSET_WHERE);
2575    
2576                    query.append(_FINDER_COLUMN_G_U_C_T_GROUPID_2);
2577    
2578                    query.append(_FINDER_COLUMN_G_U_C_T_USERID_2);
2579    
2580                    query.append(_FINDER_COLUMN_G_U_C_T_CLASSNAMEID_2);
2581    
2582                    query.append(_FINDER_COLUMN_G_U_C_T_TYPE_2);
2583    
2584                    if (orderByComparator != null) {
2585                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2586    
2587                            if (orderByConditionFields.length > 0) {
2588                                    query.append(WHERE_AND);
2589                            }
2590    
2591                            for (int i = 0; i < orderByConditionFields.length; i++) {
2592                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2593                                    query.append(orderByConditionFields[i]);
2594    
2595                                    if ((i + 1) < orderByConditionFields.length) {
2596                                            if (orderByComparator.isAscending() ^ previous) {
2597                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2598                                            }
2599                                            else {
2600                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2601                                            }
2602                                    }
2603                                    else {
2604                                            if (orderByComparator.isAscending() ^ previous) {
2605                                                    query.append(WHERE_GREATER_THAN);
2606                                            }
2607                                            else {
2608                                                    query.append(WHERE_LESSER_THAN);
2609                                            }
2610                                    }
2611                            }
2612    
2613                            query.append(ORDER_BY_CLAUSE);
2614    
2615                            String[] orderByFields = orderByComparator.getOrderByFields();
2616    
2617                            for (int i = 0; i < orderByFields.length; i++) {
2618                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2619                                    query.append(orderByFields[i]);
2620    
2621                                    if ((i + 1) < orderByFields.length) {
2622                                            if (orderByComparator.isAscending() ^ previous) {
2623                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2624                                            }
2625                                            else {
2626                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2627                                            }
2628                                    }
2629                                    else {
2630                                            if (orderByComparator.isAscending() ^ previous) {
2631                                                    query.append(ORDER_BY_ASC);
2632                                            }
2633                                            else {
2634                                                    query.append(ORDER_BY_DESC);
2635                                            }
2636                                    }
2637                            }
2638                    }
2639                    else {
2640                            query.append(SocialActivitySetModelImpl.ORDER_BY_JPQL);
2641                    }
2642    
2643                    String sql = query.toString();
2644    
2645                    Query q = session.createQuery(sql);
2646    
2647                    q.setFirstResult(0);
2648                    q.setMaxResults(2);
2649    
2650                    QueryPos qPos = QueryPos.getInstance(q);
2651    
2652                    qPos.add(groupId);
2653    
2654                    qPos.add(userId);
2655    
2656                    qPos.add(classNameId);
2657    
2658                    qPos.add(type);
2659    
2660                    if (orderByComparator != null) {
2661                            Object[] values = orderByComparator.getOrderByConditionValues(socialActivitySet);
2662    
2663                            for (Object value : values) {
2664                                    qPos.add(value);
2665                            }
2666                    }
2667    
2668                    List<SocialActivitySet> list = q.list();
2669    
2670                    if (list.size() == 2) {
2671                            return list.get(1);
2672                    }
2673                    else {
2674                            return null;
2675                    }
2676            }
2677    
2678            /**
2679             * Removes all the social activity sets where groupId = &#63; and userId = &#63; and classNameId = &#63; and type = &#63; from the database.
2680             *
2681             * @param groupId the group ID
2682             * @param userId the user ID
2683             * @param classNameId the class name ID
2684             * @param type the type
2685             */
2686            @Override
2687            public void removeByG_U_C_T(long groupId, long userId, long classNameId,
2688                    int type) {
2689                    for (SocialActivitySet socialActivitySet : findByG_U_C_T(groupId,
2690                                    userId, classNameId, type, QueryUtil.ALL_POS,
2691                                    QueryUtil.ALL_POS, null)) {
2692                            remove(socialActivitySet);
2693                    }
2694            }
2695    
2696            /**
2697             * Returns the number of social activity sets where groupId = &#63; and userId = &#63; and classNameId = &#63; and type = &#63;.
2698             *
2699             * @param groupId the group ID
2700             * @param userId the user ID
2701             * @param classNameId the class name ID
2702             * @param type the type
2703             * @return the number of matching social activity sets
2704             */
2705            @Override
2706            public int countByG_U_C_T(long groupId, long userId, long classNameId,
2707                    int type) {
2708                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_U_C_T;
2709    
2710                    Object[] finderArgs = new Object[] { groupId, userId, classNameId, type };
2711    
2712                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2713                                    this);
2714    
2715                    if (count == null) {
2716                            StringBundler query = new StringBundler(5);
2717    
2718                            query.append(_SQL_COUNT_SOCIALACTIVITYSET_WHERE);
2719    
2720                            query.append(_FINDER_COLUMN_G_U_C_T_GROUPID_2);
2721    
2722                            query.append(_FINDER_COLUMN_G_U_C_T_USERID_2);
2723    
2724                            query.append(_FINDER_COLUMN_G_U_C_T_CLASSNAMEID_2);
2725    
2726                            query.append(_FINDER_COLUMN_G_U_C_T_TYPE_2);
2727    
2728                            String sql = query.toString();
2729    
2730                            Session session = null;
2731    
2732                            try {
2733                                    session = openSession();
2734    
2735                                    Query q = session.createQuery(sql);
2736    
2737                                    QueryPos qPos = QueryPos.getInstance(q);
2738    
2739                                    qPos.add(groupId);
2740    
2741                                    qPos.add(userId);
2742    
2743                                    qPos.add(classNameId);
2744    
2745                                    qPos.add(type);
2746    
2747                                    count = (Long)q.uniqueResult();
2748    
2749                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
2750                            }
2751                            catch (Exception e) {
2752                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2753    
2754                                    throw processException(e);
2755                            }
2756                            finally {
2757                                    closeSession(session);
2758                            }
2759                    }
2760    
2761                    return count.intValue();
2762            }
2763    
2764            private static final String _FINDER_COLUMN_G_U_C_T_GROUPID_2 = "socialActivitySet.groupId = ? AND ";
2765            private static final String _FINDER_COLUMN_G_U_C_T_USERID_2 = "socialActivitySet.userId = ? AND ";
2766            private static final String _FINDER_COLUMN_G_U_C_T_CLASSNAMEID_2 = "socialActivitySet.classNameId = ? AND ";
2767            private static final String _FINDER_COLUMN_G_U_C_T_TYPE_2 = "socialActivitySet.type = ?";
2768            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_U_C_C_T = new FinderPath(SocialActivitySetModelImpl.ENTITY_CACHE_ENABLED,
2769                            SocialActivitySetModelImpl.FINDER_CACHE_ENABLED,
2770                            SocialActivitySetImpl.class,
2771                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByU_C_C_T",
2772                            new String[] {
2773                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
2774                                    Integer.class.getName(),
2775                                    
2776                            Integer.class.getName(), Integer.class.getName(),
2777                                    OrderByComparator.class.getName()
2778                            });
2779            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_C_C_T =
2780                    new FinderPath(SocialActivitySetModelImpl.ENTITY_CACHE_ENABLED,
2781                            SocialActivitySetModelImpl.FINDER_CACHE_ENABLED,
2782                            SocialActivitySetImpl.class,
2783                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByU_C_C_T",
2784                            new String[] {
2785                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
2786                                    Integer.class.getName()
2787                            },
2788                            SocialActivitySetModelImpl.USERID_COLUMN_BITMASK |
2789                            SocialActivitySetModelImpl.CLASSNAMEID_COLUMN_BITMASK |
2790                            SocialActivitySetModelImpl.CLASSPK_COLUMN_BITMASK |
2791                            SocialActivitySetModelImpl.TYPE_COLUMN_BITMASK |
2792                            SocialActivitySetModelImpl.MODIFIEDDATE_COLUMN_BITMASK);
2793            public static final FinderPath FINDER_PATH_COUNT_BY_U_C_C_T = new FinderPath(SocialActivitySetModelImpl.ENTITY_CACHE_ENABLED,
2794                            SocialActivitySetModelImpl.FINDER_CACHE_ENABLED, Long.class,
2795                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_C_C_T",
2796                            new String[] {
2797                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
2798                                    Integer.class.getName()
2799                            });
2800    
2801            /**
2802             * Returns all the social activity sets where userId = &#63; and classNameId = &#63; and classPK = &#63; and type = &#63;.
2803             *
2804             * @param userId the user ID
2805             * @param classNameId the class name ID
2806             * @param classPK the class p k
2807             * @param type the type
2808             * @return the matching social activity sets
2809             */
2810            @Override
2811            public List<SocialActivitySet> findByU_C_C_T(long userId, long classNameId,
2812                    long classPK, int type) {
2813                    return findByU_C_C_T(userId, classNameId, classPK, type,
2814                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2815            }
2816    
2817            /**
2818             * Returns a range of all the social activity sets where userId = &#63; and classNameId = &#63; and classPK = &#63; and type = &#63;.
2819             *
2820             * <p>
2821             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.social.model.impl.SocialActivitySetModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2822             * </p>
2823             *
2824             * @param userId the user ID
2825             * @param classNameId the class name ID
2826             * @param classPK the class p k
2827             * @param type the type
2828             * @param start the lower bound of the range of social activity sets
2829             * @param end the upper bound of the range of social activity sets (not inclusive)
2830             * @return the range of matching social activity sets
2831             */
2832            @Override
2833            public List<SocialActivitySet> findByU_C_C_T(long userId, long classNameId,
2834                    long classPK, int type, int start, int end) {
2835                    return findByU_C_C_T(userId, classNameId, classPK, type, start, end,
2836                            null);
2837            }
2838    
2839            /**
2840             * Returns an ordered range of all the social activity sets where userId = &#63; and classNameId = &#63; and classPK = &#63; and type = &#63;.
2841             *
2842             * <p>
2843             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.social.model.impl.SocialActivitySetModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2844             * </p>
2845             *
2846             * @param userId the user ID
2847             * @param classNameId the class name ID
2848             * @param classPK the class p k
2849             * @param type the type
2850             * @param start the lower bound of the range of social activity sets
2851             * @param end the upper bound of the range of social activity sets (not inclusive)
2852             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2853             * @return the ordered range of matching social activity sets
2854             */
2855            @Override
2856            public List<SocialActivitySet> findByU_C_C_T(long userId, long classNameId,
2857                    long classPK, int type, int start, int end,
2858                    OrderByComparator<SocialActivitySet> orderByComparator) {
2859                    boolean pagination = true;
2860                    FinderPath finderPath = null;
2861                    Object[] finderArgs = null;
2862    
2863                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2864                                    (orderByComparator == null)) {
2865                            pagination = false;
2866                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_C_C_T;
2867                            finderArgs = new Object[] { userId, classNameId, classPK, type };
2868                    }
2869                    else {
2870                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U_C_C_T;
2871                            finderArgs = new Object[] {
2872                                            userId, classNameId, classPK, type,
2873                                            
2874                                            start, end, orderByComparator
2875                                    };
2876                    }
2877    
2878                    List<SocialActivitySet> list = (List<SocialActivitySet>)FinderCacheUtil.getResult(finderPath,
2879                                    finderArgs, this);
2880    
2881                    if ((list != null) && !list.isEmpty()) {
2882                            for (SocialActivitySet socialActivitySet : list) {
2883                                    if ((userId != socialActivitySet.getUserId()) ||
2884                                                    (classNameId != socialActivitySet.getClassNameId()) ||
2885                                                    (classPK != socialActivitySet.getClassPK()) ||
2886                                                    (type != socialActivitySet.getType())) {
2887                                            list = null;
2888    
2889                                            break;
2890                                    }
2891                            }
2892                    }
2893    
2894                    if (list == null) {
2895                            StringBundler query = null;
2896    
2897                            if (orderByComparator != null) {
2898                                    query = new StringBundler(6 +
2899                                                    (orderByComparator.getOrderByFields().length * 3));
2900                            }
2901                            else {
2902                                    query = new StringBundler(6);
2903                            }
2904    
2905                            query.append(_SQL_SELECT_SOCIALACTIVITYSET_WHERE);
2906    
2907                            query.append(_FINDER_COLUMN_U_C_C_T_USERID_2);
2908    
2909                            query.append(_FINDER_COLUMN_U_C_C_T_CLASSNAMEID_2);
2910    
2911                            query.append(_FINDER_COLUMN_U_C_C_T_CLASSPK_2);
2912    
2913                            query.append(_FINDER_COLUMN_U_C_C_T_TYPE_2);
2914    
2915                            if (orderByComparator != null) {
2916                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2917                                            orderByComparator);
2918                            }
2919                            else
2920                             if (pagination) {
2921                                    query.append(SocialActivitySetModelImpl.ORDER_BY_JPQL);
2922                            }
2923    
2924                            String sql = query.toString();
2925    
2926                            Session session = null;
2927    
2928                            try {
2929                                    session = openSession();
2930    
2931                                    Query q = session.createQuery(sql);
2932    
2933                                    QueryPos qPos = QueryPos.getInstance(q);
2934    
2935                                    qPos.add(userId);
2936    
2937                                    qPos.add(classNameId);
2938    
2939                                    qPos.add(classPK);
2940    
2941                                    qPos.add(type);
2942    
2943                                    if (!pagination) {
2944                                            list = (List<SocialActivitySet>)QueryUtil.list(q,
2945                                                            getDialect(), start, end, false);
2946    
2947                                            Collections.sort(list);
2948    
2949                                            list = Collections.unmodifiableList(list);
2950                                    }
2951                                    else {
2952                                            list = (List<SocialActivitySet>)QueryUtil.list(q,
2953                                                            getDialect(), start, end);
2954                                    }
2955    
2956                                    cacheResult(list);
2957    
2958                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
2959                            }
2960                            catch (Exception e) {
2961                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2962    
2963                                    throw processException(e);
2964                            }
2965                            finally {
2966                                    closeSession(session);
2967                            }
2968                    }
2969    
2970                    return list;
2971            }
2972    
2973            /**
2974             * Returns the first social activity set in the ordered set where userId = &#63; and classNameId = &#63; and classPK = &#63; and type = &#63;.
2975             *
2976             * @param userId the user ID
2977             * @param classNameId the class name ID
2978             * @param classPK the class p k
2979             * @param type the type
2980             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2981             * @return the first matching social activity set
2982             * @throws com.liferay.portlet.social.NoSuchActivitySetException if a matching social activity set could not be found
2983             */
2984            @Override
2985            public SocialActivitySet findByU_C_C_T_First(long userId, long classNameId,
2986                    long classPK, int type,
2987                    OrderByComparator<SocialActivitySet> orderByComparator)
2988                    throws NoSuchActivitySetException {
2989                    SocialActivitySet socialActivitySet = fetchByU_C_C_T_First(userId,
2990                                    classNameId, classPK, type, orderByComparator);
2991    
2992                    if (socialActivitySet != null) {
2993                            return socialActivitySet;
2994                    }
2995    
2996                    StringBundler msg = new StringBundler(10);
2997    
2998                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2999    
3000                    msg.append("userId=");
3001                    msg.append(userId);
3002    
3003                    msg.append(", classNameId=");
3004                    msg.append(classNameId);
3005    
3006                    msg.append(", classPK=");
3007                    msg.append(classPK);
3008    
3009                    msg.append(", type=");
3010                    msg.append(type);
3011    
3012                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3013    
3014                    throw new NoSuchActivitySetException(msg.toString());
3015            }
3016    
3017            /**
3018             * Returns the first social activity set in the ordered set where userId = &#63; and classNameId = &#63; and classPK = &#63; and type = &#63;.
3019             *
3020             * @param userId the user ID
3021             * @param classNameId the class name ID
3022             * @param classPK the class p k
3023             * @param type the type
3024             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3025             * @return the first matching social activity set, or <code>null</code> if a matching social activity set could not be found
3026             */
3027            @Override
3028            public SocialActivitySet fetchByU_C_C_T_First(long userId,
3029                    long classNameId, long classPK, int type,
3030                    OrderByComparator<SocialActivitySet> orderByComparator) {
3031                    List<SocialActivitySet> list = findByU_C_C_T(userId, classNameId,
3032                                    classPK, type, 0, 1, orderByComparator);
3033    
3034                    if (!list.isEmpty()) {
3035                            return list.get(0);
3036                    }
3037    
3038                    return null;
3039            }
3040    
3041            /**
3042             * Returns the last social activity set in the ordered set where userId = &#63; and classNameId = &#63; and classPK = &#63; and type = &#63;.
3043             *
3044             * @param userId the user ID
3045             * @param classNameId the class name ID
3046             * @param classPK the class p k
3047             * @param type the type
3048             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3049             * @return the last matching social activity set
3050             * @throws com.liferay.portlet.social.NoSuchActivitySetException if a matching social activity set could not be found
3051             */
3052            @Override
3053            public SocialActivitySet findByU_C_C_T_Last(long userId, long classNameId,
3054                    long classPK, int type,
3055                    OrderByComparator<SocialActivitySet> orderByComparator)
3056                    throws NoSuchActivitySetException {
3057                    SocialActivitySet socialActivitySet = fetchByU_C_C_T_Last(userId,
3058                                    classNameId, classPK, type, orderByComparator);
3059    
3060                    if (socialActivitySet != null) {
3061                            return socialActivitySet;
3062                    }
3063    
3064                    StringBundler msg = new StringBundler(10);
3065    
3066                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3067    
3068                    msg.append("userId=");
3069                    msg.append(userId);
3070    
3071                    msg.append(", classNameId=");
3072                    msg.append(classNameId);
3073    
3074                    msg.append(", classPK=");
3075                    msg.append(classPK);
3076    
3077                    msg.append(", type=");
3078                    msg.append(type);
3079    
3080                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3081    
3082                    throw new NoSuchActivitySetException(msg.toString());
3083            }
3084    
3085            /**
3086             * Returns the last social activity set in the ordered set where userId = &#63; and classNameId = &#63; and classPK = &#63; and type = &#63;.
3087             *
3088             * @param userId the user ID
3089             * @param classNameId the class name ID
3090             * @param classPK the class p k
3091             * @param type the type
3092             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3093             * @return the last matching social activity set, or <code>null</code> if a matching social activity set could not be found
3094             */
3095            @Override
3096            public SocialActivitySet fetchByU_C_C_T_Last(long userId, long classNameId,
3097                    long classPK, int type,
3098                    OrderByComparator<SocialActivitySet> orderByComparator) {
3099                    int count = countByU_C_C_T(userId, classNameId, classPK, type);
3100    
3101                    if (count == 0) {
3102                            return null;
3103                    }
3104    
3105                    List<SocialActivitySet> list = findByU_C_C_T(userId, classNameId,
3106                                    classPK, type, count - 1, count, orderByComparator);
3107    
3108                    if (!list.isEmpty()) {
3109                            return list.get(0);
3110                    }
3111    
3112                    return null;
3113            }
3114    
3115            /**
3116             * Returns the social activity sets before and after the current social activity set in the ordered set where userId = &#63; and classNameId = &#63; and classPK = &#63; and type = &#63;.
3117             *
3118             * @param activitySetId the primary key of the current social activity set
3119             * @param userId the user ID
3120             * @param classNameId the class name ID
3121             * @param classPK the class p k
3122             * @param type the type
3123             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3124             * @return the previous, current, and next social activity set
3125             * @throws com.liferay.portlet.social.NoSuchActivitySetException if a social activity set with the primary key could not be found
3126             */
3127            @Override
3128            public SocialActivitySet[] findByU_C_C_T_PrevAndNext(long activitySetId,
3129                    long userId, long classNameId, long classPK, int type,
3130                    OrderByComparator<SocialActivitySet> orderByComparator)
3131                    throws NoSuchActivitySetException {
3132                    SocialActivitySet socialActivitySet = findByPrimaryKey(activitySetId);
3133    
3134                    Session session = null;
3135    
3136                    try {
3137                            session = openSession();
3138    
3139                            SocialActivitySet[] array = new SocialActivitySetImpl[3];
3140    
3141                            array[0] = getByU_C_C_T_PrevAndNext(session, socialActivitySet,
3142                                            userId, classNameId, classPK, type, orderByComparator, true);
3143    
3144                            array[1] = socialActivitySet;
3145    
3146                            array[2] = getByU_C_C_T_PrevAndNext(session, socialActivitySet,
3147                                            userId, classNameId, classPK, type, orderByComparator, false);
3148    
3149                            return array;
3150                    }
3151                    catch (Exception e) {
3152                            throw processException(e);
3153                    }
3154                    finally {
3155                            closeSession(session);
3156                    }
3157            }
3158    
3159            protected SocialActivitySet getByU_C_C_T_PrevAndNext(Session session,
3160                    SocialActivitySet socialActivitySet, long userId, long classNameId,
3161                    long classPK, int type,
3162                    OrderByComparator<SocialActivitySet> orderByComparator, boolean previous) {
3163                    StringBundler query = null;
3164    
3165                    if (orderByComparator != null) {
3166                            query = new StringBundler(6 +
3167                                            (orderByComparator.getOrderByFields().length * 6));
3168                    }
3169                    else {
3170                            query = new StringBundler(3);
3171                    }
3172    
3173                    query.append(_SQL_SELECT_SOCIALACTIVITYSET_WHERE);
3174    
3175                    query.append(_FINDER_COLUMN_U_C_C_T_USERID_2);
3176    
3177                    query.append(_FINDER_COLUMN_U_C_C_T_CLASSNAMEID_2);
3178    
3179                    query.append(_FINDER_COLUMN_U_C_C_T_CLASSPK_2);
3180    
3181                    query.append(_FINDER_COLUMN_U_C_C_T_TYPE_2);
3182    
3183                    if (orderByComparator != null) {
3184                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3185    
3186                            if (orderByConditionFields.length > 0) {
3187                                    query.append(WHERE_AND);
3188                            }
3189    
3190                            for (int i = 0; i < orderByConditionFields.length; i++) {
3191                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3192                                    query.append(orderByConditionFields[i]);
3193    
3194                                    if ((i + 1) < orderByConditionFields.length) {
3195                                            if (orderByComparator.isAscending() ^ previous) {
3196                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3197                                            }
3198                                            else {
3199                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3200                                            }
3201                                    }
3202                                    else {
3203                                            if (orderByComparator.isAscending() ^ previous) {
3204                                                    query.append(WHERE_GREATER_THAN);
3205                                            }
3206                                            else {
3207                                                    query.append(WHERE_LESSER_THAN);
3208                                            }
3209                                    }
3210                            }
3211    
3212                            query.append(ORDER_BY_CLAUSE);
3213    
3214                            String[] orderByFields = orderByComparator.getOrderByFields();
3215    
3216                            for (int i = 0; i < orderByFields.length; i++) {
3217                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3218                                    query.append(orderByFields[i]);
3219    
3220                                    if ((i + 1) < orderByFields.length) {
3221                                            if (orderByComparator.isAscending() ^ previous) {
3222                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3223                                            }
3224                                            else {
3225                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3226                                            }
3227                                    }
3228                                    else {
3229                                            if (orderByComparator.isAscending() ^ previous) {
3230                                                    query.append(ORDER_BY_ASC);
3231                                            }
3232                                            else {
3233                                                    query.append(ORDER_BY_DESC);
3234                                            }
3235                                    }
3236                            }
3237                    }
3238                    else {
3239                            query.append(SocialActivitySetModelImpl.ORDER_BY_JPQL);
3240                    }
3241    
3242                    String sql = query.toString();
3243    
3244                    Query q = session.createQuery(sql);
3245    
3246                    q.setFirstResult(0);
3247                    q.setMaxResults(2);
3248    
3249                    QueryPos qPos = QueryPos.getInstance(q);
3250    
3251                    qPos.add(userId);
3252    
3253                    qPos.add(classNameId);
3254    
3255                    qPos.add(classPK);
3256    
3257                    qPos.add(type);
3258    
3259                    if (orderByComparator != null) {
3260                            Object[] values = orderByComparator.getOrderByConditionValues(socialActivitySet);
3261    
3262                            for (Object value : values) {
3263                                    qPos.add(value);
3264                            }
3265                    }
3266    
3267                    List<SocialActivitySet> list = q.list();
3268    
3269                    if (list.size() == 2) {
3270                            return list.get(1);
3271                    }
3272                    else {
3273                            return null;
3274                    }
3275            }
3276    
3277            /**
3278             * Removes all the social activity sets where userId = &#63; and classNameId = &#63; and classPK = &#63; and type = &#63; from the database.
3279             *
3280             * @param userId the user ID
3281             * @param classNameId the class name ID
3282             * @param classPK the class p k
3283             * @param type the type
3284             */
3285            @Override
3286            public void removeByU_C_C_T(long userId, long classNameId, long classPK,
3287                    int type) {
3288                    for (SocialActivitySet socialActivitySet : findByU_C_C_T(userId,
3289                                    classNameId, classPK, type, QueryUtil.ALL_POS,
3290                                    QueryUtil.ALL_POS, null)) {
3291                            remove(socialActivitySet);
3292                    }
3293            }
3294    
3295            /**
3296             * Returns the number of social activity sets where userId = &#63; and classNameId = &#63; and classPK = &#63; and type = &#63;.
3297             *
3298             * @param userId the user ID
3299             * @param classNameId the class name ID
3300             * @param classPK the class p k
3301             * @param type the type
3302             * @return the number of matching social activity sets
3303             */
3304            @Override
3305            public int countByU_C_C_T(long userId, long classNameId, long classPK,
3306                    int type) {
3307                    FinderPath finderPath = FINDER_PATH_COUNT_BY_U_C_C_T;
3308    
3309                    Object[] finderArgs = new Object[] { userId, classNameId, classPK, type };
3310    
3311                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3312                                    this);
3313    
3314                    if (count == null) {
3315                            StringBundler query = new StringBundler(5);
3316    
3317                            query.append(_SQL_COUNT_SOCIALACTIVITYSET_WHERE);
3318    
3319                            query.append(_FINDER_COLUMN_U_C_C_T_USERID_2);
3320    
3321                            query.append(_FINDER_COLUMN_U_C_C_T_CLASSNAMEID_2);
3322    
3323                            query.append(_FINDER_COLUMN_U_C_C_T_CLASSPK_2);
3324    
3325                            query.append(_FINDER_COLUMN_U_C_C_T_TYPE_2);
3326    
3327                            String sql = query.toString();
3328    
3329                            Session session = null;
3330    
3331                            try {
3332                                    session = openSession();
3333    
3334                                    Query q = session.createQuery(sql);
3335    
3336                                    QueryPos qPos = QueryPos.getInstance(q);
3337    
3338                                    qPos.add(userId);
3339    
3340                                    qPos.add(classNameId);
3341    
3342                                    qPos.add(classPK);
3343    
3344                                    qPos.add(type);
3345    
3346                                    count = (Long)q.uniqueResult();
3347    
3348                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
3349                            }
3350                            catch (Exception e) {
3351                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3352    
3353                                    throw processException(e);
3354                            }
3355                            finally {
3356                                    closeSession(session);
3357                            }
3358                    }
3359    
3360                    return count.intValue();
3361            }
3362    
3363            private static final String _FINDER_COLUMN_U_C_C_T_USERID_2 = "socialActivitySet.userId = ? AND ";
3364            private static final String _FINDER_COLUMN_U_C_C_T_CLASSNAMEID_2 = "socialActivitySet.classNameId = ? AND ";
3365            private static final String _FINDER_COLUMN_U_C_C_T_CLASSPK_2 = "socialActivitySet.classPK = ? AND ";
3366            private static final String _FINDER_COLUMN_U_C_C_T_TYPE_2 = "socialActivitySet.type = ?";
3367    
3368            public SocialActivitySetPersistenceImpl() {
3369                    setModelClass(SocialActivitySet.class);
3370            }
3371    
3372            /**
3373             * Caches the social activity set in the entity cache if it is enabled.
3374             *
3375             * @param socialActivitySet the social activity set
3376             */
3377            @Override
3378            public void cacheResult(SocialActivitySet socialActivitySet) {
3379                    EntityCacheUtil.putResult(SocialActivitySetModelImpl.ENTITY_CACHE_ENABLED,
3380                            SocialActivitySetImpl.class, socialActivitySet.getPrimaryKey(),
3381                            socialActivitySet);
3382    
3383                    socialActivitySet.resetOriginalValues();
3384            }
3385    
3386            /**
3387             * Caches the social activity sets in the entity cache if it is enabled.
3388             *
3389             * @param socialActivitySets the social activity sets
3390             */
3391            @Override
3392            public void cacheResult(List<SocialActivitySet> socialActivitySets) {
3393                    for (SocialActivitySet socialActivitySet : socialActivitySets) {
3394                            if (EntityCacheUtil.getResult(
3395                                                    SocialActivitySetModelImpl.ENTITY_CACHE_ENABLED,
3396                                                    SocialActivitySetImpl.class,
3397                                                    socialActivitySet.getPrimaryKey()) == null) {
3398                                    cacheResult(socialActivitySet);
3399                            }
3400                            else {
3401                                    socialActivitySet.resetOriginalValues();
3402                            }
3403                    }
3404            }
3405    
3406            /**
3407             * Clears the cache for all social activity sets.
3408             *
3409             * <p>
3410             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
3411             * </p>
3412             */
3413            @Override
3414            public void clearCache() {
3415                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
3416                            CacheRegistryUtil.clear(SocialActivitySetImpl.class.getName());
3417                    }
3418    
3419                    EntityCacheUtil.clearCache(SocialActivitySetImpl.class);
3420    
3421                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
3422                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
3423                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3424            }
3425    
3426            /**
3427             * Clears the cache for the social activity set.
3428             *
3429             * <p>
3430             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
3431             * </p>
3432             */
3433            @Override
3434            public void clearCache(SocialActivitySet socialActivitySet) {
3435                    EntityCacheUtil.removeResult(SocialActivitySetModelImpl.ENTITY_CACHE_ENABLED,
3436                            SocialActivitySetImpl.class, socialActivitySet.getPrimaryKey());
3437    
3438                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
3439                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3440            }
3441    
3442            @Override
3443            public void clearCache(List<SocialActivitySet> socialActivitySets) {
3444                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
3445                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3446    
3447                    for (SocialActivitySet socialActivitySet : socialActivitySets) {
3448                            EntityCacheUtil.removeResult(SocialActivitySetModelImpl.ENTITY_CACHE_ENABLED,
3449                                    SocialActivitySetImpl.class, socialActivitySet.getPrimaryKey());
3450                    }
3451            }
3452    
3453            /**
3454             * Creates a new social activity set with the primary key. Does not add the social activity set to the database.
3455             *
3456             * @param activitySetId the primary key for the new social activity set
3457             * @return the new social activity set
3458             */
3459            @Override
3460            public SocialActivitySet create(long activitySetId) {
3461                    SocialActivitySet socialActivitySet = new SocialActivitySetImpl();
3462    
3463                    socialActivitySet.setNew(true);
3464                    socialActivitySet.setPrimaryKey(activitySetId);
3465    
3466                    return socialActivitySet;
3467            }
3468    
3469            /**
3470             * Removes the social activity set with the primary key from the database. Also notifies the appropriate model listeners.
3471             *
3472             * @param activitySetId the primary key of the social activity set
3473             * @return the social activity set that was removed
3474             * @throws com.liferay.portlet.social.NoSuchActivitySetException if a social activity set with the primary key could not be found
3475             */
3476            @Override
3477            public SocialActivitySet remove(long activitySetId)
3478                    throws NoSuchActivitySetException {
3479                    return remove((Serializable)activitySetId);
3480            }
3481    
3482            /**
3483             * Removes the social activity set with the primary key from the database. Also notifies the appropriate model listeners.
3484             *
3485             * @param primaryKey the primary key of the social activity set
3486             * @return the social activity set that was removed
3487             * @throws com.liferay.portlet.social.NoSuchActivitySetException if a social activity set with the primary key could not be found
3488             */
3489            @Override
3490            public SocialActivitySet remove(Serializable primaryKey)
3491                    throws NoSuchActivitySetException {
3492                    Session session = null;
3493    
3494                    try {
3495                            session = openSession();
3496    
3497                            SocialActivitySet socialActivitySet = (SocialActivitySet)session.get(SocialActivitySetImpl.class,
3498                                            primaryKey);
3499    
3500                            if (socialActivitySet == null) {
3501                                    if (_log.isWarnEnabled()) {
3502                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
3503                                    }
3504    
3505                                    throw new NoSuchActivitySetException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
3506                                            primaryKey);
3507                            }
3508    
3509                            return remove(socialActivitySet);
3510                    }
3511                    catch (NoSuchActivitySetException nsee) {
3512                            throw nsee;
3513                    }
3514                    catch (Exception e) {
3515                            throw processException(e);
3516                    }
3517                    finally {
3518                            closeSession(session);
3519                    }
3520            }
3521    
3522            @Override
3523            protected SocialActivitySet removeImpl(SocialActivitySet socialActivitySet) {
3524                    socialActivitySet = toUnwrappedModel(socialActivitySet);
3525    
3526                    Session session = null;
3527    
3528                    try {
3529                            session = openSession();
3530    
3531                            if (!session.contains(socialActivitySet)) {
3532                                    socialActivitySet = (SocialActivitySet)session.get(SocialActivitySetImpl.class,
3533                                                    socialActivitySet.getPrimaryKeyObj());
3534                            }
3535    
3536                            if (socialActivitySet != null) {
3537                                    session.delete(socialActivitySet);
3538                            }
3539                    }
3540                    catch (Exception e) {
3541                            throw processException(e);
3542                    }
3543                    finally {
3544                            closeSession(session);
3545                    }
3546    
3547                    if (socialActivitySet != null) {
3548                            clearCache(socialActivitySet);
3549                    }
3550    
3551                    return socialActivitySet;
3552            }
3553    
3554            @Override
3555            public SocialActivitySet updateImpl(
3556                    com.liferay.portlet.social.model.SocialActivitySet socialActivitySet) {
3557                    socialActivitySet = toUnwrappedModel(socialActivitySet);
3558    
3559                    boolean isNew = socialActivitySet.isNew();
3560    
3561                    SocialActivitySetModelImpl socialActivitySetModelImpl = (SocialActivitySetModelImpl)socialActivitySet;
3562    
3563                    Session session = null;
3564    
3565                    try {
3566                            session = openSession();
3567    
3568                            if (socialActivitySet.isNew()) {
3569                                    session.save(socialActivitySet);
3570    
3571                                    socialActivitySet.setNew(false);
3572                            }
3573                            else {
3574                                    session.merge(socialActivitySet);
3575                            }
3576                    }
3577                    catch (Exception e) {
3578                            throw processException(e);
3579                    }
3580                    finally {
3581                            closeSession(session);
3582                    }
3583    
3584                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
3585    
3586                    if (isNew || !SocialActivitySetModelImpl.COLUMN_BITMASK_ENABLED) {
3587                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3588                    }
3589    
3590                    else {
3591                            if ((socialActivitySetModelImpl.getColumnBitmask() &
3592                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
3593                                    Object[] args = new Object[] {
3594                                                    socialActivitySetModelImpl.getOriginalGroupId()
3595                                            };
3596    
3597                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
3598                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
3599                                            args);
3600    
3601                                    args = new Object[] { socialActivitySetModelImpl.getGroupId() };
3602    
3603                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
3604                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
3605                                            args);
3606                            }
3607    
3608                            if ((socialActivitySetModelImpl.getColumnBitmask() &
3609                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID.getColumnBitmask()) != 0) {
3610                                    Object[] args = new Object[] {
3611                                                    socialActivitySetModelImpl.getOriginalUserId()
3612                                            };
3613    
3614                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
3615                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
3616                                            args);
3617    
3618                                    args = new Object[] { socialActivitySetModelImpl.getUserId() };
3619    
3620                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
3621                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
3622                                            args);
3623                            }
3624    
3625                            if ((socialActivitySetModelImpl.getColumnBitmask() &
3626                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_T.getColumnBitmask()) != 0) {
3627                                    Object[] args = new Object[] {
3628                                                    socialActivitySetModelImpl.getOriginalGroupId(),
3629                                                    socialActivitySetModelImpl.getOriginalUserId(),
3630                                                    socialActivitySetModelImpl.getOriginalType()
3631                                            };
3632    
3633                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_T, args);
3634                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_T,
3635                                            args);
3636    
3637                                    args = new Object[] {
3638                                                    socialActivitySetModelImpl.getGroupId(),
3639                                                    socialActivitySetModelImpl.getUserId(),
3640                                                    socialActivitySetModelImpl.getType()
3641                                            };
3642    
3643                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_T, args);
3644                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_T,
3645                                            args);
3646                            }
3647    
3648                            if ((socialActivitySetModelImpl.getColumnBitmask() &
3649                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_T.getColumnBitmask()) != 0) {
3650                                    Object[] args = new Object[] {
3651                                                    socialActivitySetModelImpl.getOriginalClassNameId(),
3652                                                    socialActivitySetModelImpl.getOriginalClassPK(),
3653                                                    socialActivitySetModelImpl.getOriginalType()
3654                                            };
3655    
3656                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C_T, args);
3657                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_T,
3658                                            args);
3659    
3660                                    args = new Object[] {
3661                                                    socialActivitySetModelImpl.getClassNameId(),
3662                                                    socialActivitySetModelImpl.getClassPK(),
3663                                                    socialActivitySetModelImpl.getType()
3664                                            };
3665    
3666                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C_T, args);
3667                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C_T,
3668                                            args);
3669                            }
3670    
3671                            if ((socialActivitySetModelImpl.getColumnBitmask() &
3672                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_C_T.getColumnBitmask()) != 0) {
3673                                    Object[] args = new Object[] {
3674                                                    socialActivitySetModelImpl.getOriginalGroupId(),
3675                                                    socialActivitySetModelImpl.getOriginalUserId(),
3676                                                    socialActivitySetModelImpl.getOriginalClassNameId(),
3677                                                    socialActivitySetModelImpl.getOriginalType()
3678                                            };
3679    
3680                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_C_T, args);
3681                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_C_T,
3682                                            args);
3683    
3684                                    args = new Object[] {
3685                                                    socialActivitySetModelImpl.getGroupId(),
3686                                                    socialActivitySetModelImpl.getUserId(),
3687                                                    socialActivitySetModelImpl.getClassNameId(),
3688                                                    socialActivitySetModelImpl.getType()
3689                                            };
3690    
3691                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_C_T, args);
3692                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_C_T,
3693                                            args);
3694                            }
3695    
3696                            if ((socialActivitySetModelImpl.getColumnBitmask() &
3697                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_C_C_T.getColumnBitmask()) != 0) {
3698                                    Object[] args = new Object[] {
3699                                                    socialActivitySetModelImpl.getOriginalUserId(),
3700                                                    socialActivitySetModelImpl.getOriginalClassNameId(),
3701                                                    socialActivitySetModelImpl.getOriginalClassPK(),
3702                                                    socialActivitySetModelImpl.getOriginalType()
3703                                            };
3704    
3705                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_C_C_T, args);
3706                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_C_C_T,
3707                                            args);
3708    
3709                                    args = new Object[] {
3710                                                    socialActivitySetModelImpl.getUserId(),
3711                                                    socialActivitySetModelImpl.getClassNameId(),
3712                                                    socialActivitySetModelImpl.getClassPK(),
3713                                                    socialActivitySetModelImpl.getType()
3714                                            };
3715    
3716                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_U_C_C_T, args);
3717                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U_C_C_T,
3718                                            args);
3719                            }
3720                    }
3721    
3722                    EntityCacheUtil.putResult(SocialActivitySetModelImpl.ENTITY_CACHE_ENABLED,
3723                            SocialActivitySetImpl.class, socialActivitySet.getPrimaryKey(),
3724                            socialActivitySet, false);
3725    
3726                    socialActivitySet.resetOriginalValues();
3727    
3728                    return socialActivitySet;
3729            }
3730    
3731            protected SocialActivitySet toUnwrappedModel(
3732                    SocialActivitySet socialActivitySet) {
3733                    if (socialActivitySet instanceof SocialActivitySetImpl) {
3734                            return socialActivitySet;
3735                    }
3736    
3737                    SocialActivitySetImpl socialActivitySetImpl = new SocialActivitySetImpl();
3738    
3739                    socialActivitySetImpl.setNew(socialActivitySet.isNew());
3740                    socialActivitySetImpl.setPrimaryKey(socialActivitySet.getPrimaryKey());
3741    
3742                    socialActivitySetImpl.setActivitySetId(socialActivitySet.getActivitySetId());
3743                    socialActivitySetImpl.setGroupId(socialActivitySet.getGroupId());
3744                    socialActivitySetImpl.setCompanyId(socialActivitySet.getCompanyId());
3745                    socialActivitySetImpl.setUserId(socialActivitySet.getUserId());
3746                    socialActivitySetImpl.setCreateDate(socialActivitySet.getCreateDate());
3747                    socialActivitySetImpl.setModifiedDate(socialActivitySet.getModifiedDate());
3748                    socialActivitySetImpl.setClassNameId(socialActivitySet.getClassNameId());
3749                    socialActivitySetImpl.setClassPK(socialActivitySet.getClassPK());
3750                    socialActivitySetImpl.setType(socialActivitySet.getType());
3751                    socialActivitySetImpl.setExtraData(socialActivitySet.getExtraData());
3752                    socialActivitySetImpl.setActivityCount(socialActivitySet.getActivityCount());
3753    
3754                    return socialActivitySetImpl;
3755            }
3756    
3757            /**
3758             * Returns the social activity set with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
3759             *
3760             * @param primaryKey the primary key of the social activity set
3761             * @return the social activity set
3762             * @throws com.liferay.portlet.social.NoSuchActivitySetException if a social activity set with the primary key could not be found
3763             */
3764            @Override
3765            public SocialActivitySet findByPrimaryKey(Serializable primaryKey)
3766                    throws NoSuchActivitySetException {
3767                    SocialActivitySet socialActivitySet = fetchByPrimaryKey(primaryKey);
3768    
3769                    if (socialActivitySet == null) {
3770                            if (_log.isWarnEnabled()) {
3771                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
3772                            }
3773    
3774                            throw new NoSuchActivitySetException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
3775                                    primaryKey);
3776                    }
3777    
3778                    return socialActivitySet;
3779            }
3780    
3781            /**
3782             * Returns the social activity set with the primary key or throws a {@link com.liferay.portlet.social.NoSuchActivitySetException} if it could not be found.
3783             *
3784             * @param activitySetId the primary key of the social activity set
3785             * @return the social activity set
3786             * @throws com.liferay.portlet.social.NoSuchActivitySetException if a social activity set with the primary key could not be found
3787             */
3788            @Override
3789            public SocialActivitySet findByPrimaryKey(long activitySetId)
3790                    throws NoSuchActivitySetException {
3791                    return findByPrimaryKey((Serializable)activitySetId);
3792            }
3793    
3794            /**
3795             * Returns the social activity set with the primary key or returns <code>null</code> if it could not be found.
3796             *
3797             * @param primaryKey the primary key of the social activity set
3798             * @return the social activity set, or <code>null</code> if a social activity set with the primary key could not be found
3799             */
3800            @Override
3801            public SocialActivitySet fetchByPrimaryKey(Serializable primaryKey) {
3802                    SocialActivitySet socialActivitySet = (SocialActivitySet)EntityCacheUtil.getResult(SocialActivitySetModelImpl.ENTITY_CACHE_ENABLED,
3803                                    SocialActivitySetImpl.class, primaryKey);
3804    
3805                    if (socialActivitySet == _nullSocialActivitySet) {
3806                            return null;
3807                    }
3808    
3809                    if (socialActivitySet == null) {
3810                            Session session = null;
3811    
3812                            try {
3813                                    session = openSession();
3814    
3815                                    socialActivitySet = (SocialActivitySet)session.get(SocialActivitySetImpl.class,
3816                                                    primaryKey);
3817    
3818                                    if (socialActivitySet != null) {
3819                                            cacheResult(socialActivitySet);
3820                                    }
3821                                    else {
3822                                            EntityCacheUtil.putResult(SocialActivitySetModelImpl.ENTITY_CACHE_ENABLED,
3823                                                    SocialActivitySetImpl.class, primaryKey,
3824                                                    _nullSocialActivitySet);
3825                                    }
3826                            }
3827                            catch (Exception e) {
3828                                    EntityCacheUtil.removeResult(SocialActivitySetModelImpl.ENTITY_CACHE_ENABLED,
3829                                            SocialActivitySetImpl.class, primaryKey);
3830    
3831                                    throw processException(e);
3832                            }
3833                            finally {
3834                                    closeSession(session);
3835                            }
3836                    }
3837    
3838                    return socialActivitySet;
3839            }
3840    
3841            /**
3842             * Returns the social activity set with the primary key or returns <code>null</code> if it could not be found.
3843             *
3844             * @param activitySetId the primary key of the social activity set
3845             * @return the social activity set, or <code>null</code> if a social activity set with the primary key could not be found
3846             */
3847            @Override
3848            public SocialActivitySet fetchByPrimaryKey(long activitySetId) {
3849                    return fetchByPrimaryKey((Serializable)activitySetId);
3850            }
3851    
3852            @Override
3853            public Map<Serializable, SocialActivitySet> fetchByPrimaryKeys(
3854                    Set<Serializable> primaryKeys) {
3855                    if (primaryKeys.isEmpty()) {
3856                            return Collections.emptyMap();
3857                    }
3858    
3859                    Map<Serializable, SocialActivitySet> map = new HashMap<Serializable, SocialActivitySet>();
3860    
3861                    if (primaryKeys.size() == 1) {
3862                            Iterator<Serializable> iterator = primaryKeys.iterator();
3863    
3864                            Serializable primaryKey = iterator.next();
3865    
3866                            SocialActivitySet socialActivitySet = fetchByPrimaryKey(primaryKey);
3867    
3868                            if (socialActivitySet != null) {
3869                                    map.put(primaryKey, socialActivitySet);
3870                            }
3871    
3872                            return map;
3873                    }
3874    
3875                    Set<Serializable> uncachedPrimaryKeys = null;
3876    
3877                    for (Serializable primaryKey : primaryKeys) {
3878                            SocialActivitySet socialActivitySet = (SocialActivitySet)EntityCacheUtil.getResult(SocialActivitySetModelImpl.ENTITY_CACHE_ENABLED,
3879                                            SocialActivitySetImpl.class, primaryKey);
3880    
3881                            if (socialActivitySet == null) {
3882                                    if (uncachedPrimaryKeys == null) {
3883                                            uncachedPrimaryKeys = new HashSet<Serializable>();
3884                                    }
3885    
3886                                    uncachedPrimaryKeys.add(primaryKey);
3887                            }
3888                            else {
3889                                    map.put(primaryKey, socialActivitySet);
3890                            }
3891                    }
3892    
3893                    if (uncachedPrimaryKeys == null) {
3894                            return map;
3895                    }
3896    
3897                    StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
3898                                    1);
3899    
3900                    query.append(_SQL_SELECT_SOCIALACTIVITYSET_WHERE_PKS_IN);
3901    
3902                    for (Serializable primaryKey : uncachedPrimaryKeys) {
3903                            query.append(String.valueOf(primaryKey));
3904    
3905                            query.append(StringPool.COMMA);
3906                    }
3907    
3908                    query.setIndex(query.index() - 1);
3909    
3910                    query.append(StringPool.CLOSE_PARENTHESIS);
3911    
3912                    String sql = query.toString();
3913    
3914                    Session session = null;
3915    
3916                    try {
3917                            session = openSession();
3918    
3919                            Query q = session.createQuery(sql);
3920    
3921                            for (SocialActivitySet socialActivitySet : (List<SocialActivitySet>)q.list()) {
3922                                    map.put(socialActivitySet.getPrimaryKeyObj(), socialActivitySet);
3923    
3924                                    cacheResult(socialActivitySet);
3925    
3926                                    uncachedPrimaryKeys.remove(socialActivitySet.getPrimaryKeyObj());
3927                            }
3928    
3929                            for (Serializable primaryKey : uncachedPrimaryKeys) {
3930                                    EntityCacheUtil.putResult(SocialActivitySetModelImpl.ENTITY_CACHE_ENABLED,
3931                                            SocialActivitySetImpl.class, primaryKey,
3932                                            _nullSocialActivitySet);
3933                            }
3934                    }
3935                    catch (Exception e) {
3936                            throw processException(e);
3937                    }
3938                    finally {
3939                            closeSession(session);
3940                    }
3941    
3942                    return map;
3943            }
3944    
3945            /**
3946             * Returns all the social activity sets.
3947             *
3948             * @return the social activity sets
3949             */
3950            @Override
3951            public List<SocialActivitySet> findAll() {
3952                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3953            }
3954    
3955            /**
3956             * Returns a range of all the social activity sets.
3957             *
3958             * <p>
3959             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.social.model.impl.SocialActivitySetModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3960             * </p>
3961             *
3962             * @param start the lower bound of the range of social activity sets
3963             * @param end the upper bound of the range of social activity sets (not inclusive)
3964             * @return the range of social activity sets
3965             */
3966            @Override
3967            public List<SocialActivitySet> findAll(int start, int end) {
3968                    return findAll(start, end, null);
3969            }
3970    
3971            /**
3972             * Returns an ordered range of all the social activity sets.
3973             *
3974             * <p>
3975             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.social.model.impl.SocialActivitySetModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3976             * </p>
3977             *
3978             * @param start the lower bound of the range of social activity sets
3979             * @param end the upper bound of the range of social activity sets (not inclusive)
3980             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3981             * @return the ordered range of social activity sets
3982             */
3983            @Override
3984            public List<SocialActivitySet> findAll(int start, int end,
3985                    OrderByComparator<SocialActivitySet> orderByComparator) {
3986                    boolean pagination = true;
3987                    FinderPath finderPath = null;
3988                    Object[] finderArgs = null;
3989    
3990                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3991                                    (orderByComparator == null)) {
3992                            pagination = false;
3993                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
3994                            finderArgs = FINDER_ARGS_EMPTY;
3995                    }
3996                    else {
3997                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
3998                            finderArgs = new Object[] { start, end, orderByComparator };
3999                    }
4000    
4001                    List<SocialActivitySet> list = (List<SocialActivitySet>)FinderCacheUtil.getResult(finderPath,
4002                                    finderArgs, this);
4003    
4004                    if (list == null) {
4005                            StringBundler query = null;
4006                            String sql = null;
4007    
4008                            if (orderByComparator != null) {
4009                                    query = new StringBundler(2 +
4010                                                    (orderByComparator.getOrderByFields().length * 3));
4011    
4012                                    query.append(_SQL_SELECT_SOCIALACTIVITYSET);
4013    
4014                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4015                                            orderByComparator);
4016    
4017                                    sql = query.toString();
4018                            }
4019                            else {
4020                                    sql = _SQL_SELECT_SOCIALACTIVITYSET;
4021    
4022                                    if (pagination) {
4023                                            sql = sql.concat(SocialActivitySetModelImpl.ORDER_BY_JPQL);
4024                                    }
4025                            }
4026    
4027                            Session session = null;
4028    
4029                            try {
4030                                    session = openSession();
4031    
4032                                    Query q = session.createQuery(sql);
4033    
4034                                    if (!pagination) {
4035                                            list = (List<SocialActivitySet>)QueryUtil.list(q,
4036                                                            getDialect(), start, end, false);
4037    
4038                                            Collections.sort(list);
4039    
4040                                            list = Collections.unmodifiableList(list);
4041                                    }
4042                                    else {
4043                                            list = (List<SocialActivitySet>)QueryUtil.list(q,
4044                                                            getDialect(), start, end);
4045                                    }
4046    
4047                                    cacheResult(list);
4048    
4049                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
4050                            }
4051                            catch (Exception e) {
4052                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4053    
4054                                    throw processException(e);
4055                            }
4056                            finally {
4057                                    closeSession(session);
4058                            }
4059                    }
4060    
4061                    return list;
4062            }
4063    
4064            /**
4065             * Removes all the social activity sets from the database.
4066             *
4067             */
4068            @Override
4069            public void removeAll() {
4070                    for (SocialActivitySet socialActivitySet : findAll()) {
4071                            remove(socialActivitySet);
4072                    }
4073            }
4074    
4075            /**
4076             * Returns the number of social activity sets.
4077             *
4078             * @return the number of social activity sets
4079             */
4080            @Override
4081            public int countAll() {
4082                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
4083                                    FINDER_ARGS_EMPTY, this);
4084    
4085                    if (count == null) {
4086                            Session session = null;
4087    
4088                            try {
4089                                    session = openSession();
4090    
4091                                    Query q = session.createQuery(_SQL_COUNT_SOCIALACTIVITYSET);
4092    
4093                                    count = (Long)q.uniqueResult();
4094    
4095                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
4096                                            FINDER_ARGS_EMPTY, count);
4097                            }
4098                            catch (Exception e) {
4099                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
4100                                            FINDER_ARGS_EMPTY);
4101    
4102                                    throw processException(e);
4103                            }
4104                            finally {
4105                                    closeSession(session);
4106                            }
4107                    }
4108    
4109                    return count.intValue();
4110            }
4111    
4112            @Override
4113            protected Set<String> getBadColumnNames() {
4114                    return _badColumnNames;
4115            }
4116    
4117            /**
4118             * Initializes the social activity set persistence.
4119             */
4120            public void afterPropertiesSet() {
4121            }
4122    
4123            public void destroy() {
4124                    EntityCacheUtil.removeCache(SocialActivitySetImpl.class.getName());
4125                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
4126                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
4127                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4128            }
4129    
4130            private static final String _SQL_SELECT_SOCIALACTIVITYSET = "SELECT socialActivitySet FROM SocialActivitySet socialActivitySet";
4131            private static final String _SQL_SELECT_SOCIALACTIVITYSET_WHERE_PKS_IN = "SELECT socialActivitySet FROM SocialActivitySet socialActivitySet WHERE activitySetId IN (";
4132            private static final String _SQL_SELECT_SOCIALACTIVITYSET_WHERE = "SELECT socialActivitySet FROM SocialActivitySet socialActivitySet WHERE ";
4133            private static final String _SQL_COUNT_SOCIALACTIVITYSET = "SELECT COUNT(socialActivitySet) FROM SocialActivitySet socialActivitySet";
4134            private static final String _SQL_COUNT_SOCIALACTIVITYSET_WHERE = "SELECT COUNT(socialActivitySet) FROM SocialActivitySet socialActivitySet WHERE ";
4135            private static final String _ORDER_BY_ENTITY_ALIAS = "socialActivitySet.";
4136            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No SocialActivitySet exists with the primary key ";
4137            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No SocialActivitySet exists with the key {";
4138            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
4139            private static final Log _log = LogFactoryUtil.getLog(SocialActivitySetPersistenceImpl.class);
4140            private static final Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
4141                                    "type"
4142                            });
4143            private static final SocialActivitySet _nullSocialActivitySet = new SocialActivitySetImpl() {
4144                            @Override
4145                            public Object clone() {
4146                                    return this;
4147                            }
4148    
4149                            @Override
4150                            public CacheModel<SocialActivitySet> toCacheModel() {
4151                                    return _nullSocialActivitySetCacheModel;
4152                            }
4153                    };
4154    
4155            private static final CacheModel<SocialActivitySet> _nullSocialActivitySetCacheModel =
4156                    new CacheModel<SocialActivitySet>() {
4157                            @Override
4158                            public SocialActivitySet toEntityModel() {
4159                                    return _nullSocialActivitySet;
4160                            }
4161                    };
4162    }