001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.social.service.persistence;
016    
017    import com.liferay.portal.NoSuchModelException;
018    import com.liferay.portal.kernel.bean.BeanReference;
019    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022    import com.liferay.portal.kernel.dao.orm.FinderPath;
023    import com.liferay.portal.kernel.dao.orm.Query;
024    import com.liferay.portal.kernel.dao.orm.QueryPos;
025    import com.liferay.portal.kernel.dao.orm.QueryUtil;
026    import com.liferay.portal.kernel.dao.orm.Session;
027    import com.liferay.portal.kernel.exception.SystemException;
028    import com.liferay.portal.kernel.log.Log;
029    import com.liferay.portal.kernel.log.LogFactoryUtil;
030    import com.liferay.portal.kernel.util.GetterUtil;
031    import com.liferay.portal.kernel.util.InstanceFactory;
032    import com.liferay.portal.kernel.util.OrderByComparator;
033    import com.liferay.portal.kernel.util.StringBundler;
034    import com.liferay.portal.kernel.util.StringPool;
035    import com.liferay.portal.kernel.util.StringUtil;
036    import com.liferay.portal.model.CacheModel;
037    import com.liferay.portal.model.ModelListener;
038    import com.liferay.portal.service.persistence.BatchSessionUtil;
039    import com.liferay.portal.service.persistence.GroupPersistence;
040    import com.liferay.portal.service.persistence.LayoutPersistence;
041    import com.liferay.portal.service.persistence.ResourcePersistence;
042    import com.liferay.portal.service.persistence.UserPersistence;
043    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
044    
045    import com.liferay.portlet.asset.service.persistence.AssetEntryPersistence;
046    import com.liferay.portlet.social.NoSuchActivityException;
047    import com.liferay.portlet.social.model.SocialActivity;
048    import com.liferay.portlet.social.model.impl.SocialActivityImpl;
049    import com.liferay.portlet.social.model.impl.SocialActivityModelImpl;
050    
051    import java.io.Serializable;
052    
053    import java.util.ArrayList;
054    import java.util.Collections;
055    import java.util.List;
056    
057    /**
058     * The persistence implementation for the social activity service.
059     *
060     * <p>
061     * Caching information and settings can be found in <code>portal.properties</code>
062     * </p>
063     *
064     * @author Brian Wing Shun Chan
065     * @see SocialActivityPersistence
066     * @see SocialActivityUtil
067     * @generated
068     */
069    public class SocialActivityPersistenceImpl extends BasePersistenceImpl<SocialActivity>
070            implements SocialActivityPersistence {
071            /*
072             * NOTE FOR DEVELOPERS:
073             *
074             * Never modify or reference this class directly. Always use {@link SocialActivityUtil} to access the social activity persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
075             */
076            public static final String FINDER_CLASS_NAME_ENTITY = SocialActivityImpl.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_BY_GROUPID = new FinderPath(SocialActivityModelImpl.ENTITY_CACHE_ENABLED,
082                            SocialActivityModelImpl.FINDER_CACHE_ENABLED,
083                            SocialActivityImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
084                            "findByGroupId",
085                            new String[] {
086                                    Long.class.getName(),
087                                    
088                            "java.lang.Integer", "java.lang.Integer",
089                                    "com.liferay.portal.kernel.util.OrderByComparator"
090                            });
091            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
092                    new FinderPath(SocialActivityModelImpl.ENTITY_CACHE_ENABLED,
093                            SocialActivityModelImpl.FINDER_CACHE_ENABLED,
094                            SocialActivityImpl.class,
095                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
096                            new String[] { Long.class.getName() },
097                            SocialActivityModelImpl.GROUPID_COLUMN_BITMASK);
098            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(SocialActivityModelImpl.ENTITY_CACHE_ENABLED,
099                            SocialActivityModelImpl.FINDER_CACHE_ENABLED, Long.class,
100                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
101                            new String[] { Long.class.getName() });
102            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
103                    new FinderPath(SocialActivityModelImpl.ENTITY_CACHE_ENABLED,
104                            SocialActivityModelImpl.FINDER_CACHE_ENABLED,
105                            SocialActivityImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
106                            "findByCompanyId",
107                            new String[] {
108                                    Long.class.getName(),
109                                    
110                            "java.lang.Integer", "java.lang.Integer",
111                                    "com.liferay.portal.kernel.util.OrderByComparator"
112                            });
113            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
114                    new FinderPath(SocialActivityModelImpl.ENTITY_CACHE_ENABLED,
115                            SocialActivityModelImpl.FINDER_CACHE_ENABLED,
116                            SocialActivityImpl.class,
117                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
118                            new String[] { Long.class.getName() },
119                            SocialActivityModelImpl.COMPANYID_COLUMN_BITMASK);
120            public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(SocialActivityModelImpl.ENTITY_CACHE_ENABLED,
121                            SocialActivityModelImpl.FINDER_CACHE_ENABLED, Long.class,
122                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
123                            new String[] { Long.class.getName() });
124            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID = new FinderPath(SocialActivityModelImpl.ENTITY_CACHE_ENABLED,
125                            SocialActivityModelImpl.FINDER_CACHE_ENABLED,
126                            SocialActivityImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
127                            "findByUserId",
128                            new String[] {
129                                    Long.class.getName(),
130                                    
131                            "java.lang.Integer", "java.lang.Integer",
132                                    "com.liferay.portal.kernel.util.OrderByComparator"
133                            });
134            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID =
135                    new FinderPath(SocialActivityModelImpl.ENTITY_CACHE_ENABLED,
136                            SocialActivityModelImpl.FINDER_CACHE_ENABLED,
137                            SocialActivityImpl.class,
138                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUserId",
139                            new String[] { Long.class.getName() },
140                            SocialActivityModelImpl.USERID_COLUMN_BITMASK);
141            public static final FinderPath FINDER_PATH_COUNT_BY_USERID = new FinderPath(SocialActivityModelImpl.ENTITY_CACHE_ENABLED,
142                            SocialActivityModelImpl.FINDER_CACHE_ENABLED, Long.class,
143                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUserId",
144                            new String[] { Long.class.getName() });
145            public static final FinderPath FINDER_PATH_FETCH_BY_MIRRORACTIVITYID = new FinderPath(SocialActivityModelImpl.ENTITY_CACHE_ENABLED,
146                            SocialActivityModelImpl.FINDER_CACHE_ENABLED,
147                            SocialActivityImpl.class, FINDER_CLASS_NAME_ENTITY,
148                            "fetchByMirrorActivityId", new String[] { Long.class.getName() },
149                            SocialActivityModelImpl.MIRRORACTIVITYID_COLUMN_BITMASK);
150            public static final FinderPath FINDER_PATH_COUNT_BY_MIRRORACTIVITYID = new FinderPath(SocialActivityModelImpl.ENTITY_CACHE_ENABLED,
151                            SocialActivityModelImpl.FINDER_CACHE_ENABLED, Long.class,
152                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
153                            "countByMirrorActivityId", new String[] { Long.class.getName() });
154            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_CLASSNAMEID =
155                    new FinderPath(SocialActivityModelImpl.ENTITY_CACHE_ENABLED,
156                            SocialActivityModelImpl.FINDER_CACHE_ENABLED,
157                            SocialActivityImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
158                            "findByClassNameId",
159                            new String[] {
160                                    Long.class.getName(),
161                                    
162                            "java.lang.Integer", "java.lang.Integer",
163                                    "com.liferay.portal.kernel.util.OrderByComparator"
164                            });
165            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CLASSNAMEID =
166                    new FinderPath(SocialActivityModelImpl.ENTITY_CACHE_ENABLED,
167                            SocialActivityModelImpl.FINDER_CACHE_ENABLED,
168                            SocialActivityImpl.class,
169                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByClassNameId",
170                            new String[] { Long.class.getName() },
171                            SocialActivityModelImpl.CLASSNAMEID_COLUMN_BITMASK);
172            public static final FinderPath FINDER_PATH_COUNT_BY_CLASSNAMEID = new FinderPath(SocialActivityModelImpl.ENTITY_CACHE_ENABLED,
173                            SocialActivityModelImpl.FINDER_CACHE_ENABLED, Long.class,
174                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByClassNameId",
175                            new String[] { Long.class.getName() });
176            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_RECEIVERUSERID =
177                    new FinderPath(SocialActivityModelImpl.ENTITY_CACHE_ENABLED,
178                            SocialActivityModelImpl.FINDER_CACHE_ENABLED,
179                            SocialActivityImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
180                            "findByReceiverUserId",
181                            new String[] {
182                                    Long.class.getName(),
183                                    
184                            "java.lang.Integer", "java.lang.Integer",
185                                    "com.liferay.portal.kernel.util.OrderByComparator"
186                            });
187            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RECEIVERUSERID =
188                    new FinderPath(SocialActivityModelImpl.ENTITY_CACHE_ENABLED,
189                            SocialActivityModelImpl.FINDER_CACHE_ENABLED,
190                            SocialActivityImpl.class,
191                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByReceiverUserId",
192                            new String[] { Long.class.getName() },
193                            SocialActivityModelImpl.RECEIVERUSERID_COLUMN_BITMASK);
194            public static final FinderPath FINDER_PATH_COUNT_BY_RECEIVERUSERID = new FinderPath(SocialActivityModelImpl.ENTITY_CACHE_ENABLED,
195                            SocialActivityModelImpl.FINDER_CACHE_ENABLED, Long.class,
196                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByReceiverUserId",
197                            new String[] { Long.class.getName() });
198            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C = new FinderPath(SocialActivityModelImpl.ENTITY_CACHE_ENABLED,
199                            SocialActivityModelImpl.FINDER_CACHE_ENABLED,
200                            SocialActivityImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
201                            "findByC_C",
202                            new String[] {
203                                    Long.class.getName(), Long.class.getName(),
204                                    
205                            "java.lang.Integer", "java.lang.Integer",
206                                    "com.liferay.portal.kernel.util.OrderByComparator"
207                            });
208            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C = new FinderPath(SocialActivityModelImpl.ENTITY_CACHE_ENABLED,
209                            SocialActivityModelImpl.FINDER_CACHE_ENABLED,
210                            SocialActivityImpl.class,
211                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_C",
212                            new String[] { Long.class.getName(), Long.class.getName() },
213                            SocialActivityModelImpl.CLASSNAMEID_COLUMN_BITMASK |
214                            SocialActivityModelImpl.CLASSPK_COLUMN_BITMASK);
215            public static final FinderPath FINDER_PATH_COUNT_BY_C_C = new FinderPath(SocialActivityModelImpl.ENTITY_CACHE_ENABLED,
216                            SocialActivityModelImpl.FINDER_CACHE_ENABLED, Long.class,
217                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C",
218                            new String[] { Long.class.getName(), Long.class.getName() });
219            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_M_C_C = new FinderPath(SocialActivityModelImpl.ENTITY_CACHE_ENABLED,
220                            SocialActivityModelImpl.FINDER_CACHE_ENABLED,
221                            SocialActivityImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
222                            "findByM_C_C",
223                            new String[] {
224                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
225                                    
226                            "java.lang.Integer", "java.lang.Integer",
227                                    "com.liferay.portal.kernel.util.OrderByComparator"
228                            });
229            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_M_C_C = new FinderPath(SocialActivityModelImpl.ENTITY_CACHE_ENABLED,
230                            SocialActivityModelImpl.FINDER_CACHE_ENABLED,
231                            SocialActivityImpl.class,
232                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByM_C_C",
233                            new String[] {
234                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
235                            },
236                            SocialActivityModelImpl.MIRRORACTIVITYID_COLUMN_BITMASK |
237                            SocialActivityModelImpl.CLASSNAMEID_COLUMN_BITMASK |
238                            SocialActivityModelImpl.CLASSPK_COLUMN_BITMASK);
239            public static final FinderPath FINDER_PATH_COUNT_BY_M_C_C = new FinderPath(SocialActivityModelImpl.ENTITY_CACHE_ENABLED,
240                            SocialActivityModelImpl.FINDER_CACHE_ENABLED, Long.class,
241                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByM_C_C",
242                            new String[] {
243                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
244                            });
245            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_C_C_T_R =
246                    new FinderPath(SocialActivityModelImpl.ENTITY_CACHE_ENABLED,
247                            SocialActivityModelImpl.FINDER_CACHE_ENABLED,
248                            SocialActivityImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
249                            "findByG_U_C_C_T_R",
250                            new String[] {
251                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
252                                    Long.class.getName(), Integer.class.getName(),
253                                    Long.class.getName(),
254                                    
255                            "java.lang.Integer", "java.lang.Integer",
256                                    "com.liferay.portal.kernel.util.OrderByComparator"
257                            });
258            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_C_C_T_R =
259                    new FinderPath(SocialActivityModelImpl.ENTITY_CACHE_ENABLED,
260                            SocialActivityModelImpl.FINDER_CACHE_ENABLED,
261                            SocialActivityImpl.class,
262                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U_C_C_T_R",
263                            new String[] {
264                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
265                                    Long.class.getName(), Integer.class.getName(),
266                                    Long.class.getName()
267                            },
268                            SocialActivityModelImpl.GROUPID_COLUMN_BITMASK |
269                            SocialActivityModelImpl.USERID_COLUMN_BITMASK |
270                            SocialActivityModelImpl.CLASSNAMEID_COLUMN_BITMASK |
271                            SocialActivityModelImpl.CLASSPK_COLUMN_BITMASK |
272                            SocialActivityModelImpl.TYPE_COLUMN_BITMASK |
273                            SocialActivityModelImpl.RECEIVERUSERID_COLUMN_BITMASK);
274            public static final FinderPath FINDER_PATH_COUNT_BY_G_U_C_C_T_R = new FinderPath(SocialActivityModelImpl.ENTITY_CACHE_ENABLED,
275                            SocialActivityModelImpl.FINDER_CACHE_ENABLED, Long.class,
276                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U_C_C_T_R",
277                            new String[] {
278                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
279                                    Long.class.getName(), Integer.class.getName(),
280                                    Long.class.getName()
281                            });
282            public static final FinderPath FINDER_PATH_FETCH_BY_G_U_CD_C_C_T_R = new FinderPath(SocialActivityModelImpl.ENTITY_CACHE_ENABLED,
283                            SocialActivityModelImpl.FINDER_CACHE_ENABLED,
284                            SocialActivityImpl.class, FINDER_CLASS_NAME_ENTITY,
285                            "fetchByG_U_CD_C_C_T_R",
286                            new String[] {
287                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
288                                    Long.class.getName(), Long.class.getName(),
289                                    Integer.class.getName(), Long.class.getName()
290                            },
291                            SocialActivityModelImpl.GROUPID_COLUMN_BITMASK |
292                            SocialActivityModelImpl.USERID_COLUMN_BITMASK |
293                            SocialActivityModelImpl.CREATEDATE_COLUMN_BITMASK |
294                            SocialActivityModelImpl.CLASSNAMEID_COLUMN_BITMASK |
295                            SocialActivityModelImpl.CLASSPK_COLUMN_BITMASK |
296                            SocialActivityModelImpl.TYPE_COLUMN_BITMASK |
297                            SocialActivityModelImpl.RECEIVERUSERID_COLUMN_BITMASK);
298            public static final FinderPath FINDER_PATH_COUNT_BY_G_U_CD_C_C_T_R = new FinderPath(SocialActivityModelImpl.ENTITY_CACHE_ENABLED,
299                            SocialActivityModelImpl.FINDER_CACHE_ENABLED, Long.class,
300                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U_CD_C_C_T_R",
301                            new String[] {
302                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
303                                    Long.class.getName(), Long.class.getName(),
304                                    Integer.class.getName(), Long.class.getName()
305                            });
306            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(SocialActivityModelImpl.ENTITY_CACHE_ENABLED,
307                            SocialActivityModelImpl.FINDER_CACHE_ENABLED,
308                            SocialActivityImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
309                            "findAll", new String[0]);
310            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(SocialActivityModelImpl.ENTITY_CACHE_ENABLED,
311                            SocialActivityModelImpl.FINDER_CACHE_ENABLED,
312                            SocialActivityImpl.class,
313                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
314            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(SocialActivityModelImpl.ENTITY_CACHE_ENABLED,
315                            SocialActivityModelImpl.FINDER_CACHE_ENABLED, Long.class,
316                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
317    
318            /**
319             * Caches the social activity in the entity cache if it is enabled.
320             *
321             * @param socialActivity the social activity
322             */
323            public void cacheResult(SocialActivity socialActivity) {
324                    EntityCacheUtil.putResult(SocialActivityModelImpl.ENTITY_CACHE_ENABLED,
325                            SocialActivityImpl.class, socialActivity.getPrimaryKey(),
326                            socialActivity);
327    
328                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_MIRRORACTIVITYID,
329                            new Object[] { Long.valueOf(socialActivity.getMirrorActivityId()) },
330                            socialActivity);
331    
332                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_U_CD_C_C_T_R,
333                            new Object[] {
334                                    Long.valueOf(socialActivity.getGroupId()),
335                                    Long.valueOf(socialActivity.getUserId()),
336                                    Long.valueOf(socialActivity.getCreateDate()),
337                                    Long.valueOf(socialActivity.getClassNameId()),
338                                    Long.valueOf(socialActivity.getClassPK()),
339                                    Integer.valueOf(socialActivity.getType()),
340                                    Long.valueOf(socialActivity.getReceiverUserId())
341                            }, socialActivity);
342    
343                    socialActivity.resetOriginalValues();
344            }
345    
346            /**
347             * Caches the social activities in the entity cache if it is enabled.
348             *
349             * @param socialActivities the social activities
350             */
351            public void cacheResult(List<SocialActivity> socialActivities) {
352                    for (SocialActivity socialActivity : socialActivities) {
353                            if (EntityCacheUtil.getResult(
354                                                    SocialActivityModelImpl.ENTITY_CACHE_ENABLED,
355                                                    SocialActivityImpl.class, socialActivity.getPrimaryKey()) == null) {
356                                    cacheResult(socialActivity);
357                            }
358                            else {
359                                    socialActivity.resetOriginalValues();
360                            }
361                    }
362            }
363    
364            /**
365             * Clears the cache for all social activities.
366             *
367             * <p>
368             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
369             * </p>
370             */
371            @Override
372            public void clearCache() {
373                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
374                            CacheRegistryUtil.clear(SocialActivityImpl.class.getName());
375                    }
376    
377                    EntityCacheUtil.clearCache(SocialActivityImpl.class.getName());
378    
379                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
380                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
381                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
382            }
383    
384            /**
385             * Clears the cache for the social activity.
386             *
387             * <p>
388             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
389             * </p>
390             */
391            @Override
392            public void clearCache(SocialActivity socialActivity) {
393                    EntityCacheUtil.removeResult(SocialActivityModelImpl.ENTITY_CACHE_ENABLED,
394                            SocialActivityImpl.class, socialActivity.getPrimaryKey());
395    
396                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
397                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
398    
399                    clearUniqueFindersCache(socialActivity);
400            }
401    
402            @Override
403            public void clearCache(List<SocialActivity> socialActivities) {
404                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
405                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
406    
407                    for (SocialActivity socialActivity : socialActivities) {
408                            EntityCacheUtil.removeResult(SocialActivityModelImpl.ENTITY_CACHE_ENABLED,
409                                    SocialActivityImpl.class, socialActivity.getPrimaryKey());
410    
411                            clearUniqueFindersCache(socialActivity);
412                    }
413            }
414    
415            protected void clearUniqueFindersCache(SocialActivity socialActivity) {
416                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_MIRRORACTIVITYID,
417                            new Object[] { Long.valueOf(socialActivity.getMirrorActivityId()) });
418    
419                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_U_CD_C_C_T_R,
420                            new Object[] {
421                                    Long.valueOf(socialActivity.getGroupId()),
422                                    Long.valueOf(socialActivity.getUserId()),
423                                    Long.valueOf(socialActivity.getCreateDate()),
424                                    Long.valueOf(socialActivity.getClassNameId()),
425                                    Long.valueOf(socialActivity.getClassPK()),
426                                    Integer.valueOf(socialActivity.getType()),
427                                    Long.valueOf(socialActivity.getReceiverUserId())
428                            });
429            }
430    
431            /**
432             * Creates a new social activity with the primary key. Does not add the social activity to the database.
433             *
434             * @param activityId the primary key for the new social activity
435             * @return the new social activity
436             */
437            public SocialActivity create(long activityId) {
438                    SocialActivity socialActivity = new SocialActivityImpl();
439    
440                    socialActivity.setNew(true);
441                    socialActivity.setPrimaryKey(activityId);
442    
443                    return socialActivity;
444            }
445    
446            /**
447             * Removes the social activity with the primary key from the database. Also notifies the appropriate model listeners.
448             *
449             * @param activityId the primary key of the social activity
450             * @return the social activity that was removed
451             * @throws com.liferay.portlet.social.NoSuchActivityException if a social activity with the primary key could not be found
452             * @throws SystemException if a system exception occurred
453             */
454            public SocialActivity remove(long activityId)
455                    throws NoSuchActivityException, SystemException {
456                    return remove(Long.valueOf(activityId));
457            }
458    
459            /**
460             * Removes the social activity with the primary key from the database. Also notifies the appropriate model listeners.
461             *
462             * @param primaryKey the primary key of the social activity
463             * @return the social activity that was removed
464             * @throws com.liferay.portlet.social.NoSuchActivityException if a social activity with the primary key could not be found
465             * @throws SystemException if a system exception occurred
466             */
467            @Override
468            public SocialActivity remove(Serializable primaryKey)
469                    throws NoSuchActivityException, SystemException {
470                    Session session = null;
471    
472                    try {
473                            session = openSession();
474    
475                            SocialActivity socialActivity = (SocialActivity)session.get(SocialActivityImpl.class,
476                                            primaryKey);
477    
478                            if (socialActivity == null) {
479                                    if (_log.isWarnEnabled()) {
480                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
481                                    }
482    
483                                    throw new NoSuchActivityException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
484                                            primaryKey);
485                            }
486    
487                            return remove(socialActivity);
488                    }
489                    catch (NoSuchActivityException nsee) {
490                            throw nsee;
491                    }
492                    catch (Exception e) {
493                            throw processException(e);
494                    }
495                    finally {
496                            closeSession(session);
497                    }
498            }
499    
500            @Override
501            protected SocialActivity removeImpl(SocialActivity socialActivity)
502                    throws SystemException {
503                    socialActivity = toUnwrappedModel(socialActivity);
504    
505                    Session session = null;
506    
507                    try {
508                            session = openSession();
509    
510                            BatchSessionUtil.delete(session, socialActivity);
511                    }
512                    catch (Exception e) {
513                            throw processException(e);
514                    }
515                    finally {
516                            closeSession(session);
517                    }
518    
519                    clearCache(socialActivity);
520    
521                    return socialActivity;
522            }
523    
524            @Override
525            public SocialActivity updateImpl(
526                    com.liferay.portlet.social.model.SocialActivity socialActivity,
527                    boolean merge) throws SystemException {
528                    socialActivity = toUnwrappedModel(socialActivity);
529    
530                    boolean isNew = socialActivity.isNew();
531    
532                    SocialActivityModelImpl socialActivityModelImpl = (SocialActivityModelImpl)socialActivity;
533    
534                    Session session = null;
535    
536                    try {
537                            session = openSession();
538    
539                            BatchSessionUtil.update(session, socialActivity, merge);
540    
541                            socialActivity.setNew(false);
542                    }
543                    catch (Exception e) {
544                            throw processException(e);
545                    }
546                    finally {
547                            closeSession(session);
548                    }
549    
550                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
551    
552                    if (isNew || !SocialActivityModelImpl.COLUMN_BITMASK_ENABLED) {
553                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
554                    }
555                    else {
556                            if ((socialActivityModelImpl.getColumnBitmask() &
557                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
558                                    Object[] args = new Object[] {
559                                                    Long.valueOf(socialActivityModelImpl.getOriginalGroupId())
560                                            };
561    
562                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
563                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
564                                            args);
565    
566                                    args = new Object[] {
567                                                    Long.valueOf(socialActivityModelImpl.getGroupId())
568                                            };
569    
570                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
571                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
572                                            args);
573                            }
574    
575                            if ((socialActivityModelImpl.getColumnBitmask() &
576                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
577                                    Object[] args = new Object[] {
578                                                    Long.valueOf(socialActivityModelImpl.getOriginalCompanyId())
579                                            };
580    
581                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
582                                            args);
583                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
584                                            args);
585    
586                                    args = new Object[] {
587                                                    Long.valueOf(socialActivityModelImpl.getCompanyId())
588                                            };
589    
590                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
591                                            args);
592                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
593                                            args);
594                            }
595    
596                            if ((socialActivityModelImpl.getColumnBitmask() &
597                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID.getColumnBitmask()) != 0) {
598                                    Object[] args = new Object[] {
599                                                    Long.valueOf(socialActivityModelImpl.getOriginalUserId())
600                                            };
601    
602                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
603                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
604                                            args);
605    
606                                    args = new Object[] {
607                                                    Long.valueOf(socialActivityModelImpl.getUserId())
608                                            };
609    
610                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
611                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
612                                            args);
613                            }
614    
615                            if ((socialActivityModelImpl.getColumnBitmask() &
616                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CLASSNAMEID.getColumnBitmask()) != 0) {
617                                    Object[] args = new Object[] {
618                                                    Long.valueOf(socialActivityModelImpl.getOriginalClassNameId())
619                                            };
620    
621                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_CLASSNAMEID,
622                                            args);
623                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CLASSNAMEID,
624                                            args);
625    
626                                    args = new Object[] {
627                                                    Long.valueOf(socialActivityModelImpl.getClassNameId())
628                                            };
629    
630                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_CLASSNAMEID,
631                                            args);
632                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CLASSNAMEID,
633                                            args);
634                            }
635    
636                            if ((socialActivityModelImpl.getColumnBitmask() &
637                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RECEIVERUSERID.getColumnBitmask()) != 0) {
638                                    Object[] args = new Object[] {
639                                                    Long.valueOf(socialActivityModelImpl.getOriginalReceiverUserId())
640                                            };
641    
642                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RECEIVERUSERID,
643                                            args);
644                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RECEIVERUSERID,
645                                            args);
646    
647                                    args = new Object[] {
648                                                    Long.valueOf(socialActivityModelImpl.getReceiverUserId())
649                                            };
650    
651                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RECEIVERUSERID,
652                                            args);
653                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RECEIVERUSERID,
654                                            args);
655                            }
656    
657                            if ((socialActivityModelImpl.getColumnBitmask() &
658                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C.getColumnBitmask()) != 0) {
659                                    Object[] args = new Object[] {
660                                                    Long.valueOf(socialActivityModelImpl.getOriginalClassNameId()),
661                                                    Long.valueOf(socialActivityModelImpl.getOriginalClassPK())
662                                            };
663    
664                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
665                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C,
666                                            args);
667    
668                                    args = new Object[] {
669                                                    Long.valueOf(socialActivityModelImpl.getClassNameId()),
670                                                    Long.valueOf(socialActivityModelImpl.getClassPK())
671                                            };
672    
673                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
674                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C,
675                                            args);
676                            }
677    
678                            if ((socialActivityModelImpl.getColumnBitmask() &
679                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_M_C_C.getColumnBitmask()) != 0) {
680                                    Object[] args = new Object[] {
681                                                    Long.valueOf(socialActivityModelImpl.getOriginalMirrorActivityId()),
682                                                    Long.valueOf(socialActivityModelImpl.getOriginalClassNameId()),
683                                                    Long.valueOf(socialActivityModelImpl.getOriginalClassPK())
684                                            };
685    
686                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_M_C_C, args);
687                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_M_C_C,
688                                            args);
689    
690                                    args = new Object[] {
691                                                    Long.valueOf(socialActivityModelImpl.getMirrorActivityId()),
692                                                    Long.valueOf(socialActivityModelImpl.getClassNameId()),
693                                                    Long.valueOf(socialActivityModelImpl.getClassPK())
694                                            };
695    
696                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_M_C_C, args);
697                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_M_C_C,
698                                            args);
699                            }
700    
701                            if ((socialActivityModelImpl.getColumnBitmask() &
702                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_C_C_T_R.getColumnBitmask()) != 0) {
703                                    Object[] args = new Object[] {
704                                                    Long.valueOf(socialActivityModelImpl.getOriginalGroupId()),
705                                                    Long.valueOf(socialActivityModelImpl.getOriginalUserId()),
706                                                    Long.valueOf(socialActivityModelImpl.getOriginalClassNameId()),
707                                                    Long.valueOf(socialActivityModelImpl.getOriginalClassPK()),
708                                                    Integer.valueOf(socialActivityModelImpl.getOriginalType()),
709                                                    Long.valueOf(socialActivityModelImpl.getOriginalReceiverUserId())
710                                            };
711    
712                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_C_C_T_R,
713                                            args);
714                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_C_C_T_R,
715                                            args);
716    
717                                    args = new Object[] {
718                                                    Long.valueOf(socialActivityModelImpl.getGroupId()),
719                                                    Long.valueOf(socialActivityModelImpl.getUserId()),
720                                                    Long.valueOf(socialActivityModelImpl.getClassNameId()),
721                                                    Long.valueOf(socialActivityModelImpl.getClassPK()),
722                                                    Integer.valueOf(socialActivityModelImpl.getType()),
723                                                    Long.valueOf(socialActivityModelImpl.getReceiverUserId())
724                                            };
725    
726                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_C_C_T_R,
727                                            args);
728                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_C_C_T_R,
729                                            args);
730                            }
731                    }
732    
733                    EntityCacheUtil.putResult(SocialActivityModelImpl.ENTITY_CACHE_ENABLED,
734                            SocialActivityImpl.class, socialActivity.getPrimaryKey(),
735                            socialActivity);
736    
737                    if (isNew) {
738                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_MIRRORACTIVITYID,
739                                    new Object[] { Long.valueOf(
740                                                    socialActivity.getMirrorActivityId()) }, socialActivity);
741    
742                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_U_CD_C_C_T_R,
743                                    new Object[] {
744                                            Long.valueOf(socialActivity.getGroupId()),
745                                            Long.valueOf(socialActivity.getUserId()),
746                                            Long.valueOf(socialActivity.getCreateDate()),
747                                            Long.valueOf(socialActivity.getClassNameId()),
748                                            Long.valueOf(socialActivity.getClassPK()),
749                                            Integer.valueOf(socialActivity.getType()),
750                                            Long.valueOf(socialActivity.getReceiverUserId())
751                                    }, socialActivity);
752                    }
753                    else {
754                            if ((socialActivityModelImpl.getColumnBitmask() &
755                                            FINDER_PATH_FETCH_BY_MIRRORACTIVITYID.getColumnBitmask()) != 0) {
756                                    Object[] args = new Object[] {
757                                                    Long.valueOf(socialActivityModelImpl.getOriginalMirrorActivityId())
758                                            };
759    
760                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_MIRRORACTIVITYID,
761                                            args);
762                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_MIRRORACTIVITYID,
763                                            args);
764    
765                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_MIRRORACTIVITYID,
766                                            new Object[] {
767                                                    Long.valueOf(socialActivity.getMirrorActivityId())
768                                            }, socialActivity);
769                            }
770    
771                            if ((socialActivityModelImpl.getColumnBitmask() &
772                                            FINDER_PATH_FETCH_BY_G_U_CD_C_C_T_R.getColumnBitmask()) != 0) {
773                                    Object[] args = new Object[] {
774                                                    Long.valueOf(socialActivityModelImpl.getOriginalGroupId()),
775                                                    Long.valueOf(socialActivityModelImpl.getOriginalUserId()),
776                                                    Long.valueOf(socialActivityModelImpl.getOriginalCreateDate()),
777                                                    Long.valueOf(socialActivityModelImpl.getOriginalClassNameId()),
778                                                    Long.valueOf(socialActivityModelImpl.getOriginalClassPK()),
779                                                    Integer.valueOf(socialActivityModelImpl.getOriginalType()),
780                                                    Long.valueOf(socialActivityModelImpl.getOriginalReceiverUserId())
781                                            };
782    
783                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_CD_C_C_T_R,
784                                            args);
785                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_U_CD_C_C_T_R,
786                                            args);
787    
788                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_U_CD_C_C_T_R,
789                                            new Object[] {
790                                                    Long.valueOf(socialActivity.getGroupId()),
791                                                    Long.valueOf(socialActivity.getUserId()),
792                                                    Long.valueOf(socialActivity.getCreateDate()),
793                                                    Long.valueOf(socialActivity.getClassNameId()),
794                                                    Long.valueOf(socialActivity.getClassPK()),
795                                                    Integer.valueOf(socialActivity.getType()),
796                                                    Long.valueOf(socialActivity.getReceiverUserId())
797                                            }, socialActivity);
798                            }
799                    }
800    
801                    return socialActivity;
802            }
803    
804            protected SocialActivity toUnwrappedModel(SocialActivity socialActivity) {
805                    if (socialActivity instanceof SocialActivityImpl) {
806                            return socialActivity;
807                    }
808    
809                    SocialActivityImpl socialActivityImpl = new SocialActivityImpl();
810    
811                    socialActivityImpl.setNew(socialActivity.isNew());
812                    socialActivityImpl.setPrimaryKey(socialActivity.getPrimaryKey());
813    
814                    socialActivityImpl.setActivityId(socialActivity.getActivityId());
815                    socialActivityImpl.setGroupId(socialActivity.getGroupId());
816                    socialActivityImpl.setCompanyId(socialActivity.getCompanyId());
817                    socialActivityImpl.setUserId(socialActivity.getUserId());
818                    socialActivityImpl.setCreateDate(socialActivity.getCreateDate());
819                    socialActivityImpl.setMirrorActivityId(socialActivity.getMirrorActivityId());
820                    socialActivityImpl.setClassNameId(socialActivity.getClassNameId());
821                    socialActivityImpl.setClassPK(socialActivity.getClassPK());
822                    socialActivityImpl.setType(socialActivity.getType());
823                    socialActivityImpl.setExtraData(socialActivity.getExtraData());
824                    socialActivityImpl.setReceiverUserId(socialActivity.getReceiverUserId());
825    
826                    return socialActivityImpl;
827            }
828    
829            /**
830             * Returns the social activity with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
831             *
832             * @param primaryKey the primary key of the social activity
833             * @return the social activity
834             * @throws com.liferay.portal.NoSuchModelException if a social activity with the primary key could not be found
835             * @throws SystemException if a system exception occurred
836             */
837            @Override
838            public SocialActivity findByPrimaryKey(Serializable primaryKey)
839                    throws NoSuchModelException, SystemException {
840                    return findByPrimaryKey(((Long)primaryKey).longValue());
841            }
842    
843            /**
844             * Returns the social activity with the primary key or throws a {@link com.liferay.portlet.social.NoSuchActivityException} if it could not be found.
845             *
846             * @param activityId the primary key of the social activity
847             * @return the social activity
848             * @throws com.liferay.portlet.social.NoSuchActivityException if a social activity with the primary key could not be found
849             * @throws SystemException if a system exception occurred
850             */
851            public SocialActivity findByPrimaryKey(long activityId)
852                    throws NoSuchActivityException, SystemException {
853                    SocialActivity socialActivity = fetchByPrimaryKey(activityId);
854    
855                    if (socialActivity == null) {
856                            if (_log.isWarnEnabled()) {
857                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + activityId);
858                            }
859    
860                            throw new NoSuchActivityException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
861                                    activityId);
862                    }
863    
864                    return socialActivity;
865            }
866    
867            /**
868             * Returns the social activity with the primary key or returns <code>null</code> if it could not be found.
869             *
870             * @param primaryKey the primary key of the social activity
871             * @return the social activity, or <code>null</code> if a social activity with the primary key could not be found
872             * @throws SystemException if a system exception occurred
873             */
874            @Override
875            public SocialActivity fetchByPrimaryKey(Serializable primaryKey)
876                    throws SystemException {
877                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
878            }
879    
880            /**
881             * Returns the social activity with the primary key or returns <code>null</code> if it could not be found.
882             *
883             * @param activityId the primary key of the social activity
884             * @return the social activity, or <code>null</code> if a social activity with the primary key could not be found
885             * @throws SystemException if a system exception occurred
886             */
887            public SocialActivity fetchByPrimaryKey(long activityId)
888                    throws SystemException {
889                    SocialActivity socialActivity = (SocialActivity)EntityCacheUtil.getResult(SocialActivityModelImpl.ENTITY_CACHE_ENABLED,
890                                    SocialActivityImpl.class, activityId);
891    
892                    if (socialActivity == _nullSocialActivity) {
893                            return null;
894                    }
895    
896                    if (socialActivity == null) {
897                            Session session = null;
898    
899                            boolean hasException = false;
900    
901                            try {
902                                    session = openSession();
903    
904                                    socialActivity = (SocialActivity)session.get(SocialActivityImpl.class,
905                                                    Long.valueOf(activityId));
906                            }
907                            catch (Exception e) {
908                                    hasException = true;
909    
910                                    throw processException(e);
911                            }
912                            finally {
913                                    if (socialActivity != null) {
914                                            cacheResult(socialActivity);
915                                    }
916                                    else if (!hasException) {
917                                            EntityCacheUtil.putResult(SocialActivityModelImpl.ENTITY_CACHE_ENABLED,
918                                                    SocialActivityImpl.class, activityId,
919                                                    _nullSocialActivity);
920                                    }
921    
922                                    closeSession(session);
923                            }
924                    }
925    
926                    return socialActivity;
927            }
928    
929            /**
930             * Returns all the social activities where groupId = &#63;.
931             *
932             * @param groupId the group ID
933             * @return the matching social activities
934             * @throws SystemException if a system exception occurred
935             */
936            public List<SocialActivity> findByGroupId(long groupId)
937                    throws SystemException {
938                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
939            }
940    
941            /**
942             * Returns a range of all the social activities where groupId = &#63;.
943             *
944             * <p>
945             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
946             * </p>
947             *
948             * @param groupId the group ID
949             * @param start the lower bound of the range of social activities
950             * @param end the upper bound of the range of social activities (not inclusive)
951             * @return the range of matching social activities
952             * @throws SystemException if a system exception occurred
953             */
954            public List<SocialActivity> findByGroupId(long groupId, int start, int end)
955                    throws SystemException {
956                    return findByGroupId(groupId, start, end, null);
957            }
958    
959            /**
960             * Returns an ordered range of all the social activities where groupId = &#63;.
961             *
962             * <p>
963             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
964             * </p>
965             *
966             * @param groupId the group ID
967             * @param start the lower bound of the range of social activities
968             * @param end the upper bound of the range of social activities (not inclusive)
969             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
970             * @return the ordered range of matching social activities
971             * @throws SystemException if a system exception occurred
972             */
973            public List<SocialActivity> findByGroupId(long groupId, int start, int end,
974                    OrderByComparator orderByComparator) throws SystemException {
975                    FinderPath finderPath = null;
976                    Object[] finderArgs = null;
977    
978                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
979                                    (orderByComparator == null)) {
980                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
981                            finderArgs = new Object[] { groupId };
982                    }
983                    else {
984                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
985                            finderArgs = new Object[] { groupId, start, end, orderByComparator };
986                    }
987    
988                    List<SocialActivity> list = (List<SocialActivity>)FinderCacheUtil.getResult(finderPath,
989                                    finderArgs, this);
990    
991                    if ((list != null) && !list.isEmpty()) {
992                            for (SocialActivity socialActivity : list) {
993                                    if ((groupId != socialActivity.getGroupId())) {
994                                            list = null;
995    
996                                            break;
997                                    }
998                            }
999                    }
1000    
1001                    if (list == null) {
1002                            StringBundler query = null;
1003    
1004                            if (orderByComparator != null) {
1005                                    query = new StringBundler(3 +
1006                                                    (orderByComparator.getOrderByFields().length * 3));
1007                            }
1008                            else {
1009                                    query = new StringBundler(3);
1010                            }
1011    
1012                            query.append(_SQL_SELECT_SOCIALACTIVITY_WHERE);
1013    
1014                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1015    
1016                            if (orderByComparator != null) {
1017                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1018                                            orderByComparator);
1019                            }
1020    
1021                            else {
1022                                    query.append(SocialActivityModelImpl.ORDER_BY_JPQL);
1023                            }
1024    
1025                            String sql = query.toString();
1026    
1027                            Session session = null;
1028    
1029                            try {
1030                                    session = openSession();
1031    
1032                                    Query q = session.createQuery(sql);
1033    
1034                                    QueryPos qPos = QueryPos.getInstance(q);
1035    
1036                                    qPos.add(groupId);
1037    
1038                                    list = (List<SocialActivity>)QueryUtil.list(q, getDialect(),
1039                                                    start, end);
1040                            }
1041                            catch (Exception e) {
1042                                    throw processException(e);
1043                            }
1044                            finally {
1045                                    if (list == null) {
1046                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1047                                    }
1048                                    else {
1049                                            cacheResult(list);
1050    
1051                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1052                                    }
1053    
1054                                    closeSession(session);
1055                            }
1056                    }
1057    
1058                    return list;
1059            }
1060    
1061            /**
1062             * Returns the first social activity in the ordered set where groupId = &#63;.
1063             *
1064             * <p>
1065             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1066             * </p>
1067             *
1068             * @param groupId the group ID
1069             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1070             * @return the first matching social activity
1071             * @throws com.liferay.portlet.social.NoSuchActivityException if a matching social activity could not be found
1072             * @throws SystemException if a system exception occurred
1073             */
1074            public SocialActivity findByGroupId_First(long groupId,
1075                    OrderByComparator orderByComparator)
1076                    throws NoSuchActivityException, SystemException {
1077                    List<SocialActivity> list = findByGroupId(groupId, 0, 1,
1078                                    orderByComparator);
1079    
1080                    if (list.isEmpty()) {
1081                            StringBundler msg = new StringBundler(4);
1082    
1083                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1084    
1085                            msg.append("groupId=");
1086                            msg.append(groupId);
1087    
1088                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1089    
1090                            throw new NoSuchActivityException(msg.toString());
1091                    }
1092                    else {
1093                            return list.get(0);
1094                    }
1095            }
1096    
1097            /**
1098             * Returns the last social activity in the ordered set where groupId = &#63;.
1099             *
1100             * <p>
1101             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1102             * </p>
1103             *
1104             * @param groupId the group ID
1105             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1106             * @return the last matching social activity
1107             * @throws com.liferay.portlet.social.NoSuchActivityException if a matching social activity could not be found
1108             * @throws SystemException if a system exception occurred
1109             */
1110            public SocialActivity findByGroupId_Last(long groupId,
1111                    OrderByComparator orderByComparator)
1112                    throws NoSuchActivityException, SystemException {
1113                    int count = countByGroupId(groupId);
1114    
1115                    List<SocialActivity> list = findByGroupId(groupId, count - 1, count,
1116                                    orderByComparator);
1117    
1118                    if (list.isEmpty()) {
1119                            StringBundler msg = new StringBundler(4);
1120    
1121                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1122    
1123                            msg.append("groupId=");
1124                            msg.append(groupId);
1125    
1126                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1127    
1128                            throw new NoSuchActivityException(msg.toString());
1129                    }
1130                    else {
1131                            return list.get(0);
1132                    }
1133            }
1134    
1135            /**
1136             * Returns the social activities before and after the current social activity in the ordered set where groupId = &#63;.
1137             *
1138             * <p>
1139             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1140             * </p>
1141             *
1142             * @param activityId the primary key of the current social activity
1143             * @param groupId the group ID
1144             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1145             * @return the previous, current, and next social activity
1146             * @throws com.liferay.portlet.social.NoSuchActivityException if a social activity with the primary key could not be found
1147             * @throws SystemException if a system exception occurred
1148             */
1149            public SocialActivity[] findByGroupId_PrevAndNext(long activityId,
1150                    long groupId, OrderByComparator orderByComparator)
1151                    throws NoSuchActivityException, SystemException {
1152                    SocialActivity socialActivity = findByPrimaryKey(activityId);
1153    
1154                    Session session = null;
1155    
1156                    try {
1157                            session = openSession();
1158    
1159                            SocialActivity[] array = new SocialActivityImpl[3];
1160    
1161                            array[0] = getByGroupId_PrevAndNext(session, socialActivity,
1162                                            groupId, orderByComparator, true);
1163    
1164                            array[1] = socialActivity;
1165    
1166                            array[2] = getByGroupId_PrevAndNext(session, socialActivity,
1167                                            groupId, orderByComparator, false);
1168    
1169                            return array;
1170                    }
1171                    catch (Exception e) {
1172                            throw processException(e);
1173                    }
1174                    finally {
1175                            closeSession(session);
1176                    }
1177            }
1178    
1179            protected SocialActivity getByGroupId_PrevAndNext(Session session,
1180                    SocialActivity socialActivity, long groupId,
1181                    OrderByComparator orderByComparator, boolean previous) {
1182                    StringBundler query = null;
1183    
1184                    if (orderByComparator != null) {
1185                            query = new StringBundler(6 +
1186                                            (orderByComparator.getOrderByFields().length * 6));
1187                    }
1188                    else {
1189                            query = new StringBundler(3);
1190                    }
1191    
1192                    query.append(_SQL_SELECT_SOCIALACTIVITY_WHERE);
1193    
1194                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1195    
1196                    if (orderByComparator != null) {
1197                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1198    
1199                            if (orderByConditionFields.length > 0) {
1200                                    query.append(WHERE_AND);
1201                            }
1202    
1203                            for (int i = 0; i < orderByConditionFields.length; i++) {
1204                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1205                                    query.append(orderByConditionFields[i]);
1206    
1207                                    if ((i + 1) < orderByConditionFields.length) {
1208                                            if (orderByComparator.isAscending() ^ previous) {
1209                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1210                                            }
1211                                            else {
1212                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1213                                            }
1214                                    }
1215                                    else {
1216                                            if (orderByComparator.isAscending() ^ previous) {
1217                                                    query.append(WHERE_GREATER_THAN);
1218                                            }
1219                                            else {
1220                                                    query.append(WHERE_LESSER_THAN);
1221                                            }
1222                                    }
1223                            }
1224    
1225                            query.append(ORDER_BY_CLAUSE);
1226    
1227                            String[] orderByFields = orderByComparator.getOrderByFields();
1228    
1229                            for (int i = 0; i < orderByFields.length; i++) {
1230                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1231                                    query.append(orderByFields[i]);
1232    
1233                                    if ((i + 1) < orderByFields.length) {
1234                                            if (orderByComparator.isAscending() ^ previous) {
1235                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1236                                            }
1237                                            else {
1238                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1239                                            }
1240                                    }
1241                                    else {
1242                                            if (orderByComparator.isAscending() ^ previous) {
1243                                                    query.append(ORDER_BY_ASC);
1244                                            }
1245                                            else {
1246                                                    query.append(ORDER_BY_DESC);
1247                                            }
1248                                    }
1249                            }
1250                    }
1251    
1252                    else {
1253                            query.append(SocialActivityModelImpl.ORDER_BY_JPQL);
1254                    }
1255    
1256                    String sql = query.toString();
1257    
1258                    Query q = session.createQuery(sql);
1259    
1260                    q.setFirstResult(0);
1261                    q.setMaxResults(2);
1262    
1263                    QueryPos qPos = QueryPos.getInstance(q);
1264    
1265                    qPos.add(groupId);
1266    
1267                    if (orderByComparator != null) {
1268                            Object[] values = orderByComparator.getOrderByConditionValues(socialActivity);
1269    
1270                            for (Object value : values) {
1271                                    qPos.add(value);
1272                            }
1273                    }
1274    
1275                    List<SocialActivity> list = q.list();
1276    
1277                    if (list.size() == 2) {
1278                            return list.get(1);
1279                    }
1280                    else {
1281                            return null;
1282                    }
1283            }
1284    
1285            /**
1286             * Returns all the social activities where companyId = &#63;.
1287             *
1288             * @param companyId the company ID
1289             * @return the matching social activities
1290             * @throws SystemException if a system exception occurred
1291             */
1292            public List<SocialActivity> findByCompanyId(long companyId)
1293                    throws SystemException {
1294                    return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1295                            null);
1296            }
1297    
1298            /**
1299             * Returns a range of all the social activities where companyId = &#63;.
1300             *
1301             * <p>
1302             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1303             * </p>
1304             *
1305             * @param companyId the company ID
1306             * @param start the lower bound of the range of social activities
1307             * @param end the upper bound of the range of social activities (not inclusive)
1308             * @return the range of matching social activities
1309             * @throws SystemException if a system exception occurred
1310             */
1311            public List<SocialActivity> findByCompanyId(long companyId, int start,
1312                    int end) throws SystemException {
1313                    return findByCompanyId(companyId, start, end, null);
1314            }
1315    
1316            /**
1317             * Returns an ordered range of all the social activities where companyId = &#63;.
1318             *
1319             * <p>
1320             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1321             * </p>
1322             *
1323             * @param companyId the company ID
1324             * @param start the lower bound of the range of social activities
1325             * @param end the upper bound of the range of social activities (not inclusive)
1326             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1327             * @return the ordered range of matching social activities
1328             * @throws SystemException if a system exception occurred
1329             */
1330            public List<SocialActivity> findByCompanyId(long companyId, int start,
1331                    int end, OrderByComparator orderByComparator) throws SystemException {
1332                    FinderPath finderPath = null;
1333                    Object[] finderArgs = null;
1334    
1335                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1336                                    (orderByComparator == null)) {
1337                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
1338                            finderArgs = new Object[] { companyId };
1339                    }
1340                    else {
1341                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
1342                            finderArgs = new Object[] { companyId, start, end, orderByComparator };
1343                    }
1344    
1345                    List<SocialActivity> list = (List<SocialActivity>)FinderCacheUtil.getResult(finderPath,
1346                                    finderArgs, this);
1347    
1348                    if ((list != null) && !list.isEmpty()) {
1349                            for (SocialActivity socialActivity : list) {
1350                                    if ((companyId != socialActivity.getCompanyId())) {
1351                                            list = null;
1352    
1353                                            break;
1354                                    }
1355                            }
1356                    }
1357    
1358                    if (list == null) {
1359                            StringBundler query = null;
1360    
1361                            if (orderByComparator != null) {
1362                                    query = new StringBundler(3 +
1363                                                    (orderByComparator.getOrderByFields().length * 3));
1364                            }
1365                            else {
1366                                    query = new StringBundler(3);
1367                            }
1368    
1369                            query.append(_SQL_SELECT_SOCIALACTIVITY_WHERE);
1370    
1371                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1372    
1373                            if (orderByComparator != null) {
1374                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1375                                            orderByComparator);
1376                            }
1377    
1378                            else {
1379                                    query.append(SocialActivityModelImpl.ORDER_BY_JPQL);
1380                            }
1381    
1382                            String sql = query.toString();
1383    
1384                            Session session = null;
1385    
1386                            try {
1387                                    session = openSession();
1388    
1389                                    Query q = session.createQuery(sql);
1390    
1391                                    QueryPos qPos = QueryPos.getInstance(q);
1392    
1393                                    qPos.add(companyId);
1394    
1395                                    list = (List<SocialActivity>)QueryUtil.list(q, getDialect(),
1396                                                    start, end);
1397                            }
1398                            catch (Exception e) {
1399                                    throw processException(e);
1400                            }
1401                            finally {
1402                                    if (list == null) {
1403                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1404                                    }
1405                                    else {
1406                                            cacheResult(list);
1407    
1408                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1409                                    }
1410    
1411                                    closeSession(session);
1412                            }
1413                    }
1414    
1415                    return list;
1416            }
1417    
1418            /**
1419             * Returns the first social activity in the ordered set where companyId = &#63;.
1420             *
1421             * <p>
1422             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1423             * </p>
1424             *
1425             * @param companyId the company ID
1426             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1427             * @return the first matching social activity
1428             * @throws com.liferay.portlet.social.NoSuchActivityException if a matching social activity could not be found
1429             * @throws SystemException if a system exception occurred
1430             */
1431            public SocialActivity findByCompanyId_First(long companyId,
1432                    OrderByComparator orderByComparator)
1433                    throws NoSuchActivityException, SystemException {
1434                    List<SocialActivity> list = findByCompanyId(companyId, 0, 1,
1435                                    orderByComparator);
1436    
1437                    if (list.isEmpty()) {
1438                            StringBundler msg = new StringBundler(4);
1439    
1440                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1441    
1442                            msg.append("companyId=");
1443                            msg.append(companyId);
1444    
1445                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1446    
1447                            throw new NoSuchActivityException(msg.toString());
1448                    }
1449                    else {
1450                            return list.get(0);
1451                    }
1452            }
1453    
1454            /**
1455             * Returns the last social activity in the ordered set where companyId = &#63;.
1456             *
1457             * <p>
1458             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1459             * </p>
1460             *
1461             * @param companyId the company ID
1462             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1463             * @return the last matching social activity
1464             * @throws com.liferay.portlet.social.NoSuchActivityException if a matching social activity could not be found
1465             * @throws SystemException if a system exception occurred
1466             */
1467            public SocialActivity findByCompanyId_Last(long companyId,
1468                    OrderByComparator orderByComparator)
1469                    throws NoSuchActivityException, SystemException {
1470                    int count = countByCompanyId(companyId);
1471    
1472                    List<SocialActivity> list = findByCompanyId(companyId, count - 1,
1473                                    count, orderByComparator);
1474    
1475                    if (list.isEmpty()) {
1476                            StringBundler msg = new StringBundler(4);
1477    
1478                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1479    
1480                            msg.append("companyId=");
1481                            msg.append(companyId);
1482    
1483                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1484    
1485                            throw new NoSuchActivityException(msg.toString());
1486                    }
1487                    else {
1488                            return list.get(0);
1489                    }
1490            }
1491    
1492            /**
1493             * Returns the social activities before and after the current social activity in the ordered set where companyId = &#63;.
1494             *
1495             * <p>
1496             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1497             * </p>
1498             *
1499             * @param activityId the primary key of the current social activity
1500             * @param companyId the company ID
1501             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1502             * @return the previous, current, and next social activity
1503             * @throws com.liferay.portlet.social.NoSuchActivityException if a social activity with the primary key could not be found
1504             * @throws SystemException if a system exception occurred
1505             */
1506            public SocialActivity[] findByCompanyId_PrevAndNext(long activityId,
1507                    long companyId, OrderByComparator orderByComparator)
1508                    throws NoSuchActivityException, SystemException {
1509                    SocialActivity socialActivity = findByPrimaryKey(activityId);
1510    
1511                    Session session = null;
1512    
1513                    try {
1514                            session = openSession();
1515    
1516                            SocialActivity[] array = new SocialActivityImpl[3];
1517    
1518                            array[0] = getByCompanyId_PrevAndNext(session, socialActivity,
1519                                            companyId, orderByComparator, true);
1520    
1521                            array[1] = socialActivity;
1522    
1523                            array[2] = getByCompanyId_PrevAndNext(session, socialActivity,
1524                                            companyId, orderByComparator, false);
1525    
1526                            return array;
1527                    }
1528                    catch (Exception e) {
1529                            throw processException(e);
1530                    }
1531                    finally {
1532                            closeSession(session);
1533                    }
1534            }
1535    
1536            protected SocialActivity getByCompanyId_PrevAndNext(Session session,
1537                    SocialActivity socialActivity, long companyId,
1538                    OrderByComparator orderByComparator, boolean previous) {
1539                    StringBundler query = null;
1540    
1541                    if (orderByComparator != null) {
1542                            query = new StringBundler(6 +
1543                                            (orderByComparator.getOrderByFields().length * 6));
1544                    }
1545                    else {
1546                            query = new StringBundler(3);
1547                    }
1548    
1549                    query.append(_SQL_SELECT_SOCIALACTIVITY_WHERE);
1550    
1551                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1552    
1553                    if (orderByComparator != null) {
1554                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1555    
1556                            if (orderByConditionFields.length > 0) {
1557                                    query.append(WHERE_AND);
1558                            }
1559    
1560                            for (int i = 0; i < orderByConditionFields.length; i++) {
1561                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1562                                    query.append(orderByConditionFields[i]);
1563    
1564                                    if ((i + 1) < orderByConditionFields.length) {
1565                                            if (orderByComparator.isAscending() ^ previous) {
1566                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1567                                            }
1568                                            else {
1569                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1570                                            }
1571                                    }
1572                                    else {
1573                                            if (orderByComparator.isAscending() ^ previous) {
1574                                                    query.append(WHERE_GREATER_THAN);
1575                                            }
1576                                            else {
1577                                                    query.append(WHERE_LESSER_THAN);
1578                                            }
1579                                    }
1580                            }
1581    
1582                            query.append(ORDER_BY_CLAUSE);
1583    
1584                            String[] orderByFields = orderByComparator.getOrderByFields();
1585    
1586                            for (int i = 0; i < orderByFields.length; i++) {
1587                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1588                                    query.append(orderByFields[i]);
1589    
1590                                    if ((i + 1) < orderByFields.length) {
1591                                            if (orderByComparator.isAscending() ^ previous) {
1592                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1593                                            }
1594                                            else {
1595                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1596                                            }
1597                                    }
1598                                    else {
1599                                            if (orderByComparator.isAscending() ^ previous) {
1600                                                    query.append(ORDER_BY_ASC);
1601                                            }
1602                                            else {
1603                                                    query.append(ORDER_BY_DESC);
1604                                            }
1605                                    }
1606                            }
1607                    }
1608    
1609                    else {
1610                            query.append(SocialActivityModelImpl.ORDER_BY_JPQL);
1611                    }
1612    
1613                    String sql = query.toString();
1614    
1615                    Query q = session.createQuery(sql);
1616    
1617                    q.setFirstResult(0);
1618                    q.setMaxResults(2);
1619    
1620                    QueryPos qPos = QueryPos.getInstance(q);
1621    
1622                    qPos.add(companyId);
1623    
1624                    if (orderByComparator != null) {
1625                            Object[] values = orderByComparator.getOrderByConditionValues(socialActivity);
1626    
1627                            for (Object value : values) {
1628                                    qPos.add(value);
1629                            }
1630                    }
1631    
1632                    List<SocialActivity> list = q.list();
1633    
1634                    if (list.size() == 2) {
1635                            return list.get(1);
1636                    }
1637                    else {
1638                            return null;
1639                    }
1640            }
1641    
1642            /**
1643             * Returns all the social activities where userId = &#63;.
1644             *
1645             * @param userId the user ID
1646             * @return the matching social activities
1647             * @throws SystemException if a system exception occurred
1648             */
1649            public List<SocialActivity> findByUserId(long userId)
1650                    throws SystemException {
1651                    return findByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1652            }
1653    
1654            /**
1655             * Returns a range of all the social activities where userId = &#63;.
1656             *
1657             * <p>
1658             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1659             * </p>
1660             *
1661             * @param userId the user ID
1662             * @param start the lower bound of the range of social activities
1663             * @param end the upper bound of the range of social activities (not inclusive)
1664             * @return the range of matching social activities
1665             * @throws SystemException if a system exception occurred
1666             */
1667            public List<SocialActivity> findByUserId(long userId, int start, int end)
1668                    throws SystemException {
1669                    return findByUserId(userId, start, end, null);
1670            }
1671    
1672            /**
1673             * Returns an ordered range of all the social activities where userId = &#63;.
1674             *
1675             * <p>
1676             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1677             * </p>
1678             *
1679             * @param userId the user ID
1680             * @param start the lower bound of the range of social activities
1681             * @param end the upper bound of the range of social activities (not inclusive)
1682             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1683             * @return the ordered range of matching social activities
1684             * @throws SystemException if a system exception occurred
1685             */
1686            public List<SocialActivity> findByUserId(long userId, int start, int end,
1687                    OrderByComparator orderByComparator) throws SystemException {
1688                    FinderPath finderPath = null;
1689                    Object[] finderArgs = null;
1690    
1691                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1692                                    (orderByComparator == null)) {
1693                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID;
1694                            finderArgs = new Object[] { userId };
1695                    }
1696                    else {
1697                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID;
1698                            finderArgs = new Object[] { userId, start, end, orderByComparator };
1699                    }
1700    
1701                    List<SocialActivity> list = (List<SocialActivity>)FinderCacheUtil.getResult(finderPath,
1702                                    finderArgs, this);
1703    
1704                    if ((list != null) && !list.isEmpty()) {
1705                            for (SocialActivity socialActivity : list) {
1706                                    if ((userId != socialActivity.getUserId())) {
1707                                            list = null;
1708    
1709                                            break;
1710                                    }
1711                            }
1712                    }
1713    
1714                    if (list == null) {
1715                            StringBundler query = null;
1716    
1717                            if (orderByComparator != null) {
1718                                    query = new StringBundler(3 +
1719                                                    (orderByComparator.getOrderByFields().length * 3));
1720                            }
1721                            else {
1722                                    query = new StringBundler(3);
1723                            }
1724    
1725                            query.append(_SQL_SELECT_SOCIALACTIVITY_WHERE);
1726    
1727                            query.append(_FINDER_COLUMN_USERID_USERID_2);
1728    
1729                            if (orderByComparator != null) {
1730                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1731                                            orderByComparator);
1732                            }
1733    
1734                            else {
1735                                    query.append(SocialActivityModelImpl.ORDER_BY_JPQL);
1736                            }
1737    
1738                            String sql = query.toString();
1739    
1740                            Session session = null;
1741    
1742                            try {
1743                                    session = openSession();
1744    
1745                                    Query q = session.createQuery(sql);
1746    
1747                                    QueryPos qPos = QueryPos.getInstance(q);
1748    
1749                                    qPos.add(userId);
1750    
1751                                    list = (List<SocialActivity>)QueryUtil.list(q, getDialect(),
1752                                                    start, end);
1753                            }
1754                            catch (Exception e) {
1755                                    throw processException(e);
1756                            }
1757                            finally {
1758                                    if (list == null) {
1759                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1760                                    }
1761                                    else {
1762                                            cacheResult(list);
1763    
1764                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1765                                    }
1766    
1767                                    closeSession(session);
1768                            }
1769                    }
1770    
1771                    return list;
1772            }
1773    
1774            /**
1775             * Returns the first social activity in the ordered set where userId = &#63;.
1776             *
1777             * <p>
1778             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1779             * </p>
1780             *
1781             * @param userId the user ID
1782             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1783             * @return the first matching social activity
1784             * @throws com.liferay.portlet.social.NoSuchActivityException if a matching social activity could not be found
1785             * @throws SystemException if a system exception occurred
1786             */
1787            public SocialActivity findByUserId_First(long userId,
1788                    OrderByComparator orderByComparator)
1789                    throws NoSuchActivityException, SystemException {
1790                    List<SocialActivity> list = findByUserId(userId, 0, 1, orderByComparator);
1791    
1792                    if (list.isEmpty()) {
1793                            StringBundler msg = new StringBundler(4);
1794    
1795                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1796    
1797                            msg.append("userId=");
1798                            msg.append(userId);
1799    
1800                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1801    
1802                            throw new NoSuchActivityException(msg.toString());
1803                    }
1804                    else {
1805                            return list.get(0);
1806                    }
1807            }
1808    
1809            /**
1810             * Returns the last social activity in the ordered set where userId = &#63;.
1811             *
1812             * <p>
1813             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1814             * </p>
1815             *
1816             * @param userId the user ID
1817             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1818             * @return the last matching social activity
1819             * @throws com.liferay.portlet.social.NoSuchActivityException if a matching social activity could not be found
1820             * @throws SystemException if a system exception occurred
1821             */
1822            public SocialActivity findByUserId_Last(long userId,
1823                    OrderByComparator orderByComparator)
1824                    throws NoSuchActivityException, SystemException {
1825                    int count = countByUserId(userId);
1826    
1827                    List<SocialActivity> list = findByUserId(userId, count - 1, count,
1828                                    orderByComparator);
1829    
1830                    if (list.isEmpty()) {
1831                            StringBundler msg = new StringBundler(4);
1832    
1833                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1834    
1835                            msg.append("userId=");
1836                            msg.append(userId);
1837    
1838                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1839    
1840                            throw new NoSuchActivityException(msg.toString());
1841                    }
1842                    else {
1843                            return list.get(0);
1844                    }
1845            }
1846    
1847            /**
1848             * Returns the social activities before and after the current social activity in the ordered set where userId = &#63;.
1849             *
1850             * <p>
1851             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1852             * </p>
1853             *
1854             * @param activityId the primary key of the current social activity
1855             * @param userId the user ID
1856             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1857             * @return the previous, current, and next social activity
1858             * @throws com.liferay.portlet.social.NoSuchActivityException if a social activity with the primary key could not be found
1859             * @throws SystemException if a system exception occurred
1860             */
1861            public SocialActivity[] findByUserId_PrevAndNext(long activityId,
1862                    long userId, OrderByComparator orderByComparator)
1863                    throws NoSuchActivityException, SystemException {
1864                    SocialActivity socialActivity = findByPrimaryKey(activityId);
1865    
1866                    Session session = null;
1867    
1868                    try {
1869                            session = openSession();
1870    
1871                            SocialActivity[] array = new SocialActivityImpl[3];
1872    
1873                            array[0] = getByUserId_PrevAndNext(session, socialActivity, userId,
1874                                            orderByComparator, true);
1875    
1876                            array[1] = socialActivity;
1877    
1878                            array[2] = getByUserId_PrevAndNext(session, socialActivity, userId,
1879                                            orderByComparator, false);
1880    
1881                            return array;
1882                    }
1883                    catch (Exception e) {
1884                            throw processException(e);
1885                    }
1886                    finally {
1887                            closeSession(session);
1888                    }
1889            }
1890    
1891            protected SocialActivity getByUserId_PrevAndNext(Session session,
1892                    SocialActivity socialActivity, long userId,
1893                    OrderByComparator orderByComparator, boolean previous) {
1894                    StringBundler query = null;
1895    
1896                    if (orderByComparator != null) {
1897                            query = new StringBundler(6 +
1898                                            (orderByComparator.getOrderByFields().length * 6));
1899                    }
1900                    else {
1901                            query = new StringBundler(3);
1902                    }
1903    
1904                    query.append(_SQL_SELECT_SOCIALACTIVITY_WHERE);
1905    
1906                    query.append(_FINDER_COLUMN_USERID_USERID_2);
1907    
1908                    if (orderByComparator != null) {
1909                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1910    
1911                            if (orderByConditionFields.length > 0) {
1912                                    query.append(WHERE_AND);
1913                            }
1914    
1915                            for (int i = 0; i < orderByConditionFields.length; i++) {
1916                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1917                                    query.append(orderByConditionFields[i]);
1918    
1919                                    if ((i + 1) < orderByConditionFields.length) {
1920                                            if (orderByComparator.isAscending() ^ previous) {
1921                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1922                                            }
1923                                            else {
1924                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1925                                            }
1926                                    }
1927                                    else {
1928                                            if (orderByComparator.isAscending() ^ previous) {
1929                                                    query.append(WHERE_GREATER_THAN);
1930                                            }
1931                                            else {
1932                                                    query.append(WHERE_LESSER_THAN);
1933                                            }
1934                                    }
1935                            }
1936    
1937                            query.append(ORDER_BY_CLAUSE);
1938    
1939                            String[] orderByFields = orderByComparator.getOrderByFields();
1940    
1941                            for (int i = 0; i < orderByFields.length; i++) {
1942                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1943                                    query.append(orderByFields[i]);
1944    
1945                                    if ((i + 1) < orderByFields.length) {
1946                                            if (orderByComparator.isAscending() ^ previous) {
1947                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1948                                            }
1949                                            else {
1950                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1951                                            }
1952                                    }
1953                                    else {
1954                                            if (orderByComparator.isAscending() ^ previous) {
1955                                                    query.append(ORDER_BY_ASC);
1956                                            }
1957                                            else {
1958                                                    query.append(ORDER_BY_DESC);
1959                                            }
1960                                    }
1961                            }
1962                    }
1963    
1964                    else {
1965                            query.append(SocialActivityModelImpl.ORDER_BY_JPQL);
1966                    }
1967    
1968                    String sql = query.toString();
1969    
1970                    Query q = session.createQuery(sql);
1971    
1972                    q.setFirstResult(0);
1973                    q.setMaxResults(2);
1974    
1975                    QueryPos qPos = QueryPos.getInstance(q);
1976    
1977                    qPos.add(userId);
1978    
1979                    if (orderByComparator != null) {
1980                            Object[] values = orderByComparator.getOrderByConditionValues(socialActivity);
1981    
1982                            for (Object value : values) {
1983                                    qPos.add(value);
1984                            }
1985                    }
1986    
1987                    List<SocialActivity> list = q.list();
1988    
1989                    if (list.size() == 2) {
1990                            return list.get(1);
1991                    }
1992                    else {
1993                            return null;
1994                    }
1995            }
1996    
1997            /**
1998             * Returns the social activity where mirrorActivityId = &#63; or throws a {@link com.liferay.portlet.social.NoSuchActivityException} if it could not be found.
1999             *
2000             * @param mirrorActivityId the mirror activity ID
2001             * @return the matching social activity
2002             * @throws com.liferay.portlet.social.NoSuchActivityException if a matching social activity could not be found
2003             * @throws SystemException if a system exception occurred
2004             */
2005            public SocialActivity findByMirrorActivityId(long mirrorActivityId)
2006                    throws NoSuchActivityException, SystemException {
2007                    SocialActivity socialActivity = fetchByMirrorActivityId(mirrorActivityId);
2008    
2009                    if (socialActivity == null) {
2010                            StringBundler msg = new StringBundler(4);
2011    
2012                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2013    
2014                            msg.append("mirrorActivityId=");
2015                            msg.append(mirrorActivityId);
2016    
2017                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2018    
2019                            if (_log.isWarnEnabled()) {
2020                                    _log.warn(msg.toString());
2021                            }
2022    
2023                            throw new NoSuchActivityException(msg.toString());
2024                    }
2025    
2026                    return socialActivity;
2027            }
2028    
2029            /**
2030             * Returns the social activity where mirrorActivityId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
2031             *
2032             * @param mirrorActivityId the mirror activity ID
2033             * @return the matching social activity, or <code>null</code> if a matching social activity could not be found
2034             * @throws SystemException if a system exception occurred
2035             */
2036            public SocialActivity fetchByMirrorActivityId(long mirrorActivityId)
2037                    throws SystemException {
2038                    return fetchByMirrorActivityId(mirrorActivityId, true);
2039            }
2040    
2041            /**
2042             * Returns the social activity where mirrorActivityId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
2043             *
2044             * @param mirrorActivityId the mirror activity ID
2045             * @param retrieveFromCache whether to use the finder cache
2046             * @return the matching social activity, or <code>null</code> if a matching social activity could not be found
2047             * @throws SystemException if a system exception occurred
2048             */
2049            public SocialActivity fetchByMirrorActivityId(long mirrorActivityId,
2050                    boolean retrieveFromCache) throws SystemException {
2051                    Object[] finderArgs = new Object[] { mirrorActivityId };
2052    
2053                    Object result = null;
2054    
2055                    if (retrieveFromCache) {
2056                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_MIRRORACTIVITYID,
2057                                            finderArgs, this);
2058                    }
2059    
2060                    if (result instanceof SocialActivity) {
2061                            SocialActivity socialActivity = (SocialActivity)result;
2062    
2063                            if ((mirrorActivityId != socialActivity.getMirrorActivityId())) {
2064                                    result = null;
2065                            }
2066                    }
2067    
2068                    if (result == null) {
2069                            StringBundler query = new StringBundler(3);
2070    
2071                            query.append(_SQL_SELECT_SOCIALACTIVITY_WHERE);
2072    
2073                            query.append(_FINDER_COLUMN_MIRRORACTIVITYID_MIRRORACTIVITYID_2);
2074    
2075                            query.append(SocialActivityModelImpl.ORDER_BY_JPQL);
2076    
2077                            String sql = query.toString();
2078    
2079                            Session session = null;
2080    
2081                            try {
2082                                    session = openSession();
2083    
2084                                    Query q = session.createQuery(sql);
2085    
2086                                    QueryPos qPos = QueryPos.getInstance(q);
2087    
2088                                    qPos.add(mirrorActivityId);
2089    
2090                                    List<SocialActivity> list = q.list();
2091    
2092                                    result = list;
2093    
2094                                    SocialActivity socialActivity = null;
2095    
2096                                    if (list.isEmpty()) {
2097                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_MIRRORACTIVITYID,
2098                                                    finderArgs, list);
2099                                    }
2100                                    else {
2101                                            socialActivity = list.get(0);
2102    
2103                                            cacheResult(socialActivity);
2104    
2105                                            if ((socialActivity.getMirrorActivityId() != mirrorActivityId)) {
2106                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_MIRRORACTIVITYID,
2107                                                            finderArgs, socialActivity);
2108                                            }
2109                                    }
2110    
2111                                    return socialActivity;
2112                            }
2113                            catch (Exception e) {
2114                                    throw processException(e);
2115                            }
2116                            finally {
2117                                    if (result == null) {
2118                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_MIRRORACTIVITYID,
2119                                                    finderArgs);
2120                                    }
2121    
2122                                    closeSession(session);
2123                            }
2124                    }
2125                    else {
2126                            if (result instanceof List<?>) {
2127                                    return null;
2128                            }
2129                            else {
2130                                    return (SocialActivity)result;
2131                            }
2132                    }
2133            }
2134    
2135            /**
2136             * Returns all the social activities where classNameId = &#63;.
2137             *
2138             * @param classNameId the class name ID
2139             * @return the matching social activities
2140             * @throws SystemException if a system exception occurred
2141             */
2142            public List<SocialActivity> findByClassNameId(long classNameId)
2143                    throws SystemException {
2144                    return findByClassNameId(classNameId, QueryUtil.ALL_POS,
2145                            QueryUtil.ALL_POS, null);
2146            }
2147    
2148            /**
2149             * Returns a range of all the social activities where classNameId = &#63;.
2150             *
2151             * <p>
2152             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2153             * </p>
2154             *
2155             * @param classNameId the class name ID
2156             * @param start the lower bound of the range of social activities
2157             * @param end the upper bound of the range of social activities (not inclusive)
2158             * @return the range of matching social activities
2159             * @throws SystemException if a system exception occurred
2160             */
2161            public List<SocialActivity> findByClassNameId(long classNameId, int start,
2162                    int end) throws SystemException {
2163                    return findByClassNameId(classNameId, start, end, null);
2164            }
2165    
2166            /**
2167             * Returns an ordered range of all the social activities where classNameId = &#63;.
2168             *
2169             * <p>
2170             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2171             * </p>
2172             *
2173             * @param classNameId the class name ID
2174             * @param start the lower bound of the range of social activities
2175             * @param end the upper bound of the range of social activities (not inclusive)
2176             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2177             * @return the ordered range of matching social activities
2178             * @throws SystemException if a system exception occurred
2179             */
2180            public List<SocialActivity> findByClassNameId(long classNameId, int start,
2181                    int end, OrderByComparator orderByComparator) throws SystemException {
2182                    FinderPath finderPath = null;
2183                    Object[] finderArgs = null;
2184    
2185                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2186                                    (orderByComparator == null)) {
2187                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CLASSNAMEID;
2188                            finderArgs = new Object[] { classNameId };
2189                    }
2190                    else {
2191                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_CLASSNAMEID;
2192                            finderArgs = new Object[] { classNameId, start, end, orderByComparator };
2193                    }
2194    
2195                    List<SocialActivity> list = (List<SocialActivity>)FinderCacheUtil.getResult(finderPath,
2196                                    finderArgs, this);
2197    
2198                    if ((list != null) && !list.isEmpty()) {
2199                            for (SocialActivity socialActivity : list) {
2200                                    if ((classNameId != socialActivity.getClassNameId())) {
2201                                            list = null;
2202    
2203                                            break;
2204                                    }
2205                            }
2206                    }
2207    
2208                    if (list == null) {
2209                            StringBundler query = null;
2210    
2211                            if (orderByComparator != null) {
2212                                    query = new StringBundler(3 +
2213                                                    (orderByComparator.getOrderByFields().length * 3));
2214                            }
2215                            else {
2216                                    query = new StringBundler(3);
2217                            }
2218    
2219                            query.append(_SQL_SELECT_SOCIALACTIVITY_WHERE);
2220    
2221                            query.append(_FINDER_COLUMN_CLASSNAMEID_CLASSNAMEID_2);
2222    
2223                            if (orderByComparator != null) {
2224                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2225                                            orderByComparator);
2226                            }
2227    
2228                            else {
2229                                    query.append(SocialActivityModelImpl.ORDER_BY_JPQL);
2230                            }
2231    
2232                            String sql = query.toString();
2233    
2234                            Session session = null;
2235    
2236                            try {
2237                                    session = openSession();
2238    
2239                                    Query q = session.createQuery(sql);
2240    
2241                                    QueryPos qPos = QueryPos.getInstance(q);
2242    
2243                                    qPos.add(classNameId);
2244    
2245                                    list = (List<SocialActivity>)QueryUtil.list(q, getDialect(),
2246                                                    start, end);
2247                            }
2248                            catch (Exception e) {
2249                                    throw processException(e);
2250                            }
2251                            finally {
2252                                    if (list == null) {
2253                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
2254                                    }
2255                                    else {
2256                                            cacheResult(list);
2257    
2258                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
2259                                    }
2260    
2261                                    closeSession(session);
2262                            }
2263                    }
2264    
2265                    return list;
2266            }
2267    
2268            /**
2269             * Returns the first social activity in the ordered set where classNameId = &#63;.
2270             *
2271             * <p>
2272             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2273             * </p>
2274             *
2275             * @param classNameId the class name ID
2276             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2277             * @return the first matching social activity
2278             * @throws com.liferay.portlet.social.NoSuchActivityException if a matching social activity could not be found
2279             * @throws SystemException if a system exception occurred
2280             */
2281            public SocialActivity findByClassNameId_First(long classNameId,
2282                    OrderByComparator orderByComparator)
2283                    throws NoSuchActivityException, SystemException {
2284                    List<SocialActivity> list = findByClassNameId(classNameId, 0, 1,
2285                                    orderByComparator);
2286    
2287                    if (list.isEmpty()) {
2288                            StringBundler msg = new StringBundler(4);
2289    
2290                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2291    
2292                            msg.append("classNameId=");
2293                            msg.append(classNameId);
2294    
2295                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2296    
2297                            throw new NoSuchActivityException(msg.toString());
2298                    }
2299                    else {
2300                            return list.get(0);
2301                    }
2302            }
2303    
2304            /**
2305             * Returns the last social activity in the ordered set where classNameId = &#63;.
2306             *
2307             * <p>
2308             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2309             * </p>
2310             *
2311             * @param classNameId the class name ID
2312             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2313             * @return the last matching social activity
2314             * @throws com.liferay.portlet.social.NoSuchActivityException if a matching social activity could not be found
2315             * @throws SystemException if a system exception occurred
2316             */
2317            public SocialActivity findByClassNameId_Last(long classNameId,
2318                    OrderByComparator orderByComparator)
2319                    throws NoSuchActivityException, SystemException {
2320                    int count = countByClassNameId(classNameId);
2321    
2322                    List<SocialActivity> list = findByClassNameId(classNameId, count - 1,
2323                                    count, orderByComparator);
2324    
2325                    if (list.isEmpty()) {
2326                            StringBundler msg = new StringBundler(4);
2327    
2328                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2329    
2330                            msg.append("classNameId=");
2331                            msg.append(classNameId);
2332    
2333                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2334    
2335                            throw new NoSuchActivityException(msg.toString());
2336                    }
2337                    else {
2338                            return list.get(0);
2339                    }
2340            }
2341    
2342            /**
2343             * Returns the social activities before and after the current social activity in the ordered set where classNameId = &#63;.
2344             *
2345             * <p>
2346             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2347             * </p>
2348             *
2349             * @param activityId the primary key of the current social activity
2350             * @param classNameId the class name ID
2351             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2352             * @return the previous, current, and next social activity
2353             * @throws com.liferay.portlet.social.NoSuchActivityException if a social activity with the primary key could not be found
2354             * @throws SystemException if a system exception occurred
2355             */
2356            public SocialActivity[] findByClassNameId_PrevAndNext(long activityId,
2357                    long classNameId, OrderByComparator orderByComparator)
2358                    throws NoSuchActivityException, SystemException {
2359                    SocialActivity socialActivity = findByPrimaryKey(activityId);
2360    
2361                    Session session = null;
2362    
2363                    try {
2364                            session = openSession();
2365    
2366                            SocialActivity[] array = new SocialActivityImpl[3];
2367    
2368                            array[0] = getByClassNameId_PrevAndNext(session, socialActivity,
2369                                            classNameId, orderByComparator, true);
2370    
2371                            array[1] = socialActivity;
2372    
2373                            array[2] = getByClassNameId_PrevAndNext(session, socialActivity,
2374                                            classNameId, orderByComparator, false);
2375    
2376                            return array;
2377                    }
2378                    catch (Exception e) {
2379                            throw processException(e);
2380                    }
2381                    finally {
2382                            closeSession(session);
2383                    }
2384            }
2385    
2386            protected SocialActivity getByClassNameId_PrevAndNext(Session session,
2387                    SocialActivity socialActivity, long classNameId,
2388                    OrderByComparator orderByComparator, boolean previous) {
2389                    StringBundler query = null;
2390    
2391                    if (orderByComparator != null) {
2392                            query = new StringBundler(6 +
2393                                            (orderByComparator.getOrderByFields().length * 6));
2394                    }
2395                    else {
2396                            query = new StringBundler(3);
2397                    }
2398    
2399                    query.append(_SQL_SELECT_SOCIALACTIVITY_WHERE);
2400    
2401                    query.append(_FINDER_COLUMN_CLASSNAMEID_CLASSNAMEID_2);
2402    
2403                    if (orderByComparator != null) {
2404                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2405    
2406                            if (orderByConditionFields.length > 0) {
2407                                    query.append(WHERE_AND);
2408                            }
2409    
2410                            for (int i = 0; i < orderByConditionFields.length; i++) {
2411                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2412                                    query.append(orderByConditionFields[i]);
2413    
2414                                    if ((i + 1) < orderByConditionFields.length) {
2415                                            if (orderByComparator.isAscending() ^ previous) {
2416                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2417                                            }
2418                                            else {
2419                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2420                                            }
2421                                    }
2422                                    else {
2423                                            if (orderByComparator.isAscending() ^ previous) {
2424                                                    query.append(WHERE_GREATER_THAN);
2425                                            }
2426                                            else {
2427                                                    query.append(WHERE_LESSER_THAN);
2428                                            }
2429                                    }
2430                            }
2431    
2432                            query.append(ORDER_BY_CLAUSE);
2433    
2434                            String[] orderByFields = orderByComparator.getOrderByFields();
2435    
2436                            for (int i = 0; i < orderByFields.length; i++) {
2437                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2438                                    query.append(orderByFields[i]);
2439    
2440                                    if ((i + 1) < orderByFields.length) {
2441                                            if (orderByComparator.isAscending() ^ previous) {
2442                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2443                                            }
2444                                            else {
2445                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2446                                            }
2447                                    }
2448                                    else {
2449                                            if (orderByComparator.isAscending() ^ previous) {
2450                                                    query.append(ORDER_BY_ASC);
2451                                            }
2452                                            else {
2453                                                    query.append(ORDER_BY_DESC);
2454                                            }
2455                                    }
2456                            }
2457                    }
2458    
2459                    else {
2460                            query.append(SocialActivityModelImpl.ORDER_BY_JPQL);
2461                    }
2462    
2463                    String sql = query.toString();
2464    
2465                    Query q = session.createQuery(sql);
2466    
2467                    q.setFirstResult(0);
2468                    q.setMaxResults(2);
2469    
2470                    QueryPos qPos = QueryPos.getInstance(q);
2471    
2472                    qPos.add(classNameId);
2473    
2474                    if (orderByComparator != null) {
2475                            Object[] values = orderByComparator.getOrderByConditionValues(socialActivity);
2476    
2477                            for (Object value : values) {
2478                                    qPos.add(value);
2479                            }
2480                    }
2481    
2482                    List<SocialActivity> list = q.list();
2483    
2484                    if (list.size() == 2) {
2485                            return list.get(1);
2486                    }
2487                    else {
2488                            return null;
2489                    }
2490            }
2491    
2492            /**
2493             * Returns all the social activities where receiverUserId = &#63;.
2494             *
2495             * @param receiverUserId the receiver user ID
2496             * @return the matching social activities
2497             * @throws SystemException if a system exception occurred
2498             */
2499            public List<SocialActivity> findByReceiverUserId(long receiverUserId)
2500                    throws SystemException {
2501                    return findByReceiverUserId(receiverUserId, QueryUtil.ALL_POS,
2502                            QueryUtil.ALL_POS, null);
2503            }
2504    
2505            /**
2506             * Returns a range of all the social activities where receiverUserId = &#63;.
2507             *
2508             * <p>
2509             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2510             * </p>
2511             *
2512             * @param receiverUserId the receiver user ID
2513             * @param start the lower bound of the range of social activities
2514             * @param end the upper bound of the range of social activities (not inclusive)
2515             * @return the range of matching social activities
2516             * @throws SystemException if a system exception occurred
2517             */
2518            public List<SocialActivity> findByReceiverUserId(long receiverUserId,
2519                    int start, int end) throws SystemException {
2520                    return findByReceiverUserId(receiverUserId, start, end, null);
2521            }
2522    
2523            /**
2524             * Returns an ordered range of all the social activities where receiverUserId = &#63;.
2525             *
2526             * <p>
2527             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2528             * </p>
2529             *
2530             * @param receiverUserId the receiver user ID
2531             * @param start the lower bound of the range of social activities
2532             * @param end the upper bound of the range of social activities (not inclusive)
2533             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2534             * @return the ordered range of matching social activities
2535             * @throws SystemException if a system exception occurred
2536             */
2537            public List<SocialActivity> findByReceiverUserId(long receiverUserId,
2538                    int start, int end, OrderByComparator orderByComparator)
2539                    throws SystemException {
2540                    FinderPath finderPath = null;
2541                    Object[] finderArgs = null;
2542    
2543                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2544                                    (orderByComparator == null)) {
2545                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_RECEIVERUSERID;
2546                            finderArgs = new Object[] { receiverUserId };
2547                    }
2548                    else {
2549                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_RECEIVERUSERID;
2550                            finderArgs = new Object[] {
2551                                            receiverUserId,
2552                                            
2553                                            start, end, orderByComparator
2554                                    };
2555                    }
2556    
2557                    List<SocialActivity> list = (List<SocialActivity>)FinderCacheUtil.getResult(finderPath,
2558                                    finderArgs, this);
2559    
2560                    if ((list != null) && !list.isEmpty()) {
2561                            for (SocialActivity socialActivity : list) {
2562                                    if ((receiverUserId != socialActivity.getReceiverUserId())) {
2563                                            list = null;
2564    
2565                                            break;
2566                                    }
2567                            }
2568                    }
2569    
2570                    if (list == null) {
2571                            StringBundler query = null;
2572    
2573                            if (orderByComparator != null) {
2574                                    query = new StringBundler(3 +
2575                                                    (orderByComparator.getOrderByFields().length * 3));
2576                            }
2577                            else {
2578                                    query = new StringBundler(3);
2579                            }
2580    
2581                            query.append(_SQL_SELECT_SOCIALACTIVITY_WHERE);
2582    
2583                            query.append(_FINDER_COLUMN_RECEIVERUSERID_RECEIVERUSERID_2);
2584    
2585                            if (orderByComparator != null) {
2586                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2587                                            orderByComparator);
2588                            }
2589    
2590                            else {
2591                                    query.append(SocialActivityModelImpl.ORDER_BY_JPQL);
2592                            }
2593    
2594                            String sql = query.toString();
2595    
2596                            Session session = null;
2597    
2598                            try {
2599                                    session = openSession();
2600    
2601                                    Query q = session.createQuery(sql);
2602    
2603                                    QueryPos qPos = QueryPos.getInstance(q);
2604    
2605                                    qPos.add(receiverUserId);
2606    
2607                                    list = (List<SocialActivity>)QueryUtil.list(q, getDialect(),
2608                                                    start, end);
2609                            }
2610                            catch (Exception e) {
2611                                    throw processException(e);
2612                            }
2613                            finally {
2614                                    if (list == null) {
2615                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
2616                                    }
2617                                    else {
2618                                            cacheResult(list);
2619    
2620                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
2621                                    }
2622    
2623                                    closeSession(session);
2624                            }
2625                    }
2626    
2627                    return list;
2628            }
2629    
2630            /**
2631             * Returns the first social activity in the ordered set where receiverUserId = &#63;.
2632             *
2633             * <p>
2634             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2635             * </p>
2636             *
2637             * @param receiverUserId the receiver user ID
2638             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2639             * @return the first matching social activity
2640             * @throws com.liferay.portlet.social.NoSuchActivityException if a matching social activity could not be found
2641             * @throws SystemException if a system exception occurred
2642             */
2643            public SocialActivity findByReceiverUserId_First(long receiverUserId,
2644                    OrderByComparator orderByComparator)
2645                    throws NoSuchActivityException, SystemException {
2646                    List<SocialActivity> list = findByReceiverUserId(receiverUserId, 0, 1,
2647                                    orderByComparator);
2648    
2649                    if (list.isEmpty()) {
2650                            StringBundler msg = new StringBundler(4);
2651    
2652                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2653    
2654                            msg.append("receiverUserId=");
2655                            msg.append(receiverUserId);
2656    
2657                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2658    
2659                            throw new NoSuchActivityException(msg.toString());
2660                    }
2661                    else {
2662                            return list.get(0);
2663                    }
2664            }
2665    
2666            /**
2667             * Returns the last social activity in the ordered set where receiverUserId = &#63;.
2668             *
2669             * <p>
2670             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2671             * </p>
2672             *
2673             * @param receiverUserId the receiver user ID
2674             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2675             * @return the last matching social activity
2676             * @throws com.liferay.portlet.social.NoSuchActivityException if a matching social activity could not be found
2677             * @throws SystemException if a system exception occurred
2678             */
2679            public SocialActivity findByReceiverUserId_Last(long receiverUserId,
2680                    OrderByComparator orderByComparator)
2681                    throws NoSuchActivityException, SystemException {
2682                    int count = countByReceiverUserId(receiverUserId);
2683    
2684                    List<SocialActivity> list = findByReceiverUserId(receiverUserId,
2685                                    count - 1, count, orderByComparator);
2686    
2687                    if (list.isEmpty()) {
2688                            StringBundler msg = new StringBundler(4);
2689    
2690                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2691    
2692                            msg.append("receiverUserId=");
2693                            msg.append(receiverUserId);
2694    
2695                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2696    
2697                            throw new NoSuchActivityException(msg.toString());
2698                    }
2699                    else {
2700                            return list.get(0);
2701                    }
2702            }
2703    
2704            /**
2705             * Returns the social activities before and after the current social activity in the ordered set where receiverUserId = &#63;.
2706             *
2707             * <p>
2708             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2709             * </p>
2710             *
2711             * @param activityId the primary key of the current social activity
2712             * @param receiverUserId the receiver user ID
2713             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2714             * @return the previous, current, and next social activity
2715             * @throws com.liferay.portlet.social.NoSuchActivityException if a social activity with the primary key could not be found
2716             * @throws SystemException if a system exception occurred
2717             */
2718            public SocialActivity[] findByReceiverUserId_PrevAndNext(long activityId,
2719                    long receiverUserId, OrderByComparator orderByComparator)
2720                    throws NoSuchActivityException, SystemException {
2721                    SocialActivity socialActivity = findByPrimaryKey(activityId);
2722    
2723                    Session session = null;
2724    
2725                    try {
2726                            session = openSession();
2727    
2728                            SocialActivity[] array = new SocialActivityImpl[3];
2729    
2730                            array[0] = getByReceiverUserId_PrevAndNext(session, socialActivity,
2731                                            receiverUserId, orderByComparator, true);
2732    
2733                            array[1] = socialActivity;
2734    
2735                            array[2] = getByReceiverUserId_PrevAndNext(session, socialActivity,
2736                                            receiverUserId, orderByComparator, false);
2737    
2738                            return array;
2739                    }
2740                    catch (Exception e) {
2741                            throw processException(e);
2742                    }
2743                    finally {
2744                            closeSession(session);
2745                    }
2746            }
2747    
2748            protected SocialActivity getByReceiverUserId_PrevAndNext(Session session,
2749                    SocialActivity socialActivity, long receiverUserId,
2750                    OrderByComparator orderByComparator, boolean previous) {
2751                    StringBundler query = null;
2752    
2753                    if (orderByComparator != null) {
2754                            query = new StringBundler(6 +
2755                                            (orderByComparator.getOrderByFields().length * 6));
2756                    }
2757                    else {
2758                            query = new StringBundler(3);
2759                    }
2760    
2761                    query.append(_SQL_SELECT_SOCIALACTIVITY_WHERE);
2762    
2763                    query.append(_FINDER_COLUMN_RECEIVERUSERID_RECEIVERUSERID_2);
2764    
2765                    if (orderByComparator != null) {
2766                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2767    
2768                            if (orderByConditionFields.length > 0) {
2769                                    query.append(WHERE_AND);
2770                            }
2771    
2772                            for (int i = 0; i < orderByConditionFields.length; i++) {
2773                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2774                                    query.append(orderByConditionFields[i]);
2775    
2776                                    if ((i + 1) < orderByConditionFields.length) {
2777                                            if (orderByComparator.isAscending() ^ previous) {
2778                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2779                                            }
2780                                            else {
2781                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2782                                            }
2783                                    }
2784                                    else {
2785                                            if (orderByComparator.isAscending() ^ previous) {
2786                                                    query.append(WHERE_GREATER_THAN);
2787                                            }
2788                                            else {
2789                                                    query.append(WHERE_LESSER_THAN);
2790                                            }
2791                                    }
2792                            }
2793    
2794                            query.append(ORDER_BY_CLAUSE);
2795    
2796                            String[] orderByFields = orderByComparator.getOrderByFields();
2797    
2798                            for (int i = 0; i < orderByFields.length; i++) {
2799                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2800                                    query.append(orderByFields[i]);
2801    
2802                                    if ((i + 1) < orderByFields.length) {
2803                                            if (orderByComparator.isAscending() ^ previous) {
2804                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2805                                            }
2806                                            else {
2807                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2808                                            }
2809                                    }
2810                                    else {
2811                                            if (orderByComparator.isAscending() ^ previous) {
2812                                                    query.append(ORDER_BY_ASC);
2813                                            }
2814                                            else {
2815                                                    query.append(ORDER_BY_DESC);
2816                                            }
2817                                    }
2818                            }
2819                    }
2820    
2821                    else {
2822                            query.append(SocialActivityModelImpl.ORDER_BY_JPQL);
2823                    }
2824    
2825                    String sql = query.toString();
2826    
2827                    Query q = session.createQuery(sql);
2828    
2829                    q.setFirstResult(0);
2830                    q.setMaxResults(2);
2831    
2832                    QueryPos qPos = QueryPos.getInstance(q);
2833    
2834                    qPos.add(receiverUserId);
2835    
2836                    if (orderByComparator != null) {
2837                            Object[] values = orderByComparator.getOrderByConditionValues(socialActivity);
2838    
2839                            for (Object value : values) {
2840                                    qPos.add(value);
2841                            }
2842                    }
2843    
2844                    List<SocialActivity> list = q.list();
2845    
2846                    if (list.size() == 2) {
2847                            return list.get(1);
2848                    }
2849                    else {
2850                            return null;
2851                    }
2852            }
2853    
2854            /**
2855             * Returns all the social activities where classNameId = &#63; and classPK = &#63;.
2856             *
2857             * @param classNameId the class name ID
2858             * @param classPK the class p k
2859             * @return the matching social activities
2860             * @throws SystemException if a system exception occurred
2861             */
2862            public List<SocialActivity> findByC_C(long classNameId, long classPK)
2863                    throws SystemException {
2864                    return findByC_C(classNameId, classPK, QueryUtil.ALL_POS,
2865                            QueryUtil.ALL_POS, null);
2866            }
2867    
2868            /**
2869             * Returns a range of all the social activities where classNameId = &#63; and classPK = &#63;.
2870             *
2871             * <p>
2872             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2873             * </p>
2874             *
2875             * @param classNameId the class name ID
2876             * @param classPK the class p k
2877             * @param start the lower bound of the range of social activities
2878             * @param end the upper bound of the range of social activities (not inclusive)
2879             * @return the range of matching social activities
2880             * @throws SystemException if a system exception occurred
2881             */
2882            public List<SocialActivity> findByC_C(long classNameId, long classPK,
2883                    int start, int end) throws SystemException {
2884                    return findByC_C(classNameId, classPK, start, end, null);
2885            }
2886    
2887            /**
2888             * Returns an ordered range of all the social activities where classNameId = &#63; and classPK = &#63;.
2889             *
2890             * <p>
2891             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2892             * </p>
2893             *
2894             * @param classNameId the class name ID
2895             * @param classPK the class p k
2896             * @param start the lower bound of the range of social activities
2897             * @param end the upper bound of the range of social activities (not inclusive)
2898             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2899             * @return the ordered range of matching social activities
2900             * @throws SystemException if a system exception occurred
2901             */
2902            public List<SocialActivity> findByC_C(long classNameId, long classPK,
2903                    int start, int end, OrderByComparator orderByComparator)
2904                    throws SystemException {
2905                    FinderPath finderPath = null;
2906                    Object[] finderArgs = null;
2907    
2908                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2909                                    (orderByComparator == null)) {
2910                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C;
2911                            finderArgs = new Object[] { classNameId, classPK };
2912                    }
2913                    else {
2914                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C;
2915                            finderArgs = new Object[] {
2916                                            classNameId, classPK,
2917                                            
2918                                            start, end, orderByComparator
2919                                    };
2920                    }
2921    
2922                    List<SocialActivity> list = (List<SocialActivity>)FinderCacheUtil.getResult(finderPath,
2923                                    finderArgs, this);
2924    
2925                    if ((list != null) && !list.isEmpty()) {
2926                            for (SocialActivity socialActivity : list) {
2927                                    if ((classNameId != socialActivity.getClassNameId()) ||
2928                                                    (classPK != socialActivity.getClassPK())) {
2929                                            list = null;
2930    
2931                                            break;
2932                                    }
2933                            }
2934                    }
2935    
2936                    if (list == null) {
2937                            StringBundler query = null;
2938    
2939                            if (orderByComparator != null) {
2940                                    query = new StringBundler(4 +
2941                                                    (orderByComparator.getOrderByFields().length * 3));
2942                            }
2943                            else {
2944                                    query = new StringBundler(4);
2945                            }
2946    
2947                            query.append(_SQL_SELECT_SOCIALACTIVITY_WHERE);
2948    
2949                            query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
2950    
2951                            query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
2952    
2953                            if (orderByComparator != null) {
2954                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2955                                            orderByComparator);
2956                            }
2957    
2958                            else {
2959                                    query.append(SocialActivityModelImpl.ORDER_BY_JPQL);
2960                            }
2961    
2962                            String sql = query.toString();
2963    
2964                            Session session = null;
2965    
2966                            try {
2967                                    session = openSession();
2968    
2969                                    Query q = session.createQuery(sql);
2970    
2971                                    QueryPos qPos = QueryPos.getInstance(q);
2972    
2973                                    qPos.add(classNameId);
2974    
2975                                    qPos.add(classPK);
2976    
2977                                    list = (List<SocialActivity>)QueryUtil.list(q, getDialect(),
2978                                                    start, end);
2979                            }
2980                            catch (Exception e) {
2981                                    throw processException(e);
2982                            }
2983                            finally {
2984                                    if (list == null) {
2985                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
2986                                    }
2987                                    else {
2988                                            cacheResult(list);
2989    
2990                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
2991                                    }
2992    
2993                                    closeSession(session);
2994                            }
2995                    }
2996    
2997                    return list;
2998            }
2999    
3000            /**
3001             * Returns the first social activity in the ordered set where classNameId = &#63; and classPK = &#63;.
3002             *
3003             * <p>
3004             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3005             * </p>
3006             *
3007             * @param classNameId the class name ID
3008             * @param classPK the class p k
3009             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3010             * @return the first matching social activity
3011             * @throws com.liferay.portlet.social.NoSuchActivityException if a matching social activity could not be found
3012             * @throws SystemException if a system exception occurred
3013             */
3014            public SocialActivity findByC_C_First(long classNameId, long classPK,
3015                    OrderByComparator orderByComparator)
3016                    throws NoSuchActivityException, SystemException {
3017                    List<SocialActivity> list = findByC_C(classNameId, classPK, 0, 1,
3018                                    orderByComparator);
3019    
3020                    if (list.isEmpty()) {
3021                            StringBundler msg = new StringBundler(6);
3022    
3023                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3024    
3025                            msg.append("classNameId=");
3026                            msg.append(classNameId);
3027    
3028                            msg.append(", classPK=");
3029                            msg.append(classPK);
3030    
3031                            msg.append(StringPool.CLOSE_CURLY_BRACE);
3032    
3033                            throw new NoSuchActivityException(msg.toString());
3034                    }
3035                    else {
3036                            return list.get(0);
3037                    }
3038            }
3039    
3040            /**
3041             * Returns the last social activity in the ordered set where classNameId = &#63; and classPK = &#63;.
3042             *
3043             * <p>
3044             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3045             * </p>
3046             *
3047             * @param classNameId the class name ID
3048             * @param classPK the class p k
3049             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3050             * @return the last matching social activity
3051             * @throws com.liferay.portlet.social.NoSuchActivityException if a matching social activity could not be found
3052             * @throws SystemException if a system exception occurred
3053             */
3054            public SocialActivity findByC_C_Last(long classNameId, long classPK,
3055                    OrderByComparator orderByComparator)
3056                    throws NoSuchActivityException, SystemException {
3057                    int count = countByC_C(classNameId, classPK);
3058    
3059                    List<SocialActivity> list = findByC_C(classNameId, classPK, count - 1,
3060                                    count, orderByComparator);
3061    
3062                    if (list.isEmpty()) {
3063                            StringBundler msg = new StringBundler(6);
3064    
3065                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3066    
3067                            msg.append("classNameId=");
3068                            msg.append(classNameId);
3069    
3070                            msg.append(", classPK=");
3071                            msg.append(classPK);
3072    
3073                            msg.append(StringPool.CLOSE_CURLY_BRACE);
3074    
3075                            throw new NoSuchActivityException(msg.toString());
3076                    }
3077                    else {
3078                            return list.get(0);
3079                    }
3080            }
3081    
3082            /**
3083             * Returns the social activities before and after the current social activity in the ordered set where classNameId = &#63; and classPK = &#63;.
3084             *
3085             * <p>
3086             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3087             * </p>
3088             *
3089             * @param activityId the primary key of the current social activity
3090             * @param classNameId the class name ID
3091             * @param classPK the class p k
3092             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3093             * @return the previous, current, and next social activity
3094             * @throws com.liferay.portlet.social.NoSuchActivityException if a social activity with the primary key could not be found
3095             * @throws SystemException if a system exception occurred
3096             */
3097            public SocialActivity[] findByC_C_PrevAndNext(long activityId,
3098                    long classNameId, long classPK, OrderByComparator orderByComparator)
3099                    throws NoSuchActivityException, SystemException {
3100                    SocialActivity socialActivity = findByPrimaryKey(activityId);
3101    
3102                    Session session = null;
3103    
3104                    try {
3105                            session = openSession();
3106    
3107                            SocialActivity[] array = new SocialActivityImpl[3];
3108    
3109                            array[0] = getByC_C_PrevAndNext(session, socialActivity,
3110                                            classNameId, classPK, orderByComparator, true);
3111    
3112                            array[1] = socialActivity;
3113    
3114                            array[2] = getByC_C_PrevAndNext(session, socialActivity,
3115                                            classNameId, classPK, orderByComparator, false);
3116    
3117                            return array;
3118                    }
3119                    catch (Exception e) {
3120                            throw processException(e);
3121                    }
3122                    finally {
3123                            closeSession(session);
3124                    }
3125            }
3126    
3127            protected SocialActivity getByC_C_PrevAndNext(Session session,
3128                    SocialActivity socialActivity, long classNameId, long classPK,
3129                    OrderByComparator orderByComparator, boolean previous) {
3130                    StringBundler query = null;
3131    
3132                    if (orderByComparator != null) {
3133                            query = new StringBundler(6 +
3134                                            (orderByComparator.getOrderByFields().length * 6));
3135                    }
3136                    else {
3137                            query = new StringBundler(3);
3138                    }
3139    
3140                    query.append(_SQL_SELECT_SOCIALACTIVITY_WHERE);
3141    
3142                    query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
3143    
3144                    query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
3145    
3146                    if (orderByComparator != null) {
3147                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3148    
3149                            if (orderByConditionFields.length > 0) {
3150                                    query.append(WHERE_AND);
3151                            }
3152    
3153                            for (int i = 0; i < orderByConditionFields.length; i++) {
3154                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3155                                    query.append(orderByConditionFields[i]);
3156    
3157                                    if ((i + 1) < orderByConditionFields.length) {
3158                                            if (orderByComparator.isAscending() ^ previous) {
3159                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3160                                            }
3161                                            else {
3162                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3163                                            }
3164                                    }
3165                                    else {
3166                                            if (orderByComparator.isAscending() ^ previous) {
3167                                                    query.append(WHERE_GREATER_THAN);
3168                                            }
3169                                            else {
3170                                                    query.append(WHERE_LESSER_THAN);
3171                                            }
3172                                    }
3173                            }
3174    
3175                            query.append(ORDER_BY_CLAUSE);
3176    
3177                            String[] orderByFields = orderByComparator.getOrderByFields();
3178    
3179                            for (int i = 0; i < orderByFields.length; i++) {
3180                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3181                                    query.append(orderByFields[i]);
3182    
3183                                    if ((i + 1) < orderByFields.length) {
3184                                            if (orderByComparator.isAscending() ^ previous) {
3185                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3186                                            }
3187                                            else {
3188                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3189                                            }
3190                                    }
3191                                    else {
3192                                            if (orderByComparator.isAscending() ^ previous) {
3193                                                    query.append(ORDER_BY_ASC);
3194                                            }
3195                                            else {
3196                                                    query.append(ORDER_BY_DESC);
3197                                            }
3198                                    }
3199                            }
3200                    }
3201    
3202                    else {
3203                            query.append(SocialActivityModelImpl.ORDER_BY_JPQL);
3204                    }
3205    
3206                    String sql = query.toString();
3207    
3208                    Query q = session.createQuery(sql);
3209    
3210                    q.setFirstResult(0);
3211                    q.setMaxResults(2);
3212    
3213                    QueryPos qPos = QueryPos.getInstance(q);
3214    
3215                    qPos.add(classNameId);
3216    
3217                    qPos.add(classPK);
3218    
3219                    if (orderByComparator != null) {
3220                            Object[] values = orderByComparator.getOrderByConditionValues(socialActivity);
3221    
3222                            for (Object value : values) {
3223                                    qPos.add(value);
3224                            }
3225                    }
3226    
3227                    List<SocialActivity> list = q.list();
3228    
3229                    if (list.size() == 2) {
3230                            return list.get(1);
3231                    }
3232                    else {
3233                            return null;
3234                    }
3235            }
3236    
3237            /**
3238             * Returns all the social activities where mirrorActivityId = &#63; and classNameId = &#63; and classPK = &#63;.
3239             *
3240             * @param mirrorActivityId the mirror activity ID
3241             * @param classNameId the class name ID
3242             * @param classPK the class p k
3243             * @return the matching social activities
3244             * @throws SystemException if a system exception occurred
3245             */
3246            public List<SocialActivity> findByM_C_C(long mirrorActivityId,
3247                    long classNameId, long classPK) throws SystemException {
3248                    return findByM_C_C(mirrorActivityId, classNameId, classPK,
3249                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3250            }
3251    
3252            /**
3253             * Returns a range of all the social activities where mirrorActivityId = &#63; and classNameId = &#63; and classPK = &#63;.
3254             *
3255             * <p>
3256             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3257             * </p>
3258             *
3259             * @param mirrorActivityId the mirror activity ID
3260             * @param classNameId the class name ID
3261             * @param classPK the class p k
3262             * @param start the lower bound of the range of social activities
3263             * @param end the upper bound of the range of social activities (not inclusive)
3264             * @return the range of matching social activities
3265             * @throws SystemException if a system exception occurred
3266             */
3267            public List<SocialActivity> findByM_C_C(long mirrorActivityId,
3268                    long classNameId, long classPK, int start, int end)
3269                    throws SystemException {
3270                    return findByM_C_C(mirrorActivityId, classNameId, classPK, start, end,
3271                            null);
3272            }
3273    
3274            /**
3275             * Returns an ordered range of all the social activities where mirrorActivityId = &#63; and classNameId = &#63; and classPK = &#63;.
3276             *
3277             * <p>
3278             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3279             * </p>
3280             *
3281             * @param mirrorActivityId the mirror activity ID
3282             * @param classNameId the class name ID
3283             * @param classPK the class p k
3284             * @param start the lower bound of the range of social activities
3285             * @param end the upper bound of the range of social activities (not inclusive)
3286             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3287             * @return the ordered range of matching social activities
3288             * @throws SystemException if a system exception occurred
3289             */
3290            public List<SocialActivity> findByM_C_C(long mirrorActivityId,
3291                    long classNameId, long classPK, int start, int end,
3292                    OrderByComparator orderByComparator) throws SystemException {
3293                    FinderPath finderPath = null;
3294                    Object[] finderArgs = null;
3295    
3296                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3297                                    (orderByComparator == null)) {
3298                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_M_C_C;
3299                            finderArgs = new Object[] { mirrorActivityId, classNameId, classPK };
3300                    }
3301                    else {
3302                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_M_C_C;
3303                            finderArgs = new Object[] {
3304                                            mirrorActivityId, classNameId, classPK,
3305                                            
3306                                            start, end, orderByComparator
3307                                    };
3308                    }
3309    
3310                    List<SocialActivity> list = (List<SocialActivity>)FinderCacheUtil.getResult(finderPath,
3311                                    finderArgs, this);
3312    
3313                    if ((list != null) && !list.isEmpty()) {
3314                            for (SocialActivity socialActivity : list) {
3315                                    if ((mirrorActivityId != socialActivity.getMirrorActivityId()) ||
3316                                                    (classNameId != socialActivity.getClassNameId()) ||
3317                                                    (classPK != socialActivity.getClassPK())) {
3318                                            list = null;
3319    
3320                                            break;
3321                                    }
3322                            }
3323                    }
3324    
3325                    if (list == null) {
3326                            StringBundler query = null;
3327    
3328                            if (orderByComparator != null) {
3329                                    query = new StringBundler(5 +
3330                                                    (orderByComparator.getOrderByFields().length * 3));
3331                            }
3332                            else {
3333                                    query = new StringBundler(5);
3334                            }
3335    
3336                            query.append(_SQL_SELECT_SOCIALACTIVITY_WHERE);
3337    
3338                            query.append(_FINDER_COLUMN_M_C_C_MIRRORACTIVITYID_2);
3339    
3340                            query.append(_FINDER_COLUMN_M_C_C_CLASSNAMEID_2);
3341    
3342                            query.append(_FINDER_COLUMN_M_C_C_CLASSPK_2);
3343    
3344                            if (orderByComparator != null) {
3345                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3346                                            orderByComparator);
3347                            }
3348    
3349                            else {
3350                                    query.append(SocialActivityModelImpl.ORDER_BY_JPQL);
3351                            }
3352    
3353                            String sql = query.toString();
3354    
3355                            Session session = null;
3356    
3357                            try {
3358                                    session = openSession();
3359    
3360                                    Query q = session.createQuery(sql);
3361    
3362                                    QueryPos qPos = QueryPos.getInstance(q);
3363    
3364                                    qPos.add(mirrorActivityId);
3365    
3366                                    qPos.add(classNameId);
3367    
3368                                    qPos.add(classPK);
3369    
3370                                    list = (List<SocialActivity>)QueryUtil.list(q, getDialect(),
3371                                                    start, end);
3372                            }
3373                            catch (Exception e) {
3374                                    throw processException(e);
3375                            }
3376                            finally {
3377                                    if (list == null) {
3378                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
3379                                    }
3380                                    else {
3381                                            cacheResult(list);
3382    
3383                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
3384                                    }
3385    
3386                                    closeSession(session);
3387                            }
3388                    }
3389    
3390                    return list;
3391            }
3392    
3393            /**
3394             * Returns the first social activity in the ordered set where mirrorActivityId = &#63; and classNameId = &#63; and classPK = &#63;.
3395             *
3396             * <p>
3397             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3398             * </p>
3399             *
3400             * @param mirrorActivityId the mirror activity ID
3401             * @param classNameId the class name ID
3402             * @param classPK the class p k
3403             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3404             * @return the first matching social activity
3405             * @throws com.liferay.portlet.social.NoSuchActivityException if a matching social activity could not be found
3406             * @throws SystemException if a system exception occurred
3407             */
3408            public SocialActivity findByM_C_C_First(long mirrorActivityId,
3409                    long classNameId, long classPK, OrderByComparator orderByComparator)
3410                    throws NoSuchActivityException, SystemException {
3411                    List<SocialActivity> list = findByM_C_C(mirrorActivityId, classNameId,
3412                                    classPK, 0, 1, orderByComparator);
3413    
3414                    if (list.isEmpty()) {
3415                            StringBundler msg = new StringBundler(8);
3416    
3417                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3418    
3419                            msg.append("mirrorActivityId=");
3420                            msg.append(mirrorActivityId);
3421    
3422                            msg.append(", classNameId=");
3423                            msg.append(classNameId);
3424    
3425                            msg.append(", classPK=");
3426                            msg.append(classPK);
3427    
3428                            msg.append(StringPool.CLOSE_CURLY_BRACE);
3429    
3430                            throw new NoSuchActivityException(msg.toString());
3431                    }
3432                    else {
3433                            return list.get(0);
3434                    }
3435            }
3436    
3437            /**
3438             * Returns the last social activity in the ordered set where mirrorActivityId = &#63; and classNameId = &#63; and classPK = &#63;.
3439             *
3440             * <p>
3441             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3442             * </p>
3443             *
3444             * @param mirrorActivityId the mirror activity ID
3445             * @param classNameId the class name ID
3446             * @param classPK the class p k
3447             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3448             * @return the last matching social activity
3449             * @throws com.liferay.portlet.social.NoSuchActivityException if a matching social activity could not be found
3450             * @throws SystemException if a system exception occurred
3451             */
3452            public SocialActivity findByM_C_C_Last(long mirrorActivityId,
3453                    long classNameId, long classPK, OrderByComparator orderByComparator)
3454                    throws NoSuchActivityException, SystemException {
3455                    int count = countByM_C_C(mirrorActivityId, classNameId, classPK);
3456    
3457                    List<SocialActivity> list = findByM_C_C(mirrorActivityId, classNameId,
3458                                    classPK, count - 1, count, orderByComparator);
3459    
3460                    if (list.isEmpty()) {
3461                            StringBundler msg = new StringBundler(8);
3462    
3463                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3464    
3465                            msg.append("mirrorActivityId=");
3466                            msg.append(mirrorActivityId);
3467    
3468                            msg.append(", classNameId=");
3469                            msg.append(classNameId);
3470    
3471                            msg.append(", classPK=");
3472                            msg.append(classPK);
3473    
3474                            msg.append(StringPool.CLOSE_CURLY_BRACE);
3475    
3476                            throw new NoSuchActivityException(msg.toString());
3477                    }
3478                    else {
3479                            return list.get(0);
3480                    }
3481            }
3482    
3483            /**
3484             * Returns the social activities before and after the current social activity in the ordered set where mirrorActivityId = &#63; and classNameId = &#63; and classPK = &#63;.
3485             *
3486             * <p>
3487             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3488             * </p>
3489             *
3490             * @param activityId the primary key of the current social activity
3491             * @param mirrorActivityId the mirror activity ID
3492             * @param classNameId the class name ID
3493             * @param classPK the class p k
3494             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3495             * @return the previous, current, and next social activity
3496             * @throws com.liferay.portlet.social.NoSuchActivityException if a social activity with the primary key could not be found
3497             * @throws SystemException if a system exception occurred
3498             */
3499            public SocialActivity[] findByM_C_C_PrevAndNext(long activityId,
3500                    long mirrorActivityId, long classNameId, long classPK,
3501                    OrderByComparator orderByComparator)
3502                    throws NoSuchActivityException, SystemException {
3503                    SocialActivity socialActivity = findByPrimaryKey(activityId);
3504    
3505                    Session session = null;
3506    
3507                    try {
3508                            session = openSession();
3509    
3510                            SocialActivity[] array = new SocialActivityImpl[3];
3511    
3512                            array[0] = getByM_C_C_PrevAndNext(session, socialActivity,
3513                                            mirrorActivityId, classNameId, classPK, orderByComparator,
3514                                            true);
3515    
3516                            array[1] = socialActivity;
3517    
3518                            array[2] = getByM_C_C_PrevAndNext(session, socialActivity,
3519                                            mirrorActivityId, classNameId, classPK, orderByComparator,
3520                                            false);
3521    
3522                            return array;
3523                    }
3524                    catch (Exception e) {
3525                            throw processException(e);
3526                    }
3527                    finally {
3528                            closeSession(session);
3529                    }
3530            }
3531    
3532            protected SocialActivity getByM_C_C_PrevAndNext(Session session,
3533                    SocialActivity socialActivity, long mirrorActivityId, long classNameId,
3534                    long classPK, OrderByComparator orderByComparator, boolean previous) {
3535                    StringBundler query = null;
3536    
3537                    if (orderByComparator != null) {
3538                            query = new StringBundler(6 +
3539                                            (orderByComparator.getOrderByFields().length * 6));
3540                    }
3541                    else {
3542                            query = new StringBundler(3);
3543                    }
3544    
3545                    query.append(_SQL_SELECT_SOCIALACTIVITY_WHERE);
3546    
3547                    query.append(_FINDER_COLUMN_M_C_C_MIRRORACTIVITYID_2);
3548    
3549                    query.append(_FINDER_COLUMN_M_C_C_CLASSNAMEID_2);
3550    
3551                    query.append(_FINDER_COLUMN_M_C_C_CLASSPK_2);
3552    
3553                    if (orderByComparator != null) {
3554                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3555    
3556                            if (orderByConditionFields.length > 0) {
3557                                    query.append(WHERE_AND);
3558                            }
3559    
3560                            for (int i = 0; i < orderByConditionFields.length; i++) {
3561                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3562                                    query.append(orderByConditionFields[i]);
3563    
3564                                    if ((i + 1) < orderByConditionFields.length) {
3565                                            if (orderByComparator.isAscending() ^ previous) {
3566                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3567                                            }
3568                                            else {
3569                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3570                                            }
3571                                    }
3572                                    else {
3573                                            if (orderByComparator.isAscending() ^ previous) {
3574                                                    query.append(WHERE_GREATER_THAN);
3575                                            }
3576                                            else {
3577                                                    query.append(WHERE_LESSER_THAN);
3578                                            }
3579                                    }
3580                            }
3581    
3582                            query.append(ORDER_BY_CLAUSE);
3583    
3584                            String[] orderByFields = orderByComparator.getOrderByFields();
3585    
3586                            for (int i = 0; i < orderByFields.length; i++) {
3587                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3588                                    query.append(orderByFields[i]);
3589    
3590                                    if ((i + 1) < orderByFields.length) {
3591                                            if (orderByComparator.isAscending() ^ previous) {
3592                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3593                                            }
3594                                            else {
3595                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3596                                            }
3597                                    }
3598                                    else {
3599                                            if (orderByComparator.isAscending() ^ previous) {
3600                                                    query.append(ORDER_BY_ASC);
3601                                            }
3602                                            else {
3603                                                    query.append(ORDER_BY_DESC);
3604                                            }
3605                                    }
3606                            }
3607                    }
3608    
3609                    else {
3610                            query.append(SocialActivityModelImpl.ORDER_BY_JPQL);
3611                    }
3612    
3613                    String sql = query.toString();
3614    
3615                    Query q = session.createQuery(sql);
3616    
3617                    q.setFirstResult(0);
3618                    q.setMaxResults(2);
3619    
3620                    QueryPos qPos = QueryPos.getInstance(q);
3621    
3622                    qPos.add(mirrorActivityId);
3623    
3624                    qPos.add(classNameId);
3625    
3626                    qPos.add(classPK);
3627    
3628                    if (orderByComparator != null) {
3629                            Object[] values = orderByComparator.getOrderByConditionValues(socialActivity);
3630    
3631                            for (Object value : values) {
3632                                    qPos.add(value);
3633                            }
3634                    }
3635    
3636                    List<SocialActivity> list = q.list();
3637    
3638                    if (list.size() == 2) {
3639                            return list.get(1);
3640                    }
3641                    else {
3642                            return null;
3643                    }
3644            }
3645    
3646            /**
3647             * Returns all the social activities where groupId = &#63; and userId = &#63; and classNameId = &#63; and classPK = &#63; and type = &#63; and receiverUserId = &#63;.
3648             *
3649             * @param groupId the group ID
3650             * @param userId the user ID
3651             * @param classNameId the class name ID
3652             * @param classPK the class p k
3653             * @param type the type
3654             * @param receiverUserId the receiver user ID
3655             * @return the matching social activities
3656             * @throws SystemException if a system exception occurred
3657             */
3658            public List<SocialActivity> findByG_U_C_C_T_R(long groupId, long userId,
3659                    long classNameId, long classPK, int type, long receiverUserId)
3660                    throws SystemException {
3661                    return findByG_U_C_C_T_R(groupId, userId, classNameId, classPK, type,
3662                            receiverUserId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3663            }
3664    
3665            /**
3666             * Returns a range of all the social activities where groupId = &#63; and userId = &#63; and classNameId = &#63; and classPK = &#63; and type = &#63; and receiverUserId = &#63;.
3667             *
3668             * <p>
3669             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3670             * </p>
3671             *
3672             * @param groupId the group ID
3673             * @param userId the user ID
3674             * @param classNameId the class name ID
3675             * @param classPK the class p k
3676             * @param type the type
3677             * @param receiverUserId the receiver user ID
3678             * @param start the lower bound of the range of social activities
3679             * @param end the upper bound of the range of social activities (not inclusive)
3680             * @return the range of matching social activities
3681             * @throws SystemException if a system exception occurred
3682             */
3683            public List<SocialActivity> findByG_U_C_C_T_R(long groupId, long userId,
3684                    long classNameId, long classPK, int type, long receiverUserId,
3685                    int start, int end) throws SystemException {
3686                    return findByG_U_C_C_T_R(groupId, userId, classNameId, classPK, type,
3687                            receiverUserId, start, end, null);
3688            }
3689    
3690            /**
3691             * Returns an ordered range of all the social activities where groupId = &#63; and userId = &#63; and classNameId = &#63; and classPK = &#63; and type = &#63; and receiverUserId = &#63;.
3692             *
3693             * <p>
3694             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3695             * </p>
3696             *
3697             * @param groupId the group ID
3698             * @param userId the user ID
3699             * @param classNameId the class name ID
3700             * @param classPK the class p k
3701             * @param type the type
3702             * @param receiverUserId the receiver user ID
3703             * @param start the lower bound of the range of social activities
3704             * @param end the upper bound of the range of social activities (not inclusive)
3705             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3706             * @return the ordered range of matching social activities
3707             * @throws SystemException if a system exception occurred
3708             */
3709            public List<SocialActivity> findByG_U_C_C_T_R(long groupId, long userId,
3710                    long classNameId, long classPK, int type, long receiverUserId,
3711                    int start, int end, OrderByComparator orderByComparator)
3712                    throws SystemException {
3713                    FinderPath finderPath = null;
3714                    Object[] finderArgs = null;
3715    
3716                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3717                                    (orderByComparator == null)) {
3718                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_C_C_T_R;
3719                            finderArgs = new Object[] {
3720                                            groupId, userId, classNameId, classPK, type, receiverUserId
3721                                    };
3722                    }
3723                    else {
3724                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_C_C_T_R;
3725                            finderArgs = new Object[] {
3726                                            groupId, userId, classNameId, classPK, type, receiverUserId,
3727                                            
3728                                            start, end, orderByComparator
3729                                    };
3730                    }
3731    
3732                    List<SocialActivity> list = (List<SocialActivity>)FinderCacheUtil.getResult(finderPath,
3733                                    finderArgs, this);
3734    
3735                    if ((list != null) && !list.isEmpty()) {
3736                            for (SocialActivity socialActivity : list) {
3737                                    if ((groupId != socialActivity.getGroupId()) ||
3738                                                    (userId != socialActivity.getUserId()) ||
3739                                                    (classNameId != socialActivity.getClassNameId()) ||
3740                                                    (classPK != socialActivity.getClassPK()) ||
3741                                                    (type != socialActivity.getType()) ||
3742                                                    (receiverUserId != socialActivity.getReceiverUserId())) {
3743                                            list = null;
3744    
3745                                            break;
3746                                    }
3747                            }
3748                    }
3749    
3750                    if (list == null) {
3751                            StringBundler query = null;
3752    
3753                            if (orderByComparator != null) {
3754                                    query = new StringBundler(8 +
3755                                                    (orderByComparator.getOrderByFields().length * 3));
3756                            }
3757                            else {
3758                                    query = new StringBundler(8);
3759                            }
3760    
3761                            query.append(_SQL_SELECT_SOCIALACTIVITY_WHERE);
3762    
3763                            query.append(_FINDER_COLUMN_G_U_C_C_T_R_GROUPID_2);
3764    
3765                            query.append(_FINDER_COLUMN_G_U_C_C_T_R_USERID_2);
3766    
3767                            query.append(_FINDER_COLUMN_G_U_C_C_T_R_CLASSNAMEID_2);
3768    
3769                            query.append(_FINDER_COLUMN_G_U_C_C_T_R_CLASSPK_2);
3770    
3771                            query.append(_FINDER_COLUMN_G_U_C_C_T_R_TYPE_2);
3772    
3773                            query.append(_FINDER_COLUMN_G_U_C_C_T_R_RECEIVERUSERID_2);
3774    
3775                            if (orderByComparator != null) {
3776                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3777                                            orderByComparator);
3778                            }
3779    
3780                            else {
3781                                    query.append(SocialActivityModelImpl.ORDER_BY_JPQL);
3782                            }
3783    
3784                            String sql = query.toString();
3785    
3786                            Session session = null;
3787    
3788                            try {
3789                                    session = openSession();
3790    
3791                                    Query q = session.createQuery(sql);
3792    
3793                                    QueryPos qPos = QueryPos.getInstance(q);
3794    
3795                                    qPos.add(groupId);
3796    
3797                                    qPos.add(userId);
3798    
3799                                    qPos.add(classNameId);
3800    
3801                                    qPos.add(classPK);
3802    
3803                                    qPos.add(type);
3804    
3805                                    qPos.add(receiverUserId);
3806    
3807                                    list = (List<SocialActivity>)QueryUtil.list(q, getDialect(),
3808                                                    start, end);
3809                            }
3810                            catch (Exception e) {
3811                                    throw processException(e);
3812                            }
3813                            finally {
3814                                    if (list == null) {
3815                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
3816                                    }
3817                                    else {
3818                                            cacheResult(list);
3819    
3820                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
3821                                    }
3822    
3823                                    closeSession(session);
3824                            }
3825                    }
3826    
3827                    return list;
3828            }
3829    
3830            /**
3831             * Returns the first social activity in the ordered set where groupId = &#63; and userId = &#63; and classNameId = &#63; and classPK = &#63; and type = &#63; and receiverUserId = &#63;.
3832             *
3833             * <p>
3834             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3835             * </p>
3836             *
3837             * @param groupId the group ID
3838             * @param userId the user ID
3839             * @param classNameId the class name ID
3840             * @param classPK the class p k
3841             * @param type the type
3842             * @param receiverUserId the receiver user ID
3843             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3844             * @return the first matching social activity
3845             * @throws com.liferay.portlet.social.NoSuchActivityException if a matching social activity could not be found
3846             * @throws SystemException if a system exception occurred
3847             */
3848            public SocialActivity findByG_U_C_C_T_R_First(long groupId, long userId,
3849                    long classNameId, long classPK, int type, long receiverUserId,
3850                    OrderByComparator orderByComparator)
3851                    throws NoSuchActivityException, SystemException {
3852                    List<SocialActivity> list = findByG_U_C_C_T_R(groupId, userId,
3853                                    classNameId, classPK, type, receiverUserId, 0, 1,
3854                                    orderByComparator);
3855    
3856                    if (list.isEmpty()) {
3857                            StringBundler msg = new StringBundler(14);
3858    
3859                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3860    
3861                            msg.append("groupId=");
3862                            msg.append(groupId);
3863    
3864                            msg.append(", userId=");
3865                            msg.append(userId);
3866    
3867                            msg.append(", classNameId=");
3868                            msg.append(classNameId);
3869    
3870                            msg.append(", classPK=");
3871                            msg.append(classPK);
3872    
3873                            msg.append(", type=");
3874                            msg.append(type);
3875    
3876                            msg.append(", receiverUserId=");
3877                            msg.append(receiverUserId);
3878    
3879                            msg.append(StringPool.CLOSE_CURLY_BRACE);
3880    
3881                            throw new NoSuchActivityException(msg.toString());
3882                    }
3883                    else {
3884                            return list.get(0);
3885                    }
3886            }
3887    
3888            /**
3889             * Returns the last social activity in the ordered set where groupId = &#63; and userId = &#63; and classNameId = &#63; and classPK = &#63; and type = &#63; and receiverUserId = &#63;.
3890             *
3891             * <p>
3892             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3893             * </p>
3894             *
3895             * @param groupId the group ID
3896             * @param userId the user ID
3897             * @param classNameId the class name ID
3898             * @param classPK the class p k
3899             * @param type the type
3900             * @param receiverUserId the receiver user ID
3901             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3902             * @return the last matching social activity
3903             * @throws com.liferay.portlet.social.NoSuchActivityException if a matching social activity could not be found
3904             * @throws SystemException if a system exception occurred
3905             */
3906            public SocialActivity findByG_U_C_C_T_R_Last(long groupId, long userId,
3907                    long classNameId, long classPK, int type, long receiverUserId,
3908                    OrderByComparator orderByComparator)
3909                    throws NoSuchActivityException, SystemException {
3910                    int count = countByG_U_C_C_T_R(groupId, userId, classNameId, classPK,
3911                                    type, receiverUserId);
3912    
3913                    List<SocialActivity> list = findByG_U_C_C_T_R(groupId, userId,
3914                                    classNameId, classPK, type, receiverUserId, count - 1, count,
3915                                    orderByComparator);
3916    
3917                    if (list.isEmpty()) {
3918                            StringBundler msg = new StringBundler(14);
3919    
3920                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3921    
3922                            msg.append("groupId=");
3923                            msg.append(groupId);
3924    
3925                            msg.append(", userId=");
3926                            msg.append(userId);
3927    
3928                            msg.append(", classNameId=");
3929                            msg.append(classNameId);
3930    
3931                            msg.append(", classPK=");
3932                            msg.append(classPK);
3933    
3934                            msg.append(", type=");
3935                            msg.append(type);
3936    
3937                            msg.append(", receiverUserId=");
3938                            msg.append(receiverUserId);
3939    
3940                            msg.append(StringPool.CLOSE_CURLY_BRACE);
3941    
3942                            throw new NoSuchActivityException(msg.toString());
3943                    }
3944                    else {
3945                            return list.get(0);
3946                    }
3947            }
3948    
3949            /**
3950             * Returns the social activities before and after the current social activity in the ordered set where groupId = &#63; and userId = &#63; and classNameId = &#63; and classPK = &#63; and type = &#63; and receiverUserId = &#63;.
3951             *
3952             * <p>
3953             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3954             * </p>
3955             *
3956             * @param activityId the primary key of the current social activity
3957             * @param groupId the group ID
3958             * @param userId the user ID
3959             * @param classNameId the class name ID
3960             * @param classPK the class p k
3961             * @param type the type
3962             * @param receiverUserId the receiver user ID
3963             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3964             * @return the previous, current, and next social activity
3965             * @throws com.liferay.portlet.social.NoSuchActivityException if a social activity with the primary key could not be found
3966             * @throws SystemException if a system exception occurred
3967             */
3968            public SocialActivity[] findByG_U_C_C_T_R_PrevAndNext(long activityId,
3969                    long groupId, long userId, long classNameId, long classPK, int type,
3970                    long receiverUserId, OrderByComparator orderByComparator)
3971                    throws NoSuchActivityException, SystemException {
3972                    SocialActivity socialActivity = findByPrimaryKey(activityId);
3973    
3974                    Session session = null;
3975    
3976                    try {
3977                            session = openSession();
3978    
3979                            SocialActivity[] array = new SocialActivityImpl[3];
3980    
3981                            array[0] = getByG_U_C_C_T_R_PrevAndNext(session, socialActivity,
3982                                            groupId, userId, classNameId, classPK, type,
3983                                            receiverUserId, orderByComparator, true);
3984    
3985                            array[1] = socialActivity;
3986    
3987                            array[2] = getByG_U_C_C_T_R_PrevAndNext(session, socialActivity,
3988                                            groupId, userId, classNameId, classPK, type,
3989                                            receiverUserId, orderByComparator, false);
3990    
3991                            return array;
3992                    }
3993                    catch (Exception e) {
3994                            throw processException(e);
3995                    }
3996                    finally {
3997                            closeSession(session);
3998                    }
3999            }
4000    
4001            protected SocialActivity getByG_U_C_C_T_R_PrevAndNext(Session session,
4002                    SocialActivity socialActivity, long groupId, long userId,
4003                    long classNameId, long classPK, int type, long receiverUserId,
4004                    OrderByComparator orderByComparator, boolean previous) {
4005                    StringBundler query = null;
4006    
4007                    if (orderByComparator != null) {
4008                            query = new StringBundler(6 +
4009                                            (orderByComparator.getOrderByFields().length * 6));
4010                    }
4011                    else {
4012                            query = new StringBundler(3);
4013                    }
4014    
4015                    query.append(_SQL_SELECT_SOCIALACTIVITY_WHERE);
4016    
4017                    query.append(_FINDER_COLUMN_G_U_C_C_T_R_GROUPID_2);
4018    
4019                    query.append(_FINDER_COLUMN_G_U_C_C_T_R_USERID_2);
4020    
4021                    query.append(_FINDER_COLUMN_G_U_C_C_T_R_CLASSNAMEID_2);
4022    
4023                    query.append(_FINDER_COLUMN_G_U_C_C_T_R_CLASSPK_2);
4024    
4025                    query.append(_FINDER_COLUMN_G_U_C_C_T_R_TYPE_2);
4026    
4027                    query.append(_FINDER_COLUMN_G_U_C_C_T_R_RECEIVERUSERID_2);
4028    
4029                    if (orderByComparator != null) {
4030                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4031    
4032                            if (orderByConditionFields.length > 0) {
4033                                    query.append(WHERE_AND);
4034                            }
4035    
4036                            for (int i = 0; i < orderByConditionFields.length; i++) {
4037                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4038                                    query.append(orderByConditionFields[i]);
4039    
4040                                    if ((i + 1) < orderByConditionFields.length) {
4041                                            if (orderByComparator.isAscending() ^ previous) {
4042                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4043                                            }
4044                                            else {
4045                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4046                                            }
4047                                    }
4048                                    else {
4049                                            if (orderByComparator.isAscending() ^ previous) {
4050                                                    query.append(WHERE_GREATER_THAN);
4051                                            }
4052                                            else {
4053                                                    query.append(WHERE_LESSER_THAN);
4054                                            }
4055                                    }
4056                            }
4057    
4058                            query.append(ORDER_BY_CLAUSE);
4059    
4060                            String[] orderByFields = orderByComparator.getOrderByFields();
4061    
4062                            for (int i = 0; i < orderByFields.length; i++) {
4063                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4064                                    query.append(orderByFields[i]);
4065    
4066                                    if ((i + 1) < orderByFields.length) {
4067                                            if (orderByComparator.isAscending() ^ previous) {
4068                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4069                                            }
4070                                            else {
4071                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4072                                            }
4073                                    }
4074                                    else {
4075                                            if (orderByComparator.isAscending() ^ previous) {
4076                                                    query.append(ORDER_BY_ASC);
4077                                            }
4078                                            else {
4079                                                    query.append(ORDER_BY_DESC);
4080                                            }
4081                                    }
4082                            }
4083                    }
4084    
4085                    else {
4086                            query.append(SocialActivityModelImpl.ORDER_BY_JPQL);
4087                    }
4088    
4089                    String sql = query.toString();
4090    
4091                    Query q = session.createQuery(sql);
4092    
4093                    q.setFirstResult(0);
4094                    q.setMaxResults(2);
4095    
4096                    QueryPos qPos = QueryPos.getInstance(q);
4097    
4098                    qPos.add(groupId);
4099    
4100                    qPos.add(userId);
4101    
4102                    qPos.add(classNameId);
4103    
4104                    qPos.add(classPK);
4105    
4106                    qPos.add(type);
4107    
4108                    qPos.add(receiverUserId);
4109    
4110                    if (orderByComparator != null) {
4111                            Object[] values = orderByComparator.getOrderByConditionValues(socialActivity);
4112    
4113                            for (Object value : values) {
4114                                    qPos.add(value);
4115                            }
4116                    }
4117    
4118                    List<SocialActivity> list = q.list();
4119    
4120                    if (list.size() == 2) {
4121                            return list.get(1);
4122                    }
4123                    else {
4124                            return null;
4125                    }
4126            }
4127    
4128            /**
4129             * Returns the social activity where groupId = &#63; and userId = &#63; and createDate = &#63; and classNameId = &#63; and classPK = &#63; and type = &#63; and receiverUserId = &#63; or throws a {@link com.liferay.portlet.social.NoSuchActivityException} if it could not be found.
4130             *
4131             * @param groupId the group ID
4132             * @param userId the user ID
4133             * @param createDate the create date
4134             * @param classNameId the class name ID
4135             * @param classPK the class p k
4136             * @param type the type
4137             * @param receiverUserId the receiver user ID
4138             * @return the matching social activity
4139             * @throws com.liferay.portlet.social.NoSuchActivityException if a matching social activity could not be found
4140             * @throws SystemException if a system exception occurred
4141             */
4142            public SocialActivity findByG_U_CD_C_C_T_R(long groupId, long userId,
4143                    long createDate, long classNameId, long classPK, int type,
4144                    long receiverUserId) throws NoSuchActivityException, SystemException {
4145                    SocialActivity socialActivity = fetchByG_U_CD_C_C_T_R(groupId, userId,
4146                                    createDate, classNameId, classPK, type, receiverUserId);
4147    
4148                    if (socialActivity == null) {
4149                            StringBundler msg = new StringBundler(16);
4150    
4151                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4152    
4153                            msg.append("groupId=");
4154                            msg.append(groupId);
4155    
4156                            msg.append(", userId=");
4157                            msg.append(userId);
4158    
4159                            msg.append(", createDate=");
4160                            msg.append(createDate);
4161    
4162                            msg.append(", classNameId=");
4163                            msg.append(classNameId);
4164    
4165                            msg.append(", classPK=");
4166                            msg.append(classPK);
4167    
4168                            msg.append(", type=");
4169                            msg.append(type);
4170    
4171                            msg.append(", receiverUserId=");
4172                            msg.append(receiverUserId);
4173    
4174                            msg.append(StringPool.CLOSE_CURLY_BRACE);
4175    
4176                            if (_log.isWarnEnabled()) {
4177                                    _log.warn(msg.toString());
4178                            }
4179    
4180                            throw new NoSuchActivityException(msg.toString());
4181                    }
4182    
4183                    return socialActivity;
4184            }
4185    
4186            /**
4187             * Returns the social activity where groupId = &#63; and userId = &#63; and createDate = &#63; and classNameId = &#63; and classPK = &#63; and type = &#63; and receiverUserId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
4188             *
4189             * @param groupId the group ID
4190             * @param userId the user ID
4191             * @param createDate the create date
4192             * @param classNameId the class name ID
4193             * @param classPK the class p k
4194             * @param type the type
4195             * @param receiverUserId the receiver user ID
4196             * @return the matching social activity, or <code>null</code> if a matching social activity could not be found
4197             * @throws SystemException if a system exception occurred
4198             */
4199            public SocialActivity fetchByG_U_CD_C_C_T_R(long groupId, long userId,
4200                    long createDate, long classNameId, long classPK, int type,
4201                    long receiverUserId) throws SystemException {
4202                    return fetchByG_U_CD_C_C_T_R(groupId, userId, createDate, classNameId,
4203                            classPK, type, receiverUserId, true);
4204            }
4205    
4206            /**
4207             * Returns the social activity where groupId = &#63; and userId = &#63; and createDate = &#63; and classNameId = &#63; and classPK = &#63; and type = &#63; and receiverUserId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
4208             *
4209             * @param groupId the group ID
4210             * @param userId the user ID
4211             * @param createDate the create date
4212             * @param classNameId the class name ID
4213             * @param classPK the class p k
4214             * @param type the type
4215             * @param receiverUserId the receiver user ID
4216             * @param retrieveFromCache whether to use the finder cache
4217             * @return the matching social activity, or <code>null</code> if a matching social activity could not be found
4218             * @throws SystemException if a system exception occurred
4219             */
4220            public SocialActivity fetchByG_U_CD_C_C_T_R(long groupId, long userId,
4221                    long createDate, long classNameId, long classPK, int type,
4222                    long receiverUserId, boolean retrieveFromCache)
4223                    throws SystemException {
4224                    Object[] finderArgs = new Object[] {
4225                                    groupId, userId, createDate, classNameId, classPK, type,
4226                                    receiverUserId
4227                            };
4228    
4229                    Object result = null;
4230    
4231                    if (retrieveFromCache) {
4232                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_U_CD_C_C_T_R,
4233                                            finderArgs, this);
4234                    }
4235    
4236                    if (result instanceof SocialActivity) {
4237                            SocialActivity socialActivity = (SocialActivity)result;
4238    
4239                            if ((groupId != socialActivity.getGroupId()) ||
4240                                            (userId != socialActivity.getUserId()) ||
4241                                            (createDate != socialActivity.getCreateDate()) ||
4242                                            (classNameId != socialActivity.getClassNameId()) ||
4243                                            (classPK != socialActivity.getClassPK()) ||
4244                                            (type != socialActivity.getType()) ||
4245                                            (receiverUserId != socialActivity.getReceiverUserId())) {
4246                                    result = null;
4247                            }
4248                    }
4249    
4250                    if (result == null) {
4251                            StringBundler query = new StringBundler(9);
4252    
4253                            query.append(_SQL_SELECT_SOCIALACTIVITY_WHERE);
4254    
4255                            query.append(_FINDER_COLUMN_G_U_CD_C_C_T_R_GROUPID_2);
4256    
4257                            query.append(_FINDER_COLUMN_G_U_CD_C_C_T_R_USERID_2);
4258    
4259                            query.append(_FINDER_COLUMN_G_U_CD_C_C_T_R_CREATEDATE_2);
4260    
4261                            query.append(_FINDER_COLUMN_G_U_CD_C_C_T_R_CLASSNAMEID_2);
4262    
4263                            query.append(_FINDER_COLUMN_G_U_CD_C_C_T_R_CLASSPK_2);
4264    
4265                            query.append(_FINDER_COLUMN_G_U_CD_C_C_T_R_TYPE_2);
4266    
4267                            query.append(_FINDER_COLUMN_G_U_CD_C_C_T_R_RECEIVERUSERID_2);
4268    
4269                            query.append(SocialActivityModelImpl.ORDER_BY_JPQL);
4270    
4271                            String sql = query.toString();
4272    
4273                            Session session = null;
4274    
4275                            try {
4276                                    session = openSession();
4277    
4278                                    Query q = session.createQuery(sql);
4279    
4280                                    QueryPos qPos = QueryPos.getInstance(q);
4281    
4282                                    qPos.add(groupId);
4283    
4284                                    qPos.add(userId);
4285    
4286                                    qPos.add(createDate);
4287    
4288                                    qPos.add(classNameId);
4289    
4290                                    qPos.add(classPK);
4291    
4292                                    qPos.add(type);
4293    
4294                                    qPos.add(receiverUserId);
4295    
4296                                    List<SocialActivity> list = q.list();
4297    
4298                                    result = list;
4299    
4300                                    SocialActivity socialActivity = null;
4301    
4302                                    if (list.isEmpty()) {
4303                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_U_CD_C_C_T_R,
4304                                                    finderArgs, list);
4305                                    }
4306                                    else {
4307                                            socialActivity = list.get(0);
4308    
4309                                            cacheResult(socialActivity);
4310    
4311                                            if ((socialActivity.getGroupId() != groupId) ||
4312                                                            (socialActivity.getUserId() != userId) ||
4313                                                            (socialActivity.getCreateDate() != createDate) ||
4314                                                            (socialActivity.getClassNameId() != classNameId) ||
4315                                                            (socialActivity.getClassPK() != classPK) ||
4316                                                            (socialActivity.getType() != type) ||
4317                                                            (socialActivity.getReceiverUserId() != receiverUserId)) {
4318                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_U_CD_C_C_T_R,
4319                                                            finderArgs, socialActivity);
4320                                            }
4321                                    }
4322    
4323                                    return socialActivity;
4324                            }
4325                            catch (Exception e) {
4326                                    throw processException(e);
4327                            }
4328                            finally {
4329                                    if (result == null) {
4330                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_U_CD_C_C_T_R,
4331                                                    finderArgs);
4332                                    }
4333    
4334                                    closeSession(session);
4335                            }
4336                    }
4337                    else {
4338                            if (result instanceof List<?>) {
4339                                    return null;
4340                            }
4341                            else {
4342                                    return (SocialActivity)result;
4343                            }
4344                    }
4345            }
4346    
4347            /**
4348             * Returns all the social activities.
4349             *
4350             * @return the social activities
4351             * @throws SystemException if a system exception occurred
4352             */
4353            public List<SocialActivity> findAll() throws SystemException {
4354                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
4355            }
4356    
4357            /**
4358             * Returns a range of all the social activities.
4359             *
4360             * <p>
4361             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4362             * </p>
4363             *
4364             * @param start the lower bound of the range of social activities
4365             * @param end the upper bound of the range of social activities (not inclusive)
4366             * @return the range of social activities
4367             * @throws SystemException if a system exception occurred
4368             */
4369            public List<SocialActivity> findAll(int start, int end)
4370                    throws SystemException {
4371                    return findAll(start, end, null);
4372            }
4373    
4374            /**
4375             * Returns an ordered range of all the social activities.
4376             *
4377             * <p>
4378             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
4379             * </p>
4380             *
4381             * @param start the lower bound of the range of social activities
4382             * @param end the upper bound of the range of social activities (not inclusive)
4383             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4384             * @return the ordered range of social activities
4385             * @throws SystemException if a system exception occurred
4386             */
4387            public List<SocialActivity> findAll(int start, int end,
4388                    OrderByComparator orderByComparator) throws SystemException {
4389                    FinderPath finderPath = null;
4390                    Object[] finderArgs = new Object[] { start, end, orderByComparator };
4391    
4392                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4393                                    (orderByComparator == null)) {
4394                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
4395                            finderArgs = FINDER_ARGS_EMPTY;
4396                    }
4397                    else {
4398                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
4399                            finderArgs = new Object[] { start, end, orderByComparator };
4400                    }
4401    
4402                    List<SocialActivity> list = (List<SocialActivity>)FinderCacheUtil.getResult(finderPath,
4403                                    finderArgs, this);
4404    
4405                    if (list == null) {
4406                            StringBundler query = null;
4407                            String sql = null;
4408    
4409                            if (orderByComparator != null) {
4410                                    query = new StringBundler(2 +
4411                                                    (orderByComparator.getOrderByFields().length * 3));
4412    
4413                                    query.append(_SQL_SELECT_SOCIALACTIVITY);
4414    
4415                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4416                                            orderByComparator);
4417    
4418                                    sql = query.toString();
4419                            }
4420                            else {
4421                                    sql = _SQL_SELECT_SOCIALACTIVITY.concat(SocialActivityModelImpl.ORDER_BY_JPQL);
4422                            }
4423    
4424                            Session session = null;
4425    
4426                            try {
4427                                    session = openSession();
4428    
4429                                    Query q = session.createQuery(sql);
4430    
4431                                    if (orderByComparator == null) {
4432                                            list = (List<SocialActivity>)QueryUtil.list(q,
4433                                                            getDialect(), start, end, false);
4434    
4435                                            Collections.sort(list);
4436                                    }
4437                                    else {
4438                                            list = (List<SocialActivity>)QueryUtil.list(q,
4439                                                            getDialect(), start, end);
4440                                    }
4441                            }
4442                            catch (Exception e) {
4443                                    throw processException(e);
4444                            }
4445                            finally {
4446                                    if (list == null) {
4447                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
4448                                    }
4449                                    else {
4450                                            cacheResult(list);
4451    
4452                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
4453                                    }
4454    
4455                                    closeSession(session);
4456                            }
4457                    }
4458    
4459                    return list;
4460            }
4461    
4462            /**
4463             * Removes all the social activities where groupId = &#63; from the database.
4464             *
4465             * @param groupId the group ID
4466             * @throws SystemException if a system exception occurred
4467             */
4468            public void removeByGroupId(long groupId) throws SystemException {
4469                    for (SocialActivity socialActivity : findByGroupId(groupId)) {
4470                            remove(socialActivity);
4471                    }
4472            }
4473    
4474            /**
4475             * Removes all the social activities where companyId = &#63; from the database.
4476             *
4477             * @param companyId the company ID
4478             * @throws SystemException if a system exception occurred
4479             */
4480            public void removeByCompanyId(long companyId) throws SystemException {
4481                    for (SocialActivity socialActivity : findByCompanyId(companyId)) {
4482                            remove(socialActivity);
4483                    }
4484            }
4485    
4486            /**
4487             * Removes all the social activities where userId = &#63; from the database.
4488             *
4489             * @param userId the user ID
4490             * @throws SystemException if a system exception occurred
4491             */
4492            public void removeByUserId(long userId) throws SystemException {
4493                    for (SocialActivity socialActivity : findByUserId(userId)) {
4494                            remove(socialActivity);
4495                    }
4496            }
4497    
4498            /**
4499             * Removes the social activity where mirrorActivityId = &#63; from the database.
4500             *
4501             * @param mirrorActivityId the mirror activity ID
4502             * @throws SystemException if a system exception occurred
4503             */
4504            public void removeByMirrorActivityId(long mirrorActivityId)
4505                    throws NoSuchActivityException, SystemException {
4506                    SocialActivity socialActivity = findByMirrorActivityId(mirrorActivityId);
4507    
4508                    remove(socialActivity);
4509            }
4510    
4511            /**
4512             * Removes all the social activities where classNameId = &#63; from the database.
4513             *
4514             * @param classNameId the class name ID
4515             * @throws SystemException if a system exception occurred
4516             */
4517            public void removeByClassNameId(long classNameId) throws SystemException {
4518                    for (SocialActivity socialActivity : findByClassNameId(classNameId)) {
4519                            remove(socialActivity);
4520                    }
4521            }
4522    
4523            /**
4524             * Removes all the social activities where receiverUserId = &#63; from the database.
4525             *
4526             * @param receiverUserId the receiver user ID
4527             * @throws SystemException if a system exception occurred
4528             */
4529            public void removeByReceiverUserId(long receiverUserId)
4530                    throws SystemException {
4531                    for (SocialActivity socialActivity : findByReceiverUserId(
4532                                    receiverUserId)) {
4533                            remove(socialActivity);
4534                    }
4535            }
4536    
4537            /**
4538             * Removes all the social activities where classNameId = &#63; and classPK = &#63; from the database.
4539             *
4540             * @param classNameId the class name ID
4541             * @param classPK the class p k
4542             * @throws SystemException if a system exception occurred
4543             */
4544            public void removeByC_C(long classNameId, long classPK)
4545                    throws SystemException {
4546                    for (SocialActivity socialActivity : findByC_C(classNameId, classPK)) {
4547                            remove(socialActivity);
4548                    }
4549            }
4550    
4551            /**
4552             * Removes all the social activities where mirrorActivityId = &#63; and classNameId = &#63; and classPK = &#63; from the database.
4553             *
4554             * @param mirrorActivityId the mirror activity ID
4555             * @param classNameId the class name ID
4556             * @param classPK the class p k
4557             * @throws SystemException if a system exception occurred
4558             */
4559            public void removeByM_C_C(long mirrorActivityId, long classNameId,
4560                    long classPK) throws SystemException {
4561                    for (SocialActivity socialActivity : findByM_C_C(mirrorActivityId,
4562                                    classNameId, classPK)) {
4563                            remove(socialActivity);
4564                    }
4565            }
4566    
4567            /**
4568             * Removes all the social activities where groupId = &#63; and userId = &#63; and classNameId = &#63; and classPK = &#63; and type = &#63; and receiverUserId = &#63; from the database.
4569             *
4570             * @param groupId the group ID
4571             * @param userId the user ID
4572             * @param classNameId the class name ID
4573             * @param classPK the class p k
4574             * @param type the type
4575             * @param receiverUserId the receiver user ID
4576             * @throws SystemException if a system exception occurred
4577             */
4578            public void removeByG_U_C_C_T_R(long groupId, long userId,
4579                    long classNameId, long classPK, int type, long receiverUserId)
4580                    throws SystemException {
4581                    for (SocialActivity socialActivity : findByG_U_C_C_T_R(groupId, userId,
4582                                    classNameId, classPK, type, receiverUserId)) {
4583                            remove(socialActivity);
4584                    }
4585            }
4586    
4587            /**
4588             * Removes the social activity where groupId = &#63; and userId = &#63; and createDate = &#63; and classNameId = &#63; and classPK = &#63; and type = &#63; and receiverUserId = &#63; from the database.
4589             *
4590             * @param groupId the group ID
4591             * @param userId the user ID
4592             * @param createDate the create date
4593             * @param classNameId the class name ID
4594             * @param classPK the class p k
4595             * @param type the type
4596             * @param receiverUserId the receiver user ID
4597             * @throws SystemException if a system exception occurred
4598             */
4599            public void removeByG_U_CD_C_C_T_R(long groupId, long userId,
4600                    long createDate, long classNameId, long classPK, int type,
4601                    long receiverUserId) throws NoSuchActivityException, SystemException {
4602                    SocialActivity socialActivity = findByG_U_CD_C_C_T_R(groupId, userId,
4603                                    createDate, classNameId, classPK, type, receiverUserId);
4604    
4605                    remove(socialActivity);
4606            }
4607    
4608            /**
4609             * Removes all the social activities from the database.
4610             *
4611             * @throws SystemException if a system exception occurred
4612             */
4613            public void removeAll() throws SystemException {
4614                    for (SocialActivity socialActivity : findAll()) {
4615                            remove(socialActivity);
4616                    }
4617            }
4618    
4619            /**
4620             * Returns the number of social activities where groupId = &#63;.
4621             *
4622             * @param groupId the group ID
4623             * @return the number of matching social activities
4624             * @throws SystemException if a system exception occurred
4625             */
4626            public int countByGroupId(long groupId) throws SystemException {
4627                    Object[] finderArgs = new Object[] { groupId };
4628    
4629                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
4630                                    finderArgs, this);
4631    
4632                    if (count == null) {
4633                            StringBundler query = new StringBundler(2);
4634    
4635                            query.append(_SQL_COUNT_SOCIALACTIVITY_WHERE);
4636    
4637                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
4638    
4639                            String sql = query.toString();
4640    
4641                            Session session = null;
4642    
4643                            try {
4644                                    session = openSession();
4645    
4646                                    Query q = session.createQuery(sql);
4647    
4648                                    QueryPos qPos = QueryPos.getInstance(q);
4649    
4650                                    qPos.add(groupId);
4651    
4652                                    count = (Long)q.uniqueResult();
4653                            }
4654                            catch (Exception e) {
4655                                    throw processException(e);
4656                            }
4657                            finally {
4658                                    if (count == null) {
4659                                            count = Long.valueOf(0);
4660                                    }
4661    
4662                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
4663                                            finderArgs, count);
4664    
4665                                    closeSession(session);
4666                            }
4667                    }
4668    
4669                    return count.intValue();
4670            }
4671    
4672            /**
4673             * Returns the number of social activities where companyId = &#63;.
4674             *
4675             * @param companyId the company ID
4676             * @return the number of matching social activities
4677             * @throws SystemException if a system exception occurred
4678             */
4679            public int countByCompanyId(long companyId) throws SystemException {
4680                    Object[] finderArgs = new Object[] { companyId };
4681    
4682                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
4683                                    finderArgs, this);
4684    
4685                    if (count == null) {
4686                            StringBundler query = new StringBundler(2);
4687    
4688                            query.append(_SQL_COUNT_SOCIALACTIVITY_WHERE);
4689    
4690                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
4691    
4692                            String sql = query.toString();
4693    
4694                            Session session = null;
4695    
4696                            try {
4697                                    session = openSession();
4698    
4699                                    Query q = session.createQuery(sql);
4700    
4701                                    QueryPos qPos = QueryPos.getInstance(q);
4702    
4703                                    qPos.add(companyId);
4704    
4705                                    count = (Long)q.uniqueResult();
4706                            }
4707                            catch (Exception e) {
4708                                    throw processException(e);
4709                            }
4710                            finally {
4711                                    if (count == null) {
4712                                            count = Long.valueOf(0);
4713                                    }
4714    
4715                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
4716                                            finderArgs, count);
4717    
4718                                    closeSession(session);
4719                            }
4720                    }
4721    
4722                    return count.intValue();
4723            }
4724    
4725            /**
4726             * Returns the number of social activities where userId = &#63;.
4727             *
4728             * @param userId the user ID
4729             * @return the number of matching social activities
4730             * @throws SystemException if a system exception occurred
4731             */
4732            public int countByUserId(long userId) throws SystemException {
4733                    Object[] finderArgs = new Object[] { userId };
4734    
4735                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_USERID,
4736                                    finderArgs, this);
4737    
4738                    if (count == null) {
4739                            StringBundler query = new StringBundler(2);
4740    
4741                            query.append(_SQL_COUNT_SOCIALACTIVITY_WHERE);
4742    
4743                            query.append(_FINDER_COLUMN_USERID_USERID_2);
4744    
4745                            String sql = query.toString();
4746    
4747                            Session session = null;
4748    
4749                            try {
4750                                    session = openSession();
4751    
4752                                    Query q = session.createQuery(sql);
4753    
4754                                    QueryPos qPos = QueryPos.getInstance(q);
4755    
4756                                    qPos.add(userId);
4757    
4758                                    count = (Long)q.uniqueResult();
4759                            }
4760                            catch (Exception e) {
4761                                    throw processException(e);
4762                            }
4763                            finally {
4764                                    if (count == null) {
4765                                            count = Long.valueOf(0);
4766                                    }
4767    
4768                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_USERID,
4769                                            finderArgs, count);
4770    
4771                                    closeSession(session);
4772                            }
4773                    }
4774    
4775                    return count.intValue();
4776            }
4777    
4778            /**
4779             * Returns the number of social activities where mirrorActivityId = &#63;.
4780             *
4781             * @param mirrorActivityId the mirror activity ID
4782             * @return the number of matching social activities
4783             * @throws SystemException if a system exception occurred
4784             */
4785            public int countByMirrorActivityId(long mirrorActivityId)
4786                    throws SystemException {
4787                    Object[] finderArgs = new Object[] { mirrorActivityId };
4788    
4789                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_MIRRORACTIVITYID,
4790                                    finderArgs, this);
4791    
4792                    if (count == null) {
4793                            StringBundler query = new StringBundler(2);
4794    
4795                            query.append(_SQL_COUNT_SOCIALACTIVITY_WHERE);
4796    
4797                            query.append(_FINDER_COLUMN_MIRRORACTIVITYID_MIRRORACTIVITYID_2);
4798    
4799                            String sql = query.toString();
4800    
4801                            Session session = null;
4802    
4803                            try {
4804                                    session = openSession();
4805    
4806                                    Query q = session.createQuery(sql);
4807    
4808                                    QueryPos qPos = QueryPos.getInstance(q);
4809    
4810                                    qPos.add(mirrorActivityId);
4811    
4812                                    count = (Long)q.uniqueResult();
4813                            }
4814                            catch (Exception e) {
4815                                    throw processException(e);
4816                            }
4817                            finally {
4818                                    if (count == null) {
4819                                            count = Long.valueOf(0);
4820                                    }
4821    
4822                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_MIRRORACTIVITYID,
4823                                            finderArgs, count);
4824    
4825                                    closeSession(session);
4826                            }
4827                    }
4828    
4829                    return count.intValue();
4830            }
4831    
4832            /**
4833             * Returns the number of social activities where classNameId = &#63;.
4834             *
4835             * @param classNameId the class name ID
4836             * @return the number of matching social activities
4837             * @throws SystemException if a system exception occurred
4838             */
4839            public int countByClassNameId(long classNameId) throws SystemException {
4840                    Object[] finderArgs = new Object[] { classNameId };
4841    
4842                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_CLASSNAMEID,
4843                                    finderArgs, this);
4844    
4845                    if (count == null) {
4846                            StringBundler query = new StringBundler(2);
4847    
4848                            query.append(_SQL_COUNT_SOCIALACTIVITY_WHERE);
4849    
4850                            query.append(_FINDER_COLUMN_CLASSNAMEID_CLASSNAMEID_2);
4851    
4852                            String sql = query.toString();
4853    
4854                            Session session = null;
4855    
4856                            try {
4857                                    session = openSession();
4858    
4859                                    Query q = session.createQuery(sql);
4860    
4861                                    QueryPos qPos = QueryPos.getInstance(q);
4862    
4863                                    qPos.add(classNameId);
4864    
4865                                    count = (Long)q.uniqueResult();
4866                            }
4867                            catch (Exception e) {
4868                                    throw processException(e);
4869                            }
4870                            finally {
4871                                    if (count == null) {
4872                                            count = Long.valueOf(0);
4873                                    }
4874    
4875                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_CLASSNAMEID,
4876                                            finderArgs, count);
4877    
4878                                    closeSession(session);
4879                            }
4880                    }
4881    
4882                    return count.intValue();
4883            }
4884    
4885            /**
4886             * Returns the number of social activities where receiverUserId = &#63;.
4887             *
4888             * @param receiverUserId the receiver user ID
4889             * @return the number of matching social activities
4890             * @throws SystemException if a system exception occurred
4891             */
4892            public int countByReceiverUserId(long receiverUserId)
4893                    throws SystemException {
4894                    Object[] finderArgs = new Object[] { receiverUserId };
4895    
4896                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_RECEIVERUSERID,
4897                                    finderArgs, this);
4898    
4899                    if (count == null) {
4900                            StringBundler query = new StringBundler(2);
4901    
4902                            query.append(_SQL_COUNT_SOCIALACTIVITY_WHERE);
4903    
4904                            query.append(_FINDER_COLUMN_RECEIVERUSERID_RECEIVERUSERID_2);
4905    
4906                            String sql = query.toString();
4907    
4908                            Session session = null;
4909    
4910                            try {
4911                                    session = openSession();
4912    
4913                                    Query q = session.createQuery(sql);
4914    
4915                                    QueryPos qPos = QueryPos.getInstance(q);
4916    
4917                                    qPos.add(receiverUserId);
4918    
4919                                    count = (Long)q.uniqueResult();
4920                            }
4921                            catch (Exception e) {
4922                                    throw processException(e);
4923                            }
4924                            finally {
4925                                    if (count == null) {
4926                                            count = Long.valueOf(0);
4927                                    }
4928    
4929                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_RECEIVERUSERID,
4930                                            finderArgs, count);
4931    
4932                                    closeSession(session);
4933                            }
4934                    }
4935    
4936                    return count.intValue();
4937            }
4938    
4939            /**
4940             * Returns the number of social activities where classNameId = &#63; and classPK = &#63;.
4941             *
4942             * @param classNameId the class name ID
4943             * @param classPK the class p k
4944             * @return the number of matching social activities
4945             * @throws SystemException if a system exception occurred
4946             */
4947            public int countByC_C(long classNameId, long classPK)
4948                    throws SystemException {
4949                    Object[] finderArgs = new Object[] { classNameId, classPK };
4950    
4951                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C,
4952                                    finderArgs, this);
4953    
4954                    if (count == null) {
4955                            StringBundler query = new StringBundler(3);
4956    
4957                            query.append(_SQL_COUNT_SOCIALACTIVITY_WHERE);
4958    
4959                            query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
4960    
4961                            query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
4962    
4963                            String sql = query.toString();
4964    
4965                            Session session = null;
4966    
4967                            try {
4968                                    session = openSession();
4969    
4970                                    Query q = session.createQuery(sql);
4971    
4972                                    QueryPos qPos = QueryPos.getInstance(q);
4973    
4974                                    qPos.add(classNameId);
4975    
4976                                    qPos.add(classPK);
4977    
4978                                    count = (Long)q.uniqueResult();
4979                            }
4980                            catch (Exception e) {
4981                                    throw processException(e);
4982                            }
4983                            finally {
4984                                    if (count == null) {
4985                                            count = Long.valueOf(0);
4986                                    }
4987    
4988                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C, finderArgs,
4989                                            count);
4990    
4991                                    closeSession(session);
4992                            }
4993                    }
4994    
4995                    return count.intValue();
4996            }
4997    
4998            /**
4999             * Returns the number of social activities where mirrorActivityId = &#63; and classNameId = &#63; and classPK = &#63;.
5000             *
5001             * @param mirrorActivityId the mirror activity ID
5002             * @param classNameId the class name ID
5003             * @param classPK the class p k
5004             * @return the number of matching social activities
5005             * @throws SystemException if a system exception occurred
5006             */
5007            public int countByM_C_C(long mirrorActivityId, long classNameId,
5008                    long classPK) throws SystemException {
5009                    Object[] finderArgs = new Object[] {
5010                                    mirrorActivityId, classNameId, classPK
5011                            };
5012    
5013                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_M_C_C,
5014                                    finderArgs, this);
5015    
5016                    if (count == null) {
5017                            StringBundler query = new StringBundler(4);
5018    
5019                            query.append(_SQL_COUNT_SOCIALACTIVITY_WHERE);
5020    
5021                            query.append(_FINDER_COLUMN_M_C_C_MIRRORACTIVITYID_2);
5022    
5023                            query.append(_FINDER_COLUMN_M_C_C_CLASSNAMEID_2);
5024    
5025                            query.append(_FINDER_COLUMN_M_C_C_CLASSPK_2);
5026    
5027                            String sql = query.toString();
5028    
5029                            Session session = null;
5030    
5031                            try {
5032                                    session = openSession();
5033    
5034                                    Query q = session.createQuery(sql);
5035    
5036                                    QueryPos qPos = QueryPos.getInstance(q);
5037    
5038                                    qPos.add(mirrorActivityId);
5039    
5040                                    qPos.add(classNameId);
5041    
5042                                    qPos.add(classPK);
5043    
5044                                    count = (Long)q.uniqueResult();
5045                            }
5046                            catch (Exception e) {
5047                                    throw processException(e);
5048                            }
5049                            finally {
5050                                    if (count == null) {
5051                                            count = Long.valueOf(0);
5052                                    }
5053    
5054                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_M_C_C,
5055                                            finderArgs, count);
5056    
5057                                    closeSession(session);
5058                            }
5059                    }
5060    
5061                    return count.intValue();
5062            }
5063    
5064            /**
5065             * Returns the number of social activities where groupId = &#63; and userId = &#63; and classNameId = &#63; and classPK = &#63; and type = &#63; and receiverUserId = &#63;.
5066             *
5067             * @param groupId the group ID
5068             * @param userId the user ID
5069             * @param classNameId the class name ID
5070             * @param classPK the class p k
5071             * @param type the type
5072             * @param receiverUserId the receiver user ID
5073             * @return the number of matching social activities
5074             * @throws SystemException if a system exception occurred
5075             */
5076            public int countByG_U_C_C_T_R(long groupId, long userId, long classNameId,
5077                    long classPK, int type, long receiverUserId) throws SystemException {
5078                    Object[] finderArgs = new Object[] {
5079                                    groupId, userId, classNameId, classPK, type, receiverUserId
5080                            };
5081    
5082                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_U_C_C_T_R,
5083                                    finderArgs, this);
5084    
5085                    if (count == null) {
5086                            StringBundler query = new StringBundler(7);
5087    
5088                            query.append(_SQL_COUNT_SOCIALACTIVITY_WHERE);
5089    
5090                            query.append(_FINDER_COLUMN_G_U_C_C_T_R_GROUPID_2);
5091    
5092                            query.append(_FINDER_COLUMN_G_U_C_C_T_R_USERID_2);
5093    
5094                            query.append(_FINDER_COLUMN_G_U_C_C_T_R_CLASSNAMEID_2);
5095    
5096                            query.append(_FINDER_COLUMN_G_U_C_C_T_R_CLASSPK_2);
5097    
5098                            query.append(_FINDER_COLUMN_G_U_C_C_T_R_TYPE_2);
5099    
5100                            query.append(_FINDER_COLUMN_G_U_C_C_T_R_RECEIVERUSERID_2);
5101    
5102                            String sql = query.toString();
5103    
5104                            Session session = null;
5105    
5106                            try {
5107                                    session = openSession();
5108    
5109                                    Query q = session.createQuery(sql);
5110    
5111                                    QueryPos qPos = QueryPos.getInstance(q);
5112    
5113                                    qPos.add(groupId);
5114    
5115                                    qPos.add(userId);
5116    
5117                                    qPos.add(classNameId);
5118    
5119                                    qPos.add(classPK);
5120    
5121                                    qPos.add(type);
5122    
5123                                    qPos.add(receiverUserId);
5124    
5125                                    count = (Long)q.uniqueResult();
5126                            }
5127                            catch (Exception e) {
5128                                    throw processException(e);
5129                            }
5130                            finally {
5131                                    if (count == null) {
5132                                            count = Long.valueOf(0);
5133                                    }
5134    
5135                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_U_C_C_T_R,
5136                                            finderArgs, count);
5137    
5138                                    closeSession(session);
5139                            }
5140                    }
5141    
5142                    return count.intValue();
5143            }
5144    
5145            /**
5146             * Returns the number of social activities where groupId = &#63; and userId = &#63; and createDate = &#63; and classNameId = &#63; and classPK = &#63; and type = &#63; and receiverUserId = &#63;.
5147             *
5148             * @param groupId the group ID
5149             * @param userId the user ID
5150             * @param createDate the create date
5151             * @param classNameId the class name ID
5152             * @param classPK the class p k
5153             * @param type the type
5154             * @param receiverUserId the receiver user ID
5155             * @return the number of matching social activities
5156             * @throws SystemException if a system exception occurred
5157             */
5158            public int countByG_U_CD_C_C_T_R(long groupId, long userId,
5159                    long createDate, long classNameId, long classPK, int type,
5160                    long receiverUserId) throws SystemException {
5161                    Object[] finderArgs = new Object[] {
5162                                    groupId, userId, createDate, classNameId, classPK, type,
5163                                    receiverUserId
5164                            };
5165    
5166                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_U_CD_C_C_T_R,
5167                                    finderArgs, this);
5168    
5169                    if (count == null) {
5170                            StringBundler query = new StringBundler(8);
5171    
5172                            query.append(_SQL_COUNT_SOCIALACTIVITY_WHERE);
5173    
5174                            query.append(_FINDER_COLUMN_G_U_CD_C_C_T_R_GROUPID_2);
5175    
5176                            query.append(_FINDER_COLUMN_G_U_CD_C_C_T_R_USERID_2);
5177    
5178                            query.append(_FINDER_COLUMN_G_U_CD_C_C_T_R_CREATEDATE_2);
5179    
5180                            query.append(_FINDER_COLUMN_G_U_CD_C_C_T_R_CLASSNAMEID_2);
5181    
5182                            query.append(_FINDER_COLUMN_G_U_CD_C_C_T_R_CLASSPK_2);
5183    
5184                            query.append(_FINDER_COLUMN_G_U_CD_C_C_T_R_TYPE_2);
5185    
5186                            query.append(_FINDER_COLUMN_G_U_CD_C_C_T_R_RECEIVERUSERID_2);
5187    
5188                            String sql = query.toString();
5189    
5190                            Session session = null;
5191    
5192                            try {
5193                                    session = openSession();
5194    
5195                                    Query q = session.createQuery(sql);
5196    
5197                                    QueryPos qPos = QueryPos.getInstance(q);
5198    
5199                                    qPos.add(groupId);
5200    
5201                                    qPos.add(userId);
5202    
5203                                    qPos.add(createDate);
5204    
5205                                    qPos.add(classNameId);
5206    
5207                                    qPos.add(classPK);
5208    
5209                                    qPos.add(type);
5210    
5211                                    qPos.add(receiverUserId);
5212    
5213                                    count = (Long)q.uniqueResult();
5214                            }
5215                            catch (Exception e) {
5216                                    throw processException(e);
5217                            }
5218                            finally {
5219                                    if (count == null) {
5220                                            count = Long.valueOf(0);
5221                                    }
5222    
5223                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_U_CD_C_C_T_R,
5224                                            finderArgs, count);
5225    
5226                                    closeSession(session);
5227                            }
5228                    }
5229    
5230                    return count.intValue();
5231            }
5232    
5233            /**
5234             * Returns the number of social activities.
5235             *
5236             * @return the number of social activities
5237             * @throws SystemException if a system exception occurred
5238             */
5239            public int countAll() throws SystemException {
5240                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
5241                                    FINDER_ARGS_EMPTY, this);
5242    
5243                    if (count == null) {
5244                            Session session = null;
5245    
5246                            try {
5247                                    session = openSession();
5248    
5249                                    Query q = session.createQuery(_SQL_COUNT_SOCIALACTIVITY);
5250    
5251                                    count = (Long)q.uniqueResult();
5252                            }
5253                            catch (Exception e) {
5254                                    throw processException(e);
5255                            }
5256                            finally {
5257                                    if (count == null) {
5258                                            count = Long.valueOf(0);
5259                                    }
5260    
5261                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
5262                                            FINDER_ARGS_EMPTY, count);
5263    
5264                                    closeSession(session);
5265                            }
5266                    }
5267    
5268                    return count.intValue();
5269            }
5270    
5271            /**
5272             * Initializes the social activity persistence.
5273             */
5274            public void afterPropertiesSet() {
5275                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
5276                                            com.liferay.portal.util.PropsUtil.get(
5277                                                    "value.object.listener.com.liferay.portlet.social.model.SocialActivity")));
5278    
5279                    if (listenerClassNames.length > 0) {
5280                            try {
5281                                    List<ModelListener<SocialActivity>> listenersList = new ArrayList<ModelListener<SocialActivity>>();
5282    
5283                                    for (String listenerClassName : listenerClassNames) {
5284                                            listenersList.add((ModelListener<SocialActivity>)InstanceFactory.newInstance(
5285                                                            listenerClassName));
5286                                    }
5287    
5288                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
5289                            }
5290                            catch (Exception e) {
5291                                    _log.error(e);
5292                            }
5293                    }
5294            }
5295    
5296            public void destroy() {
5297                    EntityCacheUtil.removeCache(SocialActivityImpl.class.getName());
5298                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
5299                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
5300            }
5301    
5302            @BeanReference(type = SocialActivityPersistence.class)
5303            protected SocialActivityPersistence socialActivityPersistence;
5304            @BeanReference(type = SocialActivityAchievementPersistence.class)
5305            protected SocialActivityAchievementPersistence socialActivityAchievementPersistence;
5306            @BeanReference(type = SocialActivityCounterPersistence.class)
5307            protected SocialActivityCounterPersistence socialActivityCounterPersistence;
5308            @BeanReference(type = SocialActivityLimitPersistence.class)
5309            protected SocialActivityLimitPersistence socialActivityLimitPersistence;
5310            @BeanReference(type = SocialActivitySettingPersistence.class)
5311            protected SocialActivitySettingPersistence socialActivitySettingPersistence;
5312            @BeanReference(type = SocialRelationPersistence.class)
5313            protected SocialRelationPersistence socialRelationPersistence;
5314            @BeanReference(type = SocialRequestPersistence.class)
5315            protected SocialRequestPersistence socialRequestPersistence;
5316            @BeanReference(type = GroupPersistence.class)
5317            protected GroupPersistence groupPersistence;
5318            @BeanReference(type = LayoutPersistence.class)
5319            protected LayoutPersistence layoutPersistence;
5320            @BeanReference(type = ResourcePersistence.class)
5321            protected ResourcePersistence resourcePersistence;
5322            @BeanReference(type = UserPersistence.class)
5323            protected UserPersistence userPersistence;
5324            @BeanReference(type = AssetEntryPersistence.class)
5325            protected AssetEntryPersistence assetEntryPersistence;
5326            private static final String _SQL_SELECT_SOCIALACTIVITY = "SELECT socialActivity FROM SocialActivity socialActivity";
5327            private static final String _SQL_SELECT_SOCIALACTIVITY_WHERE = "SELECT socialActivity FROM SocialActivity socialActivity WHERE ";
5328            private static final String _SQL_COUNT_SOCIALACTIVITY = "SELECT COUNT(socialActivity) FROM SocialActivity socialActivity";
5329            private static final String _SQL_COUNT_SOCIALACTIVITY_WHERE = "SELECT COUNT(socialActivity) FROM SocialActivity socialActivity WHERE ";
5330            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "socialActivity.groupId = ?";
5331            private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "socialActivity.companyId = ?";
5332            private static final String _FINDER_COLUMN_USERID_USERID_2 = "socialActivity.userId = ?";
5333            private static final String _FINDER_COLUMN_MIRRORACTIVITYID_MIRRORACTIVITYID_2 =
5334                    "socialActivity.mirrorActivityId = ?";
5335            private static final String _FINDER_COLUMN_CLASSNAMEID_CLASSNAMEID_2 = "socialActivity.classNameId = ?";
5336            private static final String _FINDER_COLUMN_RECEIVERUSERID_RECEIVERUSERID_2 = "socialActivity.receiverUserId = ?";
5337            private static final String _FINDER_COLUMN_C_C_CLASSNAMEID_2 = "socialActivity.classNameId = ? AND ";
5338            private static final String _FINDER_COLUMN_C_C_CLASSPK_2 = "socialActivity.classPK = ?";
5339            private static final String _FINDER_COLUMN_M_C_C_MIRRORACTIVITYID_2 = "socialActivity.mirrorActivityId = ? AND ";
5340            private static final String _FINDER_COLUMN_M_C_C_CLASSNAMEID_2 = "socialActivity.classNameId = ? AND ";
5341            private static final String _FINDER_COLUMN_M_C_C_CLASSPK_2 = "socialActivity.classPK = ?";
5342            private static final String _FINDER_COLUMN_G_U_C_C_T_R_GROUPID_2 = "socialActivity.groupId = ? AND ";
5343            private static final String _FINDER_COLUMN_G_U_C_C_T_R_USERID_2 = "socialActivity.userId = ? AND ";
5344            private static final String _FINDER_COLUMN_G_U_C_C_T_R_CLASSNAMEID_2 = "socialActivity.classNameId = ? AND ";
5345            private static final String _FINDER_COLUMN_G_U_C_C_T_R_CLASSPK_2 = "socialActivity.classPK = ? AND ";
5346            private static final String _FINDER_COLUMN_G_U_C_C_T_R_TYPE_2 = "socialActivity.type = ? AND ";
5347            private static final String _FINDER_COLUMN_G_U_C_C_T_R_RECEIVERUSERID_2 = "socialActivity.receiverUserId = ?";
5348            private static final String _FINDER_COLUMN_G_U_CD_C_C_T_R_GROUPID_2 = "socialActivity.groupId = ? AND ";
5349            private static final String _FINDER_COLUMN_G_U_CD_C_C_T_R_USERID_2 = "socialActivity.userId = ? AND ";
5350            private static final String _FINDER_COLUMN_G_U_CD_C_C_T_R_CREATEDATE_2 = "socialActivity.createDate = ? AND ";
5351            private static final String _FINDER_COLUMN_G_U_CD_C_C_T_R_CLASSNAMEID_2 = "socialActivity.classNameId = ? AND ";
5352            private static final String _FINDER_COLUMN_G_U_CD_C_C_T_R_CLASSPK_2 = "socialActivity.classPK = ? AND ";
5353            private static final String _FINDER_COLUMN_G_U_CD_C_C_T_R_TYPE_2 = "socialActivity.type = ? AND ";
5354            private static final String _FINDER_COLUMN_G_U_CD_C_C_T_R_RECEIVERUSERID_2 = "socialActivity.receiverUserId = ?";
5355            private static final String _ORDER_BY_ENTITY_ALIAS = "socialActivity.";
5356            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No SocialActivity exists with the primary key ";
5357            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No SocialActivity exists with the key {";
5358            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
5359            private static Log _log = LogFactoryUtil.getLog(SocialActivityPersistenceImpl.class);
5360            private static SocialActivity _nullSocialActivity = new SocialActivityImpl() {
5361                            @Override
5362                            public Object clone() {
5363                                    return this;
5364                            }
5365    
5366                            @Override
5367                            public CacheModel<SocialActivity> toCacheModel() {
5368                                    return _nullSocialActivityCacheModel;
5369                            }
5370                    };
5371    
5372            private static CacheModel<SocialActivity> _nullSocialActivityCacheModel = new CacheModel<SocialActivity>() {
5373                            public SocialActivity toEntityModel() {
5374                                    return _nullSocialActivity;
5375                            }
5376                    };
5377    }