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