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